Minerals.AutoCQRS
0.1.0
See the version list below for details.
dotnet add package Minerals.AutoCQRS --version 0.1.0
NuGet\Install-Package Minerals.AutoCQRS -Version 0.1.0
<PackageReference Include="Minerals.AutoCQRS" Version="0.1.0" />
paket add Minerals.AutoCQRS --version 0.1.0
#r "nuget: Minerals.AutoCQRS, 0.1.0"
// Install Minerals.AutoCQRS as a Cake Addin #addin nuget:?package=Minerals.AutoCQRS&version=0.1.0 // Install Minerals.AutoCQRS as a Cake Tool #tool nuget:?package=Minerals.AutoCQRS&version=0.1.0
Minerals.AutoCQRS
WORK IN PROGRESS...
This NuGet package offers a lightweight and efficient way to implement the CQRS pattern in ASP.NET Core applications. It focuses on providing basic interfaces for commands and queries, along with automatic dependency injection, without introducing the overhead of a mediator library such as MediatR.
Features
- Reduced boilerplate: Package has dedicated interfaces for commands and queries, you don't need to write additional intermediate interfaces for code readability.
- Automatic Dependency Injection: Package provides automatic registration of all classes that implements ICommandHandler<,> or IQueryHandler<,> interfaces.
- Performance: Package does not use System.Reflection at all, dependency injection is resolved at compile time.
- Compatible with .NET Standard 2.0 and C# 7.3+: Works on a wide range of platforms and development environments.
Installation
Add the Minerals.AutoCQRS nuget package to your C# project using the following methods:
1. Project file definition
<PackageReference Include="Minerals.AutoCQRS" Version="0.1.0" />
2. dotnet command
dotnet add package Minerals.AutoCQRS
Usage
Example of command and query usage along with their handlers:
namespace Minerals.Examples
{
public class ExampleCommand : Minerals.AutoCQRS.Interfaces.ICommand
{
// ...
}
public class ExampleQuery : Minerals.AutoCQRS.Interfaces.IQuery
{
// ...
}
public class ExampleCommandHandler : Minerals.AutoCQRS.Interfaces.ICommandHandler<ExampleCommand, int>
{
public Task<int> Handle(ExampleCommand command, CancellationToken cancellation)
{
// ...
}
}
public class ExampleQueryHandler : Minerals.AutoCQRS.Interfaces.IQueryHandler<ExampleQuery, int>
{
public Task<int> Handle(ExampleQuery query, CancellationToken cancellation)
{
// ...
}
}
}
Dependency Registration
// By default, dependencies are registered as Singleton
builder.Services.AddCommandsAndQueries();
// or
// You can set your own policy for dependency injection
builder.Services.AddCommandsAndQueries((collection, serviceType) => collection.AddScoped(serviceType));
Dispatchers
You can write your own implementation of a command or query dispatcher using the appropriate interface, ICommandDispatcher
or IQueryDispatcher
:
public class CustomCommandDispatcher : ICommandDispatcher
{
public Task<TResult> Dispatch<TCommand, TResult>(TCommand command, CancellationToken cancellation) where TCommand : ICommand, new()
{
// ...
}
}
Versioning
We use SemVer for versioning. For the versions available, see the branches on this repository.
Authors
- Szymon Hałucha - Maintainer
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
First release