public void ConfigureServices(IServiceCollection services) { var postgresSection = Configuration.GetSection("Postgres"); postgresSettings = postgresSection.Get <PostgresSettings>(); var routesSection = Configuration.GetSection("Routes"); routesSettings = routesSection.Get <RoutesSettings>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddScoped <IResultRepository, ResultRepository>(); if (postgresSettings != null && postgresSettings.ConnectionString != null) { services.AddSingleton(postgresSettings); } if (routesSettings != null && routesSettings.GetDataAddress != null) { services.AddSingleton(routesSettings); } }
public DataController(IResultRepository repository, RoutesSettings routesSettings) { this.repository = repository; this.routesSettings = routesSettings; }