Accord.Controls.ArrayRowView.GetProperties C# (CSharp) Method

GetProperties() public method

Gets the values of the multidimensional array as properties.
public GetProperties ( Attribute attributes ) : PropertyDescriptorCollection
attributes System.Attribute
return System.ComponentModel.PropertyDescriptorCollection
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptor[] prop;

            Array array = owner.ArrayData;
            int cols = owner.ColumnsCount;

            Type type = array.GetType().GetElementType();
            if (owner.ArrayType == ArrayDataType.Jagged)
            {
                if (array.GetLength(0) == 0)
                    return null;
                type = owner.ArrayData.GetValue(0).GetType().GetElementType();
            }


            if (owner.ArrayType == ArrayDataType.Multidimensional ||
                owner.ArrayType == ArrayDataType.Jagged)
            {
                if (owner.RowNames != null)
                {
                    prop = new PropertyDescriptor[cols + 1];
                    prop[0] = new RowNamePropertyDescriptor("Row");
                    for (int i = 0; i < cols; i++)
                        prop[i + 1] = new ArrayPropertyDescriptor(owner.ColumnNames[i], type, i);
                }
                else
                {
                    prop = new PropertyDescriptor[cols];
                    for (int i = 0; i < cols; i++)
                        prop[i] = new ArrayPropertyDescriptor(owner.ColumnNames[i], type, i);
                }
            }
            else if (owner.ArrayType == ArrayDataType.Simple)
            {
                prop = new PropertyDescriptor[cols];
                for (int i = 0; i < prop.Length; i++)
                    prop[i] = new ArrayPropertyDescriptor(owner.ColumnNames[i], type, i);
            }
            else
            {
                throw new InvalidOperationException("Invalid type");
            }

            return new PropertyDescriptorCollection(prop);
        }