在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
add a class: [DisplayName("Department Name")] [ExportAttribute(FieldOrder = 2)] public string DepartmentName { get { return this.Department.DepartmentName; } } public PropertyInfo[] GetPropertyInfoArray(Type type) { PropertyInfo[] props = null; try { object obj = Activator.CreateInstance(type); //props = (from r in type.GetProperties(BindingFlags.Public | BindingFlags.Instance) // where r.GetCustomAttribute(typeof(DisplayNameAttribute)) != null // select r).ToArray(); props = type.GetProperties(BindingFlags.Instance | BindingFlags.Public) .Select(x => new { Property = x, Attribute = (ExportAttribute)Attribute.GetCustomAttribute(x, typeof(ExportAttribute), true) }) .Where(x => x.Property.GetCustomAttribute(typeof(DisplayNameAttribute)) != null ) .OrderBy(x => x.Attribute != null ? x.Attribute.FieldOrder : -1) .Select(x => x.Property ) .ToArray(); } catch (Exception ex) { AppLogger.LogErrorOnly(ex); } return props; } |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论