static string GetNameByCulture(EnumAttribute attr, int lcid) { bool zh = lcid == 2052; if (zh) { return(attr.Name); } else { return(attr.EnName); } }
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()); }