CommandQuery is a CQRS implementation.
Supports request/response, commands, queries, notifications and events, synchronous and async with intelligent dispatching via C# generic variance.
Examples in this Project.
You should install CommandQuery with NuGet
Install-Package Bas24.CommandQuery
Or via the .NET Core command line interface:
dotnet add package Bas24.CommandQuery
services.CommandQuery(cq => cq.RegisterAssembly(typeof(Program).Assembly));
This registers:
ICommandQuery
as scopedIRequestHandler<,>
concrete implementations as transientIRequestHandler<>
concrete implementations as transientINotificationHandler<>
concrete implementations as transient
This also registers open generic implementations for:
INotificationHandler<>
To register behaviors, pre/post processors:
services.AddCommandQuery(cfg => {
cq.RegisterAssembly(typeof(Program).Assembly);
cq.NotificationPublisher = new MultipleNotificationPublisher();
cq.NotificationPublisherType = typeof(MultipleNotificationPublisher);
cq.AddBehavior(typeof(LoggingPipelineBehavior<,>));
cq.AddRequestPreProcessor(typeof(GenericRequestPreProcessor<>));
cq.AddRequestPostProcessor(typeof(GenericRequestPostProcessor<,>));
});
With additional methods for open generics and overloads for explicit service types.