/// <summary> /// /// </summary> /// <param name="builder"></param> public void ConfigureContainer(ContainerBuilder container) { container.ConfigureCore(typeof(Startup).Assembly); container.AddApplication <NpgsqlContext>(); container.AddUnitOfWork <NpgsqlContext>(); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { //TODO: change when database is setup services.AddDbContext <AppDbContext>(options => { options.UseLazyLoadingProxies(); options.UseInMemoryDatabase("InMemoryDatabase"); }); //OpenAPI for sweet swagger documentation services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" }); }); services.AddMvc(options => { }).AddJsonOptions( options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore ); //services.AddMvcCore().AddJsonFormatters(f => f.Converters.Add(new StringEnumConverter())); services.AddAppHangfire(); // Create the container builder. var builder = new ContainerBuilder(); builder.Populate(services); //Register app builder.AddApplication(); this.ApplicationContainer = builder.Build(); GlobalConfiguration.Configuration.UseAutofacActivator(ApplicationContainer); // Create the IServiceProvider based on the container. return(new AutofacServiceProvider(ApplicationContainer)); }