Mo.Custome.Mediator 1.0.1

Suggested Alternatives

MoMediator

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

Custom Mediator Implementation (C#)

This project provides a clean, extensible implementation of the Mediator pattern in C#, inspired by MediatR but built from scratch for learning, customization, or lightweight usage.


✨ Features

  • ✅ Supports Send<TResponse> for request/response interactions.
  • ✅ Supports Publish<TNotification> for broadcasting notifications.
  • ✅ Reflection-based method invocation with validation.
  • ✅ Clean code principles: null checks, proper error handling, and separation of concerns.

🧱 Architecture

This project uses the Mediator pattern to decouple sender and receiver components via two core interfaces:

  • IRequest<TResponse> – Represents a command or query expecting a response.
  • INotification – Represents a notification/event without an expected return.

Handlers are resolved using IServiceProvider, and their Handle methods are dynamically invoked using reflection.


🧩 Interfaces

public interface IRequest<TResponse> { }

public interface INotification { }

public interface IRequestHandler<TRequest, TResponse>
    where TRequest : IRequest<TResponse>
{
    Task<TResponse> Handle(TRequest request, CancellationToken cancellationToken);
}

public interface INotificationHandler<TNotification>
    where TNotification : INotification
{
    Task Handle(TNotification notification, CancellationToken cancellationToken);
}

DOCS

  • For advanced usage, see the docs.
Product 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.