Пример #1
0
        public MethodRefSignature(byte[] signiture) : base(Signatures.MethodRef)
        {
            Offset offset = 0;

            var calling = new CallingConventionSignatureToken(signiture, offset);

            Tokens.Add(calling);
            if ((calling.Convention & CallingConventions.Generic) != 0)
            {
                var genParamCount = new GenericParamaterCountSignatureToken(signiture, offset);
                Tokens.Add(genParamCount);
            }

            var paramCount = new ParameterCountSignatureToken(signiture, offset);

            Tokens.Add(paramCount);

            var returnType = new ReturnTypeSignatureToken(signiture, offset);

            Tokens.Add(returnType);

            for (int i = 0; i < paramCount.Count; i++)
            {
                if (SentinalSignatureToken.IsToken(signiture, offset))
                {
                    i--;    // This is not a parameter
                    Tokens.Add(new SentinalSignatureToken(signiture, offset));
                }
                else
                {
                    var param = new ParamSignatureToken(signiture, offset);
                    Tokens.Add(param);
                }
            }
        }
        private void ReadMethodSignature(byte[] signitureBytes, Signature created)
        {
            created.Type = Signatures.MethodDef;

            Offset offset = 0;

            var convention = new CallingConventionSignatureToken(signitureBytes, offset);

            created.Tokens.Add(convention);
            if ((convention.Convention & CallingConventions.Generic) != 0)
            {
                var genericParam = new GenericParamaterCountSignatureToken(signitureBytes, offset);
                created.Tokens.Add(genericParam);
            }

            var paramCount = new ParameterCountSignatureToken(signitureBytes, offset);

            created.Tokens.Add(paramCount);

            ReadReturnTypeSignature(created, signitureBytes, offset);
        }