Allegro.Extensions.Cqrs.Abstractions
1.0.0
Prefix Reserved
See the version list below for details.
dotnet add package Allegro.Extensions.Cqrs.Abstractions --version 1.0.0
NuGet\Install-Package Allegro.Extensions.Cqrs.Abstractions -Version 1.0.0
<PackageReference Include="Allegro.Extensions.Cqrs.Abstractions" Version="1.0.0" />
paket add Allegro.Extensions.Cqrs.Abstractions --version 1.0.0
#r "nuget: Allegro.Extensions.Cqrs.Abstractions, 1.0.0"
// Install Allegro.Extensions.Cqrs.Abstractions as a Cake Addin #addin nuget:?package=Allegro.Extensions.Cqrs.Abstractions&version=1.0.0 // Install Allegro.Extensions.Cqrs.Abstractions as a Cake Tool #tool nuget:?package=Allegro.Extensions.Cqrs.Abstractions&version=1.0.0
Allegro.Extensions.Cqrs
Believe that there is no need to describe it once more and point you to authority:
https://martinfowler.com/bliki/CQRS.html
In this package our custom implementation of tools and markers are delivered.
Allegro.Extensions.Cqrs.Abstractions
Contains common CQRS set of markers and abstractions like ICommand
, IQuery<>
, ICommandDispatcher
, IQueryDispatcher
, ICommandHandler
, IQueryHandler
.
Additionally we introduce some additonaly things like ICommandValidator, ICommandExecutionActions and Decorator.
ICommandValidator
In more sophisticated validation cases, that simple DataAnnotations are not enough we introduce ICommandValidator<ICommand>
to enables adding some validation logic before command execution.
internal class SampleCommandValidator : ICommandValidator<SampleCommand>
{
public Task Validate(SampleCommand command)
{
// validation logic
}
}
ICommandExecutionActions
To be able to run some additional actions before and after command execution (like unit of work, collect metrics, diagnostics etc.) without messing business logic code in handler we introduce ICommandExecutionActions<>
interface.
We can easily split business logic from some technical noise.
internal class SampleCommandActions : ICommandExecutionActions<SampleCommand>
{
public Task Before(SampleCommand command)
{
...
}
public Task After(SampleCommand command)
{
...
}
}
Decorators
To be able to use decorator pattern we introduced DecoratorAttribute
. Each handler marked with it wont be registered automatically in services by our extensions and give opportunity to Decorate handlers with any custom code.
Example:
[Decorator]
internal class CommandHandlerDecorator<T> : ICommandHandler<T> where T : ICommand
{
...
}
Registration with Scrutor:
services.TryDecorate(typeof(ICommandHandler<>), typeof(CommandHandlerDecorator<>));
Remember to first register all commands handlers and than register custom decorator.
Samples
Some sample usage could be found:
Allegro.Extensions.Cqrs
This package contains:
- default implementation of
ICommandDispatcher
andIQueryDispatcher
- automatic registrations of all
ICommandHandler
,IQueryHandler
,ICommandValidator
,ICommandExecutionActions
For registrations Scrutor packages is uses as a tool.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Scrutor (>= 4.2.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Allegro.Extensions.Cqrs.Abstractions:
Package | Downloads |
---|---|
Allegro.Extensions.Cqrs
Contains Cqrs defualt implementation of automatic registration, default dispatchers and command actions support used in Allegro services |
|
Allegro.Extensions.Cqrs.FluentValidations
Contains FluentVlidations extension for Allegro.Extensions.Cqrs |
GitHub repositories
This package is not used by any popular GitHub repositories.