AdvancedWf.Shared/Extensions/EnumExtensions.cs
/// <summary>
/// Get Enum value as localized text
/// </summary>
/// <param name="enumValue">ref enum</param>
/// <returns></returns>
Get Enum value as localized text
Get Enum value as localized text
public static string GetDescription(this Enum enumValue)
        {
            var fi = enumValue.GetType().GetField(enumValue.ToString());
            var attributes =
                (DisplayAttribute[])fi.GetCustomAttributes(
                typeof(DisplayAttribute),
                false);
            if (attributes.Length > 0)
                return new ResourceManager(attributes[0].ResourceType).GetString(attributes[0].Name);
            return enumValue.ToString();
        }
public static string GetDescription ( this Enum enumValue ) { var fi = enumValue . GetType ( ) . GetField ( enumValue . ToString ( ) ) ; var attributes = ( DisplayAttribute [ ] ) fi . GetCustomAttributes ( typeof ( DisplayAttribute ) , false ) ; if ( attributes . Length > 0 ) return new ResourceManager ( attributes [ 0 ] . ResourceType ) . GetString ( attributes [ 0 ] . Name ) ; return enumValue . ToString ( ) ; }
Get Enum value as localized text
Get Enum value as localized text
None
Enum
this
enumValue
None