public static string GetName(this Type iType, string iPropertyString, string iLang) { NameAttribute[] attribs = iType.GetProperty(iPropertyString).GetCustomAttributes(typeof(NameAttribute), false) as NameAttribute[]; NameAttribute name = (NameAttribute)attribs.Where(a => a is NameAttribute).Where(a => ((NameAttribute)a).lang == iLang).SingleOrDefault(); return(name?.GetName()); }
public static string GetName(this object iValue, string iLang) { Type type = iValue.GetType(); FieldInfo fieldInfo = type.GetField(iValue.ToString()); NameAttribute[] attrs = fieldInfo.GetCustomAttributes(typeof(NameAttribute), false) as NameAttribute[]; NameAttribute name = (NameAttribute)attrs.Where(a => a is NameAttribute).Where(a => ((NameAttribute)a).lang == iLang).SingleOrDefault(); return(name?.GetName()); }