using System; using System.Reflection; using System.ComponentModel; namespace VEPROMS.CSLA.Library { public class EnumDetail { public T EValue { get; set; } public string Name { get; set; } public EnumDetail(string name, T eValue) { Name = name; EValue = eValue; } public static EnumDetail[] Details() { string[] names = Enum.GetNames(typeof(T)); Array values = Enum.GetValues(typeof(T)); EnumDetail[] retval = new EnumDetail[values.Length]; for (int i = 0; i < values.Length; i++) { T val = (T)values.GetValue(i); FieldInfo fi = val.GetType().GetField(val.ToString()); DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); retval[i] = new EnumDetail(((attributes.Length > 0) ? attributes[0].Description : names[i]), (T)values.GetValue(i)); } return retval; } } }