System.ComponentModel.ArrayConverter.GetProperties C# (CSharp) Method

GetProperties() public method

public GetProperties ( ITypeDescriptorContext context, object value, Attribute attributes ) : PropertyDescriptorCollection
context ITypeDescriptorContext
value object
attributes Attribute
return PropertyDescriptorCollection
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) {

            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);
        }