public void BootstrapRuntime() { var config = kernel.Get<IWurmAssistantConfig>(); loggingManager = new LoggingManager(Path.Combine(config.DataDirectoryFullPath, "Logs")); kernel.Bind<LoggingManager>().ToConstant(loggingManager); var loggerFactory = kernel.Get<LoggerFactory>(); coreLogger = loggerFactory.Create("Core"); coreLogger.Info("Logging system ready"); coreLogger.Info("WurmApi init"); var eventMarshaller = kernel.Get<IEventMarshaller>(); ConstructWurmApi(config, loggerFactory, eventMarshaller); coreLogger.Info("WurmApi ready"); coreLogger.Info("GUI init"); BindViewModels(); coreLogger.Info("GUI ready"); coreLogger.Info("ModuleManager init"); var moduleManager = new ModuleManager(new[] { new LogSearcher(kernel.Get<ILogSearcherModuleGui>()), }); kernel.Bind<ModuleManager>().ToConstant(moduleManager); coreLogger.Info("ModuleManager ready"); }
protected override void OnStartup(object sender, StartupEventArgs e) { // configure and bind app-specific dependencies kernel.Bind<IEnvironment>().ToConstant(environment).InSingletonScope(); windowManager = new WindowManager(); kernel.Bind<WindowManager>().ToConstant(windowManager); kernel.Bind<IWindowManager>().To<WindowManager>(); kernel.Bind<AppHostViewModel>().ToSelf().InSingletonScope(); try { sharedDataDirectory = new SharedDataDirectory(); } catch (LockFailedException) { // if cannot obtain exclusive lock on data directory, it means another instance is already running Application.Current.Shutdown(); return; } var config = new WurmAssistantConfig() {DataDirectoryFullPath = sharedDataDirectory.FullName}; kernel.Bind<IWurmAssistantConfig>().ToConstant(config); var marshaller = new WpfGuiThreadEventMarshaller(environment); kernel.Bind<IEventMarshaller, WpfGuiThreadEventMarshaller>().ToConstant(marshaller); // bind app-specific dependencies kernel.Bind<ILogSearcherModuleGui>().To<LogSearcherForm>(); // create hosting window for the app var hostView = kernel.Get<AppHostViewModel>(); windowManager.ShowWindow(hostView, null, new Dictionary<string, object>()); // initialize and resolve the app coreBootstrapper = new CoreBootstrapper(kernel); // show the application startup screen var appStartVm = coreBootstrapper.GetAppStartViewModel(); hostView.CurrentScreen = appStartVm; // initialize application coreBootstrapper.BootstrapRuntime(); globalLogger = kernel.Get<LoggerFactory>().Create(); // show the application running screen var appRunningVm = coreBootstrapper.GetAppRunningViewModel(); hostView.CurrentScreen = appRunningVm; }