Profiles that simplify the registration of MediatR behaviors.
Create a profile:
using MediatR.BehaviorProfiles;
public class MyBehaviorProfile : BehaviorProfile
{
public override void Configure()
{
Register(typeof(LoggingBehavior<,>));
Register(typeof(TransactionBehavior<,>), handlers =>
{
handlers.Include<CreateOrderHandler>();
handlers.Include<DeleteOrderHandler>();
});
}
}Add the profile in ConfigureServices:
using MediatR.BehaviorProfiles.Extensions;
public void ConfigureServices(IServiceCollection services)
{
services
.AddMediatR()
.AddBehaviorProfile<MyBehaviorProfile>();
}