Allegro.Extensions.Cqrs.Abstractions 1.0.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer version of this package available.
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
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Allegro.Extensions.Cqrs.Abstractions" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Allegro.Extensions.Cqrs.Abstractions --version 1.0.0
#r "nuget: Allegro.Extensions.Cqrs.Abstractions, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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
    }
}

Sample

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)
    {
       ...
    }
}

Sample

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 and IQueryDispatcher
  • automatic registrations of all ICommandHandler, IQueryHandler, ICommandValidator, ICommandExecutionActions

For registrations Scrutor packages is uses as a tool.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Allegro.Extensions.Cqrs.Abstractions:

Package Downloads
Allegro.Extensions.Cqrs The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Contains Cqrs defualt implementation of automatic registration, default dispatchers and command actions support used in Allegro services

Allegro.Extensions.Cqrs.FluentValidations The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Contains FluentVlidations extension for Allegro.Extensions.Cqrs

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 464 1/27/2023
1.1.0 464 11/22/2022
1.0.0 403 11/10/2022