Exemple #1
0
        static string GetNameByCulture(EnumAttribute attr, int lcid)
        {
            bool zh = lcid == 2052;

            if (zh)
            {
                return(attr.Name);
            }
            else
            {
                return(attr.EnName);
            }
        }
Exemple #2
0
        static string GetName(object obj, int lcid)
        {
            Type typeDescription = typeof(EnumAttribute);
            Type enumType        = obj.GetType();

            if (enumType.IsEnum)
            {
                System.Reflection.FieldInfo fieldInfo = enumType.GetField(obj.ToString());
                object[] attr = fieldInfo.GetCustomAttributes(typeDescription, false);
                if (attr.Length > 0)
                {
                    EnumAttribute attrEnum = attr[0] as EnumAttribute;
                    return(GetNameByCulture(attrEnum, lcid));
                }
            }
            return(obj.ToString());
        }