FromReader() public static method

public static FromReader ( MetadataHeader header, IBinaryStreamReader reader ) : ParameterSignature
header MetadataHeader
reader IBinaryStreamReader
return ParameterSignature
        /// <summary>
        /// Reads a single property signature at the current position of the provided stream reader.
        /// </summary>
        /// <param name="image">The image the signature resides in.</param>
        /// <param name="reader">The reader to use.</param>
        /// <param name="readToEnd">Determines whether any extra data after the signature should be read and
        /// put into the <see cref="ExtendableBlobSignature.ExtraData"/> property.</param>
        /// <param name="protection">The recursion protection that is used to detect malicious loops in the metadata.</param>
        /// <returns>The read signature.</returns>
        public new static PropertySignature FromReader(
            MetadataImage image,
            IBinaryStreamReader reader,
            bool readToEnd,
            RecursionProtection protection)
        {
            var signature = new PropertySignature
            {
                Attributes = (CallingConventionAttributes)reader.ReadByte(),
            };

            if (!reader.TryReadCompressedUInt32(out uint paramCount))
            {
                return(null);
            }

            signature.PropertyType = TypeSignature.FromReader(image, reader, false, protection);

            for (int i = 0; i < paramCount; i++)
            {
                signature.Parameters.Add(ParameterSignature.FromReader(image, reader, protection));
            }

            if (readToEnd)
            {
                signature.ExtraData = reader.ReadToEnd();
            }

            return(signature);
        }
Beispiel #2
0
        /// <summary>
        /// Reads a single method signature at the current position of the provided stream reader.
        /// </summary>
        /// <param name="image">The image the field is defined in.</param>
        /// <param name="reader">The reader to use.</param>
        /// <param name="readToEnd">Determines whether any extra data after the signature should be read and
        /// put into the <see cref="ExtendableBlobSignature.ExtraData"/> property.</param>
        /// <param name="protection">The recursion protection that is used to detect malicious loops in the metadata.</param>
        /// <returns>The read signature.</returns>
        public new static MethodSignature FromReader(
            MetadataImage image,
            IBinaryStreamReader reader,
            bool readToEnd,
            RecursionProtection protection)
        {
            if (!reader.CanRead(sizeof(byte)))
            {
                return(null);
            }

            var signature = new MethodSignature
            {
                Attributes = (CallingConventionAttributes)reader.ReadByte()
            };

            if (signature.IsGeneric)
            {
                if (!reader.TryReadCompressedUInt32(out uint genericParameterCount))
                {
                    return(signature);
                }
                signature.GenericParameterCount = (int)genericParameterCount;
            }

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

            signature.ReturnType = TypeSignature.FromReader(image, reader);

            for (int i = 0; i < parameterCount; i++)
            {
                signature.Parameters.Add(ParameterSignature.FromReader(image, reader, protection));
            }

            if (readToEnd)
            {
                signature.ExtraData = reader.ReadToEnd();
            }

            return(signature);
        }
Beispiel #3
0
        public new static MethodSignature FromReader(MetadataHeader header, IBinaryStreamReader reader)
        {
            if (!reader.CanRead(sizeof(byte)))
            {
                return(null);
            }

            var signature = new MethodSignature
            {
                StartOffset = reader.Position,
                Attributes  = (CallingConventionAttributes)reader.ReadByte()
            };

            if (signature.IsGeneric)
            {
                uint genericParameterCount;
                if (!reader.TryReadCompressedUInt32(out genericParameterCount))
                {
                    return(signature);
                }
                signature.GenericParameterCount = (int)genericParameterCount;
            }

            uint parameterCount;

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

            signature.ReturnType = TypeSignature.FromReader(header, reader);
            for (int i = 0; i < parameterCount; i++)
            {
                signature.Parameters.Add(ParameterSignature.FromReader(header, reader));
            }

            return(signature);
        }
Beispiel #4
0
        public new static PropertySignature FromReader(MetadataImage image, IBinaryStreamReader reader)
        {
            var signature = new PropertySignature
            {
                Attributes = (CallingConventionAttributes)reader.ReadByte(),
            };

            uint paramCount;

            if (!reader.TryReadCompressedUInt32(out paramCount))
            {
                return(null);
            }

            signature.PropertyType = TypeSignature.FromReader(image, reader);

            for (int i = 0; i < paramCount; i++)
            {
                signature.Parameters.Add(ParameterSignature.FromReader(image, reader));
            }

            return(signature);
        }