public override PropertyDescriptorCollection GetChildProperties(object instance, Attribute[] filter) { PropertyDescriptorCollection pdc = null; var tc = this.Converter; if (tc.GetPropertiesSupported(null) == false) { pdc = base.GetChildProperties(instance, filter); } else { } if (propertyDescriptor != null) { tc = propertyDescriptor.Converter; } else { //pdc = base.GetChildProperties(instance, filter);// this gives us a readonly collection, no good tc = TypeDescriptor.GetConverter(instance, true); } if (pdc == null || pdc.Count == 0) { return(pdc); } if (pdc[0] is CustomPropertyDescriptor) { return(pdc); } // now wrap these properties with our CustomPropertyDescriptor var pdl = new PropertyDescriptorList( ); foreach (PropertyDescriptor pd in pdc) { if (pd is CustomPropertyDescriptor) { pdl.Add(pd as CustomPropertyDescriptor); } else { pdl.Add(new CustomPropertyDescriptor(instance, pd)); } } pdl.Sort(new PropertySorter( )); var pdcReturn = new PropertyDescriptorCollection(pdl.ToArray( )); pdcReturn.Sort( ); return(pdcReturn); }
public CustomPropertyDescriptor CreateProperty(string name, Type type, object value, int index, params Attribute[] attributes) { var cpd = new CustomPropertyDescriptor(instance, name, type, value, attributes); if (index == -1) { propertyDescriptorList.Add(cpd); } else { propertyDescriptorList.Insert(index, cpd); } TypeDescriptor.Refresh(instance); return(cpd); }
public override PropertyDescriptorCollection GetChildProperties( object instance, Attribute[] filter ) { PropertyDescriptorCollection pdc = null; var tc = this.Converter; if (tc.GetPropertiesSupported(null) == false) { pdc = base.GetChildProperties(instance, filter); } else { } if (propertyDescriptor != null) { tc = propertyDescriptor.Converter; } else { //pdc = base.GetChildProperties(instance, filter);// this gives us a readonly collection, no good tc = TypeDescriptor.GetConverter(instance, true); } if (pdc == null || pdc.Count == 0) { return pdc; } if (pdc[0] is CustomPropertyDescriptor) { return pdc; } // now wrap these properties with our CustomPropertyDescriptor var pdl = new PropertyDescriptorList( ); foreach (PropertyDescriptor pd in pdc) { if (pd is CustomPropertyDescriptor) { pdl.Add(pd as CustomPropertyDescriptor); } else { pdl.Add(new CustomPropertyDescriptor(instance, pd)); } } pdl.Sort(new PropertySorter( )); var pdcReturn = new PropertyDescriptorCollection(pdl.ToArray( )); pdcReturn.Sort( ); return pdcReturn; }