public void ConfigureServices(IServiceCollection services) { var autoReloaderService = services.FirstOrDefault(m => m.ServiceType == typeof(AutoReloader)); _reloader = autoReloaderService?.ImplementationInstance as AutoReloader; var dashboardService = services.FirstOrDefault(m => m.ServiceType == typeof(IDashboardService)).ImplementationInstance as IDashboardService; ConfigureServiceActions.ForEach(x => x(services)); services.AddResponseCompression(); services.AddSignalR(hubOptions => { hubOptions.EnableDetailedErrors = true; }).AddJsonProtocol(x => { x.PayloadSerializerSettings.ContractResolver = new CustomContractResolver(); }); services.AddTransient <StateRequestService>(); services.AddSingleton <IHostedService, ScheduledEndpointManager>(); services.AddTransient <IExecutionService, ExecutionService>(); services.AddTransient <ILanguageExecutionService, PowerShellExecutionService>(); services.AddCors(); services.AddDirectoryBrowser(); services.AddMemoryCache(); services.AddSingleton(new ConnectionManager()); var mvc = services.AddMvc().AddJsonOptions(x => { x.SerializerSettings.ContractResolver = new CustomContractResolver(); }); ConfigureMvcActions.ForEach(x => x(mvc)); if (dashboardService?.DashboardOptions?.Certificate != null || dashboardService?.DashboardOptions?.CertificateFile != null) { if (dashboardService.DashboardOptions.Port == dashboardService.DashboardOptions.HttpsPort) { Logger.Warn("Port and HTTPS port are the same. HTTPS Redirection will not work. Select two different ports."); } else { services.AddHttpsRedirection(options => { options.RedirectStatusCode = StatusCodes.Status308PermanentRedirect; options.HttpsPort = dashboardService.DashboardOptions.HttpsPort; }); } } services.AddSession(options => { options.IdleTimeout = dashboardService.Dashboard == null ? TimeSpan.FromMinutes(25) : dashboardService.Dashboard.IdleTimeout; options.Cookie.HttpOnly = true; options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest; }); var serviceDescriptor = services.FirstOrDefault(descriptor => descriptor.ServiceType.Name == "IRegistryPolicyResolver"); services.Remove(serviceDescriptor); dashboardService.ServiceProvider = services.BuildServiceProvider(); }
public ExpressApp ConfigureServices(Action <IConfiguration> configureServiceAction) { ConfigureServiceActions.Add(configureServiceAction); return(this); }