Sidio.Mediator 1.0.7

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

Sidio.Mediator

A simple implementation of the mediator pattern in .NET.

build Coverage Status

Core package

NuGet Version

Request validation package

NuGet Version

Usage

Requests and requests handlers

// Define a request and request handler
public class MyRequest : IRequest<string>
{
    public string Name { get; init; }
}

public class MyRequestHandler : IRequestHandler<MyRequest, string>
{
    public Task<Result<string>> HandleAsync(MyRequest request, CancellationToken cancellationToken = default)
    {
        var result = Result<string>.Success($"Hello {request.Name}");
        // Or: Result<string>.Failure("error code", "error message");
        return Task.FromResult(result);
    }
}

// Register the request handler
services.AddMediator(typeof(MyRequest));

// Get the request handler from the service provider
var requestHander = serviceProvider.GetRequiredService<IRequestHandler<MyRequest, string>>();
var result = await requestHander.HandleAsync(new MyRequest { Name = "World" });

Http requests

// Define a request and request handler
public class MyHttpRequest : IHttpRequest<string>
{
    public string Name { get; init; }
}

public class MyHttpRequestHandler : IHttpRequestHandler<MyRequest, string>
{
    public Task<HttpResult<string>> HandleAsync(MyRequest request, CancellationToken cancellationToken = default)
    {
        var result = HttpResult<string>.Ok($"Hello {request.Name}");
        // Or for example: HttpResult<string>.Unauthorized();
        return Task.FromResult(result);
    }
}

Request validation

Request validation uses FluentValidation.

// Define a validator
public class MyRequestValidator : AbstractValidator<MyRequest>
{
    public MyRequestValidator()
    {
        RuleFor(x => x.Name).NotEmpty();
    }
}

// Register the validators
services.AddMediatorValidation(typeof(MyRequest));
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 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. 
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 Sidio.Mediator:

Package Downloads
Sidio.Mediator.Validation

Validation features for Sidio.Mediator.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.7 0 5/23/2025