FloppyShelf.Mediator
1.0.1
dotnet add package FloppyShelf.Mediator --version 1.0.1
NuGet\Install-Package FloppyShelf.Mediator -Version 1.0.1
<PackageReference Include="FloppyShelf.Mediator" Version="1.0.1" />
<PackageVersion Include="FloppyShelf.Mediator" Version="1.0.1" />
<PackageReference Include="FloppyShelf.Mediator" />
paket add FloppyShelf.Mediator --version 1.0.1
#r "nuget: FloppyShelf.Mediator, 1.0.1"
#addin nuget:?package=FloppyShelf.Mediator&version=1.0.1
#tool nuget:?package=FloppyShelf.Mediator&version=1.0.1
FloppyShelf.Mediator
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
- Fully compatible with .NET Standard 2.0 and above.
- 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.
Installation
Install via NuGet Package Manager:
Install-Package FloppyShelf.Mediator
Or via .NET CLI:
dotnet add package FloppyShelf.Mediator
Note: This package depends on
Microsoft.Extensions.DependencyInjection.Abstractions
for dependency injection. It will be automatically installed when you add this package.
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 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. |
.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. |
-
.NETStandard 2.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.