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


C# IMetaDataImport类代码示例

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


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


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