public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { if (value is ControlBindingsCollection) { ControlBindingsCollection collection = (ControlBindingsCollection)value; Control control = collection.Control; Type type = control.GetType(); PropertyDescriptorCollection bindableProperties = TypeDescriptor.GetProperties(control, null); ArrayList props = new ArrayList(); for (int i = 0; i < bindableProperties.Count; i++) { DesignBindingPropertyDescriptor property = new DesignBindingPropertyDescriptor(bindableProperties[i], null); bool bindable = ((BindableAttribute)bindableProperties[i].Attributes[typeof(BindableAttribute)]).Bindable; if (bindable || !((DesignBinding)property.GetValue(collection)).IsNull) { props.Add(property); } } props.Add(new AdvancedBindingPropertyDescriptor()); PropertyDescriptor[] propArray = new PropertyDescriptor[props.Count]; props.CopyTo(propArray, 0); return(new PropertyDescriptorCollection(propArray)); } return(new PropertyDescriptorCollection(new PropertyDescriptor[0])); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { if (!(value is ControlBindingsCollection)) { return(new PropertyDescriptorCollection(new PropertyDescriptor[0])); } ControlBindingsCollection component = (ControlBindingsCollection)value; PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(component.BindableComponent, (Attribute[])null); ArrayList list = new ArrayList(); for (int i = 0; i < properties.Count; i++) { Binding binding = component[properties[i].Name]; bool readOnly = (((binding != null) && !(binding.DataSource is IListSource)) && !(binding.DataSource is IList)) && !(binding.DataSource is Array); DesignBindingPropertyDescriptor descriptor = new DesignBindingPropertyDescriptor(properties[i], null, readOnly); if (((BindableAttribute)properties[i].Attributes[typeof(BindableAttribute)]).Bindable || !((DesignBinding)descriptor.GetValue(component)).IsNull) { list.Add(descriptor); } } list.Add(new AdvancedBindingPropertyDescriptor()); PropertyDescriptor[] array = new PropertyDescriptor[list.Count]; list.CopyTo(array, 0); return(new PropertyDescriptorCollection(array)); }
/// <include file='doc\AdvancedBindingObject.uex' path='docs/doc[@for="AdvancedBindingObject.ICustomTypeDescriptor.GetProperties1"]/*' /> /// <devdoc> /// Retrieves an array of properties that the given component instance /// provides. This may differ from the set of properties the class /// provides. If the component is sited, the site may add or remove /// additional properties. The returned array of properties will be /// filtered by the given set of attributes. /// </devdoc> PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) { if (propsCollection == null) { Control control = bindings.Control; Type type = control.GetType(); PropertyDescriptorCollection bindableProperties = TypeDescriptor.GetProperties(control, attributes); AttributeCollection controlAttributes = TypeDescriptor.GetAttributes(type); DefaultPropertyAttribute defPropAttr = ((DefaultPropertyAttribute)controlAttributes[typeof(DefaultPropertyAttribute)]); ArrayList props = new ArrayList(); for (int i = 0; i < bindableProperties.Count; i++) { if (bindableProperties[i].IsReadOnly) { continue; } bool bindable = ((BindableAttribute)bindableProperties[i].Attributes[typeof(BindableAttribute)]).Bindable; DesignOnlyAttribute designAttr = ((DesignOnlyAttribute)bindableProperties[i].Attributes[typeof(DesignOnlyAttribute)]); DesignBindingPropertyDescriptor property = new DesignBindingPropertyDescriptor(bindableProperties[i], null); property.AddValueChanged(bindings, new EventHandler(OnBindingChanged)); // ASURT 45429: skip the Design time properties // if (!bindable && !showAll || designAttr.IsDesignOnly) { if (((DesignBinding)property.GetValue(this)).IsNull) { continue; } } props.Add(property); // ASURT 45429: make the default property have focus in the properties window // if (defPropAttr != null && property.Name.Equals(defPropAttr.Name)) { System.Diagnostics.Debug.Assert(this.defaultProp == null, "a control cannot have two default properties"); this.defaultProp = property; } } PropertyDescriptor[] propArray = new PropertyDescriptor[props.Count]; props.CopyTo(propArray, 0); this.propsCollection = new PropertyDescriptorCollection(propArray); } return(propsCollection); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { if (!(value is ControlBindingsCollection)) { return new PropertyDescriptorCollection(new PropertyDescriptor[0]); } ControlBindingsCollection component = (ControlBindingsCollection) value; PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(component.BindableComponent, (Attribute[]) null); ArrayList list = new ArrayList(); for (int i = 0; i < properties.Count; i++) { Binding binding = component[properties[i].Name]; bool readOnly = (((binding != null) && !(binding.DataSource is IListSource)) && !(binding.DataSource is IList)) && !(binding.DataSource is Array); DesignBindingPropertyDescriptor descriptor = new DesignBindingPropertyDescriptor(properties[i], null, readOnly); if (((BindableAttribute) properties[i].Attributes[typeof(BindableAttribute)]).Bindable || !((DesignBinding) descriptor.GetValue(component)).IsNull) { list.Add(descriptor); } } list.Add(new AdvancedBindingPropertyDescriptor()); PropertyDescriptor[] array = new PropertyDescriptor[list.Count]; list.CopyTo(array, 0); return new PropertyDescriptorCollection(array); }