public static string GetRemark(this Enum eValue) { Type type = eValue.GetType(); FieldInfo field = type.GetField(eValue.ToString()); RemarkAttribute remarkAttribute = field.GetCustomAttribute(typeof(RemarkAttribute)) as RemarkAttribute; return(remarkAttribute == null ? field.Name : remarkAttribute.Remark); }
public static string GetColumnName(this PropertyInfo prop) { if (prop.IsDefined(typeof(RemarkAttribute), true)) { RemarkAttribute attribute = (RemarkAttribute)prop.GetCustomAttribute(typeof(RemarkAttribute), true); return(attribute.GetRemark()); } else { return(prop.Name); } }
public static IList <string> GetALLRemark(this Enum eType) { IList <string> list = new List <string>(); Type type = eType.GetType(); foreach (var field in type.GetFields()) { if (field.Name.Equals("value__")) { continue; } RemarkAttribute remarkAttribute = field.GetCustomAttribute(typeof(RemarkAttribute)) as RemarkAttribute; list.Add(remarkAttribute == null ? field.Name : remarkAttribute.Remark); } return(list); }