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

original CommandContext

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

correlationId CorrelationId

The correlation ID for the command.

type Type

The type of the command.

command object

The command instance.

dependencies IEnumerable<object>

The dependencies required to handle the command.

values CommandContextValues

A set of values associated with the command context.

allowedSeverity ValidationResultSeverity?

The maximum validation result severity level to allow. Validation results with severity higher than this will cause the command to fail.

response object

The optional response from handling the command, if any.

serviceProvider IServiceProvider

The 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

CorrelationId CorrelationId

The correlation ID for the command.

Type Type

The type of the command.

Command object

The command instance.

Dependencies IEnumerable<object>

The dependencies required to handle the command.

Values CommandContextValues

A set of values associated with the command context.

AllowedSeverity ValidationResultSeverity?

The maximum validation result severity level to allow. Validation results with severity higher than this will cause the command to fail.

Response object

The optional response from handling the command, if any.

ServiceProvider IServiceProvider

The IServiceProvider scoped to the command, used to resolve scoped collaborators such as validators and read models during the command's lifetime.

CancellationToken CancellationToken

The 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

ValidationResultSeverity?

AuthorizedPrincipal

Gets the principal selected by scheme authentication for the rest of this command execution.

public ClaimsPrincipal? AuthorizedPrincipal { get; }

Property Value

ClaimsPrincipal

CancellationToken

The cancellation token for the command execution.

public CancellationToken CancellationToken { get; init; }

Property Value

CancellationToken

Command

The command instance.

public object Command { get; init; }

Property Value

object

CorrelationId

The correlation ID for the command.

public CorrelationId CorrelationId { get; init; }

Property Value

CorrelationId

Dependencies

The dependencies required to handle the command.

public IEnumerable<object?> Dependencies { get; init; }

Property Value

IEnumerable<object>

EqualityContract

protected virtual Type EqualityContract { get; }

Property Value

Type

GeneratedValues

Gets the validated generated values captured in resolution order. Values must not be logged or traced.

public GeneratedValues GeneratedValues { get; init; }

Property Value

GeneratedValues

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

DateTimeOffset

Response

The optional response from handling the command, if any.

public object? Response { get; init; }

Property Value

object

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

IServiceProvider

Type

The type of the command.

public Type Type { get; init; }

Property Value

Type

Values

A set of values associated with the command context.

public CommandContextValues Values { get; init; }

Property Value

CommandContextValues

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

CorrelationId CorrelationId
Type Type
Command object
Dependencies IEnumerable<object>
Values CommandContextValues
AllowedSeverity ValidationResultSeverity?
Response object
ServiceProvider IServiceProvider
CancellationToken CancellationToken

Equals(CommandContext?)

public virtual bool Equals(CommandContext? other)

Parameters

other CommandContext

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

PrintMembers(StringBuilder)

protected virtual bool PrintMembers(StringBuilder builder)

Parameters

builder StringBuilder

Returns

bool

ToString()

public override string ToString()

Returns

string

Operators

operator ==(CommandContext?, CommandContext?)

public static bool operator ==(CommandContext? left, CommandContext? right)

Parameters

left CommandContext
right CommandContext

Returns

bool

operator !=(CommandContext?, CommandContext?)

public static bool operator !=(CommandContext? left, CommandContext? right)

Parameters

left CommandContext
right CommandContext

Returns

bool