Trellis.Mediator
3.0.0-alpha.304
dotnet add package Trellis.Mediator --version 3.0.0-alpha.304
NuGet\Install-Package Trellis.Mediator -Version 3.0.0-alpha.304
<PackageReference Include="Trellis.Mediator" Version="3.0.0-alpha.304" />
<PackageVersion Include="Trellis.Mediator" Version="3.0.0-alpha.304" />
<PackageReference Include="Trellis.Mediator" />
paket add Trellis.Mediator --version 3.0.0-alpha.304
#r "nuget: Trellis.Mediator, 3.0.0-alpha.304"
#:package Trellis.Mediator@3.0.0-alpha.304
#addin nuget:?package=Trellis.Mediator&version=3.0.0-alpha.304&prerelease
#tool nuget:?package=Trellis.Mediator&version=3.0.0-alpha.304&prerelease
Trellis.Mediator
Result-aware pipeline behaviors for Mediator that keep handlers focused on business work.
Installation
dotnet add package Trellis.Mediator
Quick Example
using Mediator;
using Trellis;
using Trellis.Mediator;
public sealed record GetOrderQuery(string Id) : IQuery<Result<string>>, IValidate
{
public IResult Validate() =>
string.IsNullOrWhiteSpace(Id)
? Result.Fail(new Error.InvalidInput(EquatableArray.Create(new FieldViolation(InputPointer.ForProperty(nameof(Id)), "validation.error") { Detail = "Order ID is required." })))
: Result.Ok();
}
builder.Services.AddMediator(opts => opts.ServiceLifetime = ServiceLifetime.Scoped);
builder.Services.AddTrellisBehaviors();
Use ServiceLifetime.Scoped when calling AddMediator(...) in a host with a request scope. The Trellis behaviors are scoped (they depend on per-request services); the Mediator default of Singleton will fail ASP.NET's root-scope validation as soon as the first behavior tries to resolve a scoped dependency.
Key Features
- Adds validation, authorization, tracing, logging, and exception behaviors that understand
Result<T>. - Short-circuits failures before handlers do unnecessary work.
- Unified
ValidationBehaviorcomposesIValidate+ everyIMessageValidator<TMessage>(e.g., theTrellis.FluentValidationadapter) and aggregates failures into one response. - Supports resource authorization with explicit or assembly-scanned registration.
- Domain event dispatch: implement
IDomainEventHandler<TEvent>, register withAddDomainEventDispatch(...), and the framework fires events fromIAggregate.UncommittedEvents()after a successful command handler whose response is anIResult<TAggregate>(typicallyResult<TAggregate>) whereTAggregate : IAggregate. Other response shapes (Result<Unit>,Result<TDto>,Result<(A,B)>) pass through untouched in v1. Non-cancellation handler exceptions are logged and swallowed so side effects never break the originating request;OperationCanceledExceptionmatching the request's token is the one exception that propagates so the caller can abort cleanly.
Documentation
Part of Trellis
This package is part of the Trellis framework.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Mediator.Abstractions (>= 3.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.7)
- Trellis.Authorization (>= 3.0.0-alpha.304)
- Trellis.Core (>= 3.0.0-alpha.304)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Trellis.Mediator:
| Package | Downloads |
|---|---|
|
Trellis.FluentValidation
Convert fluent validation errors to Trellis Validation errors. |
|
|
Trellis.ServiceDefaults
Opinionated service composition defaults for Trellis web services. Provides a tiered builder that wires ASP integration, Mediator behaviors, FluentValidation, resource authorization, actor providers, and EF Core Unit of Work in canonical order. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-alpha.304 | 62 | 5/29/2026 |
| 3.0.0-alpha.158 | 94 | 4/5/2026 |
| 3.0.0-alpha.157 | 68 | 4/4/2026 |
| 3.0.0-alpha.140 | 71 | 3/30/2026 |
| 3.0.0-alpha.137 | 79 | 3/27/2026 |
| 3.0.0-alpha.135 | 57 | 3/26/2026 |
| 3.0.0-alpha.127 | 58 | 3/23/2026 |
| 3.0.0-alpha.123 | 64 | 3/19/2026 |
| 3.0.0-alpha.118 | 70 | 3/14/2026 |
| 3.0.0-alpha.111 | 62 | 3/12/2026 |
| 3.0.0-alpha.104 | 78 | 3/9/2026 |
| 3.0.0-alpha.100 | 58 | 3/4/2026 |
| 3.0.0-alpha.99 | 61 | 3/4/2026 |
| 3.0.0-alpha.98 | 63 | 3/3/2026 |
| 3.0.0-alpha.95 | 61 | 3/2/2026 |
| 3.0.0-alpha.94 | 57 | 3/2/2026 |
| 3.0.0-alpha.93 | 65 | 3/1/2026 |
| 3.0.0-alpha.92 | 70 | 2/28/2026 |