Created
August 2, 2020 18:51
-
-
Save Manu06D/33388cdf2d84c720d420780bb5615002 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var services = new ServiceCollection(); | |
Assembly[] assembliesToScan = new Assembly[]{ | |
AppFramework.Core.AppFrameworkCore.Assembly, | |
Core.CarCatalogCore.Assembly, | |
AppFrameworkModels.Assembly | |
}; | |
services.AddMediatR(assembliesToScan); | |
services.AddAutoMapper(new Assembly[] { | |
AppFramework.Core.AppFrameworkCore.Assembly, //Automatic IMapFrom mapping | |
Assembly.GetExecutingAssembly() //Custom Mapping | |
}); | |
builder.Populate(services); | |
builder.RegisterModule(new RegisterAutofacModule() { Assemblies = assembliesToScan }); | |
builder.RegisterAssemblyTypes(CarCatalogModels.Assembly).Where(t => t.IsClosedTypeOf(typeof(IValidator<>))).AsImplementedInterfaces(); | |
builder.RegisterType<CarCatalogContext>(); | |
builder.RegisterGeneric(typeof(CarCatalogRepository<>)).As(typeof(IAsyncRepository<>)).InstancePerLifetimeScope() | |
.PropertiesAutowired() | |
.OnActivated(args => AutofacHelper.InjectProperties(args.Context, args.Instance, true)); | |
builder.RegisterType<AutofacValidatorFactory>().As<IValidatorFactory>().SingleInstance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment