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


C# DotNet.TypeRef类代码示例

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


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

示例1: GetColor

		/// <summary>
		/// Gets a type color
		/// </summary>
		/// <param name="type">Type</param>
		/// <returns></returns>
		public virtual object GetColor(TypeRef type) {
			if (type == null)
				return BoxedTextColor.Text;

			var td = type.Resolve();
			if (td != null)
				return GetColor(td);

			return BoxedTextColor.Type;
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:15,代码来源:MetadataTextColorProvider.cs

示例2: ResolveExportedType

		TypeDef ResolveExportedType(IList<ModuleDef> modules, TypeRef typeRef) {
			var exportedType = FindExportedType(modules, typeRef);
			if (exportedType == null)
				return null;

			var asmResolver = modules[0].Context.AssemblyResolver;
			var etAsm = asmResolver.Resolve(exportedType.DefinitionAssembly, typeRef.Module);
			if (etAsm == null)
				return null;

			return etAsm.Find(typeRef);
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:12,代码来源:Resolver.cs

示例3: CheckType

		/// <summary>
		/// Checks whether the type matches an expected type
		/// </summary>
		/// <param name="module">Module</param>
		/// <param name="name">Type name</param>
		/// <param name="expectedType">Expected type</param>
		/// <returns></returns>
		public static bool CheckType(ModuleDef module, string name, TypeRef expectedType) {
			if (module == null)
				module = new ModuleDefUser();
			var tr = TypeNameParser.ParseReflection(module, name, null);
			if (tr == null)
				return false;

			var flags = AssemblyNameComparerFlags.All & ~AssemblyNameComparerFlags.Version;
			if (!new AssemblyNameComparer(flags).Equals(tr.DefinitionAssembly, expectedType.DefinitionAssembly))
				return false;

			if (!new SigComparer().Equals(tr, expectedType))
				return false;

			return true;
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:23,代码来源:SerializedImageUtilities.cs

示例4: ResolveExportedType

		TypeDef ResolveExportedType(IList<ModuleDef> modules, TypeRef typeRef, ModuleDef sourceModule) {
			for (int i = 0; i < 30; i++) {
				var exportedType = FindExportedType(modules, typeRef);
				if (exportedType == null)
					return null;

				var asmResolver = modules[0].Context.AssemblyResolver;
				var etAsm = asmResolver.Resolve(exportedType.DefinitionAssembly, sourceModule ?? typeRef.Module);
				if (etAsm == null)
					return null;

				var td = etAsm.Find(typeRef);
				if (td != null)
					return td;

				modules = etAsm.Modules;
			}

			return null;
		}
开发者ID:EmilZhou,项目名称:dnlib,代码行数:20,代码来源:Resolver.cs

示例5: Resolve

		/// <inheritdoc/>
		public TypeDef Resolve(TypeRef typeRef, ModuleDef sourceModule) {
			if (typeRef == null)
				return null;

			if (ProjectWinMDRefs)
				typeRef = WinMDHelpers.ToCLR(typeRef.Module ?? sourceModule, typeRef) ?? typeRef;

			var nonNestedTypeRef = TypeRef.GetNonNestedTypeRef(typeRef);
			if (nonNestedTypeRef == null)
				return null;

			var nonNestedResolutionScope = nonNestedTypeRef.ResolutionScope;
			var nonNestedModule = nonNestedTypeRef.Module;
			var asmRef = nonNestedResolutionScope as AssemblyRef;
			if (asmRef != null) {
				var asm = assemblyResolver.Resolve(asmRef, sourceModule ?? nonNestedModule);
				return asm == null ? null : asm.Find(typeRef) ?? ResolveExportedType(asm.Modules, typeRef, sourceModule);
			}

			var moduleDef = nonNestedResolutionScope as ModuleDef;
			if (moduleDef != null)
				return moduleDef.Find(typeRef) ??
					ResolveExportedType(new ModuleDef[] { moduleDef }, typeRef, sourceModule);

			var moduleRef = nonNestedResolutionScope as ModuleRef;
			if (moduleRef != null) {
				if (nonNestedModule == null)
					return null;
				if (new SigComparer().Equals(moduleRef, nonNestedModule))
					return nonNestedModule.Find(typeRef) ??
						ResolveExportedType(new ModuleDef[] { nonNestedModule }, typeRef, sourceModule);
				var nonNestedAssembly = nonNestedModule.Assembly;
				if (nonNestedAssembly == null)
					return null;
				var resolvedModule = nonNestedAssembly.FindModule(moduleRef.Name);
				return resolvedModule == null ? null : resolvedModule.Find(typeRef) ??
						ResolveExportedType(new ModuleDef[] { resolvedModule }, typeRef, sourceModule);
			}

			return null;
		}
开发者ID:EmilZhou,项目名称:dnlib,代码行数:42,代码来源:Resolver.cs

示例6: FindAssemblyRef

		/// <inheritdoc/>
		public AssemblyRef FindAssemblyRef(TypeRef nonNestedTypeRef) {
			var modAsm = module.Assembly;
			if (modAsm != null) {
				var type = modAsm.Find(nonNestedTypeRef);
				if (type != null)
					return module.UpdateRowId(new AssemblyRefUser(modAsm));
			}
			else if (module.Find(nonNestedTypeRef) != null)
				return AssemblyRef.CurrentAssembly;

			var corLibAsm = module.Context.AssemblyResolver.Resolve(module.CorLibTypes.AssemblyRef, module);
			if (corLibAsm != null) {
				var type = corLibAsm.Find(nonNestedTypeRef);
				if (type != null)
					return module.CorLibTypes.AssemblyRef;
			}

			if (modAsm != null)
				return module.UpdateRowId(new AssemblyRefUser(modAsm));
			return AssemblyRef.CurrentAssembly;
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:22,代码来源:CustomAttributeReader.cs

示例7: CreateFullName

		void CreateFullName(TypeRef typeRef) {
			if (typeRef == null) {
				sb.Append(NULLVALUE);
				return;
			}
			if (!recursionCounter.Increment()) {
				sb.Append(RECURSION_ERROR_RESULT_STRING);
				return;
			}

			var declaringTypeRef = typeRef.ResolutionScope as TypeRef;
			if (declaringTypeRef != null) {
				CreateFullName(declaringTypeRef);
				AddNestedTypeSeparator();
			}

			if (AddNamespace(typeRef.Namespace))
				sb.Append('.');
			AddName(typeRef.Name);

			recursionCounter.Decrement();
		}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:22,代码来源:FullNameCreator.cs

示例8: OwnerModule

		/// <summary>
		/// Returns the owner module. The type was created from metadata in this module.
		/// </summary>
		/// <param name="typeRef">The <c>TypeRef</c></param>
		/// <returns>A <see cref="ModuleDef"/> or <c>null</c> if none found</returns>
		public static ModuleDef OwnerModule(TypeRef typeRef) {
			return new FullNameCreator().GetOwnerModule(typeRef);
		}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:8,代码来源:FullNameCreator.cs

示例9: DefinitionAssembly

		/// <summary>
		/// Returns the assembly where this type is defined
		/// </summary>
		/// <param name="typeRef">The <c>TypeRef</c></param>
		/// <returns>A <see cref="IAssembly"/> or <c>null</c> if none found</returns>
		public static IAssembly DefinitionAssembly(TypeRef typeRef) {
			return new FullNameCreator().GetDefinitionAssembly(typeRef);
		}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:8,代码来源:FullNameCreator.cs

示例10: AssemblyQualifiedName

		/// <summary>
		/// Returns the assembly qualified full name of a <see cref="TypeRef"/>
		/// </summary>
		/// <param name="typeRef">The <c>TypeRef</c></param>
		/// <returns>The assembly qualified full name</returns>
		public static string AssemblyQualifiedName(TypeRef typeRef) {
			return AssemblyQualifiedName(typeRef, null);
		}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:8,代码来源:FullNameCreator.cs

示例11: FullName

		/// <summary>
		/// Returns the full name of a <see cref="TypeRef"/>
		/// </summary>
		/// <param name="typeRef">The <c>TypeRef</c></param>
		/// <param name="isReflection">Set if output should be compatible with reflection</param>
		/// <returns>The full name</returns>
		public static string FullName(TypeRef typeRef, bool isReflection) {
			return FullName(typeRef, isReflection, null);
		}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:9,代码来源:FullNameCreator.cs

示例12: GetOwnerModule

		ModuleDef GetOwnerModule(TypeRef typeRef) {
			if (typeRef == null)
				return null;
			return typeRef.Module;
		}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:5,代码来源:FullNameCreator.cs

示例13: FindSlow

		TypeDef FindSlow(TypeRef typeRef) {
			InitializeTypeEnumerator();
			var comparer = new SigComparer { Options = TypeComparerOptions };
			while (true) {
				var type = GetNextTypeDef();
				if (type == null || comparer.Equals(type, typeRef))
					return type;
			}
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:9,代码来源:TypeDefFinder.cs

示例14: FindCache

		TypeDef FindCache(TypeRef typeRef) {
			TypeDef cachedType;
			if (typeRefCache.TryGetValue(typeRef, out cachedType))
				return cachedType;

			// Build the cache lazily
			var comparer = new SigComparer { Options = TypeComparerOptions };
			while (true) {
				cachedType = GetNextTypeDefCache();
				if (cachedType == null || comparer.Equals(cachedType, typeRef))
					return cachedType;
			}
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:13,代码来源:TypeDefFinder.cs

示例15: Find

		/// <inheritdoc/>
		public TypeDef Find(TypeRef typeRef) {
			if (typeRef == null)
				return null;
			return isCacheEnabled ? FindCache(typeRef) : FindSlow(typeRef);
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:6,代码来源:TypeDefFinder.cs


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