public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) { // Retrieve cached properties and filtered properties bool filtering = attributes != null && attributes.Length > 0; FilterCache <PropertyDescriptorCollection> propertyCache = TypeDescriptionProvider._filterPropertyCache; PropertyDescriptorCollection propertyDescriptorCollection = TypeDescriptionProvider._propertyCache; // Use a cached version if we can if (filtering && propertyCache != null && propertyCache.IsValid(attributes)) { return(propertyCache.FilteredMembers); } else if (!filtering && propertyDescriptorCollection != null) { return(propertyDescriptorCollection); } // Otherwise, create the property collection propertyDescriptorCollection = new PropertyDescriptorCollection(null); foreach (PropertyDescriptor prop in base.GetProperties(attributes)) { propertyDescriptorCollection.Add(prop); } foreach (FieldInfo field in ObjectType.GetFields()) { ChoConfigurationFieldPropertyDescriptor fieldDesc = new ChoConfigurationFieldPropertyDescriptor(field); if (!filtering || fieldDesc.Attributes.Contains(attributes)) { propertyDescriptorCollection.Add(fieldDesc); } } // Store the updated properties if (filtering) { propertyCache = new FilterCache <PropertyDescriptorCollection>(); propertyCache.FilteredMembers = propertyDescriptorCollection; propertyCache.Attributes = attributes; TypeDescriptionProvider._filterPropertyCache = propertyCache; } else { TypeDescriptionProvider._propertyCache = propertyDescriptorCollection; } // Return the computed properties return(propertyDescriptorCollection); }
public IEnumerable <IMemberInfo> GetMemberInfos() { if (_descriprors != null) { return(_descriprors); } _descriprors = new List <IMemberInfo>(); foreach (var fieldInfo in ObjectType.GetFields()) { var descriptor = new FieldMemberInfo(fieldInfo); var arg = new CancelEventArgs(); OnEditMemberDescriptorOverride(fieldInfo, arg); if (arg.Cancel) { continue; } EditFieldDecriptor(descriptor); _descriprors.Add(descriptor); } return(_descriprors); }