本文整理汇总了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());
}
示例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;
}
示例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 ());
}
}
示例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()));
}
示例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;
}