FloppyShelf.Mediator
1.0.3
dotnet add package FloppyShelf.Mediator --version 1.0.3
NuGet\Install-Package FloppyShelf.Mediator -Version 1.0.3
<PackageReference Include="FloppyShelf.Mediator" Version="1.0.3" />
<PackageVersion Include="FloppyShelf.Mediator" Version="1.0.3" />
<PackageReference Include="FloppyShelf.Mediator" />
paket add FloppyShelf.Mediator --version 1.0.3
#r "nuget: FloppyShelf.Mediator, 1.0.3"
#:package FloppyShelf.Mediator@1.0.3
#addin nuget:?package=FloppyShelf.Mediator&version=1.0.3
#tool nuget:?package=FloppyShelf.Mediator&version=1.0.3
A lightweight mediator implementation designed for .NET Standard 2.0 and higher. It simplifies request handling by decoupling it from application logic, enabling easier maintenance, better testability, and clean separation of concerns — while leveraging dependency injection through Microsoft.Extensions.DependencyInjection.Abstractions
.
Features
- Target frameworks:
netstandard2.0
,netstandard2.1
,net8.0
,net9.0
,net472
,net48
, andnet481
. - No external dependencies (except
Microsoft.Extensions.DependencyInjection.Abstractions
for DI). - Simple setup and configuration.
- Supports multiple assemblies and namespace filtering.
- Clean, extensible, and minimalistic design.
Note: When targeting .NET Framework 4.7.2, 4.8, or 4.8.1 (net472, net48, net481), the following additional dependencies are required to support modern
async/await
features:
Microsoft.Bcl.AsyncInterfaces
System.Runtime.CompilerServices.Unsafe
System.Threading.Tasks.Extensions
Installation
Install via NuGet Package Manager:
Install-Package FloppyShelf.Mediator
Or via .NET CLI:
dotnet add package FloppyShelf.Mediator
Usage
1. Define a Request
using FloppyShelf.Mediator.Interfaces;
public class GetProductQuery : IRequest<Product>
{
public int Id { get; set; }
}
2. Implement a RequestHandler
using FloppyShelf.Mediator.Interfaces;
public class GetProductQueryHandler : IRequestHandler<GetProductQuery, Product>
{
public Task<Product> HandleAsync(GetProductQuery request, CancellationToken cancellationToken)
{
// Simulated database access
return Task.FromResult(new Product { Id = request.Id, Name = "Sample Product" });
}
}
3. Register the Mediator
using FloppyShelf.Mediator.Extensions;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
// Register handlers from the specified assemblies
services.AddMediator(new[] { typeof(Program).Assembly });
// Optional: Pass a string[] to filter specific namespaces
4. Send a Request
using Microsoft.Extensions.DependencyInjection;
var provider = services.BuildServiceProvider();
var mediator = provider.GetRequiredService<IMediator>();
var result = await mediator.SendAsync(new GetProductQuery { Id = 1 });
Console.WriteLine(result.Name);
API Overview
Interfaces
IRequest<TResponse>
- Represents a request expecting a response.IRequestHandler<TRequest, TResponse>
- Handles a specific request.IMediator
- Sends requests to handlers.
Key Classes
Mediator
- Core implementation of the mediator pattern.ServiceCollectionExtensions
- Provides theAddMediator()
extension method for easy DI setup.
Why FloppyShelf.Mediator?
- Clean and Minimal - Only the essentials, no magic.
- Fully Open Source - MIT licensed.
- Great for Learning - Understand how mediators work internally.
- Extremely Lightweight - No unnecessary complexity.
Product | Versions 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 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. |
.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 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 is compatible. net481 is compatible. |
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. |
-
.NETFramework 4.7.2
- Microsoft.Bcl.AsyncInterfaces (>= 9.0.6)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.6)
- System.Runtime.CompilerServices.Unsafe (>= 6.1.2)
- System.Threading.Tasks.Extensions (>= 4.6.3)
-
.NETFramework 4.8
- Microsoft.Bcl.AsyncInterfaces (>= 9.0.6)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.6)
- System.Runtime.CompilerServices.Unsafe (>= 6.1.2)
- System.Threading.Tasks.Extensions (>= 4.6.3)
-
.NETFramework 4.8.1
- Microsoft.Bcl.AsyncInterfaces (>= 9.0.6)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.6)
- System.Runtime.CompilerServices.Unsafe (>= 6.1.2)
- System.Threading.Tasks.Extensions (>= 4.6.3)
-
.NETStandard 2.0
-
.NETStandard 2.1
-
net8.0
-
net9.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.3 | 150 | 6/30/2025 |