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 MeasurementDao(AirMonitorDbContext db) { this._db = db; }
public static MeasurementDao Create(AirMonitorDbContext db) => new MeasurementDao(db ?? throw new AggregateException("DatabaseContext is null"));
public static InstallationDao Create(AirMonitorDbContext db) => new InstallationDao(db ?? throw new AggregateException("DatabaseContext is null"));
private InstallationDao(AirMonitorDbContext db) { this._db = db; }