Class CommandContextExtensions

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

Provides provider-neutral extension methods for the CommandContext.

public static class CommandContextExtensions
Inheritance
CommandContextExtensions
Inherited Members

Methods

GetResolvedKey(CommandContext)

Gets the provider-neutral resolved key for the command.

public static string? GetResolvedKey(this CommandContext commandContext)

Parameters

commandContext CommandContext

The CommandContext to get the resolved key from.

Returns

string

The resolved key, or null when the command carried no usable key.

Remarks

The key is resolved once, while the command context values are being built: by whichever integration owns key resolution — the Chronicle one resolves an event source id — and otherwise from the command itself through ICommandKeys. Reading it is therefore only ever a lookup, and everything reading it sees the same answer for a command.

GetResolvedKey(CommandContext, IServiceProvider?)

Gets the provider-neutral resolved key for the command, reading it from the command itself when nothing wrote one.

[Obsolete("The key is resolved while the command context values are being built, so GetResolvedKey() reads it without a service provider. This overload only matters for a CommandContext assembled without ICommandContextValuesBuilder, and will be removed.")]
public static string? GetResolvedKey(this CommandContext commandContext, IServiceProvider? serviceProvider)

Parameters

commandContext CommandContext

The CommandContext to get the resolved key from.

serviceProvider IServiceProvider

The IServiceProvider to resolve ICommandKeys from.

Returns

string

The resolved key, or null when the command carried no usable key.