/// <summary>
        /// 获取枚举值的描述文本。
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string GetDescriptionByValue <T>(Object value) where T : struct
        {
            Type enumType = typeof(T);
            IList <EnumDescriptionAttribute> descriptions = GetDescriptions(enumType);
            EnumDescriptionAttribute         description  = descriptions.First(e => string.Equals(e.EnumValue.ToString(), value.ToString()));

            return(description.Description);
        }
        /// <summary>
        /// GetEnumValueByTag 根据描述Tag获取对应的枚举值
        /// </summary>
        public static object GetEnumValueByTag(Type enumType, object tag)
        {
            IList <EnumDescriptionAttribute> list = EnumDescriptionAttribute.GetDescriptions(enumType);

            if (list == null)
            {
                return(null);
            }
            return(list.ConvertFirst <EnumDescriptionAttribute, object>(ed => ed.enumValue, ed => string.Equals(ed.Tag.ToString(), tag.ToString())));
        }
        /// <summary>
        /// GetFieldTag 获得指定枚举值的Tag。
        /// </summary>
        /// <param name="enumValue"></param>
        /// <returns></returns>
        public static object GetFieldTag(object enumValue)
        {
            IList <EnumDescriptionAttribute> list = EnumDescriptionAttribute.GetDescriptions(enumValue.GetType());

            if (list == null)
            {
                return(null);
            }

            return(list.ConvertFirst <EnumDescriptionAttribute, object>(ed => ed.Tag, ed => string.Equals(ed.EnumValue.ToString(), enumValue.ToString())));
        }
        /// <summary>
        /// GetFieldDescriptionText 获得指定枚举值的描述文本。
        /// </summary>
        public static string GetFieldText(object enumValue)
        {
            IList <EnumDescriptionAttribute> list = EnumDescriptionAttribute.GetDescriptions(enumValue.GetType());

            if (list == null)
            {
                return(null);
            }
            list.ToArray();
            return(list.ConvertFirst <EnumDescriptionAttribute, string>(ed => ed.Description, ed => string.Equals(ed.EnumValue.ToString(), enumValue.ToString())));
        }
        /// <summary>
        /// DoGetFieldTexts 得到枚举类型定义的所有枚举值的描述文本
        /// </summary>
        private static IList <EnumDescriptionAttribute> GetDescriptions(Type enumType)
        {
            if (!EnumDescriptionAttribute.EnumDescriptionCache.ContainsKey(enumType.FullName))
            {
                FieldInfo[] fields = enumType.GetFields();
                IList <EnumDescriptionAttribute> list = new List <EnumDescriptionAttribute>();
                foreach (FieldInfo fi in fields)
                {
                    object[] eds = fi.GetCustomAttributes(typeof(EnumDescriptionAttribute), false);
                    if (eds.Length == 1)
                    {
                        EnumDescriptionAttribute enumDescription = (EnumDescriptionAttribute)eds[0];
                        enumDescription.enumValue = fi.GetValue(null);
                        list.Add(enumDescription);
                    }
                }

                EnumDescriptionAttribute.EnumDescriptionCache.Add(enumType.FullName, list);
            }

            return(EnumDescriptionAttribute.EnumDescriptionCache[enumType.FullName]);
        }
        public static T GetEnumValueByDescription <T>(string description)
        {
            IList <EnumDescriptionAttribute> list = EnumDescriptionAttribute.GetDescriptions(typeof(T));

            return((T)list.First(ed => string.Equals(ed.Description, description)).EnumValue);
        }