Referenzen entfernt
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using SewerStammGen.EntityFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -14,38 +13,6 @@ namespace SewerStammGen.HostBuilders
|
||||
{
|
||||
static class AddDBContextHostBuilderExtensions
|
||||
{
|
||||
public static IHostBuilder AddDBContext(this IHostBuilder hostBuilder)
|
||||
{
|
||||
hostBuilder.ConfigureServices((context, services) =>
|
||||
{
|
||||
string? connectionString = "";
|
||||
Action<DbContextOptionsBuilder>? configureDbContext = null;
|
||||
string? databaseToUse = context.Configuration.GetConnectionString("databaseToUse");
|
||||
if (databaseToUse != null)
|
||||
{
|
||||
|
||||
if (databaseToUse.Equals("default"))
|
||||
{
|
||||
connectionString = context.Configuration.GetConnectionString("default");
|
||||
configureDbContext = o =>
|
||||
{
|
||||
o.EnableSensitiveDataLogging();
|
||||
o.UseNpgsql(connectionString);
|
||||
};
|
||||
}
|
||||
else if (databaseToUse.Equals("sqlite"))
|
||||
{
|
||||
connectionString = context.Configuration.GetConnectionString("sqlite");
|
||||
configureDbContext = o => o.UseSqlite(connectionString);
|
||||
}
|
||||
services.AddDbContext<SewerStammGenDbContext>(configureDbContext);
|
||||
services.AddSingleton<SewerStammGenDbContextFactory>(new SewerStammGenDbContextFactory(configureDbContext));
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
return hostBuilder;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using SewerStammGen.EntityFramework.Services;
|
||||
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Services;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
@@ -25,11 +25,12 @@ namespace SewerStammGen.HostBuilders
|
||||
{
|
||||
services.AddSingleton<IMainWindowNavigator, MainWindowNavigator>();
|
||||
services.AddSingleton<ViewModelDelegateRenavigator<ProjektEditViewModel>>();
|
||||
services.AddSingleton<IDataService<Projekt>, GenericDataService<Projekt>>();
|
||||
/* services.AddSingleton<IDataService<Projekt>, GenericDataService<Projekt>>();
|
||||
services.AddSingleton<IDataService<Schacht>, GenericDataService<Schacht>>();
|
||||
services.AddSingleton<IDataService<Kanal>, GenericDataService<Kanal>>();
|
||||
services.AddSingleton<ISchachtDataService, SchachtDataService>();
|
||||
services.AddSingleton<IHaltungDataService, HaltungDataService>();
|
||||
*/
|
||||
services.AddSingleton<ISchachtService, SchachtService>();
|
||||
});
|
||||
return host;
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace SewerStammGen.HostBuilders
|
||||
services.AddSingleton<CreateViewModel<HaltungListViewModel>>(services =>
|
||||
{
|
||||
return () => new HaltungListViewModel(
|
||||
services.GetRequiredService<IHaltungDataService>(),
|
||||
|
||||
services.GetRequiredService<IActualState>(),
|
||||
services.GetRequiredService<ViewModelDelegateRenavigator<HaltungEditViewModel>>()
|
||||
);
|
||||
@@ -75,7 +75,7 @@ namespace SewerStammGen.HostBuilders
|
||||
services.AddTransient<CreateViewModel<HaltungEditViewModel>>(services =>
|
||||
{
|
||||
return () => new HaltungEditViewModel(
|
||||
services.GetRequiredService<IHaltungDataService>(),
|
||||
|
||||
services.GetRequiredService<ISchachtService>(),
|
||||
services.GetRequiredService<IActualState>()
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user