Jaroszek.CoderHouse.ScrutorMediator.Abstractions
1.0.3
dotnet add package Jaroszek.CoderHouse.ScrutorMediator.Abstractions --version 1.0.3
NuGet\Install-Package Jaroszek.CoderHouse.ScrutorMediator.Abstractions -Version 1.0.3
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="Jaroszek.CoderHouse.ScrutorMediator.Abstractions" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Jaroszek.CoderHouse.ScrutorMediator.Abstractions" Version="1.0.3" />
<PackageReference Include="Jaroszek.CoderHouse.ScrutorMediator.Abstractions" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Jaroszek.CoderHouse.ScrutorMediator.Abstractions --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jaroszek.CoderHouse.ScrutorMediator.Abstractions, 1.0.3"
#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.
#:package Jaroszek.CoderHouse.ScrutorMediator.Abstractions@1.0.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Jaroszek.CoderHouse.ScrutorMediator.Abstractions&version=1.0.3
#tool nuget:?package=Jaroszek.CoderHouse.ScrutorMediator.Abstractions&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
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.