/// <summary> /// 初始化一个<see cref="TypeMetadata"/>类型的新实例 /// </summary> public TypeMetadata(Type type) { if (type == null) { return; } Name = type.Name; FullName = type.FullName; Namespace = type.Namespace; Display = type.GetDescription().Replace("信息", ""); PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo property in properties) { if (property.HasAttribute <IgnoreGenPropertyAttribute>()) { continue; } if (property.GetMethod.IsVirtual && !property.GetMethod.IsFinal) { continue; } if (PropertyMetadatas == null) { PropertyMetadatas = new List <PropertyMetadata>(); } PropertyMetadatas.Add(new PropertyMetadata(property)); } }
/// <summary> /// 初始化一个<see cref="TypeMetadata"/>类型的新实例 /// </summary> public TypeMetadata(Type type) { if (type == null) { return; } Name = type.Name; FullName = type.FullName; Namespace = type.Namespace; Display = type.GetDescription(); PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo property in properties.Where(m => !m.HasAttribute <IgnoreGenPropertyAttribute>())) { if (PropertyMetadatas == null) { PropertyMetadatas = new List <PropertyMetadata>(); } PropertyMetadatas.Add(new PropertyMetadata(property)); } }