All Projects → simplesoft-pt → Mediator

simplesoft-pt / Mediator

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

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to Mediator

AvroConvert
Apache Avro serializer for .NET
Stars: ✭ 44 (+41.94%)
Mutual labels:  netcore
ormdb
ORM tool for .Net / .Net.Core
Stars: ✭ 14 (-54.84%)
Mutual labels:  netcore
EPPlus4PHP
an easy-to-use excel library for php project which is compiled with peachpie. NOT FOR THE COMMON PHP PROJECT!
Stars: ✭ 15 (-51.61%)
Mutual labels:  netcore
Study.Microservices
一步一步,由浅入深,学习如何使用.net core搭建微服务框架。
Stars: ✭ 18 (-41.94%)
Mutual labels:  netcore
aseprite-to-godot-variables
A Lua script to create arrays of colors and indexes of those colors from an Aseprite sprite to be used in Godot.
Stars: ✭ 19 (-38.71%)
Mutual labels:  patterns
geo-pattern
Create beautiful generative geometric background images from a string ✨ TypeScript port of jasonlong/geo_pattern. Supports both Node.js and Browser.
Stars: ✭ 33 (+6.45%)
Mutual labels:  patterns
kafka-net-core
kafka .net core library
Stars: ✭ 23 (-25.81%)
Mutual labels:  netcore
Tesseract
A set of libraries for rapidly developing Pipeline driven micro/macroservices.
Stars: ✭ 20 (-35.48%)
Mutual labels:  netcore
CmlLib.Core
.NET Minecraft Launcher Library. All Version, Auth, Forge, Java, Crossplatform
Stars: ✭ 87 (+180.65%)
Mutual labels:  netcore
onvif-discovery
C# .NetStandard 2.0 library to discover ONVIF compliant devices
Stars: ✭ 29 (-6.45%)
Mutual labels:  netcore
Cosmos.Identity
A Cosmos storage provider for ASP.NET Core Identity.
Stars: ✭ 26 (-16.13%)
Mutual labels:  netcore
nactivity
workflow engine activity activiti
Stars: ✭ 55 (+77.42%)
Mutual labels:  netcore
awesome-dotnet-async
A curated list of awesome articles and resources to learning and practicing about async, threading, and channels in .Net platform. 😉
Stars: ✭ 84 (+170.97%)
Mutual labels:  netcore
GenshinPray
一个.net core编写的模拟原神抽卡的api,根据米哈游公布的概率模拟生成十连或单抽结果图,并返回图片地址
Stars: ✭ 33 (+6.45%)
Mutual labels:  netcore
AspNetCore.Identity.RavenDb
RavenDB user/role persistent store for ASP.NET Core identity provider
Stars: ✭ 17 (-45.16%)
Mutual labels:  netcore
front-end-resources
📚Resources for front-end developer
Stars: ✭ 32 (+3.23%)
Mutual labels:  patterns
Kodkod
https://github.com/alirizaadiyahsi/Nucleus Web API layered architecture startup template with ASP.NET Core 2.1, EF Core 2.1 and Vue Client
Stars: ✭ 45 (+45.16%)
Mutual labels:  netcore
EntityFrameworkCore.SqlServer.SimpleBulks
Very simple .net library (lightweight, easy to use and customize) that supports bulk insert (return db generated Ids), bulk update, bulk delete and bulk merge database operations. Lambda Expression is also supported.
Stars: ✭ 95 (+206.45%)
Mutual labels:  netcore
Sharer
Arduino & .NET serial communication library to read/write variables and remote call functions using the Sharer protocol. Works on Windows, Linux and MacOS.
Stars: ✭ 21 (-32.26%)
Mutual labels:  netcore
ddd-net-ef-core
Self study: DDD, .net core, entity framework core
Stars: ✭ 41 (+32.26%)
Mutual labels:  netcore

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.

Articles

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.DatabaseTransactionPipeline mediator pipeline to enforce SimpleSoft.Database transactions 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.DatabaseTransactionPipeline
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.DatabaseTransactionPipeline
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.DatabaseTransactionPipeline
    • .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+;

Usage

Documentation is available via wiki or you can check the working examples or test code.

Here is an example of a command handler that also sends some events:

public class CreateUserCommand : Command {
  public string Email { get; set; }
  public string Password { get; set; }
}

public class UserCreatedEvent : Event {
  public User User { get; set; }
}

public class UserByIdQuery : Query<User> {
  public Guid UserId { get; set; }
}

public class User {
  public Guid Id { get; set; }
  public string Email { get; set; }
}

public class ExampleHandlers : ICommandHandler<CreateUserCommand>, IQueryHandler<UserByIdQuery,User> {
  
  private readonly IMediator _mediator;
  
  public UsersService(IMediator mediator) {
    _mediator = mediator;
  }
  
  public async Task HandleAsync(CreateUserCommand cmd, CancellationToken ct) {
    var userId = Guid.NewGuid();
    
    // try add the user to some store
    
    await _mediator.BroadcastAsync(new UserCreatedEvent {
      User = new User {
        Id = userId,
        Email = cmd.Email
      }
    }, ct);
  }
  
  public async Task<User> HandleAsync(UserByIdQuery query, CancellationToken ct) {
    User user = null;
    
    // search the store by user id
    
    return user;
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].