using System.Reflection;

namespace xCoreSDK_CSharp
{
    internal static class Program
    {
        static Program()
        {
            AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
        }

        private static Assembly? OnResolveAssembly(object? sender, ResolveEventArgs args)
        {
            var requestedName = new AssemblyName(args.Name);
            if (!string.Equals(requestedName.Name, "xCoreSDK_cli", StringComparison.OrdinalIgnoreCase))
            {
                return null;
            }

            var path = Path.Combine(AppContext.BaseDirectory, "xCoreSDK_cli.dll");
            return File.Exists(path) ? Assembly.LoadFrom(path) : null;
        }

        /// <summary>
        ///  The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            // To customize application configuration such as set high DPI settings or default font,
            // see https://aka.ms/applicationconfiguration.
            ApplicationConfiguration.Initialize();
            Application.Run(new DemoForm());
        }
    }
}
