Class CommandContext
- Namespace
- Cratis.Arc.Commands
- Assembly
- Cratis.Arc.Core.dll
Represents the context for a command being executed.
public record CommandContext : IEquatable<CommandContext>
- Inheritance
-
CommandContext
- Implements
- Inherited Members
- Extension Methods
Constructors
CommandContext(CommandContext)
protected CommandContext(CommandContext original)
Parameters
originalCommandContext
CommandContext(CorrelationId, Type, object, IEnumerable<object?>, CommandContextValues, ValidationResultSeverity?, object?, IServiceProvider?)
Initializes a new instance of the CommandContext record.
public CommandContext(CorrelationId correlationId, Type type, object command, IEnumerable<object?> dependencies, CommandContextValues values, ValidationResultSeverity? allowedSeverity, object? response, IServiceProvider? serviceProvider)
Parameters
correlationIdCorrelationIdThe correlation ID for the command.
typeTypeThe type of the command.
commandobjectThe command instance.
dependenciesIEnumerable<object>The dependencies required to handle the command.
valuesCommandContextValuesA set of values associated with the command context.
allowedSeverityValidationResultSeverity?The maximum validation result severity level to allow. Validation results with severity higher than this will cause the command to fail.
responseobjectThe optional response from handling the command, if any.
serviceProviderIServiceProviderThe IServiceProvider scoped to the command, used to resolve scoped collaborators such as validators and read models during the command's lifetime.
CommandContext(CorrelationId, Type, object, IEnumerable<object?>, CommandContextValues, ValidationResultSeverity?, object?, IServiceProvider?, CancellationToken)
Represents the context for a command being executed.
public CommandContext(CorrelationId CorrelationId, Type Type, object Command, IEnumerable<object?> Dependencies, CommandContextValues Values, ValidationResultSeverity? AllowedSeverity = null, object? Response = null, IServiceProvider? ServiceProvider = null, CancellationToken CancellationToken = default)
Parameters
CorrelationIdCorrelationIdThe correlation ID for the command.
TypeTypeThe type of the command.
CommandobjectThe command instance.
DependenciesIEnumerable<object>The dependencies required to handle the command.
ValuesCommandContextValuesA set of values associated with the command context.
AllowedSeverityValidationResultSeverity?The maximum validation result severity level to allow. Validation results with severity higher than this will cause the command to fail.
ResponseobjectThe optional response from handling the command, if any.
ServiceProviderIServiceProviderThe IServiceProvider scoped to the command, used to resolve scoped collaborators such as validators and read models during the command's lifetime.
CancellationTokenCancellationTokenThe cancellation token for the command execution.
Properties
AllowedSeverity
The maximum validation result severity level to allow. Validation results with severity higher than this will cause the command to fail.
public ValidationResultSeverity? AllowedSeverity { get; init; }
Property Value
AuthorizedPrincipal
Gets the principal selected by scheme authentication for the rest of this command execution.
public ClaimsPrincipal? AuthorizedPrincipal { get; }
Property Value
CancellationToken
The cancellation token for the command execution.
public CancellationToken CancellationToken { get; init; }
Property Value
Command
The command instance.
public object Command { get; init; }
Property Value
CorrelationId
The correlation ID for the command.
public CorrelationId CorrelationId { get; init; }
Property Value
Dependencies
The dependencies required to handle the command.
public IEnumerable<object?> Dependencies { get; init; }
Property Value
EqualityContract
protected virtual Type EqualityContract { get; }
Property Value
GeneratedValues
Gets the validated generated values captured in resolution order. Values must not be logged or traced.
public GeneratedValues GeneratedValues { get; init; }
Property Value
ReceivedAt
Gets the time Arc received this command operation. Model-bound dispatch captures it before binding and authorization preparation; MVC action filters capture it after MVC binding. This is neither network arrival nor time before application middleware. A hand-constructed context has default unless the caller sets this property.
public DateTimeOffset ReceivedAt { get; init; }
Property Value
Response
The optional response from handling the command, if any.
public object? Response { get; init; }
Property Value
ServiceProvider
The IServiceProvider scoped to the command, used to resolve scoped collaborators such as validators and read models during the command's lifetime.
public IServiceProvider? ServiceProvider { get; init; }
Property Value
Type
The type of the command.
public Type Type { get; init; }
Property Value
Values
A set of values associated with the command context.
public CommandContextValues Values { get; init; }
Property Value
Methods
Deconstruct(out CorrelationId, out Type, out object, out IEnumerable<object?>, out CommandContextValues, out ValidationResultSeverity?, out object?, out IServiceProvider?, out CancellationToken)
public void Deconstruct(out CorrelationId CorrelationId, out Type Type, out object Command, out IEnumerable<object?> Dependencies, out CommandContextValues Values, out ValidationResultSeverity? AllowedSeverity, out object? Response, out IServiceProvider? ServiceProvider, out CancellationToken CancellationToken)
Parameters
CorrelationIdCorrelationIdTypeTypeCommandobjectDependenciesIEnumerable<object>ValuesCommandContextValuesAllowedSeverityValidationResultSeverity?ResponseobjectServiceProviderIServiceProviderCancellationTokenCancellationToken
Equals(CommandContext?)
public virtual bool Equals(CommandContext? other)
Parameters
otherCommandContext
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
PrintMembers(StringBuilder)
protected virtual bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
ToString()
public override string ToString()
Returns
Operators
operator ==(CommandContext?, CommandContext?)
public static bool operator ==(CommandContext? left, CommandContext? right)
Parameters
leftCommandContextrightCommandContext
Returns
operator !=(CommandContext?, CommandContext?)
public static bool operator !=(CommandContext? left, CommandContext? right)
Parameters
leftCommandContextrightCommandContext