Jaroszek.CoderHouse.ScrutorMediator.Abstractions
1.0.0
See the version list below for details.
dotnet add package Jaroszek.CoderHouse.ScrutorMediator.Abstractions --version 1.0.0
NuGet\Install-Package Jaroszek.CoderHouse.ScrutorMediator.Abstractions -Version 1.0.0
<PackageReference Include="Jaroszek.CoderHouse.ScrutorMediator.Abstractions" Version="1.0.0" />
<PackageVersion Include="Jaroszek.CoderHouse.ScrutorMediator.Abstractions" Version="1.0.0" />
<PackageReference Include="Jaroszek.CoderHouse.ScrutorMediator.Abstractions" />
paket add Jaroszek.CoderHouse.ScrutorMediator.Abstractions --version 1.0.0
#r "nuget: Jaroszek.CoderHouse.ScrutorMediator.Abstractions, 1.0.0"
#:package Jaroszek.CoderHouse.ScrutorMediator.Abstractions@1.0.0
#addin nuget:?package=Jaroszek.CoderHouse.ScrutorMediator.Abstractions&version=1.0.0
#tool nuget:?package=Jaroszek.CoderHouse.ScrutorMediator.Abstractions&version=1.0.0
ScrutorMediator
ScrutorMediator is a lightweight alternative to MediatR, providing CQRS pattern support using Scrutor for automatic handler registration.
Installation
dotnet add package Jaroszek.CoderHouse.ScrutorMediator
Usage
- Register ScrutorMediator in your DI container:
// Program.cs or Startup.cs
services.AddScrutorMediator(
// Optional: Change lifetime (default is Scoped)
ServiceLifetime.Scoped,
// Provide assemblies to scan for handlers
typeof(YourCommand).Assembly
);
- Create commands and queries:
// Command (request without result)
public record CreateUserCommand(string Name, string Email) : ICommand;
// Command handler
public class CreateUserCommandHandler : ICommandHandler<CreateUserCommand>
{
public async Task HandleAsync(CreateUserCommand command, CancellationToken cancellationToken = default)
{
// Implementation
}
}
// Query (request with result)
public record GetUserQuery(int Id) : IQuery<UserDto>;
// Query handler
public class GetUserQueryHandler : IQueryHandler<GetUserQuery, UserDto>
{
public async Task<UserDto> HandleAsync(GetUserQuery query, CancellationToken cancellationToken = default)
{
// Implementation
return new UserDto();
}
}
- Inject and use the mediator:
public class UserService
{
private readonly IMediator _mediator;
public UserService(IMediator mediator)
{
_mediator = mediator;
}
public async Task CreateUser(string name, string email)
{
await _mediator.SendAsync(new CreateUserCommand(name, email));
}
public async Task<UserDto> GetUser(int id)
{
return await _mediator.SendAsync(new GetUserQuery(id));
}
}
Benefits Over MediatR
- Lightweight: fewer dependencies
- Simplified API: just what you need
- Full control: extend as you need
- Better performance: optimized for your use case
License
MIT
Krok 3: Utworzenie rozwiązania i dodanie projektów
dotnet new sln -n ScrutorMediator dotnet sln add Jaroszek.CoderHouse.ScrutorMediator.Abstractions dotnet sln add Jaroszek.CoderHouse.ScrutorMediator
Krok 4: Tworzenie paczki NuGet
W katalogu projektu abstrakcji
dotnet pack -c Release -o ./nupkgs
W katalogu projektu implementacji
dotnet pack -c Release -o ./nupkgs
Krok 5: Publikacja paczki NuGet
Aby opublikować na nuget.org (potrzebujesz klucza API)
dotnet nuget push ./nupkgs/Jaroszek.CoderHouse.ScrutorMediator.Abstractions.1.0.0.nupkg -k [twój_klucz_api] -s https://api.nuget.org/v3/index.json dotnet nuget push ./nupkgs/Jaroszek.CoderHouse.ScrutorMediator.1.0.0.nupkg -k [twój_klucz_api] -s https://api.nuget.org/v3/index.json
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Jaroszek.CoderHouse.ScrutorMediator.Abstractions:
Package | Downloads |
---|---|
Jaroszek.CoderHouse.ScrutorMediator
Scrutor-based Mediator implementation. Provides CQRS pattern support without MediatR dependency. |
GitHub repositories
This package is not used by any popular GitHub repositories.