public void ConfigureServices(IServiceCollection services) { // Db string connectionString = Configuration.GetConnectionString("Development"); AirMonitorDbContext db = InstallationPersistenceDiFactory.CreateDbContext(connectionString); IInstallationRepository installationRepository = InstallationPersistenceDiFactory.CreateInstallationRepository(db); IMeasurementRepository measurementRepository = InstallationPersistenceDiFactory.CreateMeasurementRepository(db); services.AddSingleton <IInstallationRepository>(installationRepository); services.AddSingleton <IMeasurementRepository>(measurementRepository); // Client ClientConfig clientConfig = new ClientConfig(); Configuration.Bind("ClientConfig", clientConfig); IAirlyClient client = AirlyClientFactory.Create(clientConfig); services.AddSingleton <IAirlyClient>(client); services.AddSingleton <AirlyClientWrapper>(); services.AddSingleton <IInstallationClient>(x => x.GetRequiredService <AirlyClientWrapper>()); services.AddSingleton <IMeasurementClient>(x => x.GetRequiredService <AirlyClientWrapper>()); // Service services.AddSingleton <IInstallationFacade, InstallationService>(); services.AddSingleton <IMeasurementFacade, MeasurementService>(); // services.AddSingleton<IIntegrationFacade, _Obsolete_IntegrationService>(); services.AddSingleton <IIntegrationFacade, AirlyIntegrationService>(); services.AddControllersWithViews(); }
private static IAirlyClient CreateAirlyClient(IAppProfile appProfile) => AirlyClientFactory.CreateClient(appProfile.ClientConfiguration.AirlyClientConfiguration);