Class CommandsLoader
A service that loads Command instance descriptors from types and assemblies.
Inheritance
Implements
Namespace: TehGM.Wolfringo.Commands.Initialization
Assembly: Wolfringo.Commands.dll
Syntax
public class CommandsLoader : ICommandsLoader
Constructors
| Improve this Doc View SourceCommandsLoader(ICommandInitializerProvider, ILogger)
Creates a new loader instance.
Declaration
public CommandsLoader(ICommandInitializerProvider initializers, ILogger log = null)
Parameters
Type | Name | Description |
---|---|---|
ICommandInitializerProvider | initializers | Command initializers mapping. |
Microsoft.Extensions.Logging.ILogger | log | Logger to log messages and errors to. If null, all logging will be disabled. |
CommandsLoader(ICommandInitializerProvider, ILogger<CommandsLoader>)
Creates a new loader instance.
Declaration
public CommandsLoader(ICommandInitializerProvider initializers, ILogger<CommandsLoader> log)
Parameters
Type | Name | Description |
---|---|---|
ICommandInitializerProvider | initializers | Command initializers mapping. |
Microsoft.Extensions.Logging.ILogger<CommandsLoader> | log | Logger to log messages and errors to. If null, all logging will be disabled. |
Methods
| Improve this Doc View SourceLoadFromAssemblyAsync(Assembly, CancellationToken)
Loads all command instance descriptors from an assembly.
Declaration
public Task<IEnumerable<ICommandInstanceDescriptor>> LoadFromAssemblyAsync(Assembly assembly, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | Assembly to load descriptors from. |
System.Threading.CancellationToken | cancellationToken | Token that can be used to stop loading. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ICommandInstanceDescriptor>> | Enumerable of all loaded command descriptors. |
Remarks
Only commands from types marked with CommandsHandlerAttribute will be loaded.
LoadFromMethodAsync(MethodInfo, CancellationToken)
Loads all command instance descriptors from a method.
Declaration
public Task<IEnumerable<ICommandInstanceDescriptor>> LoadFromMethodAsync(MethodInfo method, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.MethodInfo | method | Method to load descriptors from. |
System.Threading.CancellationToken | cancellationToken | Token that can be used to stop loading. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ICommandInstanceDescriptor>> | Enumerable of all loaded command descriptors. |
Remarks
Commands will be loaded regardless of presence of CommandsHandlerAttribute.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | No mapped initializer for a command was found. |
LoadFromTypeAsync(TypeInfo, CancellationToken)
Loads all command instance descriptors from a type.
Declaration
public Task<IEnumerable<ICommandInstanceDescriptor>> LoadFromTypeAsync(TypeInfo type, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.TypeInfo | type | Type to load descriptors from. |
System.Threading.CancellationToken | cancellationToken | Token that can be used to stop loading. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ICommandInstanceDescriptor>> | Enumerable of all loaded command descriptors. |
Remarks
Commands will be loaded regardless of presence of CommandsHandlerAttribute.