Just another simple mediator implementation library.
First you need to install the according packages from NuGet:
Medici.Abstractionscontains all abstract contracts and interfaces to use in your codeMedicicontains the implementations for the abstractions aboveMedici.DependencyInjectioncontains basic extensions for yourIServiceCollectionfor proper dependency registrationMedici.CQRS.Abstractionscontains abstract contracts to CQRS and Result patternsMedici.Behaviors.Validationcontains simple validation pre-processor realisationMedici.OpenProcessorscontains the implementations for open pre/post behavior
IBaseRequest- marker interface for requestsIRequest- a request message, no return value (including generic variants)ICommand- a command message with a Result-pattern responseIQuery- a query message with a Result-pattern response
IRequestHandler<in TRequest>IRequestHandler<in TRequest, TResponse>ICommandHandler<in TCommand>ICommandHandler<in TCommand, TResponse>IQueryHandler<in TQuery>IQueryHandler<in TQuery, TResponse>
RequestPreProcessorBehavior<TRequest, TResponse>RequestPostProcessorBehavior<TRequest, TResponse>
ResultResult<TValue>
Medici supports Microsoft.Extensions.DependencyInjection.Abstractions directly. To register various Medici services and handlers:
services.AddMedici(cfg => cfg.RegisterServicesFromAssemblyWithType<Program>());or with an assembly:
services.AddMedici(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly));This registers:
IMedicias transientISenderas transientIRequestHandler<,>concrete implementations as transientIRequestHandler<>concrete implementations as transient
To register pre/post processors:
services.AddMedici(cfg => {
cfg.RegisterServicesFromAssembly(typeof(Program).Assembly);
cfg.AddRequestPreProcessor<PingPreProcessor>();
cfg.AddRequestPostProcessor<PingPongPostProcessor>();
});or with implementation type
services.AddMedici(cfg => {
cfg.RegisterServicesFromAssembly(typeof(Program).Assembly);
cfg.AddRequestPreProcessor<IPingPreProcessor, PingPreProcessor>();
cfg.AddRequestPostProcessor<IPingPongPostProcessor, PingPongPostProcessor>();
});- This package depends on Scrutor, licensed under the MIT License.
- This package depends on FluentValidation, licensed under the Apache License 2.0.