• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IMetaDataImport类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: IsGlobal

		static bool IsGlobal(IMetaDataImport mdi, uint token) {
			if (mdi == null)
				return false;
			int bGlobal;
			int hr = mdi.IsGlobal(token, out bGlobal);
			return hr == 0 && bGlobal != 0;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:7,代码来源:MDAPI.cs


示例2: MetadataCustomAttribute

 /*
 public MetadataCustomAttribute(IMetaDataImport import, uint token)
 {
     this._import = import;
     this._token = token;
 }
 */
 public MetadataCustomAttribute(IMetaDataImport import, uint token, uint methodToken)
 {
     _import = import;
     _token = token;
     if(methodToken != 0)
         _method = new MetadataMethod(import, methodToken);
 }
开发者ID:zedr0n,项目名称:testJS,代码行数:14,代码来源:MetadataCustomAttribute.cs


示例3: GetRVA

		public unsafe static uint? GetRVA(IMetaDataImport mdi, uint token) {
			if (mdi == null)
				return null;

			uint ulCodeRVA;
			int hr = mdi.GetRVA(token, out ulCodeRVA, IntPtr.Zero);
			if (hr != 0)
				return null;
			return ulCodeRVA;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:10,代码来源:MDAPI.cs


示例4: ComReader

        public ComReader(string assemblyPath)
        {
            IMetaDataDispenserEx dispenser = new MetaDataDispenserEx();
            object rawScope;
            //GUID of the IMetaDataImport interface.
            var metaDataImportGuid = new Guid("7DAC8207-D3AE-4c75-9B67-92801A497D44");

            //Open the assembly.
            dispenser.OpenScope(assemblyPath, 0, ref metaDataImportGuid, out rawScope);
            //The rawScope contains an IMetaDataImport interface.
            _import = (IMetaDataImport)rawScope;
        }
开发者ID:zedr0n,项目名称:testJS,代码行数:12,代码来源:COMReader.cs


示例5: GetClassLayout

		public unsafe static bool GetClassLayout(IMetaDataImport mdi, uint token, out ushort packingSize, out uint classSize) {
			packingSize = 0;
			classSize = 0;
			if (mdi == null)
				return false;

			uint dwPackSize = 0, ulClassSize = 0;
			int hr = mdi.GetClassLayout(token, new IntPtr(&dwPackSize), null, 0, IntPtr.Zero, new IntPtr(&ulClassSize));
			if (hr != 0)
				return false;

			packingSize = (ushort)dwPackSize;
			classSize = ulClassSize;
			return true;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:15,代码来源:MDAPI.cs


示例6: GetUtf8Name

		public unsafe static UTF8String GetUtf8Name(IMetaDataImport mdi, uint token) {
			if (mdi == null)
				return null;
			IntPtr pszUtf8NamePtr;
			int hr = mdi.GetNameFromToken(token, out pszUtf8NamePtr);
			if (hr != 0 || pszUtf8NamePtr == IntPtr.Zero)
				return null;
			const int MAX_LEN = 0x1000;
			byte* p = (byte*)pszUtf8NamePtr;
			for (int i = 0; i < MAX_LEN; i++, p++) {
				if (*p == 0)
					break;
			}
			byte[] buf = new byte[p - (byte*)pszUtf8NamePtr];
			Marshal.Copy(pszUtf8NamePtr, buf, 0, buf.Length);
			return new UTF8String(buf);
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:17,代码来源:MDAPI.cs


示例7: GetFieldAttributes

		public unsafe static FieldAttributes GetFieldAttributes(IMetaDataImport mdi, uint token) {
			uint dwAttr;
			int hr = mdi.GetFieldProps(token, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, new IntPtr(&dwAttr), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
			Debug.Assert(hr == 0);
			return hr < 0 ? 0 : (FieldAttributes)dwAttr;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:6,代码来源:MDAPI.cs


示例8: GetFieldName

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

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


示例9: GetFieldSignatureBlob

		public static unsafe byte[] GetFieldSignatureBlob(IMetaDataImport mdi, uint token) {
			if (mdi == null)
				return null;

			uint sigLen = 0;
			IntPtr sigAddr;
			int hr = mdi.GetFieldProps(token, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, new IntPtr(&sigAddr), new IntPtr(&sigLen), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
			if (hr < 0 || sigAddr == IntPtr.Zero)
				return null;

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


示例10: GetEventAddRemoveFireTokens

		public unsafe static bool GetEventAddRemoveFireTokens(IMetaDataImport mdi, uint token, out uint addToken, out uint removeToken, out uint fireToken) {
			addToken = 0;
			removeToken = 0;
			fireToken = 0;
			if (mdi == null)
				return false;
			uint addTokenTmp, removeTokenTmp, fireTokenTmp;
			int hr = mdi.GetEventProps(token, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, new IntPtr(&addTokenTmp), new IntPtr(&removeTokenTmp), new IntPtr(&fireTokenTmp), IntPtr.Zero, 0, IntPtr.Zero);
			if (hr != 0)
				return false;
			addToken = addTokenTmp;
			removeToken = removeTokenTmp;
			fireToken = fireTokenTmp;
			return true;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:15,代码来源:MDAPI.cs


示例11: GetParamOwnerRid

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


示例12: GetEventOwnerRid

		public unsafe static uint GetEventOwnerRid(IMetaDataImport mdi, uint token) {
			if (mdi == null)
				return 0;
			if (IsGlobal(mdi, token))
				return 1;
			uint ownerToken;
			int hr = mdi.GetEventProps(token, new IntPtr(&ownerToken), IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, 0, 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


示例13: GetEventName

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

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


示例14: GetTypeDefEnclosingType

		public static unsafe uint GetTypeDefEnclosingType(IMetaDataImport mdi, uint token) {
			if (mdi == null)
				return 0;
			uint dwTypeDefFlags;
			int hr = mdi.GetTypeDefProps(token, IntPtr.Zero, 0, IntPtr.Zero, new IntPtr(&dwTypeDefFlags), IntPtr.Zero);
			if (hr != 0)
				return 0;

			if ((dwTypeDefFlags & 7) >= 2) {
				uint enclType;
				hr = mdi.GetNestedClassProps(token, out enclType);
				if (hr == 0)
					return enclType;
			}

			return 0;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:17,代码来源:MDAPI.cs


示例15: GetParamName

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

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


示例16: GetTypeDefName

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

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


示例17: GetTypeDefAttributes

		public static unsafe TypeAttributes? GetTypeDefAttributes(IMetaDataImport mdi, uint token) {
			uint dwTypeDefFlags;
			int hr = mdi.GetTypeDefProps(token, IntPtr.Zero, 0, IntPtr.Zero, new IntPtr(&dwTypeDefFlags), IntPtr.Zero);
			return hr == 0 ? (TypeAttributes)dwTypeDefFlags : (TypeAttributes?)null;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:5,代码来源:MDAPI.cs


示例18: GetTypeDefExtends

		public unsafe static uint GetTypeDefExtends(IMetaDataImport mdi, uint token) {
			uint tkExtends;
			int hr = mdi.GetTypeDefProps(token, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, new IntPtr(&tkExtends));
			return hr != 0 ? 0 : tkExtends;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:5,代码来源:MDAPI.cs


示例19: GetTypeDefTokens

		public unsafe static uint[] GetTypeDefTokens(IMetaDataImport mdi) {
			if (mdi == null)
				return new uint[0];

			IntPtr iter = IntPtr.Zero;
			try {
				uint count;
				int hr = mdi.EnumTypeDefs(ref iter, IntPtr.Zero, 0, out count);
				if (hr < 0)
					return new uint[0];

				uint ulCount = 0;
				hr = mdi.CountEnum(iter, ref ulCount);
				if (hr < 0)
					return new uint[0];

				hr = mdi.ResetEnum(iter, 0);
				if (hr < 0)
					return new uint[0];

				// The global type isn't included
				uint[] tokens = new uint[ulCount + 1];
				if (tokens.Length > 1) {
					fixed (uint* p = &tokens[1])
						hr = mdi.EnumTypeDefs(ref iter, new IntPtr(p), ulCount, out count);
				}
				if (hr < 0)
					return new uint[0];
				tokens[0] = 0x02000001;
				return tokens;
			}
			finally {
				if (iter != IntPtr.Zero)
					mdi.CloseEnum(iter);
			}
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:36,代码来源:MDAPI.cs


示例20: GetTypeRefResolutionScope

		public static unsafe uint GetTypeRefResolutionScope(IMetaDataImport mdi, uint token) {
			if (mdi == null)
				return 0;
			uint tkResolutionScope;
			int hr = mdi.GetTypeRefProps(token, new IntPtr(&tkResolutionScope), IntPtr.Zero, 0, IntPtr.Zero);
			return hr == 0 ? tkResolutionScope : 0;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:7,代码来源:MDAPI.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IMetadataHost类代码示例发布时间:2022-05-24
下一篇:
C# IMessenger类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap