using DataModel; using DataModel.Database.Common; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Processor; namespace UI_WinForms; internal static class Program { internal const string VERSION = "v0.1.0"; internal static IServiceProvider? SERVICE_PROVIDER; [STAThread] private static void Main() { ApplicationConfiguration.Initialize(); Application.EnableVisualStyles(); // Start the loader screen: var loader = new Loader(); Application.Run(loader); // Check, if the user closes the loader screen: if (loader.DialogResult != DialogResult.OK) return; // // Create the DI system // var builder = new HostBuilder(); // // Add services // builder.ConfigureServices((hostContext, serviceCollection) => { // The database: serviceCollection.AddDatabase(loader.DataFile, true); }); // Get the host out of the DI system: var host = builder.Build(); // Create a service scope: using (var scope = host.Services.CreateScope()) { // Get a service provider: SERVICE_PROVIDER = scope.ServiceProvider; // Set the service provider to the processor: ProcessorMeta.ServiceProvider = SERVICE_PROVIDER; // Apply database migrations: using (var database = SERVICE_PROVIDER.GetRequiredService()) Setup.PerformDataMigration(database).Wait(); // Start the app: Application.Run(new Main()); } } }