Interface ICommandDispatchContext
Context information used during command dispatch and execution to track and correlate commands
Namespace: AzureFromTheTrenches.Commanding.Abstractions
Assembly: AzureFromTheTrenches.Commanding.Abstractions.dll
Syntax
public interface ICommandDispatchContext
Properties
| Improve this Doc View SourceAdditionalProperties
Audit item enrichers are able to add properties into this dictionary so that they are available for audit across the dispatch process
Declaration
IReadOnlyDictionary<string, object> AdditionalProperties { get; }
Property Value
Type | Description |
---|---|
IReadOnlyDictionary<System.String, System.Object> |
CorrelationId
The correlation ID for the current context
Declaration
string CorrelationId { get; }
Property Value
Type | Description |
---|---|
System.String |
Depth
On first dispatch of a command (for example in a Web API controller) depth will be 0. If the handler for that command then dispatches another command depth will be 1. Etc. This is accurate unless a handler dispatches commands in parallel. I.e. if a handler dispatches a set of commands and awaits for them all as a batch e.g. Task.WhenAll(setOfDispatchTasks). In which case while the depth will be incremented and decremented reliably (it will unwind correctly to 0) it can no longer be used to ascertain command dispatch chain depth.
However depth > 0 is always an accurate way to ascertain whether or not we are in the root command which is the core frameworks usecase.
Declaration
int Depth { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceCopy()
Return a copy of the context
Declaration
ICommandDispatchContext Copy()
Returns
Type | Description |
---|---|
ICommandDispatchContext | A new copy |
Decrement()
Decrement the command depth tracker
Declaration
int Decrement()
Returns
Type | Description |
---|---|
System.Int32 | The depth |
Increment()
Increment the command depth tracker
Declaration
int Increment()
Returns
Type | Description |
---|---|
System.Int32 | The depth |