-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathMediatrConfig.cs
26 lines (24 loc) · 1.01 KB
/
MediatrConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using System.Reflection;
namespace CleanArchitectureCosmosDB.WebAPI.Config
{
/// <summary>
/// MediatR config
/// </summary>
public static class MediatrConfig
{
/// <summary>
/// Setup mediatr to use command/query pattern and pipeline behaviors
/// </summary>
/// <param name="services"></param>
public static void SetupMediatr(this IServiceCollection services)
{
// MediatR, this will scan and register everything that inherits IRequest
services.AddMediatR(Assembly.GetExecutingAssembly());
// Register MediatR pipeline behaviors, in the same order the behaviors should be called.
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(Infrastructure.Behaviours.ValidationBehaviour<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(Infrastructure.Behaviours.UnhandledExceptionBehaviour<,>));
}
}
}