using Microsoft.Extensions.DependencyInjection; using Database; using System; using Commentbase; using Microsoft.VisualBasic; using static System.Windows.Forms.DataFormats; namespace View { public static class Program { private static ServiceProvider? _serviceProvider; public static ServiceProvider? ServiceProvider => _serviceProvider; [STAThread] public static void Main() { ApplicationConfiguration.Initialize(); var services = new ServiceCollection(); ConfigureServices(services); _serviceProvider = services.BuildServiceProvider(); Application.Run(_serviceProvider.GetRequiredService()); } private static bool isPostgreSQL = true; private static void ConfigureServices(ServiceCollection services) { if (isPostgreSQL) { services.AddTransient(); } else { services.AddTransient(); } services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); } public static void ChangeDB() { isPostgreSQL = !isPostgreSQL; var services = new ServiceCollection(); ConfigureServices(services); _serviceProvider = services.BuildServiceProvider(); } public static void ChangeDB(bool newIsPostrgeSQL) { if (newIsPostrgeSQL == isPostgreSQL) return; isPostgreSQL = newIsPostrgeSQL; var services = new ServiceCollection(); ConfigureServices(services); _serviceProvider = services.BuildServiceProvider(); } } }