Class UseCaseAsyncCommand<TCommandSettings, TUseCase, TUseCaseRequest, TUseCaseResponse>
- Namespace
- Ploch.CommandLine.UseCases
- Assembly
- Ploch.CommandLine.UseCases.dll
Base class for asynchronous commands that delegate their work to a use case and render its result.
public abstract class UseCaseAsyncCommand<TCommandSettings, TUseCase, TUseCaseRequest, TUseCaseResponse> : AsyncAppCommand<TCommandSettings>, ICommand<TCommandSettings>, ICommandLimiter<TCommandSettings>, ICommand where TCommandSettings : CommandSettings where TUseCase : IResultUseCase<TUseCaseRequest, TUseCaseResponse>
Type Parameters
TCommandSettingsThe settings type accepted by the command.
TUseCaseThe use case type executed by the command.
TUseCaseRequestThe request type passed to the use case.
TUseCaseResponseThe response type produced by the use case.
- Inheritance
-
AsyncCommand<TCommandSettings>AsyncAppCommand<TCommandSettings>UseCaseAsyncCommand<TCommandSettings, TUseCase, TUseCaseRequest, TUseCaseResponse>
- Implements
-
ICommand<TCommandSettings>ICommandLimiter<TCommandSettings>ICommand
- Inherited Members
Remarks
The four type parameters are deliberate. TCommandSettings is required by the
AsyncAppCommand<TSettings> base class. TUseCase keeps the concrete use
case type, so a derived command can reach members beyond IResultUseCase<TRequest, TResponse>.
C# cannot infer TUseCaseRequest and TUseCaseResponse from
TUseCase, so they must be stated to constrain it and to type the request and the
rendered result.
Constructors
- UseCaseAsyncCommand(IOutput, TUseCase, CommandArgumentsRootProcessor, ICommandSettingsValidator<TCommandSettings>, IExceptionHandler)
Base class for asynchronous commands that delegate their work to a use case and render its result.
Properties
- EchoSettings
Gets a value indicating whether every public settings value is echoed to the output before the use case runs. Defaults to false.
- UseCase
Gets the use case executed by this command.
Methods
- CreateRequest(TCommandSettings)
Builds the use case request from the validated command settings.
- DoExecuteAsync(CommandContext, TCommandSettings, CancellationToken)
Runs the use case and renders its outcome, echoing the supplied settings first only when EchoSettings is true.
- ProcessFailureResponse(Result<TUseCaseResponse>)
Renders a failed use case result. Override to customise failure reporting.
- ProcessSuccessResponse(Result<TUseCaseResponse>)
Renders a successful use case result. Override to customise success reporting.