Exemple #1
0
        // Configure is called after ConfigureServices is called.
        public void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            ILoggerFactory loggerFactory,
            IPageConfiguration pageConfiguration,
            ILanguageManipulationService languageManipulationService,
            IRoutesBuilder routesBuilder)
        {
            loggerFactory.AddConsole();

            // Configure the HTTP request pipeline.

            // Add the following to the request pipeline only in development environment.
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();

                loggerFactory.AddDebug(LogLevel.Debug);
            }
            else
            {
                loggerFactory.AddDebug(LogLevel.Critical);
            }

            // Add static files to the request pipeline.
            app.UseStaticFiles();

            // Add cookie-based authentication to the request pipeline.
            app.UseIdentity();


            var defaultCulture = languageManipulationService
                                 .LanguageDefinitionToCultureInfo(
                pageConfiguration.DefaultLanguage
                );

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                SupportedCultures       = languageManipulationService.SupportedCultures,
                SupportedUICultures     = languageManipulationService.SupportedCultures,
                RequestCultureProviders = new[] { new CustomUrlStringCultureProvider(languageManipulationService) },
                DefaultRequestCulture   = new RequestCulture(defaultCulture, defaultCulture)
            }
                                       );

            app.UseMvc(routesBuilder.Build);

            using (var dataInitializer = new DataInitializer(app.ApplicationServices))
            {
                dataInitializer.EnsureRequiredContentsAvailable();
                dataInitializer.EnsureInitialUserAvaialble();
            }
        }
        public CliActionRuntimeBuilder(ICliActionRouter actionRouter,
                                       IRoutesBuilder routesBuilder, IServiceProvider serviceProvider,
                                       ICliActionExecutor actionExecutor)
        {
            _actionRouter    = Ensure.NotNull(actionRouter, nameof(actionRouter));
            _routesBuilder   = Ensure.NotNull(routesBuilder, nameof(routesBuilder));
            _serviceProvider = Ensure.NotNull(serviceProvider, nameof(serviceProvider));
            _actionExecutor  = Ensure.NotNull(actionExecutor, nameof(actionExecutor));

            _middlewareRegistrations = new List <MiddlewareRegistration>();
        }