本文整理汇总了C#中IAssemblyLoadContext类的典型用法代码示例。如果您正苦于以下问题:C# IAssemblyLoadContext类的具体用法?C# IAssemblyLoadContext怎么用?C# IAssemblyLoadContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IAssemblyLoadContext类属于命名空间,在下文中一共展示了IAssemblyLoadContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public Assembly Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
{
// An assembly name like "MyLibrary!alternate!more-text"
// is parsed into:
// name == "MyLibrary"
// aspect == "alternate"
// and the more-text may be used to force a recompilation of an aspect that would
// otherwise have been cached by some layer within Assembly.Load
var name = assemblyName.Name;
string aspect = null;
var parts = name.Split(new[] { '!' }, 3);
if (parts.Length != 1)
{
name = parts[0];
aspect = parts[1];
}
var library = _libraryManager.GetLibraryDescription(name) as ProjectDescription;
if (library == null)
{
return null;
}
return _compilationEngine.LoadProject(
library.Project,
aspect,
loadContext);
}
示例2: TryRegisterFaultedPlugins
public void TryRegisterFaultedPlugins(IAssemblyLoadContext assemblyLoadContext)
{
if (assemblyLoadContext == null)
{
throw new ArgumentNullException(nameof(assemblyLoadContext));
}
// Capture the messages here so we can clear the original list to potentially re-add messages if they
// fail to recover.
var faultedRegistrations = _faultedRegisterPluginMessages.ToArray();
_faultedRegisterPluginMessages.Clear();
foreach (var faultedRegisterPluginMessage in faultedRegistrations)
{
var response = RegisterPlugin(faultedRegisterPluginMessage, assemblyLoadContext);
if (response.Success)
{
SendMessage(faultedRegisterPluginMessage.PluginId, response);
}
else
{
// We were unable to recover, re-add the faulted register plugin message.
_faultedRegisterPluginMessages.Add(faultedRegisterPluginMessage);
}
}
}
示例3: LibraryExporter
public LibraryExporter(LibraryManager manager, IAssemblyLoadContext loadContext, CompilationEngine compilationEngine, string configuration)
{
LibraryManager = manager;
_compilationEngine = compilationEngine;
_configuration = configuration;
_loadContext = loadContext;
}
示例4: Load
public Assembly Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
{
// An assembly name like "MyLibrary!alternate!more-text"
// is parsed into:
// name == "MyLibrary"
// aspect == "alternate"
// and the more-text may be used to force a recompilation of an aspect that would
// otherwise have been cached by some layer within Assembly.Load
var name = assemblyName.Name;
string aspect = null;
var parts = name.Split(new[] { '!' }, 3);
if (parts.Length != 1)
{
name = parts[0];
aspect = parts[1];
}
Project project;
if (!_projectResolver.TryResolveProject(name, out project))
{
return null;
}
return _compilationEngine.LoadProject(
project,
aspect,
loadContext);
}
示例5: LoadAssembly
/// <summary>
/// Loads the assembly containing precompiled views.
/// </summary>
/// <param name="loadContext">The <see cref="IAssemblyLoadContext"/>.</param>
/// <returns>The <see cref="Assembly"/> containing precompiled views.</returns>
public virtual Assembly LoadAssembly(IAssemblyLoadContext loadContext)
{
var viewCollectionAssembly = GetType().GetTypeInfo().Assembly;
using (var assemblyStream = viewCollectionAssembly.GetManifestResourceStream(AssemblyResourceName))
{
if (assemblyStream == null)
{
var message = Resources.FormatRazorFileInfoCollection_ResourceCouldNotBeFound(AssemblyResourceName,
GetType().FullName);
throw new InvalidOperationException(message);
}
Stream symbolsStream = null;
if (!string.IsNullOrEmpty(SymbolsResourceName))
{
symbolsStream = viewCollectionAssembly.GetManifestResourceStream(SymbolsResourceName);
}
using (symbolsStream)
{
return loadContext.LoadStream(assemblyStream, symbolsStream);
}
}
}
示例6: CompilationEngineContext
public CompilationEngineContext(IApplicationEnvironment applicationEnvironment,
IRuntimeEnvironment runtimeEnvironment,
IAssemblyLoadContext defaultLoadContext,
CompilationCache cache)
: this(applicationEnvironment, runtimeEnvironment, defaultLoadContext, cache, NoopWatcher.Instance)
{
}
示例7: CompilationEngineContext
public CompilationEngineContext(IApplicationEnvironment applicationEnvironment,
IAssemblyLoadContext defaultLoadContext,
CompilationCache cache) :
this(applicationEnvironment, defaultLoadContext, cache, NoopWatcher.Instance, new ProjectGraphProvider())
{
}
示例8: LibraryAssemblyLoadContext
public LibraryAssemblyLoadContext(ProjectAssemblyLoader projectAssemblyLoader,
NuGetAssemblyLoader nugetAssemblyLoader,
IAssemblyLoadContext defaultContext)
{
_projectAssemblyLoader = projectAssemblyLoader;
_nugetAssemblyLoader = nugetAssemblyLoader;
_defaultContext = defaultContext;
}
示例9: RoslynCompilationService
public RoslynCompilationService(IApplicationEnvironment environment,
IAssemblyLoadContextAccessor accessor,
ILibraryExporter libraryExporter)
{
_environment = environment;
_loader = accessor.GetLoadContext(typeof(RoslynCompilationService).GetTypeInfo().Assembly);
_libraryExporter = libraryExporter;
}
示例10: RuntimeLoadContext
public RuntimeLoadContext(LibraryManager libraryManager,
ICompilationEngine compilationEngine,
IAssemblyLoadContext defaultContext)
{
_projectAssemblyLoader = new ProjectAssemblyLoader(loadContextAccessor: null, compilationEngine: compilationEngine, libraryManager: libraryManager);
_packageAssemblyLoader = new PackageAssemblyLoader(loadContextAccessor: null, libraryManager: libraryManager);
_defaultContext = defaultContext;
}
示例11: Load
public Assembly Load(string name, IAssemblyLoadContext loadContext)
{
PackageAssembly assemblyInfo;
if (_dependencyResolver.PackageAssemblyLookup.TryGetValue(name, out assemblyInfo))
{
return loadContext.LoadFile(assemblyInfo.Path);
}
return null;
}
示例12: Load
public Assembly Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
{
// TODO: preserve name and culture info (we don't need to look at any other information)
PackageAssembly assemblyInfo;
if (_dependencyResolver.PackageAssemblyLookup.TryGetValue(new AssemblyName(assemblyName.Name), out assemblyInfo))
{
return loadContext.LoadFile(assemblyInfo.Path);
}
return null;
}
示例13: Load
public Assembly Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
{
// TODO: preserve name and culture info (we don't need to look at any other information)
string path;
if (_assemblies.TryGetValue(new AssemblyName(assemblyName.Name), out path))
{
return loadContext.LoadFile(path);
}
return null;
}
示例14: AssemblyCache
public AssemblyCache(ILibraryManager manager,
IAssemblyLoadContextAccessor accessor,
IAssemblyLoaderContainer container,
IApplicationEnvironment environment)
{
_libraryManager = manager;
_environment = environment;
_loadContext = accessor.GetLoadContext(typeof (Program).GetTypeInfo().Assembly);
Loader = new DirectoryLookupAssemblyLoader(_loadContext);
_loaderRegistration = container.AddLoader(Loader);
}
示例15: Register
public static void Register(CommandLineApplication app, IAssemblyLoadContext assemblyLoadContext)
{
app.Command("resolve-taghelpers", config =>
{
config.Description = "Resolves TagHelperDescriptors in the specified assembly(s).";
config.HelpOption("-?|-h|--help");
var clientProtocol = config.Option(
"-p|--protocol",
"Provide client protocol version.",
CommandOptionType.SingleValue);
var assemblyNames = config.Argument(
"[name]",
"Assembly name to resolve TagHelperDescriptors in.",
multipleValues: true);
config.OnExecute(() =>
{
var messageBroker = new CommandMessageBroker();
var plugin = new RazorPlugin(messageBroker);
var resolvedProtocol = ResolveProtocolCommand.ResolveProtocol(clientProtocol, plugin.Protocol);
plugin.Protocol = resolvedProtocol;
var success = true;
foreach (var assemblyName in assemblyNames.Values)
{
var messageData = new ResolveTagHelperDescriptorsRequestData
{
AssemblyName = assemblyName,
SourceLocation = SourceLocation.Zero
};
var message = new RazorPluginRequestMessage(
RazorPluginMessageTypes.ResolveTagHelperDescriptors,
JObject.FromObject(messageData));
success &= plugin.ProcessMessage(JObject.FromObject(message), assemblyLoadContext);
}
var resolvedDescriptors = messageBroker.Results.SelectMany(result => result.Data.Descriptors);
var resolvedErrors = messageBroker.Results.SelectMany(result => result.Data.Errors);
var resolvedResult = new ResolvedTagHelperDescriptorsResult
{
Descriptors = resolvedDescriptors,
Errors = resolvedErrors
};
var serializedResult = JsonConvert.SerializeObject(resolvedResult, Formatting.Indented);
Console.WriteLine(serializedResult);
return success ? 0 : 1;
});
});
}