/// <summary> /// Provides custom type information for properties. /// </summary> /// <remarks>This is where the properties we want exposed are created, each with their own DynamicPropDescriptor Class wich handles the communication with the PropertyGrid.</remarks> public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection mOriginalPropertyDescriptors = TypeDescriptor.GetProperties(mInstance, bInherited); List <DynamicPropDescriptor> newPropDescriptiors = new List <DynamicPropDescriptor>(mOriginalPropertyDescriptors.Count); PropertyDescriptor origProp; DynPropertyOverride dynProp; for (int i = 0; i < mOriginalPropertyDescriptors.Count; i++) { origProp = mOriginalPropertyDescriptors[i]; List <Attribute> newAttributeList = new List <Attribute>(origProp.Attributes.Count); foreach (Attribute origAttr in origProp.Attributes) { newAttributeList.Add(origAttr); } dynProp = null; if (mOverrideProps.TryGetValue(origProp.Name, out dynProp)) { if (dynProp.Overrides.Count > 0) { doAttributeOverrides(dynProp, newAttributeList); } // ADD / MODIFY / REMOVE Property information HERE // // .. ///////////////////////////////////////////////////// } Attribute[] newAttributeArray = new Attribute[newAttributeList.Count]; newAttributeList.CopyTo(newAttributeArray); DynamicPropDescriptor dynNew = new DynamicPropDescriptor(mInstance, origProp, mOverrideProps, dynProp, newAttributeArray); newPropDescriptiors.Add(dynNew); } return(sortedPropertyDescriptorCollection(newPropDescriptiors)); }
/// <summary> /// Provides custom type information for properties. /// </summary> /// <remarks>This is where the properties we want exposed are created, each with their own DynamicPropDescriptor Class wich handles the communication with the PropertyGrid.</remarks> public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection mOriginalPropertyDescriptors = TypeDescriptor.GetProperties(mInstance, bInherited); List<DynamicPropDescriptor> newPropDescriptiors = new List<DynamicPropDescriptor>(mOriginalPropertyDescriptors.Count); PropertyDescriptor origProp; DynPropertyOverride dynProp; for (int i = 0; i < mOriginalPropertyDescriptors.Count; i++) { origProp = mOriginalPropertyDescriptors[i]; List<Attribute> newAttributeList = new List<Attribute>(origProp.Attributes.Count); foreach (Attribute origAttr in origProp.Attributes) newAttributeList.Add(origAttr); dynProp = null; if (mOverrideProps.TryGetValue(origProp.Name, out dynProp)) { if (dynProp.Overrides.Count > 0) doAttributeOverrides(dynProp, newAttributeList); // ADD / MODIFY / REMOVE Property information HERE // // .. ///////////////////////////////////////////////////// } Attribute[] newAttributeArray = new Attribute[newAttributeList.Count]; newAttributeList.CopyTo(newAttributeArray); DynamicPropDescriptor dynNew = new DynamicPropDescriptor(mInstance, origProp, mOverrideProps, dynProp, newAttributeArray); newPropDescriptiors.Add(dynNew); } return sortedPropertyDescriptorCollection(newPropDescriptiors); }