/// <summary> /// Konfiguracja serwisów użytych w aplikacji /// </summary> /// <param name="services">Kolekcja serwisów</param> /// <returns>Service Provider</returns> public IServiceProvider ConfigureServices(IServiceCollection services) { // api documentation services.AddSwaggerGen(); services.ConfigureSwaggerGen(options => { options.SingleApiVersion(new Info { Version = "v1", Title = "Learn our Language - WebAPI", Description = "", TermsOfService = "None" }); options.DescribeAllEnumsAsStrings(); options.IncludeXmlComments(Path.ChangeExtension(Assembly.GetEntryAssembly().Location, "xml")); }); // Add framework services. services.AddMvc() .AddMvcOptions(options => { options.CacheProfiles.Add("NoCache", new CacheProfile { NoStore = true, Duration = 0 }); }); //services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); // Database DI var connectionString = Configuration.GetConnectionString("LearnOurLanguageContext"); services.AddDbContext <DatabaseContext>(options => options.UseSqlServer(connectionString)); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(30); options.CookieName = ".LearnOurLanguage"; }); // Autofac var builder = new ContainerBuilder(); ConfigHelper.BindAssemblyForBuilder(ref builder, "LearnOurLanguage.Web", "Model"); builder.Populate(services); ApplicationContainer = builder.Build(); return(new AutofacServiceProvider(ApplicationContainer)); }