Provides an abstraction of array values.
Inheritance: System.ComponentModel.PropertyDescriptor
 /// <summary>
 ///   Gets the values of the multidimensional array as properties.
 /// </summary>
 public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
 {
     if (owner.Data.Rank == 2)
     {
         int  col  = owner.Data.GetLength(1);
         Type type = owner.Data.GetType().GetElementType();
         PropertyDescriptor[] 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
     {
         int  col  = owner.Data.GetLength(0);
         Type type = owner.Data.GetType().GetElementType();
         PropertyDescriptor[] prop = new PropertyDescriptor[col];
         for (int i = 0; i < col; i++)
         {
             prop[i] = new ArrayPropertyDescriptor(owner.ColumnNames[i], type, i);
         }
         return(new PropertyDescriptorCollection(prop));
     }
 }
Example #2
0
        /// <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));
                }
            }
        }
Example #3
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));
        }
 /// <summary>
 ///   Gets the values of the multidimensional array as properties.
 /// </summary>
 public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
 {
     if (owner.Data.Rank == 2)
     {
         int col = owner.Data.GetLength(1);
         Type type = owner.Data.GetType().GetElementType();
         PropertyDescriptor[] 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
     {
         int col = owner.Data.GetLength(0);
         Type type = owner.Data.GetType().GetElementType();
         PropertyDescriptor[] prop = new PropertyDescriptor[col];
         for (int i = 0; i < col; i++)
         {
             prop[i] = new ArrayPropertyDescriptor(owner.ColumnNames[i], type, i);
         }
         return new PropertyDescriptorCollection(prop);
     }
 }
Example #5
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);
        }
Example #6
0
        /// <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);
                }
            }
        }