using System; using System.Collections.Generic; using System.Threading; using CommandLine; namespace ET.Server { internal static class Init { private static int Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += (sender, e) => { Log.Error(e.ExceptionObject.ToString()); }; try { // 异步方法全部会回掉到主线程 Game.AddSingleton(); // 命令行参数 Parser.Default.ParseArguments(args) .WithNotParsed(error => throw new Exception($"命令行格式错误! {error}")) .WithParsed(Game.AddSingleton); Game.AddSingleton(); Game.AddSingleton().ILog = new NLogger(Options.Instance.AppType.ToString(), Options.Instance.Process, "../Config/NLog/NLog.config"); Game.AddSingleton(); Game.AddSingleton(); Game.AddSingleton(); Game.AddSingleton(); ETTask.ExceptionHandler += Log.Error; Dictionary types = AssemblyHelper.GetAssemblyTypes(typeof (Game).Assembly); EventSystem.Instance.Add(types); MongoHelper.Init(); ProtobufHelper.Init(); Log.Info($"server start........................ {Root.Instance.Scene.Id}"); switch (Options.Instance.AppType) { case AppType.ExcelExporter: { Options.Instance.Console = 1; ExcelExporter.Export(); return 0; } case AppType.Proto2CS: { Options.Instance.Console = 1; Proto2CS.Export(); return 0; } } } catch (Exception e) { Log.Console(e.ToString()); } return 1; } } }