/// <summary> /// <para>Gets a collection of properties for the type of array specified by the value parameter.</para> /// </summary> public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { if (value == null) { return null; } PropertyDescriptor[] props = null; if (value.GetType().IsArray) { Array valueArray = (Array)value; int length = valueArray.GetLength(0); props = new PropertyDescriptor[length]; Type arrayType = value.GetType(); Type elementType = arrayType.GetElementType(); for (int i = 0; i < length; i++) { props[i] = new ArrayPropertyDescriptor(arrayType, elementType, i); } } return new PropertyDescriptorCollection(props); }
public override PropertyDescriptorCollection?GetProperties(ITypeDescriptorContext?context, object?value, Attribute[]?attributes) { if (value == null) { return(null); } if (!(value is Array valueArray)) { return(new PropertyDescriptorCollection(null)); } int length = valueArray.GetLength(0); PropertyDescriptor[] props = new PropertyDescriptor[length]; Type arrayType = value.GetType(); Type elementType = arrayType.GetElementType() !; for (int i = 0; i < length; i++) { props[i] = new ArrayPropertyDescriptor(arrayType, elementType, i); } return(new PropertyDescriptorCollection(props)); }
/// <summary> /// <para>Gets a collection of properties for the type of array specified by the value parameter.</para> /// </summary> public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { if (value == null) { return(null); } PropertyDescriptor[] props = null; if (value.GetType().IsArray) { Array valueArray = (Array)value; int length = valueArray.GetLength(0); props = new PropertyDescriptor[length]; Type arrayType = value.GetType(); Type elementType = arrayType.GetElementType(); for (int i = 0; i < length; i++) { props[i] = new ArrayPropertyDescriptor(arrayType, elementType, i); } } return(new PropertyDescriptorCollection(props)); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { var keyValueAttribute = context?.PropertyDescriptor?.Attributes?[typeof(KeyValueElementAttribute)] as KeyValueElementAttribute; if (keyValueAttribute == null) { throw new ArgumentException($"The {typeof(KeyValueExpandableArrayConverter).Name} can only be used on properties that have the " + $"{typeof(KeyValueElementAttribute).Name} defined."); } PropertyDescriptor[] properties = null; var array = value as Array; if (array != null) { Type type = array.GetType(); Type elementType = type.GetElementType(); int length = array.GetLength(0); properties = new PropertyDescriptor[length]; for (var index = 0; index < length; ++index) { object source = array.GetValue(index); properties[index] = new ArrayPropertyDescriptor(elementType, keyValueAttribute.GetName(source), keyValueAttribute.GetValue(source)); } } return(new PropertyDescriptorCollection(properties)); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptor[] descriptorArray1 = null; if (value.GetType().IsArray) { int num1 = ((Array)value).GetLength(0); descriptorArray1 = new PropertyDescriptor[num1]; Type type1 = value.GetType(); Type type2 = type1.GetElementType(); for (int num2 = 0; num2 < num1; num2++) { descriptorArray1[num2] = new ArrayPropertyDescriptor(type1, type2, num2); } } return(new PropertyDescriptorCollection(descriptorArray1)); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptor[] properties = null; if (value.GetType().IsArray) { int length = ((Array)value).GetLength(0); properties = new PropertyDescriptor[length]; Type arrayType = value.GetType(); Type elementType = typeof(Reference <T, Ti>); for (int i = 0; i < length; i++) { properties[i] = new ArrayPropertyDescriptor(arrayType, elementType, i); } } return(new PropertyDescriptorCollection(properties)); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptor[] properties = null; //Type type = value.GetType(); Collection <W> collection = value as Collection <W>; if (value != null) { List <Attribute> alist = new List <Attribute>(attributes); alist.Add(new ReadOnlyAttribute(true)); alist.Add(new TypeConverterAttribute(typeof(ExpandableObjectConverterEx))); int length = collection.Count; properties = new PropertyDescriptor[length]; Type arrayType = collection.GetType(); Type elementType = typeof(W); for (int i = 0; i < length; i++) { properties[i] = new ArrayPropertyDescriptor(arrayType, elementType, i, alist.ToArray()); } } return(new PropertyDescriptorCollection(properties)); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptor[] descriptorArray1 = null; if (value.GetType().IsArray) { int num1 = ((Array) value).GetLength(0); descriptorArray1 = new PropertyDescriptor[num1]; Type type1 = value.GetType(); Type type2 = type1.GetElementType(); for (int num2 = 0; num2 < num1; num2++) { descriptorArray1[num2] = new ArrayPropertyDescriptor(type1, type2, num2); } } return new PropertyDescriptorCollection(descriptorArray1); }