Class PublishedAssemblyLoader
The default AssemblyLoadContext based ITerminalCommandSourceAssemblyLoader<TContext>.
public sealed class PublishedAssemblyLoader : ITerminalCommandSourceAssemblyLoader<PublishedCommandSourceContext>
- Inheritance
-
PublishedAssemblyLoader
- Implements
- Inherited Members
Remarks
This class provides a basic implementation for loading command source assemblies from a given context. It loads each assembly specified in the PublishedCommandSourceContext without resolving conflicts that might arise from different versions of the same assembly or dependencies. The loader checks if an assembly is already loaded before attempting to load it again and logs a warning if so.
The default implementation is straightforward but does not handle advanced scenarios such as version conflicts or loading assemblies with different dependency trees. For more complex requirements, including advanced conflict resolution and dependency management, developers should create a custom loader by implementing the ITerminalCommandSourceAssemblyLoader<TContext> interface with their own logic.
Constructors
PublishedAssemblyLoader(ILogger<PublishedAssemblyLoader>)
Initializes a new instance of the PublishedAssemblyLoader class.
public PublishedAssemblyLoader(ILogger<PublishedAssemblyLoader> logger)
Parameters
logger
ILogger<PublishedAssemblyLoader>The logger.
Methods
LoadAssembliesAsync(PublishedCommandSourceContext)
Asynchronously loads the primary command source assemblies specified in the context
.
While loading these primary assemblies, dependency assemblies may also be loaded. However, the returned
enumerable only includes the primary assemblies that are requested by the context, not the dependencies.
public Task<IEnumerable<Assembly>> LoadAssembliesAsync(PublishedCommandSourceContext context)
Parameters
context
PublishedCommandSourceContextThe context containing information about the primary command source assemblies to load, such as their paths.
Returns
- Task<IEnumerable<Assembly>>
A task representing the asynchronous operation, with a result of an enumerable of the loaded primary command source assemblies.