Provides an abstraction for array names.
Inheritance: System.ComponentModel.PropertyDescriptor
コード例 #1
0
ファイル: ArrayRowView.cs プロジェクト: kamranamini61/Accord
        /// <summary>
        ///   Gets the values of the multidimensional array as properties.
        /// </summary>
        ///
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            if (owner.ArrayData.Rank == 2)
            {
                // Multidimensional array of rank 2
                int  col  = owner.ArrayData.GetLength(1);
                Type type = owner.ArrayData.GetType().GetElementType();
                PropertyDescriptor[] prop;

                if (owner.RowNames != null)
                {
                    prop    = new PropertyDescriptor[col + 1];
                    prop[0] = new RowNamePropertyDescriptor("Row");
                    for (int i = 0; i < col; i++)
                    {
                        prop[i + 1] = new ArrayPropertyDescriptor(owner.ColumnNames[i], type, i);
                    }
                }
                else
                {
                    prop = new PropertyDescriptor[col];
                    for (int i = 0; i < col; i++)
                    {
                        prop[i] = new ArrayPropertyDescriptor(owner.ColumnNames[i], type, i);
                    }
                }
                return(new PropertyDescriptorCollection(prop));
            }
            else
            {
                if (owner.ArrayType == ArrayDataType.Simple)
                {
                    int  col  = owner.ArrayData.GetLength(0);
                    Type type = owner.ArrayData.GetType().GetElementType();
                    PropertyDescriptor[] prop = new PropertyDescriptor[col];

                    for (int i = 0; i < prop.Length; i++)
                    {
                        prop[i] = new ArrayPropertyDescriptor(owner.ColumnNames[i], type, i);
                    }

                    return(new PropertyDescriptorCollection(prop));
                }
                else
                {
                    Type type = owner.ArrayData.GetType().GetElementType();
                    PropertyDescriptor[] prop = new PropertyDescriptor[owner.ColumnsCount];

                    for (int i = 0; i < prop.Length; i++)
                    {
                        prop[i] = new ArrayPropertyDescriptor(owner.ColumnNames[i], type, i);
                    }

                    return(new PropertyDescriptorCollection(prop));
                }
            }
        }
コード例 #2
0
        /// <summary>
        ///   Gets the values of the multidimensional array as properties.
        /// </summary>
        ///
        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));
        }
コード例 #3
0
ファイル: ArrayRowView.cs プロジェクト: CanerPatir/framework
        /// <summary>
        ///   Gets the values of the multidimensional array as properties.
        /// </summary>
        /// 
        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);
        }
コード例 #4
0
ファイル: ArrayRowView.cs プロジェクト: natepan/framework
        /// <summary>
        ///   Gets the values of the multidimensional array as properties.
        /// </summary>
        /// 
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            if (owner.ArrayData.Rank == 2)
            {
                // Multidimensional array of rank 2
                int col = owner.ArrayData.GetLength(1);
                Type type = owner.ArrayData.GetType().GetElementType();
                PropertyDescriptor[] prop;

                if (owner.RowNames != null)
                {
                    prop = new PropertyDescriptor[col+1];
                    prop[0] = new RowNamePropertyDescriptor("Row");
                    for (int i = 0; i < col; i++)
                        prop[i+1] = new ArrayPropertyDescriptor(owner.ColumnNames[i], type, i);
                }
                else
                {
                    prop = new PropertyDescriptor[col];
                    for (int i = 0; i < col; i++)
                        prop[i] = new ArrayPropertyDescriptor(owner.ColumnNames[i], type, i);
                }
                return new PropertyDescriptorCollection(prop);
            }
            else
            {
                if (owner.ArrayType == ArrayDataType.Simple)
                {
                    int col = owner.ArrayData.GetLength(0);
                    Type type = owner.ArrayData.GetType().GetElementType();
                    PropertyDescriptor[] prop = new PropertyDescriptor[col];

                    for (int i = 0; i < prop.Length; i++)
                        prop[i] = new ArrayPropertyDescriptor(owner.ColumnNames[i], type, i);

                    return new PropertyDescriptorCollection(prop);
                }
                else
                {
                    Type type = owner.ArrayData.GetType().GetElementType();
                    PropertyDescriptor[] prop = new PropertyDescriptor[owner.ColumnsCount];

                    for (int i = 0; i < prop.Length; i++)
                        prop[i] = new ArrayPropertyDescriptor(owner.ColumnNames[i], type, i);

                    return new PropertyDescriptorCollection(prop);
                }
            }
        }