/// <summary> /// 注册类属性 /// </summary> /// <param name="obj"></param> /// <param name="pds"></param> public static void RegisteProperties(this IPropertyObject obj, PropertyDescriptorCollection pds = null) { if (typeProperties.ContainsKey(obj.GetType())) { return; } if (pds == null || pds.Count <= 0) { PropertiesAttribute attr = obj.GetType().FindAttribute <PropertiesAttribute>(false); if (attr == null || attr.items == null || attr.items.Length <= 0) { return; } pds = new PropertyDescriptorCollection(); pds.AddRange(attr.items); } PropertyDescriptorCollection pdc = new PropertyDescriptorCollection(); pdc.AddRange(pds); typeProperties[obj.GetType()] = pdc; if (!objectPropertiesValues.ContainsKey(obj)) { objectPropertiesValues[obj] = new Dictionary <PropertyDescriptor, object>(); } }
/// <summary> /// 注册属性 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="pds"></param> public static void RegisteProperties <T>(PropertyDescriptorCollection pds) //where T : IPropertyObject { if (typeProperties.ContainsKey(typeof(T))) { return; } if (pds == null || pds.Count <= 0) { PropertiesAttribute attr = typeof(T).FindAttribute <PropertiesAttribute>(false); if (attr == null || attr.items == null || attr.items.Length <= 0) { return; } pds = new PropertyDescriptorCollection(); pds.AddRange(attr.items); } typeProperties[typeof(T)] = pds; }