using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using StammGenerator.HostBuilders;
using StammGenerator.ViewModel;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace StammGenerator
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private readonly IHost _host;
        public App()
        {
            _host = CreateHostBuilder().Build();
        }

        static IHostBuilder CreateHostBuilder(string[]? args = null)
        {
            return Host.CreateDefaultBuilder(args)
                .AddConfiguration()
                .AddServices()
                .AddViewModels()
                .AddStores();
        }

        protected override void OnStartup(StartupEventArgs e)
        {
            _host.Start();



            MainWindow? window = new MainWindow() { DataContext = _host.Services.GetRequiredService<MainWindowViewModel>() };
            window.Show();

            base.OnStartup(e);
        }
    }
}
