9. Configuration Options - JamesRandall/AzureFromTheTrenches.Commanding GitHub Wiki
Applies to v5.0.0 and higher. See revision history for documentation for prior versions.
The UseCommanding() method can be supplied an optional Options object to further configure the commanding system. For example:
var options = new Options() { CommandActorContainerRegistration = type => services.AddTransient(type, type) };
resolver.UseCommanding(options);
The options class has the following properties:
Property | Description |
---|---|
CommandHandlerContainerRegistration | Unless an alternative implementation of ICommandHandlerFactory is supplied or the CommandHandlerFactoryFunc in this options class is set then handlers are created through the dependency resolver but not all IoC containers can resolve unregistered concrete types (for example the built in ASP.Net Core IServiceCollection and IServiceProvider IoC cannot). Where this is the case supply an implementation for the CommandHandlerContainerRegistration action that registers the handlers in the container. For example using an IServiceCollection instance of serviceCollection:var options = new Options() { CommandHandlerContainerRegistration = type => services.AddTransient(type, type) };
|
CommandHandlerFactoryFunc | By default handlers are created through the dependency resolver but if a function is assigned to the CommandHandlerFactoryFunc property then that function will be called to instantiate a handler. |
Reset | The commanding system maintains command registrations, command context enrichers, and auditors between calls to UseCommanding to enable sub-modules to extend the system without any awareness / tight coupling between them. If you want to force a reset of the shared state then set this property to true (generally this is only useful in sample apps where you might repeatedly recreate and reconfigure an IoC container as the included samples do. |
Enrichers | It can be useful to include additional properties in the command context, for example the Application Insights Operation ID. This can be done by setting this property to a set of enrichment functions - these functions are called in sequence and are passed the current state of the command contexts enriched properties and can return a dictionary of properties to insert. If the returned dictionary contains a property that already exists it will be replaced in the command context property bag. |