using System; using System.Collections.Generic; using System.Text; using System.Reflection; using System.ComponentModel; namespace VEPROMS.CSLA.Library { public class EnumDetail { private T _EValue; public T EValue { get { return _EValue; } set { _EValue = value; } } private string _Name; public string Name { get { return _Name; } set { _Name = value; } } 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; } } }