本文整理汇总了C#中AssemblyLoader.Load方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyLoader.Load方法的具体用法?C# AssemblyLoader.Load怎么用?C# AssemblyLoader.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssemblyLoader
的用法示例。
在下文中一共展示了AssemblyLoader.Load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
var assemblyLoader = new AssemblyLoader("DomainTestClasses.dll");
var assembly = assemblyLoader.Load();
_methodFinder = new AssemblySearcher(assembly);
}
示例2: DownloadXapFile
/// <summary>Downloads the specified XAP file.</summary>
/// <param name="xapFileName">The name of the XAP file to download.</param>
/// <param name="callback">Action to invoke when complete (passes back the entry-point assembly).</param>
public static void DownloadXapFile(string xapFileName, Action<Assembly> callback)
{
// Setup initial conditions.
if (DownloadCatalog == null) throw new InitializationException("The 'DownloadCatalog' has not been set. Create this an initialize it with the CompositionHost during startup.");
// Download the XAP file.
var loader = new AssemblyLoader(xapFileName);
loader.Load(() =>
{
// Check for errors.
if (loader.Error != null)
{
Output.Write("Failed to load XAP file: " + xapFileName);
Output.Write(loader.Error);
if (callback != null) callback(loader.RootAssembly);
return;
}
// Register the assemblies with MEF.
var currentAssemblies = Deployment.Current.GetAssemblies();
foreach (var assembly in loader.Assemblies)
{
try
{
if (currentAssemblies.Contains(assembly)) continue; // Ensure assemblies are not added more than once.
DownloadCatalog.Catalogs.Add(new AssemblyCatalog(assembly));
}
catch (Exception error)
{
Output.WriteTitle(Colors.Red, "Load Failure");
Output.Write(
Colors.Red,
string.Format("Failed to load assembly while downloading the XAP file: '{0}'",
xapFileName));
Output.WriteException(error);
break;
}
}
// Finish up.
if (callback != null) callback(loader.RootAssembly);
//TEMP
// Re-download with the MEF package-downloader to ensure it gets registered correctly with MEF.
// NB: This should get the XAP file from cache.
//var mefDownloader = new DeploymentCatalog(loader.XapFileName);
//mefDownloader.DownloadCompleted += delegate
// {
// // Finish up.
// if (callback != null) callback(loader.RootAssembly);
// };
//mefDownloader.DownloadAsync();
});
}