Class EnumExtentions
- Namespace
- Arc4u.Extensions
- Assembly
- Arc4u.dll
Extension methods to display enumeration values, based on the DisplayAttribute.
public static class EnumExtentions
- Inheritance
-
EnumExtentions
- Inherited Members
Methods
GetDisplayName(Enum)
Gets the name defined by the DisplayAttribute of an enumeration value.
public static string GetDisplayName(this Enum value)
Parameters
valueEnumThe enumeration value.
Returns
- string
The display name of the value.
Exceptions
- ArgumentException
The value has no DisplayAttribute.
- InvalidOperationException
The value is not a member of its enumeration.
GetValue(Enum)
Gets the name of an enumeration value (the result of ToString()).
public static string GetValue(this Enum value)
Parameters
valueEnumThe enumeration value.
Returns
- string
The name of the value.
ToTranslationDictionary(Type)
Maps the members of an enumeration to their display name.
public static Dictionary<Enum, string> ToTranslationDictionary(this Type enumType)
Parameters
enumTypeTypeThe enumeration type.
Returns
- Dictionary<Enum, string>
A dictionary whose keys are the members and whose values are the display names.
Exceptions
- ArgumentException
enumTypeis not an enumeration, or one of its members has no DisplayAttribute.
ToTranslationList(Type)
Lists the members of an enumeration together with their display name.
public static List<KeyValuePair<string, string>> ToTranslationList(this Type enumType)
Parameters
enumTypeTypeThe enumeration type.
Returns
- List<KeyValuePair<string, string>>
A list of pairs (member name, display name).
Exceptions
- ArgumentException
enumTypeis not an enumeration, or one of its members has no DisplayAttribute.