Esempio n. 1
0
        public ArrayType ReadArrayType()
        {
            TypeReference arrayType = ReadTypeReference((ElementType)this.ReadByte());
            uint          rank      = NETGlobals.ReadCompressedUInt32(this);

            uint[] upperbounds = new uint[NETGlobals.ReadCompressedUInt32(this)];

            for (int i = 0; i < upperbounds.Length; i++)
            {
                upperbounds[i] = NETGlobals.ReadCompressedUInt32(this);
            }

            int[] lowerbounds = new int[NETGlobals.ReadCompressedUInt32(this)];

            for (int i = 0; i < lowerbounds.Length; i++)
            {
                lowerbounds[i] = NETGlobals.ReadCompressedInt32(this);
            }


            ArrayDimension[] dimensions = new ArrayDimension[rank];

            for (int i = 0; i < rank; i++)
            {
                int?lower = null;
                int?upper = null;

                if (i < lowerbounds.Length)
                {
                    lower = new int?(lowerbounds[i]);
                }

                if (i < upperbounds.Length)
                {
                    int x = (int)upperbounds[i];
                    upper = (lower.HasValue ? new int?(lower.GetValueOrDefault() + x) : 0) - 1;
                }
                ArrayDimension dimension = new ArrayDimension(lower, upper);
                dimensions[i] = dimension;
            }



            return(new ArrayType(arrayType, (int)rank, dimensions));
        }
Esempio n. 2
0
        public ArrayType ReadArrayType()
        {
            TypeReference arrayType = ReadTypeReference((ElementType)this.ReadByte());
            uint rank = NETGlobals.ReadCompressedUInt32(this);
            uint[] upperbounds = new uint[NETGlobals.ReadCompressedUInt32(this)];

            for (int i = 0; i < upperbounds.Length; i++)
                upperbounds[i] = NETGlobals.ReadCompressedUInt32(this);

            int[] lowerbounds = new int[NETGlobals.ReadCompressedUInt32(this)];

            for (int i = 0; i < lowerbounds.Length; i++)
                lowerbounds[i] = NETGlobals.ReadCompressedInt32(this);

            ArrayDimension[] dimensions = new ArrayDimension[rank];

            for (int i = 0; i < rank; i++)
            {
                int? lower = null;
                int? upper = null;

                if (i < lowerbounds.Length)
                    lower = new int?(lowerbounds[i]);

                if (i < upperbounds.Length)
                {
                    int x = (int)upperbounds[i];
                    upper = (lower.HasValue ? new int?(lower.GetValueOrDefault() + x) : 0) - 1;
                }
                ArrayDimension dimension = new ArrayDimension(lower, upper);
                dimensions[i] = dimension;

            }

            return new ArrayType(arrayType, (int)rank, dimensions);
        }
Esempio n. 3
0
 public ArrayType(TypeReference typeRef, int rank, ArrayDimension[] dimensions)
     : base(typeRef)
 {
     Rank = rank;
     Dimensions = dimensions;
 }