using Gready_Poang.DataLayer.Database;
using Gready_Poang.ViewModelLayer;
using System.Diagnostics;

namespace Gready_Poang;

public partial class App : Application
{
    private readonly AppShellViewModel _shellViewModel;

    //private readonly IServiceProvider _services;

    //public App(IServiceProvider services, DataContext dataContext)
    public App(DataContext dataContext, AppShellViewModel shellViewModel)
    {
        InitializeComponent();
        dataContext.Database.EnsureCreated();
        //_services = services;

        AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
        {
            if (Debugger.IsAttached)
                Debugger.Break();
        };

        TaskScheduler.UnobservedTaskException += (sender, e) =>
        {
            if (Debugger.IsAttached)
                Debugger.Break();
        };
        _shellViewModel = shellViewModel;
    }

    protected override Window CreateWindow(IActivationState? activationState)
    {
        //var shell = _services.GetRequiredService<AppShell>();
        //return new Window(shell);
        return new Window(new AppShell(_shellViewModel));
    }
}