Interface ICommandPipeline
- Namespace
- Cratis.Arc.Commands
- Assembly
- Cratis.Arc.Core.dll
Defines a system can execute commands.
public interface ICommandPipeline
- Extension Methods
Methods
Execute(object, IServiceProvider, ValidationResultSeverity?)
Executes the given command within the provided service scope.
Task<CommandResult> Execute(object command, IServiceProvider serviceProvider, ValidationResultSeverity? allowedSeverity = null)
Parameters
commandobjectThe command to execute.
serviceProviderIServiceProviderThe IServiceProvider scoped to the current request, used to resolve handler dependencies.
allowedSeverityValidationResultSeverity?Optional maximum validation result severity level to allow.
Returns
- Task<CommandResult>
A CommandResult representing the result of executing the command.
Execute(object, ValidationResultSeverity?)
Executes the given command, creating a dedicated service scope for dependency resolution.
Task<CommandResult> Execute(object command, ValidationResultSeverity? allowedSeverity = null)
Parameters
commandobjectThe command to execute.
allowedSeverityValidationResultSeverity?Optional maximum validation result severity level to allow.
Returns
- Task<CommandResult>
A CommandResult representing the result of executing the command.
Execute<TResult>(object, IServiceProvider, ValidationResultSeverity?)
Executes the given command and returns a strongly-typed result within the provided service scope.
Task<CommandResult<TResult>> Execute<TResult>(object command, IServiceProvider serviceProvider, ValidationResultSeverity? allowedSeverity = null)
Parameters
commandobjectThe command to execute.
serviceProviderIServiceProviderThe IServiceProvider scoped to the current request, used to resolve handler dependencies.
allowedSeverityValidationResultSeverity?Optional maximum validation result severity level to allow.
Returns
- Task<CommandResult<TResult>>
A CommandResult<TResponse> representing the result of executing the command.
Type Parameters
TResultThe type of the response returned by the command handler.
Remarks
If the handler returns a response of a different type than TResult, an InvalidCastException is thrown.
If the handler returns no response, or the command fails (authorization, validation, exception, no handler), the result is returned with Response set to default.
Execute<TResult>(object, ValidationResultSeverity?)
Executes the given command and returns a strongly-typed result, creating a dedicated service scope for dependency resolution.
Task<CommandResult<TResult>> Execute<TResult>(object command, ValidationResultSeverity? allowedSeverity = null)
Parameters
commandobjectThe command to execute.
allowedSeverityValidationResultSeverity?Optional maximum validation result severity level to allow.
Returns
- Task<CommandResult<TResult>>
A CommandResult<TResponse> representing the result of executing the command.
Type Parameters
TResultThe type of the response returned by the command handler.
Remarks
If the handler returns a response of a different type than TResult, an InvalidCastException is thrown.
If the handler returns no response, or the command fails (authorization, validation, exception, no handler), the result is returned with Response set to default.
Validate(object, IServiceProvider, ValidationResultSeverity?)
Validates the given command without executing it, within the provided service scope.
Task<CommandResult> Validate(object command, IServiceProvider serviceProvider, ValidationResultSeverity? allowedSeverity = null)
Parameters
commandobjectThe command to validate.
serviceProviderIServiceProviderThe IServiceProvider scoped to the current request, used to resolve handler dependencies.
allowedSeverityValidationResultSeverity?Optional maximum validation result severity level to allow.
Returns
- Task<CommandResult>
A CommandResult representing the validation result.
Remarks
This method runs authorization and validation filters but does not invoke the command handler. Use this for pre-flight validation before executing a command.
Validate(object, ValidationResultSeverity?)
Validates the given command without executing it, creating a dedicated service scope for dependency resolution.
Task<CommandResult> Validate(object command, ValidationResultSeverity? allowedSeverity = null)
Parameters
commandobjectThe command to validate.
allowedSeverityValidationResultSeverity?Optional maximum validation result severity level to allow.
Returns
- Task<CommandResult>
A CommandResult representing the validation result.
Remarks
This method runs authorization and validation filters but does not invoke the command handler. Use this for pre-flight validation before executing a command.