Class EnumExtensions
Extension methods for enums
Inheritance
System.Object
EnumExtensions
Assembly: ImageVault.Common.dll
Syntax
public static class EnumExtensions : Object
Methods
GetAttribute<TAttribute>(Enum)
Get attribute value of enum
Declaration
public static TAttribute GetAttribute<TAttribute>(this Enum value)
where TAttribute : Attribute
Parameters
Type |
Name |
Description |
System.Enum |
value |
|
Returns
Type |
Description |
TAttribute |
|
Type Parameters
Name |
Description |
TAttribute |
|
GetName(Enum)
Gets the description for the supplied enum
Declaration
public static string GetName(this Enum val)
Parameters
Type |
Name |
Description |
System.Enum |
val |
The enum value to get the description for
|
Returns
Type |
Description |
System.String |
|
GetNames<TEnum>(TEnum)
Gets the names of the enum. If the enum is a System.FlagsAttribute enum, then each flag is parsed
individually and if set, the Name of the flag is included in the list.
Gets the name by using the GetName(Enum) method to include names specified by the System.ComponentModel.DataAnnotations.DisplayAttribute.
Declaration
public static IList<string> GetNames<TEnum>(this TEnum val)
Parameters
Type |
Name |
Description |
TEnum |
val |
The enum to get the names for
|
Returns
Type |
Description |
System.Collections.Generic.IList<System.String> |
A System.Collections.Generic.IList<> of System.String containing the names of the enum
|
Type Parameters
Name |
Description |
TEnum |
The type of Enum to get values for
|
Exceptions
Type |
Condition |
System.ArgumentException |
If val is not an enum.
|
GetOrderedEnumValues<TEnum>(Type)
Declaration
public static IEnumerable<TEnum> GetOrderedEnumValues<TEnum>(this Type enumType)
Parameters
Type |
Name |
Description |
System.Type |
enumType |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<TEnum> |
|
Type Parameters