本文整理汇总了C#中System.Global.AddAssemblies方法的典型用法代码示例。如果您正苦于以下问题:C# Global.AddAssemblies方法的具体用法?C# Global.AddAssemblies怎么用?C# Global.AddAssemblies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Global
的用法示例。
在下文中一共展示了Global.AddAssemblies方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
//.........这里部分代码省略.........
// asmRef.Location = <the right place>;
// }
// SystemAssemblyLocation.Location = <the right place>;
// SystemXmlAssemblyLocation.Location = <the right place>;
//
// But so far that doesn't seem necessary
CCI.SystemTypes.Initialize(false, true, resolver);
// ----------------------------------------
// Account for mscorlib being loaded
// ----------------------------------------
var mscorlib = CCI.SystemTypes.SystemAssembly;
if (mscorlib == null || mscorlib.Directory == null)
{
log(new UnloadableMSCorLibMessage(frameworkDir));
throw new ExitException();
}
var mscorlibName = StrongAssemblyNameFromCCIAssembly(mscorlib);
fileNameToStrongName[mscorlibCanonicalName] = mscorlibName;
strongNameToInfo.Add(mscorlibName, new AssemblyInfo { Assembly = mscorlib, FileName = mscorlibCanonicalName });
log(new LoadedAssemblyMessage(mscorlib.StrongName, mscorlibCanonicalName));
Void = ResolveCCIType(mscorlib, "System", "Void");
ValueType = ResolveCCIType(mscorlib, "System", "ValueType");
Enum = ResolveCCIType(mscorlib, "System", "Enum");
global = new Global(mscorlibName);
// The global environment is now ready for use...
// ----------------------------------------
// Load the remaining registered assemblies
// ----------------------------------------
var pending = new List<string>();
foreach (var kv in fileNameToStrongName)
{
if (kv.Value == null)
pending.Add(kv.Key);
// else: must have been mscorlib, which we loaded above
}
foreach (var canonicalFileName in pending)
{
var assembly = CCI.AssemblyNode.GetAssembly(canonicalFileName, null, false, true, true);
if (assembly == null)
{
log(new UnloadableAssemblyMessage(canonicalFileName));
throw new ExitException();
}
var sn = StrongAssemblyNameFromCCIAssembly(assembly);
var info = default(AssemblyInfo);
if (strongNameToInfo.TryGetValue(sn, out info))
{
log(new DuplicateAssemblyStrongNameMessage(canonicalFileName, sn.ToString(), info.FileName));
throw new ExitException();
}
log(new LoadedAssemblyMessage(sn.ToString(), canonicalFileName));
fileNameToStrongName[canonicalFileName] = sn;
strongNameToInfo.Add(sn, new AssemblyInfo { Assembly = assembly, FileName = canonicalFileName });
assembly.AssemblyReferenceResolution += resolver;
}
// ----------------------------------------
// Convert all assemblies. Since we visit all assemblies and types this will also check that
// all assembly references resolved to valid assemblies.
// ----------------------------------------
// We use the global environment for the first time here...
var assemblies = new List<AssemblyDef>();
foreach (var kv in strongNameToInfo)
{
try
{
assemblies.Add(AssemblyDefFromCCIAssembly(kv.Value.Assembly));
log(new ResolvedAssemblyMessage(kv.Key.ToString(), kv.Value.FileName));
}
catch (InvalidOperationException)
{
log(new UnresolvableAssemblyMessage(kv.Key.ToString(), kv.Value.FileName));
throw new ExitException();
}
}
global.AddAssemblies(assemblies);
// ----------------------------------------
// Teardown CCI
// ----------------------------------------
cciQualifiedTypeNameCache.Clear();
foreach (var kv in strongNameToInfo)
kv.Value.Assembly.Dispose();
strongNameToInfo.Clear();
CCI.TargetPlatform.Clear();
return global;
}