当前位置: 首页>>代码示例>>C#>>正文


C# IMetaDataImport.GetMethodProps方法代码示例

本文整理汇总了C#中IMetaDataImport.GetMethodProps方法的典型用法代码示例。如果您正苦于以下问题:C# IMetaDataImport.GetMethodProps方法的具体用法?C# IMetaDataImport.GetMethodProps怎么用?C# IMetaDataImport.GetMethodProps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMetaDataImport的用法示例。


在下文中一共展示了IMetaDataImport.GetMethodProps方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMethodAttributes

		public static unsafe bool GetMethodAttributes(IMetaDataImport mdi, uint token, out MethodAttributes dwAttr, out MethodImplAttributes dwImplFlags) {
			dwAttr = 0;
			dwImplFlags = 0;
			if (mdi == null)
				return false;
			uint dwAttr2, dwImplFlags2;
			int hr = mdi.GetMethodProps(token, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, new IntPtr(&dwAttr2), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, new IntPtr(&dwImplFlags2));
			if (hr < 0)
				return false;
			dwAttr = (MethodAttributes)dwAttr2;
			dwImplFlags = (MethodImplAttributes)dwImplFlags2;
			return true;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:13,代码来源:MDAPI.cs

示例2: GetMethodSignatureBlob

		public unsafe static byte[] GetMethodSignatureBlob(IMetaDataImport mdi, uint token) {
			if (mdi == null)
				return null;
			uint cbSigBlob;
			IntPtr pvSigBlob;
			int hr = mdi.GetMethodProps(token, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, new IntPtr(&pvSigBlob), new IntPtr(&cbSigBlob), IntPtr.Zero, IntPtr.Zero);
			if (hr < 0 || pvSigBlob == IntPtr.Zero)
				return null;

			var sig = new byte[cbSigBlob];
			Marshal.Copy(pvSigBlob, sig, 0, sig.Length);
			return sig;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:13,代码来源:MDAPI.cs

示例3: GetMethodName

		public static unsafe string GetMethodName(IMetaDataImport mdi, uint token) {
			if (mdi == null)
				return null;
			char[] nameBuf = null;
			uint chMethod;
			int hr = mdi.GetMethodProps(token, IntPtr.Zero, IntPtr.Zero, 0, new IntPtr(&chMethod), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
			if (hr >= 0 && chMethod != 0) {
				nameBuf = new char[chMethod];
				fixed (char* p = &nameBuf[0])
					hr = mdi.GetMethodProps(token, IntPtr.Zero, new IntPtr(p), (uint)nameBuf.Length, new IntPtr(&chMethod), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
			}
			if (hr < 0)
				return null;

			if (chMethod <= 1)
				return string.Empty;
			return new string(nameBuf, 0, (int)chMethod - 1);
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:18,代码来源:MDAPI.cs

示例4: _PrintArgs

            static void _PrintArgs(ICorDebugILFrame ilframe, IMetaDataImport importer, System.IO.TextWriter writer)
            {
                uint argcount;
                {
                    ICorDebugValueEnum ven;
                    ilframe.EnumerateArguments(out ven);
                    ven.GetCount(out argcount);
                }
                if (argcount < 1)
                {
                    return;
                }

                uint ftoken;
                ilframe.GetFunctionToken(out ftoken);

                System.Reflection.MethodAttributes fattribs;
                {
                    uint chMethod;
                    uint dwAttr;
                    IntPtr pvSigBlob;
                    uint cbSigBlob;
                    uint ulCodeRVA;
                    uint dwImplFlags;
                    uint ftypedeftoken;
                    int hrmethodprops = (int)importer.GetMethodProps(ftoken, out ftypedeftoken,
                        null, 0, out chMethod,
                        out dwAttr,
                        out pvSigBlob, out cbSigBlob,
                        out ulCodeRVA, out dwImplFlags);
                    Marshal.ThrowExceptionForHR(hrmethodprops);
                    char[] methodnamechars = new char[chMethod];
                    hrmethodprops = (int)importer.GetMethodProps(ftoken, out ftypedeftoken,
                        methodnamechars, (uint)methodnamechars.Length, out chMethod,
                        out dwAttr,
                        out pvSigBlob, out cbSigBlob,
                        out ulCodeRVA, out dwImplFlags);
                    Marshal.ThrowExceptionForHR(hrmethodprops);
                    chMethod--; // Remove nul.
                    //MethodName = new string(methodnamechars, 0, (int)chMethod);
                    fattribs = (System.Reflection.MethodAttributes)dwAttr;
                }

                List<uint> paramtoks = new List<uint>();
                {
                    uint henum = 0;
                    try
                    {
                        uint[] aoneparamtok = new uint[1];
                        for (; ; )
                        {
                            uint count;
                            importer.EnumParams(ref henum, ftoken, aoneparamtok, 1, out count);
                            if (1 != count)
                            {
                                break;
                            }
                            paramtoks.Add(aoneparamtok[0]);
                        }
                    }
                    finally
                    {
                        importer.CloseEnum(henum);
                    }
                }

                uint ia = 0;
                int ip = 0; //paramtoks.Count - (int)argcount;
                for (; ia < argcount; ia++)
                {
                    string argname;
                    if (0 == ia
                            && System.Reflection.MethodAttributes.Static != (fattribs & System.Reflection.MethodAttributes.Static))
                    {
                        argname = "this";
                    }
                    else
                    {
                        if (ip >= paramtoks.Count)
                        {
                            argname = "unnamed_param_" + (1 + ia).ToString();
                        }
                        else
                        {
                            {
                                uint ptok = paramtoks[ip++];
                                uint parenttok;
                                uint pulSequence;
                                uint argnamelen = 0;
                                uint dwAttr, dwCPlusTypeFlag, cchValue;
                                IntPtr pValue;
                                importer.GetParamProps(ptok, out parenttok, out pulSequence, null, argnamelen, out argnamelen,
                                    out dwAttr, out dwCPlusTypeFlag, out pValue, out cchValue);
                                char[] argnamebuf = new char[argnamelen];
                                importer.GetParamProps(ptok, out parenttok, out pulSequence, argnamebuf, argnamelen, out argnamelen,
                                    out dwAttr, out dwCPlusTypeFlag, out pValue, out cchValue);
                                argnamelen--; // Remove nul.
                                argname = new string(argnamebuf, 0, (int)argnamelen);
                            }
                        }
//.........这里部分代码省略.........
开发者ID:erisonliang,项目名称:qizmt,代码行数:101,代码来源:Program.cs

示例5: GetMethodOwnerRid

		public unsafe static uint GetMethodOwnerRid(IMetaDataImport mdi, uint token) {
			if (mdi == null)
				return 0;
			if (IsGlobal(mdi, token))
				return 1;
			uint ownerToken;
			int hr = mdi.GetMethodProps(token, new IntPtr(&ownerToken), IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
			if (hr != 0)
				return 0;
			var ownerMdToken = new MDToken(ownerToken);
			return ownerMdToken.Table == Table.TypeDef ? ownerMdToken.Rid : 0;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:12,代码来源:MDAPI.cs

示例6: GetMethodSignature

		public static MethodSig GetMethodSignature(IMetaDataImport mdi, uint token) {
			if (mdi == null)
				return null;
			MethodAttributes attrs;
			MethodImplAttributes implAttrs;
			uint chMethod, cbSigBlob, ulCodeRVA;
			IntPtr pvSigBlob;
			int hr = mdi.GetMethodProps(token, IntPtr.Zero, IntPtr.Zero, 0, out chMethod, out attrs, out pvSigBlob, out cbSigBlob, out ulCodeRVA, out implAttrs);
			if (hr < 0)
				return null;

			byte[] sig = new byte[cbSigBlob];
			Marshal.Copy(pvSigBlob, sig, 0, sig.Length);
			return new DebugSignatureReader().ReadSignature(mdi, sig) as MethodSig;
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:15,代码来源:MetaDataUtils.cs

示例7: ReadPropertyInfo

		unsafe static CorPropertyInfo ReadPropertyInfo(IMetaDataImport mdi, uint token, CorType type) {
			if (mdi == null)
				return null;

			uint chProperty, dwPropFlags, mdSetter, mdGetter;
			int hr = mdi.GetPropertyProps(token, IntPtr.Zero, IntPtr.Zero, 0, out chProperty, out dwPropFlags, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, out mdSetter, out mdGetter, IntPtr.Zero, 0, IntPtr.Zero);
			char[] nameBuf = null;
			if (hr >= 0 && chProperty != 0) {
				nameBuf = new char[chProperty];
				fixed (char* p = &nameBuf[0])
					hr = mdi.GetPropertyProps(token, IntPtr.Zero, new IntPtr(p), (uint)nameBuf.Length, out chProperty, out dwPropFlags, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, out mdSetter, out mdGetter, IntPtr.Zero, 0, IntPtr.Zero);
			}
			if (hr < 0)
				return null;

			string name = chProperty <= 1 ? string.Empty : new string(nameBuf, 0, (int)chProperty - 1);

			var getSig = GetMethodSignature(mdi, mdGetter);
			var setSig = GetMethodSignature(mdi, mdSetter);

			if (getSig == null)
				return null;
			if (getSig.ParamsAfterSentinel != null)
				return null;
			if (getSig.GenParamCount != 0)
				return null;
			if (getSig.Params.Count != 0)
				return null;
			if (getSig.RetType.RemovePinnedAndModifiers().GetElementType() == ElementType.Void)
				return null;

			if (setSig != null && setSig.ParamsAfterSentinel != null)
				setSig = null;
			if (setSig != null && setSig.GenParamCount != 0)
				setSig = null;
			if (setSig != null && setSig.Params.Count != 1)
				setSig = null;
			if (setSig != null && setSig.RetType.RemovePinnedAndModifiers().GetElementType() != ElementType.Void)
				setSig = null;

			if (setSig != null && getSig.HasThis != setSig.HasThis)
				setSig = null;
			if (setSig != null && !Equals(getSig.RetType.RemovePinnedAndModifiers(), setSig.Params[0].RemovePinnedAndModifiers()))
				setSig = null;

			if (setSig == null)
				mdSetter = 0;

			MethodAttributes getMethodAttrs;
			MethodImplAttributes dwImplAttrs;
			IntPtr pvSigBlob;
			hr = mdi.GetMethodProps(mdGetter, IntPtr.Zero, IntPtr.Zero, 0, out chProperty, out getMethodAttrs, out pvSigBlob, out chProperty, out chProperty, out dwImplAttrs);
			if (hr < 0)
				return null;

			var browseState = GetDebuggerBrowsableState(mdi, token);

			return new CorPropertyInfo(type, token, mdGetter, mdSetter, name, getSig, setSig, getMethodAttrs, browseState);
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:59,代码来源:MetaDataUtils.cs

示例8: GetMethodDefName

		public static unsafe string GetMethodDefName(IMetaDataImport mdi, uint token, out MethodAttributes dwAttr, out MethodImplAttributes dwImplFlags) {
			dwAttr = 0;
			dwImplFlags = 0;
			if (mdi == null)
				return null;
			char[] nameBuf = null;
			uint chMethod, cbSigBlob, ulCodeRVA;
			IntPtr pvSigBlob;
			int hr = mdi.GetMethodProps(token, IntPtr.Zero, IntPtr.Zero, 0, out chMethod, out dwAttr, out pvSigBlob, out cbSigBlob, out ulCodeRVA, out dwImplFlags);
			if (hr >= 0 && chMethod != 0) {
				nameBuf = new char[chMethod];
				fixed (char* p = &nameBuf[0])
					hr = mdi.GetMethodProps(token, IntPtr.Zero, new IntPtr(p), (uint)nameBuf.Length, out chMethod, out dwAttr, out pvSigBlob, out cbSigBlob, out ulCodeRVA, out dwImplFlags);
			}
			if (hr < 0)
				return null;

			if (chMethod <= 1)
				return string.Empty;
			return new string(nameBuf, 0, (int)chMethod - 1);
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:21,代码来源:MetaDataUtils.cs

示例9: MethodGetNumArg

        //need to parse methodsig
        public static uint MethodGetNumArg(IMetaDataImport mdi, uint tk)
        {
            uint cbSig;
            byte* pSig;
            mdi.GetMethodProps(tk, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, (IntPtr)(&pSig), (IntPtr)(&cbSig), IntPtr.Zero, IntPtr.Zero);

            byte flags = *pSig++;
            uint cArgs = CorSigUncompressData(ref pSig);

            if ((flags & (byte)CorCallingConvention.IMAGE_CEE_CS_CALLCONV_HASTHIS) != 0)
                cArgs++;

            return cArgs;
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:15,代码来源:MetaDataImportInterface.cs

示例10: MethodGetName

        public static string MethodGetName(IMetaDataImport mdi, uint tk)
        {
            uint chName;

            mdi.GetMethodProps(tk, IntPtr.Zero, IntPtr.Zero, 0, (IntPtr)(&chName), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

            char* szName = stackalloc char[(int)chName];

            mdi.GetMethodProps(tk, IntPtr.Zero, (IntPtr)szName, chName, (IntPtr)(&chName), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
            return new string(szName);
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:11,代码来源:MetaDataImportInterface.cs

示例11: MethodGetAttributes

        public static int MethodGetAttributes(IMetaDataImport mdi, uint tk)
        {
            int dwAttributes;

            mdi.GetMethodProps(tk, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, new IntPtr(&dwAttributes), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
            return dwAttributes;
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:7,代码来源:MetaDataImportInterface.cs

示例12: MethodGetImplFlags

        public static int MethodGetImplFlags(IMetaDataImport mdi, uint tk)
        {
            int dwImplFlags;

            mdi.GetMethodProps(tk, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, new IntPtr(&dwImplFlags));
            return dwImplFlags;
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:7,代码来源:MetaDataImportInterface.cs


注:本文中的IMetaDataImport.GetMethodProps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。