using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using SystemX.Net.Platform.SystemX.Net.XEFCore;
using SystemX.Net.Platform.SystemX.Net.XEFCore.DBContext.CPXV2Log;
using SystemX.Net.Platform.SystemX.Net.XEFCore.DBContext.CPXV2LogJson;

namespace SystemX.Net.MiddlewareUI
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            bool bCreateProgram = false;

            Mutex SetMutex = new Mutex(true, "SystemX.Net.Middleware.UI.Log CPXV2", out bCreateProgram);

            if (bCreateProgram)
            {
                //종속성 주입
                /*
                ServiceCollection collection = new ServiceCollection();
                collection.AddSingleton<XEFCore<CPXV2ShortTermLogJson>>();
                collection.AddSingleton<MainForm>();

                ServiceProvider provider = collection.BuildServiceProvider();
                var shortTermJson = provider.GetService<XEFCore<CPXV2ShortTermLogJson>>();
                shortTermJson.SetConnectionString("Server=127.0.0.1;Database=CPXV2ShortTermLogJson;User Id=Alis;Password=Kefico!@34;");
                

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(provider.GetService<MainForm>());
                */
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());

                SetMutex.ReleaseMutex();
            }
            else
            {
                MessageBox.Show("[SystemX.Net.Middleware.UI.Log CPXV2] Already this program excute now. Check the process.", "SystemX.Net.Middleware.UI.Log", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }
        }
    }
}