// ConfigureServices is where you register dependencies and return an `IServiceProvider` implemented by `AutofacServiceProvider`. // This is the old, not recommended way, and is NOT SUPPORTED in ASP.NET Core 3.0+. public IServiceProvider ConfigureServices(IServiceCollection services) { // Add services to the collection services.AddOptions(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddAutoMapper(typeof(BLMapperProfile)); //Mapper.AssertConfigurationIsValid(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Values Api", Version = "v1" }); }); // create a container-builder and register dependencies var builder = new ContainerBuilder(); // populate the service-descriptors added to `IServiceCollection` // BEFORE you add things to Autofac so that the Autofac // registrations can override stuff in the `IServiceCollection` // as needed builder.Populate(services); builder.Register(c => { var confDto = new HereApiConfDTO(); Configuration.GetSection("HereApiConfDTO").Bind(confDto); return(confDto); }).As <HereApiConfDTO>(); builder.RegisterModule(new BLAutofacModule()); builder.RegisterModule(new DALAutofacModule()); AutofacContainer = builder.Build(); // this will be used as the service-provider for the application! return(new AutofacServiceProvider(AutofacContainer)); }
public RouteMatchingService(HereApiConfDTO hereApiConfDTO) { HereApiConfDTO = hereApiConfDTO; }