GetSignatureFromToken() public method

public GetSignatureFromToken ( int token ) : ConstArray
token int
return ConstArray
コード例 #1
0
ファイル: RuntimeModule.cs プロジェクト: belav/runtime
        public override byte[] ResolveSignature(int metadataToken)
        {
            MetadataToken tk = new MetadataToken(metadataToken);

            if (!MetadataImport.IsValidToken(tk))
            {
                throw new ArgumentOutOfRangeException(
                          nameof(metadataToken),
                          SR.Format(SR.Argument_InvalidToken, tk, this)
                          );
            }

            if (
                !tk.IsMemberRef &&
                !tk.IsMethodDef &&
                !tk.IsTypeSpec &&
                !tk.IsSignature &&
                !tk.IsFieldDef
                )
            {
                throw new ArgumentException(
                          SR.Format(SR.Argument_InvalidToken, tk, this),
                          nameof(metadataToken)
                          );
            }

            ConstArray signature;

            if (tk.IsMemberRef)
            {
                signature = MetadataImport.GetMemberRefProps(metadataToken);
            }
            else
            {
                signature = MetadataImport.GetSignatureFromToken(metadataToken);
            }

            byte[] sig = new byte[signature.Length];

            for (int i = 0; i < signature.Length; i++)
            {
                sig[i] = signature[i];
            }

            return(sig);
        }
コード例 #2
0
        public byte[] ResolveSignature(int metadataToken)
        {
            MetadataToken tk = new MetadataToken(metadataToken);

            if (!MetadataImport.IsValidToken(tk))
            {
                throw new ArgumentOutOfRangeException("metadataToken",
                                                      String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidToken", tk, this)));
            }

            if (!tk.IsMemberRef && !tk.IsMethodDef && !tk.IsTypeSpec && !tk.IsSignature && !tk.IsFieldDef)
            {
                throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidToken", tk, this)),
                                            "metadataToken");
            }

            ConstArray signature;

            if (tk.IsMemberRef)
            {
                signature = MetadataImport.GetMemberRefProps(metadataToken);
            }
            else
            {
                signature = MetadataImport.GetSignatureFromToken(metadataToken);
            }

            byte[] sig = new byte[signature.Length];

            for (int i = 0; i < signature.Length; i++)
            {
                sig[i] = signature[i];
            }

            return(sig);
        }