Exemple #1
0
 public AnyTypeSpecifier(object prototype)
 {
     System.Type type = prototype.GetType();
     this.Type = type;
     if (!type.IsArray)
     {
         if (type != typeof(string))
         {
             this.Category    = DataTypeCategory.Primitive;
             this.StrLen      = -1;
             this.DimLengths  = null;
             this.ElementType = null;
         }
         else
         {
             string str = (string)prototype;
             this.Category    = DataTypeCategory.String;
             this.StrLen      = str.Length;
             this.DimLengths  = null;
             this.ElementType = null;
         }
     }
     else
     {
         Array array     = (Array)prototype;
         int   rank      = array.Rank;
         int[] indices   = new int[rank];
         int[] numArray2 = new int[rank];
         DimensionCollection dimensions = new DimensionCollection();
         for (int i = 0; i < rank; i++)
         {
             indices[i]   = array.GetLowerBound(i);
             numArray2[i] = array.GetLength(i);
             dimensions.Add(new Dimension(indices[i], numArray2[i]));
         }
         this.Category   = DataTypeCategory.Array;
         this.StrLen     = -1;
         this.DimLengths = new List <IDimensionCollection> {
             dimensions.AsReadOnly()
         }.AsReadOnly();
         System.Type elementType = this.Type.GetElementType();
         if (array.Length <= 0)
         {
             this.ElementType = new AnyTypeSpecifier(elementType);
         }
         else
         {
             object obj2 = array.GetValue(indices);
             this.ElementType = new AnyTypeSpecifier(obj2);
         }
     }
 }
Exemple #2
0
 public AnyTypeSpecifier(System.Type type)
 {
     this.StrLen      = -1;
     this.DimLengths  = null;
     this.ElementType = null;
     if (!type.IsArray)
     {
         this.Category = (type != typeof(string)) ? DataTypeCategory.Primitive : DataTypeCategory.String;
     }
     else
     {
         this.Category    = DataTypeCategory.Array;
         this.ElementType = new AnyTypeSpecifier(type.GetElementType());
     }
     this.Type = type;
 }
Exemple #3
0
 private AnyTypeSpecifier(System.Type type, IList <IDimensionCollection> dimLengths, int jaggedLevel) : this(type)
 {
     if (!type.IsArray)
     {
         throw new ArgumentOutOfRangeException("type");
     }
     this.DimLengths = dimLengths;
     System.Type elementType = type.GetElementType();
     if (!elementType.IsArray)
     {
         this.ElementType = new AnyTypeSpecifier(elementType);
     }
     else
     {
         IList <IDimensionCollection> list = new List <IDimensionCollection>();
         for (int i = 1; i < dimLengths.Count; i++)
         {
             list.Add(dimLengths[i]);
         }
         this.ElementType = new AnyTypeSpecifier(elementType, list, ++jaggedLevel);
     }
 }