Skip to content

nith-aba/CommandQuery

 
 

Repository files navigation

CommandQuery

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.

Installing CommandQuery

You should install CommandQuery with NuGet

Install-Package Bas24.CommandQuery

Or via the .NET Core command line interface:

dotnet add package Bas24.CommandQuery

Registering with assembly

services.CommandQuery(cq => cq.RegisterAssembly(typeof(Program).Assembly));

This registers:

  • ICommandQuery as scoped
  • IRequestHandler<,> concrete implementations as transient
  • IRequestHandler<> concrete implementations as transient
  • INotificationHandler<> 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.

About

CommandQuery is a Mediator CQRS implementation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%