protected override async void OnStartup(StartupEventArgs e) { base.OnStartup(e); await DbInitialise.Initialise(); _container.RegisterType <IServiceRepository, ServiceRepository>(new ContainerControlledLifetimeManager()); _container.RegisterType <IWatchedServiceRepository, WatchedServiceRepository>(new ContainerControlledLifetimeManager()); _container.RegisterType <IDescriptionService, DescriptionService>(new TransientLifetimeManager()); _container.RegisterType <IStatusService, StatusService>(new TransientLifetimeManager()); UnityBootstrapper.Register(_container); var window = _container.Resolve <MainWindow>(); _trayIcon = Icon.Create(window); }
public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <UserDbContext>(); DbInitialise.Initialise(context); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the database."); } } host.Run(); }