public void ConfigureServices(IServiceCollection services) { services.AddLogging(builder => builder #if DEBUG .SetMinimumLevel(LogLevel.Trace) #else .SetMinimumLevel(LogLevel.Warning) #endif ); TypeDescriptorProviderGenerator.AddTypeDescriptorProviders(typeof(Schema.Deployment).Namespace, typeof(SchemaExtentions.Deployment).Namespace); services.AddFileReaderService(); services.AddBlazorFileSaver(); services.AddSingleton <IState, State>(); services.AddTransient <IValidatorFactory, ServiceProviderValidatorFactory>(); var config = new FluentValidationMvcConfiguration(); config.RegisterValidatorsFromAssemblyContaining <Startup>(); AssemblyScanner.FindValidatorsInAssemblies(config.AssembliesToRegister).ForEach(pair => { services.Add(ServiceDescriptor.Transient(pair.InterfaceType, pair.ValidatorType)); }); services.AddScoped <IAppInsights, AppInsights>(); }
/// <summary> /// this method dos not modelBuilder method. this is register all dto validator for Fluent Validation Library /// </summary> /// <typeparam name="TInterFace"></typeparam> /// <param name="configuration"></param> /// <param name="assemblies"></param> public static void RegisterAllDtoValidators <TInterFace>(this FluentValidationMvcConfiguration configuration, params Assembly[] assemblies) { IEnumerable <Type> types = assemblies.SelectMany(a => a.GetExportedTypes()) .Where(c => c.IsClass && !c.IsAbstract && c.IsPublic && typeof(TInterFace).IsAssignableFrom(c)); foreach (Type type in types) { configuration.RegisterValidatorsFromAssemblyContaining(type); } }
public void ConfigureServices(IServiceCollection services) { services.AddLogging(builder => builder #if DEBUG .SetMinimumLevel(LogLevel.Information) #else .SetMinimumLevel(LogLevel.Warning) #endif ); services.AddSingleton <IState, State>(); services.AddScoped <IAppInsights, AppInsights>(); services.AddSingleton <Updater>(); var cfg = new FluentValidationMvcConfiguration(); cfg.RegisterValidatorsFromAssemblyContaining <Startup>(); }
public static FluentValidationMvcConfiguration RegisterValidatorsFromDomain(this FluentValidationMvcConfiguration configuration) { configuration.RegisterValidatorsFromAssemblyContaining(typeof(DependencyRegistrationExtensions)); return(configuration); }
private void ConfigureValidators(FluentValidationMvcConfiguration cfg) { cfg.RegisterValidatorsFromAssemblyContaining <ApplicationValidator>(); }
private static void ConfigurationExpression(FluentValidationMvcConfiguration s) { s.RegisterValidatorsFromAssemblyContaining <Startup> (); s.RunDefaultMvcValidationAfterFluentValidationExecutes = false; }