value) { FieldInfo field = value.GetType().GetField(value.ToString()); DescriptionAttribute...attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute
另外,为了使扩展性更好,我们还需要DescriptionAttribute....descriptionAttribute = null; 51: foreach (DescriptionAttribute a in info.GetCustomAttributes...(typeof(DescriptionAttribute), false)) 52: { 53:...descriptionAttribute = a; 54: break; 55: } 56:...if (descriptionAttribute !
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)] public class DescriptionAttribute.../// 定义描述名称 /// /// 名称 public DescriptionAttribute.../// 名称 /// 排序 public DescriptionAttribute...22 object[] attrs = fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);...23 DescriptionAttribute attr = (DescriptionAttribute)attrs.FirstOrDefault(a => a is DescriptionAttribute
{ private float _TieMu = 5.5f; private string _Rule = "数子法"; [CategoryAttribute("规则"), DescriptionAttribute... get { return _TieMu; } set { _TieMu = TieMu; } } [CategoryAttribute("规则"), DescriptionAttribute...Rule; } } private int _Black = 0; private int _White = 0; [CategoryAttribute("围棋"), DescriptionAttribute... get { return _Black; } set { _Black = Black; } } [CategoryAttribute("围棋"), DescriptionAttribute...private Color _BoardColor = Color.Yellow; [CategoryAttribute("围棋"), DescriptionAttribute("棋盘颜色")] public
this->IsMale = false; this->SkinColor = Color::Yellow; } [CategoryAttribute("常规"), DescriptionAttribute...("名字")] property String^ Name; [CategoryAttribute("常规"), DescriptionAttribute("年龄")] ...property int Age; [CategoryAttribute("外观"), DescriptionAttribute("性别")] property bool IsMale...; [CategoryAttribute("外观"), DescriptionAttribute("肤色")] property Color SkinColor; };
>Age = 0; this->IsMale = false; this->SkinColor = Color::Yellow; } [CategoryAttribute("常规"), DescriptionAttribute...("名字")] property String^ Name; [CategoryAttribute("常规"), DescriptionAttribute("年龄")] property int...Age; [CategoryAttribute("外观"), DescriptionAttribute("性别")] property bool IsMale; [CategoryAttribute...("外观"), DescriptionAttribute("肤色")] property Color SkinColor; }; ?
value) { FieldInfo fi = value.GetType().GetField(value.ToString()); DescriptionAttribute...[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes( typeof(...DescriptionAttribute), false); return (attributes.Length > 0) ?
value) { FieldInfo fi = value.GetType().GetField(value.ToString()); DescriptionAttribute...[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
(Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute attribute)...(Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute attribute)
var field = enumType.GetField(item); object[] arr = field.GetCustomAttributes(typeof(DescriptionAttribute...= null && arr.Length > 0) { description = ((DescriptionAttribute)
value.ToString()); //Object[] objs = fieldinfo.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute...value.ToString(); //} //else //{ // System.ComponentModel.DescriptionAttribute...da = (System.ComponentModel.DescriptionAttribute)objs[0]; // return da.Description;...field.FieldType.IsEnum) { Object[] objs = field.GetCustomAttributes(typeof(DescriptionAttribute...objs.Length > 0) { dic.Add(Enum.Parse(enumType, field.Name), ((DescriptionAttribute
tabtype.GetProperties(); var descriptionAttrtable = tabtype.GetCustomAttributes(typeof(DescriptionAttribute...descriptionAttrtable.Length > 0) { modelBuilder.Entity(item.Name).HasComment(((DescriptionAttribute...props) { var descriptionAttr = prop.GetCustomAttributes(typeof(DescriptionAttribute...{ modelBuilder.Entity(item.Name).Property(prop.Name).HasComment(((DescriptionAttribute...descriptionAttr[0]).Description); } } } } 这里通过反射,得到包含DescriptionAttribute
propertyInfos) 171 { 172 object[] objs = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute...), true); 173 if (objs.Length > 0) 174 { 175 DescriptionAttribute...attr = objs[0] as DescriptionAttribute; 176 string result = attr.Description; 177
FirstOrDefault(a => a.Name == name); 59 object[] obj = fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute...), false); 60 if (obj.Length > 0) 61 { 62 des = ((DescriptionAttribute
Description特性值 item.Description = string.Empty; var descrAttr = field.GetCustomAttribute<DescriptionAttribute...descrAttr.Description; } items.Add(item); } } return items; } 代码中,使用了Type对象,FieldInfo对象,DescriptionAttribute...Description特性值 item.Description = string.Empty; var descrAttr = field.GetCustomAttribute<DescriptionAttribute
(enumvalue); object[] enumAttr = finfo.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute...), true); if (enumAttr.Length > 0) { System.ComponentModel.DescriptionAttribute...desc = enumAttr[0] as System.ComponentModel.DescriptionAttribute; if (desc !
(Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute descAttr))
增加Excel枚举导出对DescriptionAttribute的支持 #168 (https://github.com/dotnetcore/Magicodes.IE/issues/168) 在导出枚举类型时起初我们可以通过...ValueMapping和导出枚举本身的字符串名称,在现在我们可以通过 DescriptionAttribute、 DisplayAttribute, DisplayNameAttribute 实现Text
Microsoft.VisualStudio.TestTools.UnitTesting; using Category = Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute
in swagger document o.ApplyDocumentFilter = true; // add descriptions from DescriptionAttribute...descriptions from xml-comments o.IncludeXEnumRemarks = true; // get descriptions from DescriptionAttribute
领取专属 10元无门槛券
手把手带您无忧上云