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


C# IMetadataScope.GetType方法代码示例

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


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

示例1: getCanonicalizedScopeName

        public static string getCanonicalizedScopeName(IMetadataScope scope)
        {
            AssemblyNameReference asmRef = null;

            switch (scope.MetadataScopeType) {
            case MetadataScopeType.AssemblyNameReference:
                asmRef = (AssemblyNameReference)scope;
                break;
            case MetadataScopeType.ModuleDefinition:
                var module = (ModuleDefinition)scope;
                if (module.Assembly != null)
                    asmRef = module.Assembly.Name;
                break;
            case MetadataScopeType.ModuleReference:
                break;
            default:
                throw new ApplicationException(string.Format("Invalid scope type: {0}", scope.GetType()));
            }

            if (asmRef != null) {
                // The version number should be ignored. Older code may reference an old version of
                // the assembly, but if the newer one has been loaded, that one is used.
                return asmRef.Name.ToLowerInvariant();
            }
            return string.Format("{0}", scope.ToString().ToLowerInvariant());
        }
开发者ID:ldh0227,项目名称:de4dot,代码行数:26,代码来源:MemberReferenceHelper.cs

示例2: GetScopeName

		private string GetScopeName (IMetadataScope scope)
		{
			if (scope == null)
				return String.Empty;
			
			ModuleDefinition md = (scope as ModuleDefinition);
			if (md != null)
				return md.Name.Replace (", ", ",\\n");
				
			AssemblyNameReference anr = (scope as AssemblyNameReference);
			if (anr != null)
				return anr.FullName.Replace (", ", ",\\n");
			
			Console.WriteLine ("GetScopeName {0}", scope.GetType ());
			return String.Empty;
		}
开发者ID:transformersprimeabcxyz,项目名称:cecil-old,代码行数:16,代码来源:CallerAnalysisVisualizer.cs

示例3: EmitScope

	void EmitScope (IMetadataScope s, StringBuilder sb) {
		if (s is AssemblyNameReference) {
			AssemblyNameReference aname = (s as AssemblyNameReference);
			sb.Append ("[" + EscapeName (aname.Name) + "]");
		} else if (s is ModuleDefinition) {
			if (s != main)
				throw new NotImplementedException ();
		} else {
			throw new NotImplementedException (s.GetType ().ToString ());
		}
	}
开发者ID:sesef,项目名称:mono,代码行数:11,代码来源:ildasm.cs

示例4: getAssemblyNameReference

        public static AssemblyNameReference getAssemblyNameReference(IMetadataScope scope)
        {
            if (scope is ModuleDefinition) {
                var moduleDefinition = (ModuleDefinition)scope;
                return moduleDefinition.Assembly.Name;
            }
            else if (scope is AssemblyNameReference)
                return (AssemblyNameReference)scope;

            throw new ApplicationException(string.Format("Unknown IMetadataScope type: {0}", scope.GetType()));
        }
开发者ID:ostuda,项目名称:de4dot,代码行数:11,代码来源:DotNetUtils.cs

示例5: findModules

        // Returns null if it's a non-loaded module/assembly
        IEnumerable<Module> findModules(IMetadataScope scope)
        {
            if (scope is AssemblyNameReference) {
                var assemblyRef = (AssemblyNameReference)scope;
                var moduleHash = assemblyHash.lookup(assemblyRef.ToString());
                if (moduleHash != null)
                    return moduleHash.Modules;
            }
            else if (scope is ModuleDefinition) {
                var moduleDefinition = (ModuleDefinition)scope;
                var module = modulesDict.lookup(moduleDefinition.FullyQualifiedName);
                if (module != null)
                    return new List<Module> { module };
            }
            else
                throw new ApplicationException(string.Format("IMetadataScope is an unsupported type: {0}", scope.GetType()));

            return null;
        }
开发者ID:ostuda,项目名称:de4dot,代码行数:20,代码来源:DefinitionsRenamer.cs


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