using System; using System.Collections.Generic; using System.ComponentModel; namespace Aitex.Sorter.UI.ViewModel { public static class EnumHelper { public static Dictionary ToDictionary() { var result = new Dictionary(); var values = Enum.GetValues(typeof(T)); foreach (T value in values) { var fi = value.GetType().GetField(value.ToString()); var attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); if (attributes.Length > 0) result.Add(value, attributes[0].Description); else result.Add(value, value.ToString()); } return result; } } }