Dom.Mediator 1.0.0

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

Dom.Mediator

Dom.Mediator is a clean, minimal, zero-dependency implementation of the Mediator pattern for .NET, focused on:

  • ✅ Request/Response messaging (CQRS)
  • ✅ Composable pipeline behaviors (validation, logging, etc.)
  • ✅ Built-in Result<T> handling with typed errors
  • ✅ No external dependencies — just C#
  • ✅ Perfect fit for Minimal APIs or Clean Architecture

📦 Install via NuGet

dotnet add package Dom.Mediator

🚀 Quick Example

Define your command:

public class EchoCommand : IRequest<string>
{
    public string Message { get; set; } = string.Empty;
}

Create a handler:

public class EchoHandler : IRequestHandler<EchoCommand, string>
{
    public Task<Result<string>> Handle(EchoCommand request, CancellationToken cancellationToken)
    {
        return Task.FromResult(Result<string>.Success($"Echo: {request.Message}"));
    }
}

Register and send:

var mediator = new Dom.Mediator.PureMediator();
mediator.ScanHandlersFrom(Assembly.GetExecutingAssembly());

var result = await mediator.Send(new EchoCommand { Message = "Hello" });

return result.Match(
    value => Results.Ok(value),
    error => Results.Problem(error)
);

⚙️ Built-in Features

  • 🧱 Pipeline Behaviors: Add logging, validation, error handling in a clean chain.
  • 🎯 Result Pattern (Result<T> and Result): Native success/failure with structured error codes.
  • 🧪 FluentValidation Support: Easily add a validation behavior.
  • 🔄 Auto-Handler Discovery: Reflective scanning via assembly input.
  • 💡 Custom Behaviors: Plug in your own pre-/post-handling logic.

🧩 Extensibility

mediator.RegisterGlobalPipelineBehavior(typeof(MyCustomBehavior<,>));

Each behavior implements:

Task<Result<TResponse>> Handle(
    TRequest request,
    CancellationToken cancellationToken,
    RequestHandlerDelegate<TResponse> next);

📜 License

Dom.Mediator is MIT licensed.

👤 Author

Made with ❤️ by André Dominic Santacroce

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.
  • net8.0

    • No dependencies.

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.0 130 7/10/2025
1.0.0-preview.9 29 8/1/2025
1.0.0-preview.8 106 7/16/2025
1.0.0-preview.7 112 7/16/2025
1.0.0-preview.6 108 7/16/2025
1.0.0-preview.5 114 7/14/2025
1.0.0-preview.4 61 7/11/2025
1.0.0-preview.3 62 7/11/2025
1.0.0-preview.2 68 7/11/2025
1.0.0-preview.1 113 7/10/2025