namespace MinicsConsole; internal class Program { private readonly static ILog _expLog = new Logger.Logger(); public static WebApplication? WebApplication { get; private set; } static void Main(string[] args) { Mutex mutex = new(true, "7E862400-8020-BE75-5266-B2C4BEB54076", out bool flag); if (!flag) return; _expLog.Initialize("Exceptions"); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; if (!BaseConfigFileLoader.Load(out BasicInfo? basicInfo) || basicInfo is null) { MessageBox.Show("BaseInfo.xml Load Failed"); return; } WebApplicationBuilder builder = WebApplication.CreateBuilder(args); builder.Services.AddSignalR( options => { options.EnableDetailedErrors = true; options.MaximumReceiveMessageSize = 262144;//256k //options.ClientTimeoutInterval = TimeSpan.FromSeconds(5); //options.KeepAliveInterval = TimeSpan.FromSeconds(10); //options.MaximumParallelInvocationsPerClient = 5; }); //Host Service builder.Services.AddHostedService(); //Connections builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); //Configs builder.Services.AddSingleton(basicInfo); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); //Function Helpers builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); //DataBase builder.Services.AddSingleton(); //Businesses builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); WebApplication = builder.Build(); WebApplication.MapHub("/UIHub"); WebApplication.MapHub("/LogHub"); WebApplication.RunAsync($"http://{basicInfo.ServerAddress}:{basicInfo.ServerPort}").Wait(); } private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { string s = e.ExceptionObject!.ToString()!; MessageBox.Show(s); _expLog.Fatal(s); } private static void TaskScheduler_UnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e) { //_expLog.Fatal(e.Exception!.ToString()!); } }