Skip to content

Instantly share code, notes, and snippets.

@timdows
Created June 1, 2020 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timdows/e54455063552f9dc95fe2300708e685d to your computer and use it in GitHub Desktop.
Save timdows/e54455063552f9dc95fe2300708e685d to your computer and use it in GitHub Desktop.
// Add all the assemblies to MediatR
services.AddMediatR(typeof(DABBaseRequest).GetTypeInfo().Assembly);
// For all the validators, register them with dependency injection as scoped
AssemblyScanner.FindValidatorsInAssembly(typeof(DABBaseRequest).Assembly)
.ForEach(item => services.AddScoped(item.InterfaceType, item.ValidatorType));
// Add the custome pipeline validation to DI
services.AddScoped(typeof(IPipelineBehavior<,>), typeof(MyCustomPipelineValidationBehavior<,>));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment