/// <summary> /// Returns a collection of properties for the type of array specified by the value parameter, using the specified context and attributes. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a format context.</param> /// <param name="value">An <see cref="T:System.Object"/> that specifies the type of array for which to get properties.</param> /// <param name="attributes">An array of type <see cref="T:System.Attribute"/> that is used as a filter.</param> /// <remarks> /// This is the point where instead of the actual properties of the object a collection of special, always read only, <see cref="T:System.ComponentModel.PropertyDescriptor"/> is returned. /// </remarks> /// <returns> /// A <see cref="T:System.ComponentModel.PropertyDescriptorCollection"/> with the properties that are exposed for this data type, or null if there are no properties. /// </returns> public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptorCollection originalProperties = _originalConverter.GetProperties(context, value, attributes); PropertyDescriptor[] readOnlyProperties = new PropertyDescriptor[originalProperties.Count]; for (int i = 0; i < originalProperties.Count; i++) { readOnlyProperties[i] = new ReadOnlyPropertyDescriptor(originalProperties[i]); } return(new PropertyDescriptorCollection(readOnlyProperties)); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection originalProperties = TypeDescriptor.GetProperties(_wrappedObject, attributes); PropertyDescriptor[] readOnlyProperties = new PropertyDescriptor[originalProperties.Count]; for (int i = 0; i < originalProperties.Count; i++) { readOnlyProperties[i] = new ReadOnlyPropertyDescriptor(originalProperties[i]); } return(new PropertyDescriptorCollection(readOnlyProperties)); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { var props = base.GetProperties(context, value, attributes); if (!((Foo)value).IsBarEditable) { // swap it PropertyDescriptor[] arr = new PropertyDescriptor[props.Count]; props.CopyTo(arr, 0); for (int i = 0; i < arr.Length; i++) { if (arr[i].Name == "Bar") { arr[i] = new ReadOnlyPropertyDescriptor(arr[i]); } } props = new PropertyDescriptorCollection(arr); } return(props); }
/// <summary> /// Returns a collection of properties for the type of array specified by the value parameter, using the specified context and attributes. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a format context.</param> /// <param name="value">An <see cref="T:System.Object"/> that specifies the type of array for which to get properties.</param> /// <param name="attributes">An array of type <see cref="T:System.Attribute"/> that is used as a filter.</param> /// <remarks> /// This is the point where instead of the actual properties of the object a collection of special, always read only, <see cref="T:System.ComponentModel.PropertyDescriptor"/> is returned. /// </remarks> /// <returns> /// A <see cref="T:System.ComponentModel.PropertyDescriptorCollection"/> with the properties that are exposed for this data type, or null if there are no properties. /// </returns> public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptorCollection originalProperties = _originalConverter.GetProperties(context, value, attributes); PropertyDescriptor[] readOnlyProperties = new PropertyDescriptor[originalProperties.Count]; for (int i = 0; i < originalProperties.Count; i++) { readOnlyProperties[i] = new ReadOnlyPropertyDescriptor(originalProperties[i]); } return new PropertyDescriptorCollection(readOnlyProperties); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection originalProperties = TypeDescriptor.GetProperties(_wrappedObject, attributes); PropertyDescriptor[] readOnlyProperties = new PropertyDescriptor[originalProperties.Count]; for (int i = 0; i < originalProperties.Count; i++) { readOnlyProperties[i] = new ReadOnlyPropertyDescriptor(originalProperties[i]); } return new PropertyDescriptorCollection(readOnlyProperties); }