public void ConfigureServices(IServiceCollection services) { services.AddHttpContextAccessor(); var settings = new Settings(); Configuration.Bind(settings); services.AddSingleton <Settings>(settings); services.AddMemoryCache(); // In production, the React files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = GetSpaOutputDir(HostingEnvironment); }); var demoContainer = DemoContainer.Initialize(DemoCodePaths, LoggerFactory.CreateLogger <DemoContainer>(), settings); services.AddSingleton(demoContainer); services.AddSingleton <DocumentStoreHolder>(); services.AddSingleton(_ => new DatabaseName(settings.Database, settings.ConferenceMode)); services.AddScoped <UserStoreCache>(); services.AddScoped <MediaStoreCache>(); services.AddScoped <HeadersAccessor>(); services.AddScoped <UserIdContainer>(); services.AddScoped <DatabaseSetup>(); services.AddScoped <DatabaseLinks>(); services.AddScoped <AddUserIdToResponseHeaderAttribute>(); services .AddControllers() .AddApplicationPart(typeof(Startup).Assembly) .AddControllersAsServices(); services.AddHsts(options => { options.MaxAge = TimeSpan.FromDays(365); }); }
public void ConfigureServices(IServiceCollection services) { services.AddHttpContextAccessor(); var settings = new Settings(); Configuration.Bind(settings); services.AddSingleton <Settings>(settings); var serviceProvider = services.BuildServiceProvider(); services.AddMemoryCache(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); // In production, the React files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = GetSpaOutputDir(HostingEnvironment); }); var demoContainer = DemoContainer.Initialize(DemoCodePaths, LoggerFactory.CreateLogger <DemoContainer>(), settings); services.AddSingleton(demoContainer); services.AddSingleton <DocumentStoreHolder>(); services.AddSingleton(_ => new DatabaseName(settings.Database, settings.ConferenceMode)); services.AddScoped <UserStoreCache>(); services.AddScoped <MediaStoreCache>(); services.AddScoped <HeadersAccessor>(); services.AddScoped <UserIdContainer>(); services.AddScoped <DatabaseSetup>(); services.AddScoped <DatabaseLinks>(); services.AddScoped <AddUserIdToResponseHeaderAttribute>(); }