public static List<KeyValuePair<string, string>> Ergodic(Type enumType)
{
List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
if (!enumType.IsEnum) return null;
foreach (var item in Enum.GetNames(enumType))
{
FieldInfo fieldInfo = enumType.GetField(item);
DescriptionAttribute descriptionAttribute = Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute), false) as DescriptionAttribute;
if (descriptionAttribute != null)
{
string iName = Enum.Format(enumType, Enum.Parse(enumType, item), "d");
list.Add(new KeyValuePair<string, string>(iName, descriptionAttribute.Description));
}
}
return list;
}