Example #1
0
 private static void ConfigureFluentValidation(VanthOptions options, ISolariBuilder builder)
 {
     if (!options.UseFluentValidation)
     {
         return;
     }
     builder.Services.TryAddSingleton <IVanthValidationService, VanthValidationService>();
     builder.Services.TryAddSingleton <IValidatorFactory, VanthValidatorFactory>();
     builder.Services.AddValidatorsFromAssemblies(AppDomain.CurrentDomain.GetAssemblies().Where(a => !a.IsDynamic));
 }
Example #2
0
 private static void ConfigureExceptionMiddleware(VanthOptions options, ISolariBuilder builder, IConfigurationSection section)
 {
     if (!options.UseExceptionHandlingMiddleware)
     {
         return;
     }
     builder.Services.Configure <VanthOptions>(section);
     builder.AddBuildAction(new BuildAction("Solari.Vanth (ExceptionHandlingMiddleware)")
     {
         Action = provider =>
         {
             var marshal = provider.GetService <ISolariMarshal>();
             if (marshal.ApplicationBuilder == null)
             {
                 return;
             }
             marshal.ApplicationBuilder.UseMiddleware <ExceptionHandlingMiddleware>();
         }
     });
 }