Пример #1
0
        /// <summary>
        /// 通过枚举<paramref name="enumObj"/>得到该枚举的Description
        /// 如果该枚举没有对应的Description,则将返回该枚举的ToString()值
        /// </summary>
        /// <param name="enumObj">枚举</param>
        /// <returns>对应的Description</returns>
        public string GetName(Enum enumObj)
        {
            EnumObject obj = null;
            Type       t   = enumObj.GetType();

            testEnum(t);

            string             strType    = t.FullName;
            IList <EnumObject> list       = dicEnum[strType];
            string             testString = enumObj.ToString();

            foreach (EnumObject item in list)
            {
                if (item.ID == testString)
                {
                    obj = item;
                }
            }
            if (obj == null)
            {
                //throw new NeuException(string.Format( "所指定的类型值不存在[0]...",enumObj.ToString()))
                return(testString);
            }
            return(obj.GetNameByLanguage(this.language));
        }
Пример #2
0
        public string GetEnumName <T>(T enumObj)
        {
            EnumObject obj = this.GetEnum <T>(enumObj);

            if (obj != null)
            {
                return(obj.GetNameByLanguage(this.language));
            }
            return(enumObj.ToString());
        }