Skip to content
João Simões edited this page Oct 22, 2020 · 17 revisions

Mediator

Small .NET library that helps with the implementation of mediator pattern for commands, events and queries.

Using a mediator instance, send commands, broadcast events and fetch queries from their respective generic handlers.

Documentation

Check the rest of the documentation for more details:

  • Mediator - mediator concepts and how to use it;
  • Commands - commands, command handlers and how send works;
  • Events - events, event handlers and how broadcast works;
  • Queries - queries, query handlers and how fetch works;
  • Middleware - explanation about the command, event and query pipeline;
  • Configuration (and Dependency Injection) - how core instances behave and how can they be configured in a dependency injection container;
  • Logging - how to enable mediator logging via wrappers or middleware;

Installation

The library is available via NuGet packages:

NuGet Description Version
SimpleSoft.Mediator.Abstractions interfaces and abstract implementations (commands, events, queries, mediator, ...) NuGet
SimpleSoft.Mediator core implementation NuGet
SimpleSoft.Mediator.Microsoft.Extensions specialized methods and classes for the Microsoft dependency injection container and logging facades NuGet
SimpleSoft.Mediator.Microsoft.Extensions.EFCoreTransactionPipeline mediator pipeline to enforce Entity Framework Core transactions NuGet
SimpleSoft.Mediator.Microsoft.Extensions.LoggingPipeline pipeline that serializes commands, queries, events and results into the logging NuGet
SimpleSoft.Mediator.Microsoft.Extensions.ValidationPipeline pipeline that enforces validation into commands, queries and events before entering the handlers by using FluentValidation NuGet

Package Manager

Install-Package SimpleSoft.Mediator.Abstractions
Install-Package SimpleSoft.Mediator
Install-Package SimpleSoft.Mediator.Microsoft.Extensions
Install-Package SimpleSoft.Mediator.Microsoft.Extensions.EFCoreTransactionPipeline
Install-Package SimpleSoft.Mediator.Microsoft.Extensions.LoggingPipeline
Install-Package SimpleSoft.Mediator.Microsoft.Extensions.ValidationPipeline

.NET CLI

dotnet add package SimpleSoft.Mediator.Abstractions
dotnet add package SimpleSoft.Mediator
dotnet add package SimpleSoft.Mediator.Microsoft.Extensions
dotnet add package SimpleSoft.Mediator.Microsoft.Extensions.EFCoreTransactionPipeline
dotnet add package SimpleSoft.Mediator.Microsoft.Extensions.LoggingPipeline
dotnet add package SimpleSoft.Mediator.Microsoft.Extensions.ValidationPipeline

Compatibility

This library is compatible with the following frameworks:

  • SimpleSoft.Mediator.Abstractions
    • .NET Framework 4.0+;
    • .NET Standard 1.0+;
  • SimpleSoft.Mediator
    • .NET Framework 4.0+;
    • .NET Standard 1.0+;
  • SimpleSoft.Mediator.Microsoft.Extensions
    • .NET Standard 1.1+;
  • SimpleSoft.Mediator.Microsoft.Extensions.EFCoreTransactionPipeline
    • .NET Standard 1.3+;
  • SimpleSoft.Mediator.Microsoft.Extensions.LoggingPipeline
    • .NET Standard 1.1+;
  • SimpleSoft.Mediator.Microsoft.Extensions.ValidationPipeline
    • .NET Standard 1.1+;

Examples

Usage examples of the mediator: