Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alternative to pr/251. That method uses an enum with a function to tr…
…anslate the names. My implementation names the enum values the actual API string values which eliminates the need for the extra ConversationTypesToQueryParam() function. For example, instead of: Tuple.Create("types", Conversation.ConversationTypesToQueryParam(types)); We can leave this unchanged: parameters.Add(Tuple.Create("types", string.Join(",", types))); This works because when string.Join translate types[] into strings, it calls ToString() which by default returns the enum element name. This is also nice because we don't have to update the ConversationTypesToQueryParam() function whenever elements are added or removed from the enum. If there is some kind of naming standard violation here, (e.g. The first enum element should be PublicChannel instead of public_channel), yet another alternative would be to use a class instead of an enum. For example: public static class Type { public static readonly string PublicChannel = "public_channel"; public static readonly string PrivateChannel = "private_channel"; ... } There is a detailed discussion on using friendly strings with enums on Stack Overflow here: https://stackoverflow.com/questions/479410/enum-tostring-with-user-friendly-strings
- Loading branch information