Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Use scruptor for scan and register IValidatorConsumer type
supportbff68f581713
diff --git a/src/Core/Grand.Infrastructure/StartupBase.cs b/src/Core/Grand.Infrastructure/StartupBase.csindex 4d81ed813..a062bcdb8 100644--- a/src/Core/Grand.Infrastructure/StartupBase.cs+++ b/src/Core/Grand.Infrastructure/StartupBase.cs@@ -89,6 +89,19 @@ namespace Grand.Infrastructureitem.Register();}+ /// <summary>+ /// Register type ValidatorConsumer+ /// </summary>+ /// <param name="services">Service collection</param>+ /// <param name="typeSearcher">TypeSearcher</param>+ private static void RegisterValidatorConsumer(IServiceCollection services, ITypeSearcher typeSearcher)+ {+ services.Scan(scan => scan.FromAssemblies(typeSearcher.GetAssemblies())+ .AddClasses(classes => classes.AssignableTo(typeof(IValidatorConsumer<>)))+ .AsImplementedInterfaces().WithScopedLifetime());+ }++private static T StartupConfig<T>(this IServiceCollection services, IConfiguration configuration) where T : class, new(){if (services == null)@@ -263,6 +276,9 @@ namespace Grand.Infrastructure//Register custom type convertersRegisterTypeConverter(typeSearcher);+ //Register type validator consumer+ RegisterValidatorConsumer(services, typeSearcher);+//add mediatorAddMediator(services, typeSearcher);