Snowberry.Mediator.Abstractions 3.0.0

dotnet add package Snowberry.Mediator.Abstractions --version 3.0.0
                    
NuGet\Install-Package Snowberry.Mediator.Abstractions -Version 3.0.0
                    
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="Snowberry.Mediator.Abstractions" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Snowberry.Mediator.Abstractions" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Snowberry.Mediator.Abstractions" />
                    
Project file
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 Snowberry.Mediator.Abstractions --version 3.0.0
                    
#r "nuget: Snowberry.Mediator.Abstractions, 3.0.0"
                    
#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 Snowberry.Mediator.Abstractions@3.0.0
                    
#: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=Snowberry.Mediator.Abstractions&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Snowberry.Mediator.Abstractions&version=3.0.0
                    
Install as a Cake Tool

Snowberry.Mediator.Abstractions

The contracts of Snowberry.Mediator. This package holds the message, handler and pipeline interfaces, the IMediator surface, the priority attribute and the exception types. It targets net11.0, net10.0 and netstandard2.0, and has no dependencies on modern .NET (on netstandard2.0 it uses System.Threading.Tasks.Extensions and Microsoft.Bcl.AsyncInterfaces for ValueTask and IAsyncEnumerable).

Reference it directly when a library only defines messages, handlers or behaviors and should not depend on the mediator implementation. Applications reference a DI integration package instead, which brings this package in.

Table of Contents

Installation

dotnet add package Snowberry.Mediator.Abstractions

Quick Start

Define a request and its handler in a library that only references the abstractions:

using Snowberry.Mediator.Abstractions.Handler;
using Snowberry.Mediator.Abstractions.Messages;

public sealed record GetUser(int Id) : IRequest<GetUser, string>;

public sealed class GetUserHandler : IRequestHandler<GetUser, string>
{
    public ValueTask<string> HandleAsync(GetUser request, CancellationToken cancellationToken = default)
        => new($"user-{request.Id}");
}

The application registers GetUserHandler through a DI integration and calls IMediator.SendAsync(new GetUser(42)).

Type Catalog

Type Namespace Purpose
IMediator Snowberry.Mediator.Abstractions The mediator; combines IMediatorSender and IMediatorPublisher. The only one registered in DI.
IMediatorSender Snowberry.Mediator.Abstractions.Mediator SendAsync and CreateStreamAsync.
IMediatorPublisher Snowberry.Mediator.Abstractions.Mediator PublishAsync.
Empty Snowberry.Mediator.Abstractions Unit response type for requests without a result (Empty.Value, Empty.ValueTask).
IRequest<TRequest, TResponse> Snowberry.Mediator.Abstractions.Messages Marks a request; TRequest is the request type itself and must be a class.
IStreamRequest<TRequest, TResponse> Snowberry.Mediator.Abstractions.Messages Marks a stream request.
INotification Snowberry.Mediator.Abstractions.Messages Marks a notification.
IRequestHandler<TRequest, TResponse> Snowberry.Mediator.Abstractions.Handler Handles a request: ValueTask<TResponse> HandleAsync(request, ct).
IStreamRequestHandler<TRequest, TResponse> Snowberry.Mediator.Abstractions.Handler Handles a stream request: IAsyncEnumerable<TResponse> HandleAsync(request, ct).
INotificationHandler<TNotification> Snowberry.Mediator.Abstractions.Handler Handles a notification: ValueTask HandleAsync(notification, ct).
IPipelineBehavior<TRequest, TResponse> Snowberry.Mediator.Abstractions.Pipeline Wraps request handling; receives the next step as TNext : struct, IPipelineContinuation<,>.
IPipelineContinuation<TRequest, TResponse> Snowberry.Mediator.Abstractions.Pipeline The next step of a request pipeline (InvokeAsync).
IStreamPipelineBehavior<TRequest, TResponse> Snowberry.Mediator.Abstractions.Pipeline Wraps stream handling.
IStreamPipelineContinuation<TRequest, TResponse> Snowberry.Mediator.Abstractions.Pipeline The next step of a stream pipeline.
PipelineOverwritePriorityAttribute Snowberry.Mediator.Abstractions.Attributes Priority moves a behavior ahead of the registration order; higher runs earlier.
HandlerNotFoundException Snowberry.Mediator.Abstractions.Exceptions No handler for a request or stream request (RequestType, IsStream).
NotificationHandlerNotFoundException Snowberry.Mediator.Abstractions.Exceptions PublishAsync with no notification handlers registered at all (NotificationType).
NotificationHandlerNotResolvedException Snowberry.Mediator.Abstractions.Exceptions No handler could be resolved for this notification type (NotificationType, HandlerType).

Pitfalls

  • The request names itself. Write record GetUser : IRequest<GetUser, string>, not IRequest<string>. The self-reference lets SendAsync infer both type arguments.
  • Requests must be reference types. TRequest is constrained to class, so a struct request does not compile.
  • Positive priorities only. Zero and negative Priority values interleave with unattributed behaviors instead of running last; see ordering and priority.
  • Defining a handler does not register it. Registration happens in the application through a DI integration or the source generator.
Package Purpose
Snowberry.Mediator The mediator implementation and registries.
Snowberry.Mediator.Extensions.DependencyInjection Microsoft.Extensions.DependencyInjection integration.
Snowberry.Mediator.DependencyInjection Snowberry.DependencyInjection integration.
Snowberry.Mediator.SourceGenerator Compile-time, reflection-free registration.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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 was computed.  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.  net11.0 is compatible. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Snowberry.Mediator.Abstractions:

Package Downloads
Snowberry.Mediator

A tiny mediator for clean, decoupled application flow.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 372 11/12/2026
2.0.0 5,690 6/1/2026
1.1.0 1,189 1/28/2026
1.0.4-alpha 357 11/15/2025
1.0.3-alpha 320 11/4/2025
1.0.2-alpha 406 10/7/2025 1.0.2-alpha is deprecated because it is no longer maintained.
1.0.1-alpha 406 9/23/2025 1.0.1-alpha is deprecated because it is no longer maintained.
1.0.0-alpha 399 9/9/2025 1.0.0-alpha is deprecated because it is no longer maintained.