コード例 #1
0
        internal new static GenericInstanceTypeSignature FromReader(ModuleDefinition module, IBinaryStreamReader reader,
                                                                    RecursionProtection protection)
        {
            var genericType = TypeSignature.FromReader(module, reader, protection);
            var signature   = new GenericInstanceTypeSignature(genericType.ToTypeDefOrRef(), genericType.ElementType == ElementType.ValueType);

            if (!reader.TryReadCompressedUInt32(out uint count))
            {
                return(signature);
            }

            for (int i = 0; i < count; i++)
            {
                signature.TypeArguments.Add(TypeSignature.FromReader(module, reader, protection));
            }

            return(signature);
        }
コード例 #2
0
 /// <summary>
 /// Reads a single dimension array type signature with 0 as a lower bound from an input stream.
 /// </summary>
 /// <param name="parentModule">The module containing the signature.</param>
 /// <param name="reader">The input stream.</param>
 /// <param name="protection">The object instance responsible for detecting infinite recursion.</param>
 /// <returns>The signature.</returns>
 public new static SzArrayTypeSignature FromReader(ModuleDefinition parentModule, IBinaryStreamReader reader,
                                                   RecursionProtection protection)
 {
     return(new SzArrayTypeSignature(TypeSignature.FromReader(parentModule, reader, protection)));
 }
コード例 #3
0
        internal new static ArrayTypeSignature FromReader(ModuleDefinition parentModule, IBinaryStreamReader reader,
                                                          RecursionProtection protection)
        {
            var signature = new ArrayTypeSignature(TypeSignature.FromReader(parentModule, reader, protection));

            // Rank
            if (!reader.TryReadCompressedUInt32(out uint rank))
            {
                return(signature);
            }

            // Sizes.
            if (!reader.TryReadCompressedUInt32(out uint numSizes))
            {
                return(signature);
            }

            var sizes = new List <uint>();

            for (int i = 0; i < numSizes; i++)
            {
                if (!reader.TryReadCompressedUInt32(out uint size))
                {
                    return(signature);
                }
                sizes.Add(size);
            }

            // Lower bounds.
            if (!reader.TryReadCompressedUInt32(out uint numLoBounds))
            {
                return(signature);
            }

            var loBounds = new List <uint>();

            for (int i = 0; i < numLoBounds; i++)
            {
                if (!reader.TryReadCompressedUInt32(out uint bound))
                {
                    return(signature);
                }
                loBounds.Add(bound);
            }

            // Create dimensions.
            for (int i = 0; i < rank; i++)
            {
                int?size = null, lowerBound = null;

                if (i < numSizes)
                {
                    size = (int)sizes[i];
                }
                if (i < numLoBounds)
                {
                    lowerBound = (int)loBounds[i];
                }

                signature.Dimensions.Add(new ArrayDimension(size, lowerBound));
            }

            return(signature);
        }