Tooark.Mediator.Abstractions
4.7.0
dotnet add package Tooark.Mediator.Abstractions --version 4.7.0
NuGet\Install-Package Tooark.Mediator.Abstractions -Version 4.7.0
<PackageReference Include="Tooark.Mediator.Abstractions" Version="4.7.0" />
<PackageVersion Include="Tooark.Mediator.Abstractions" Version="4.7.0" />
<PackageReference Include="Tooark.Mediator.Abstractions" />
paket add Tooark.Mediator.Abstractions --version 4.7.0
#r "nuget: Tooark.Mediator.Abstractions, 4.7.0"
#:package Tooark.Mediator.Abstractions@4.7.0
#addin nuget:?package=Tooark.Mediator.Abstractions&version=4.7.0
#tool nuget:?package=Tooark.Mediator.Abstractions&version=4.7.0
Tooark.Mediator.Abstractions
Library with the base contracts of the Mediator pattern for .NET projects, used by implementations such as Tooark.Mediator.
π Languages: πΊπΈ English (this file) Β· π§π· PortuguΓͺs
π Contents
- Overview
- Installation
- Components
- Usage Examples
- Dependencies
- Contributing
- Help & Security
- Support
- License
π Overview
The Tooark.Mediator.Abstractions package defines the contracts for:
- requests (
IRequest,IRequest<TResponse>); - commands (
ICommand,ICommand<TResponse>); - queries (
IQuery<TResponse>); - notifications (
INotify); - sending and publishing (
ISender,IPublisher); - the main interface (
IMediator); - the empty return (
Unit).
π§ Installation
dotnet add package Tooark.Mediator.Abstractions
π¦ Components
Message contracts
IRequest<TResponse>: base contract of a request with a response.IRequest: shortcut for a request without a response payload (Unit).ICommand<TResponse>: command with a response.ICommand: command without an explicit response (Unit).IQuery<TResponse>: query with a response.INotify: notification/event without a response.
Orchestration contracts
ISenderTask<TResponse> SendAsync<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken = default)
IPublisherTask PublishAsync(INotify notify, CancellationToken cancellationToken = default)
IMediator: combinesISenderandIPublisher.
Utility type
UnitUnit.Value: the single instance ofUnit.Unit.Task: a task completed withUnit.Value, created once and reused on every access.
π Usage Examples
Defining messages
using Tooark.Mediator.Abstractions;
public sealed record CreateOrderCommand(string CustomerName) : ICommand<Guid>;
public sealed record GetOrderByIdQuery(Guid Id) : IQuery<string>;
public sealed record OrderCreatedNotify(Guid OrderId) : INotify;
Depending on the contracts in a service
using Tooark.Mediator.Abstractions;
public sealed class OrderApplicationService(ISender sender, IPublisher publisher)
{
public async Task<Guid> CreateAsync(string customerName, CancellationToken cancellationToken)
{
var id = await sender.SendAsync(new CreateOrderCommand(customerName), cancellationToken);
await publisher.PublishAsync(new OrderCreatedNotify(id), cancellationToken);
return id;
}
public Task<string> GetByIdAsync(Guid id, CancellationToken cancellationToken)
{
return sender.SendAsync(new GetOrderByIdQuery(id), cancellationToken);
}
}
Using Unit in commands without a return value
using Tooark.Mediator.Abstractions;
public sealed record DeactivateOrderCommand(Guid Id) : ICommand;
// ICommand is a shortcut for ICommand<Unit>: sending returns Task<Unit>
public sealed class OrderMaintenanceService(ISender sender)
{
public Task<Unit> DeactivateAsync(Guid id, CancellationToken cancellationToken)
{
// Synchronous short-circuit: Unit.Task reuses the pre-built task, with no new allocation
if (id == Guid.Empty)
{
return Unit.Task;
}
return sender.SendAsync(new DeactivateOrderCommand(id), cancellationToken);
}
}
π Dependencies
| Package | Version | Description |
|---|---|---|
Tooark.Exceptions |
4.x | Exceptions (e.g. BadRequestException) |
π€ Contributing
Contributions are welcome! Start with CONTRIBUTING.md β it covers the development workflow, the coding and commit conventions and the pull request checklist. Bugs and feature requests go through the issue templates of the Tooark repository.
By participating you agree to the Code of Conduct.
π Help & Security
- β Questions, bugs, feature ideas β see SUPPORT.md for the right channel
- π Security vulnerabilities β do not open a public issue; follow SECURITY.md
π Support
If Tooark helps your projects, consider supporting its development:
- π GitHub Sponsors
- β Ko-fi
Every contribution helps keep the project maintained and improving. Thank you! π
π License
This project is licensed under the BSD 3-Clause License.
| 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
- Tooark.Exceptions (>= 4.7.0)
-
net8.0
- Tooark.Exceptions (>= 4.7.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Tooark.Mediator.Abstractions:
| Package | Downloads |
|---|---|
|
Tooark
Package with all Tooark resources for .NET applications. |
|
|
Tooark.Mediator
Library for decoupling requests and handlers with the Mediator pattern in .NET applications. |
|
|
Tooark.Mediator.EntityFrameworkCore
Library that moves Entity Framework Core persistence into the Tooark.Mediator pipeline, keeping handlers free of SaveChanges. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.7.0 | 276 | 9/30/2026 |
| 4.6.0 | 174 | 9/29/2026 |
| 4.5.0 | 135 | 9/29/2026 |
| 4.4.0 | 141 | 9/28/2026 |
| 4.3.0 | 146 | 9/26/2026 |
| 4.2.1 | 139 | 9/25/2026 |
| 4.2.0 | 146 | 9/20/2026 |
| 4.1.0 | 144 | 9/18/2026 |
| 4.0.1 | 186 | 8/25/2026 |
| 4.0.0 | 162 | 8/25/2026 |
| 3.3.6 | 125 | 9/18/2026 |
| 3.3.5 | 139 | 8/25/2026 |
| 3.3.4 | 148 | 8/12/2026 |
| 3.3.3 | 149 | 7/27/2026 |
| 3.3.2 | 327 | 6/11/2026 |
| 3.3.1 | 170 | 6/6/2026 |
| 3.3.0 | 176 | 4/17/2026 |