ModulusKit.Mediator.Abstractions
4.0.0
dotnet add package ModulusKit.Mediator.Abstractions --version 4.0.0
NuGet\Install-Package ModulusKit.Mediator.Abstractions -Version 4.0.0
<PackageReference Include="ModulusKit.Mediator.Abstractions" Version="4.0.0" />
<PackageVersion Include="ModulusKit.Mediator.Abstractions" Version="4.0.0" />
<PackageReference Include="ModulusKit.Mediator.Abstractions" />
paket add ModulusKit.Mediator.Abstractions --version 4.0.0
#r "nuget: ModulusKit.Mediator.Abstractions, 4.0.0"
#:package ModulusKit.Mediator.Abstractions@4.0.0
#addin nuget:?package=ModulusKit.Mediator.Abstractions&version=4.0.0
#tool nuget:?package=ModulusKit.Mediator.Abstractions&version=4.0.0
Modulus.Mediator.Abstractions
Abstractions for the Modulus mediator — interfaces, Result types, and pipeline behavior contracts.
Installation
dotnet add package ModulusKit.Mediator.Abstractions
Key Types
Commands and Queries
// Command with no return value
public record CreateOrder(string CustomerId) : ICommand;
// Command with a return value
public record CreateProduct(string Name, decimal Price) : ICommand<Guid>;
// Query
public record GetOrderById(Guid Id) : IQuery<OrderDto>;
// Streaming query
public record GetOrderStream() : IStreamQuery<OrderDto>;
// Domain event
public record OrderCreated(Guid OrderId) : IDomainEvent;
Handlers
public class CreateOrderHandler : ICommandHandler<CreateOrder>
{
public Task<Result> Handle(CreateOrder command, CancellationToken ct)
{
// ...
return Task.FromResult(Result.Success());
}
}
public class GetOrderByIdHandler : IQueryHandler<GetOrderById, OrderDto>
{
public Task<Result<OrderDto>> Handle(GetOrderById query, CancellationToken ct)
{
// ...
return Task.FromResult(Result<OrderDto>.Success(dto));
}
}
Result Pattern
// Success
Result.Success();
Result<OrderDto>.Success(dto);
// Failure
Result.Failure(Error.NotFound("Order.NotFound", "Order was not found"));
Result<OrderDto>.Failure(Error.Validation("Order.InvalidId", "ID must not be empty"));
// Implicit conversions
Result result = Error.NotFound("Order.NotFound", "Not found");
// Checking results
if (result.IsSuccess) { /* ... */ }
if (result.IsFailure) { /* inspect result.Errors */ }
Error Types
Error.Failure(code, description) // General failure
Error.Validation(code, description) // Validation error
Error.NotFound(code, description) // Resource not found
Error.Conflict(code, description) // State conflict
Error.Unauthorized(code, description) // Authentication required
Error.Forbidden(code, description) // Permission denied
Pipeline Behaviors
public class TimingBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
where TRequest : notnull
{
public async Task<TResponse> Handle(
TRequest request,
RequestHandlerDelegate<TResponse> next,
CancellationToken cancellationToken)
{
var sw = Stopwatch.StartNew();
var response = await next(cancellationToken);
sw.Stop();
// log elapsed time
return response;
}
}
4.0 —
RequestHandlerDelegate<TResponse>takes aCancellationToken.nextnow accepts an optional token (next(CancellationToken cancellationToken = default)), so a behavior can substitute a different token — e.g. a timeout's linked token — for every inner behavior and the handler.await next()still compiles and still means "flow the token I received"; see Pipeline Behaviors for the full semantics and a timeout example.
Source Generators & Analyzers
Referencing this package transitively includes the ModulusKit.Generators and ModulusKit.Analyzers packages as analyzer references. This means your project automatically gets:
- Source generators for strongly typed IDs, handler registration, and module auto-discovery
- Roslyn analyzers (MOD001--MOD005) for compile-time architecture enforcement
Strongly Typed IDs
Use the [StronglyTypedId] attribute to generate type-safe entity identifiers with full EF Core, JSON, and model binding support:
using Modulus.Mediator.Abstractions;
[StronglyTypedId]
public readonly partial record struct OrderId;
[StronglyTypedId(typeof(int))]
public readonly partial record struct SequenceNumber;
Supported backing types: Guid (default), int, long.
Module Ordering
Use the [ModuleOrder] attribute to control module initialization order in the auto-discovery generator:
[ModuleOrder(1)]
public class CatalogModule : IModuleRegistration { /* ... */ }
Learn More
See the Modulus repository for full documentation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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 is compatible. 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. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ModulusKit.Mediator.Abstractions:
| Package | Downloads |
|---|---|
|
ModulusKit.Mediator
Lightweight CQRS mediator for .NET with pipeline behaviors, validation, logging, and a built-in Result pattern. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.0 | 122 | 7/26/2026 |
| 3.1.0 | 345 | 7/26/2026 |
| 3.0.0 | 258 | 7/26/2026 |
| 2.1.0 | 118 | 7/4/2026 |
| 2.0.0 | 117 | 7/3/2026 |
| 1.2.5 | 133 | 3/15/2026 |
| 1.2.4 | 124 | 3/15/2026 |
| 1.2.3 | 133 | 3/14/2026 |
| 1.2.2 | 123 | 3/14/2026 |
| 1.2.1 | 120 | 3/14/2026 |
| 1.2.0 | 124 | 3/14/2026 |
| 1.1.1 | 117 | 3/8/2026 |
| 1.1.0 | 122 | 3/5/2026 |
| 1.0.1 | 127 | 3/3/2026 |