Class CommandResult<TResponse>

Namespace
Cratis.Arc.Commands
Assembly
Cratis.Arc.Core.dll

Represents the result coming from executing a command with a response.

public class CommandResult<TResponse> : CommandResult

Type Parameters

TResponse

Type of the data returned.

Inheritance
CommandResult<TResponse>
Inherited Members
Extension Methods

Constructors

CommandResult()

Initializes a new instance of the CommandResult<TResponse> class.

public CommandResult()

CommandResult(CorrelationId, TResponse?)

Initializes a new instance of the CommandResult<TResponse> class.

public CommandResult(CorrelationId correlationId, TResponse? response)

Parameters

correlationId CorrelationId

The CorrelationId associated with the command.

response TResponse

The response.

CommandResult(TResponse?)

Initializes a new instance of the CommandResult<TResponse> class.

public CommandResult(TResponse? response)

Parameters

response TResponse

The response.

Properties

Response

Gets or sets the optional response object that will be returned from the command handler.

public TResponse? Response { get; set; }

Property Value

TResponse

ResponseValue

Gets the response value carried by this result, if any, boxed as an object. This lets a caller read the response without knowing its concrete generic type.

protected override object? ResponseValue { get; }

Property Value

object

Methods

ClearResponse()

Removes the response value carried by this result, if any. This lets a caller holding an untyped CommandResult remove the response without knowing its concrete generic type.

protected override void ClearResponse()

Remarks

A response is bound onto the result the moment the handler produces it - before the command's execution scopes complete, and therefore before a transaction has committed. Anything failing after that point leaves a result that is not successful yet still carries a value the caller must not act on. This is the seam that lets the pipeline take that value back. The base result carries no response, so this does nothing.

Success(CorrelationId)

Creates a new CommandResult representing a successful command execution.

public static CommandResult<TResponse> Success(CorrelationId correlationId)

Parameters

correlationId CorrelationId

The CorrelationId associated with the command.

Returns

CommandResult<TResponse>

A CommandResult<TResponse>.