private DIContext(DIContext parent) { _parent = parent; _childs = new List <IDIContext>(); }
internal override void ApplicationStartupProcess(CancellationToken token) { _activeApplicationModules = new List <IApplicationModule>(); _applicationDIContext = new DIContext(); _uiManager = new UIManager(GobchatApplicationContext.UISynchronizer); //_applicationDIContext.Register<string>((c, _) => GobchatApplicationContext.ResourceLocation, nameof(ResourceLocation)); //_applicationDIContext.Register<string>((c, _) => GobchatApplicationContext.UserConfigLocation, nameof(UserConfigLocation)); //_applicationDIContext.Register<string>((c, _) => GobchatApplicationContext.ApplicationLocation, nameof(ApplicationLocation)); //_applicationDIContext.Register<GobVersion>((c, _) => GobchatApplicationContext.ApplicationVersion, nameof(ApplicationVersion)); _applicationDIContext.Register <IUISynchronizer>((c, _) => GobchatApplicationContext.UISynchronizer); _applicationDIContext.Register <IUIManager>((c, _) => _uiManager); var moduleActivationSequence = new List <IApplicationModule>() { //config new global::Gobchat.Module.Config.AppModuleConfig(), new global::Gobchat.Module.Language.AppModuleLanguage(), //updater and downloadable dependencies new global::Gobchat.Module.Updater.AppModuleUpdater(), new global::Gobchat.Module.Cef.AppModuleCefDependencyChecker(), new global::Gobchat.Module.Cef.AppModuleCefInstaller(), //base managers new global::Gobchat.Module.NotifyIcon.AppModuleNotifyIcon(), new global::Gobchat.Module.Hotkey.AppModuleHotkeyManager(), new global::Gobchat.Module.MemoryReader.AppModuleMemoryReader(), new global::Gobchat.Module.Actor.AppModuleActorManager(), new global::Gobchat.Module.Chat.AppModuleChatManager(), // CEF overlay and javascript api new global::Gobchat.Module.Cef.AppModuleCefManager(), new global::Gobchat.Module.Overlay.AppModuleChatOverlay(), new global::Gobchat.Module.UI.AppModuleBrowserAPIManager(), // Misc new global::Gobchat.Module.Misc.AppModuleShowConnectionOnTrayIcon(), new global::Gobchat.Module.Misc.AppModuleHideOnMinimize(), new global::Gobchat.Module.Misc.Chatlogger.AppModuleChatLogger(), new global::Gobchat.Module.Misc.AppModuleInformUserAboutMemoryState(), new global::Gobchat.Module.Misc.AppModuleShowHideHotkey(), //UI Adapter new global::Gobchat.Module.UI.AppModuleChatToUI(), new global::Gobchat.Module.UI.AppModuleConfigToUI(), new global::Gobchat.Module.UI.AppModuleActorToUI(), new global::Gobchat.Module.UI.AppModuleMemoryToUI(), //Start UI new global::Gobchat.Module.UI.AppModuleLoadUI(), }; logger.Info(() => $"Initialize Gobchat v{GobchatContext.ApplicationVersion} on {(Environment.Is64BitProcess ? "x64" : "x86")}"); var startupHandler = new ApplicationStartupHandler(); foreach (var module in moduleActivationSequence) { try { _activeApplicationModules.Add(module); logger.Info($"Starting: {module}"); module.Initialize(startupHandler, _applicationDIContext); } catch (System.Exception ex1) { logger.Fatal($"Initialization error in {module}"); logger.Fatal(ex1); startupHandler.StopStartup = true; try { MessageBox.Show($"An error prevents Gobchat from starting. For more details please check gobchat_debug.log.\nError:\n{ex1.GetType()}: {ex1.Message}", "Error on start", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.Exception) { } } if (startupHandler.StopStartup) { logger.Fatal("Shutdown in initialization phase"); GobchatApplicationContext.ExitGobchat(); return; } } logger.Info("Initialization complete"); }