Class HostedCommandsService
A wrapper for CommandsService designed to use with .NET Core Host.
Namespace: TehGM.Wolfringo.Hosting.Commands
Assembly: Wolfringo.Hosting.dll
Syntax
public class HostedCommandsService : ICommandsService, IHostedService, IDisposable
Remarks
This wrapper uses CommandsService internally, and delegates all method calls and events.
This class supports configuration changes by using IOptionsMonitor<TOptions>. Whenever settings are changed, existing commands service is disposed, and a new one is constructed.
Constructors
| Improve this Doc View SourceHostedCommandsService(IOptionsMonitor<CommandsOptions>, IServiceProvider, ILogger<HostedCommandsService>, IApplicationLifetime)
Creates a new hosted commands service.
Declaration
public HostedCommandsService(IOptionsMonitor<CommandsOptions> options, IServiceProvider services, ILogger<HostedCommandsService> log, IApplicationLifetime hostLifetime)
Parameters
Type | Name | Description |
---|---|---|
IOptionsMonitor<CommandsOptions> | options | Commands options that will be used as default when running a command. |
IServiceProvider | services | Services provider that will be used by all commands. |
ILogger<HostedCommandsService> | log | Logger used by hosted commands service. |
IApplicationLifetime | hostLifetime | Host lifetime that will be used to dispose service when application is exiting. |
Properties
| Improve this Doc View SourceCommands
Descriptors of all commands loaded to this commands service.
Declaration
public IEnumerable<ICommandInstanceDescriptor> Commands { get; }
Property Value
Type | Description |
---|---|
IEnumerable<ICommandInstanceDescriptor> |
Methods
| Improve this Doc View SourceDispose()
Declaration
public void Dispose()
Explicit Interface Implementations
| Improve this Doc View SourceIHostedService.StartAsync(CancellationToken)
Declaration
async Task IHostedService.StartAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
IHostedService.StopAsync(CancellationToken)
Declaration
Task IHostedService.StopAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
ICommandsService.ExecuteAsync(ICommandContext, CancellationToken)
Executes commands against a command context.
Declaration
Task<ICommandResult> ICommandsService.ExecuteAsync(ICommandContext context, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
ICommandContext | context | Context to execute commands with. |
CancellationToken | cancellationToken | Cancellation token to cancel execution with. |
Returns
Type | Description |
---|---|
Task<ICommandResult> | Result of the execution. |
ICommandsService.StartAsync(CancellationToken)
Starts the Command Service.
Declaration
async Task ICommandsService.StartAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Cancellation token to cancel loading with. |
Returns
Type | Description |
---|---|
Task |