/// <summary> /// 获取字段说明符上的说明文本 /// </summary> /// <param name="member"></param> /// <returns></returns> public static string GetDescription(this FieldInfo field) { if (Attribute.IsDefined(field, typeof(ResourceDescriptionAttribute))) { ResourceDescriptionAttribute att = Attribute.GetCustomAttribute(field, typeof(ResourceDescriptionAttribute)) as ResourceDescriptionAttribute; return(att.ResourceDescription); } if (Attribute.IsDefined(field, typeof(DescriptionAttribute))) { DescriptionAttribute att = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute; return(att.Description); } return(null); }
/// <summary> /// 获取属性说明符上的说明文本 /// </summary> /// <param name="member"></param> /// <returns></returns> public static string GetDescription(this PropertyDescriptor member) { ResourceDescriptionAttribute attr = member.Attributes[typeof(ResourceDescriptionAttribute)] as ResourceDescriptionAttribute; if (attr != null) { return(attr.ResourceDescription); } DescriptionAttribute attr2 = member.Attributes[typeof(DescriptionAttribute)] as DescriptionAttribute; if (attr2 != null) { return(attr2.Description); } return(null); }