Skip to content

Instantly share code, notes, and snippets.

@benjaminvanrenterghem
Last active September 17, 2022 00:25
Show Gist options
  • Save benjaminvanrenterghem/d7911a616a68ccb993a7eed288d247a7 to your computer and use it in GitHub Desktop.
Save benjaminvanrenterghem/d7911a616a68ccb993a7eed288d247a7 to your computer and use it in GitHub Desktop.
ServiceCollectionExtensions snippet 1
// [i] Bestand terug te vinden onder project: Logic.Extensions.ServiceCollectionExtensions.AddMediation
public static void AddMediation(this IServiceCollection services) {
// #1 Mediatr registreren
services.AddMediatR(Assembly.GetExecutingAssembly());
// #2 We wensen als eerste PipelineBehavior de logging
services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>));
services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly(), ServiceLifetime.Scoped);
// #3 We wensen na de logging pas de data te valideren
services.AddScoped(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment