Net.Bluewalk.DotNetUtils/StringEnum.cs
/// <summary>
/// Gets a string value for a particular enum value.
/// </summary>
/// <param name="value">Value.</param>
/// <returns>String Value associated via a <see cref="StringValueAttribute"/> attribute, or null if not found.</returns>
Gets a string value for a particular enum value.
Gets a string value for a particular enum value .
public static string GetStringValue(Enum value)
        {
            string output = null;
            var type = value.GetType();
            if (StringValues.ContainsKey(value))
                output = (StringValues[value] as StringValueAttribute).Value;
            else
            {
                var fi = type.GetField(value.ToString());
                var attrs = fi.GetCustomAttributes(typeof(StringValueAttribute), false) as StringValueAttribute[];
                if (attrs.Length > 0)
                {
                    StringValues.Add(value, attrs[0]);
                    output = attrs[0].Value;
                }
            }
            return output;
        }
public static string GetStringValue ( Enum value ) { string output = null ; var type = value . GetType ( ) ; if ( StringValues . ContainsKey ( value ) ) output = ( StringValues [ value ] as StringValueAttribute ) . Value ; else { var fi = type . GetField ( value . ToString ( ) ) ; var attrs = fi . GetCustomAttributes ( typeof ( StringValueAttribute ) , false ) as StringValueAttribute [ ] ; if ( attrs . Length > 0 ) { StringValues . Add ( value , attrs [ 0 ] ) ; output = attrs [ 0 ] . Value ; } } return output ; }
Gets a string value for a particular enum value.
Gets a string value for a particular enum value .
//Look for our 'StringValueAttribute' in the field's custom attributes
String Value associated via a  attribute, or null if not found.
String Value associated via a attribute or null if not found .
value
Enum
None