using System.Runtime.CompilerServices;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using YMhut.Box.WinUI.Services;

namespace YMhut.Box.WinUI;

public static class Program
{
    [STAThread]
    public static void Main(string[] args)
    {
        if (!LanguagePackService.EnsureLanguagePacksExtracted())
        {
            Environment.Exit(2);
            return;
        }

        RunWinUiApp();
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    private static void RunWinUiApp()
    {
        WinRT.ComWrappersSupport.InitializeComWrappers();
        Application.Start(_ =>
        {
            var context = new DispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread());
            SynchronizationContext.SetSynchronizationContext(context);
            new App();
        });
    }
}
