예제 #1
0
파일: App.xaml.cs 프로젝트: ycdivfx/nyx
        public async void InitCore()
        {
            var splash = new Splash();

            splash.Show();

            var pluginDir = Path.Combine(Assembly.GetExecutingAssembly().AssemblyDirectory(), "plugins");

            NyxBoot.With()
            .NyxBorg()
            .AndPlugins(pluginDir)
            .Start(RxAppAutofacExtension.UseAutofacDependencyResolver);

            IConfigManager config;

            try
            {
                config = NyxBoot.Container.Resolve <IConfigManager>();
                config.Setup(Path.Combine(GetType().Assembly.AssemblyDirectory(), "nyx.cfg"));
                _borg = NyxBoot.Container.Resolve <INyxBorg>();
                NyxBoot.Container.Resolve <ILogger <App> >();
                _borg.HostApp = "enslaver";
            }
            catch (Exception ex)
            {
                MessageBox.Show("[Nyx] Error building container ...\n" + ex);
                Shutdown();
                return;
            }
            var shellViewModel = NyxBoot.Container.Resolve <IShellViewModel>();

            MainWindow = new MainWindow {
                Content = new ShellView(shellViewModel)
            };
            await Task.Delay(TimeSpan.FromSeconds(1.5));

            splash.Close();
            MainWindow.Show();

            // Sets the default hub.
            string hubAddress;
            string hubPort;

            if (_commandLineArgs.TryGetValue("c", out hubAddress))
            {
                config.Set("borg", "hubIp", hubAddress);
            }
            if (_commandLineArgs.TryGetValue("p", out hubPort))
            {
                int port;
                if (int.TryParse(hubPort, out port))
                {
                    config.Set("hub", "port", port);
                }
            }
            await _borg.Start();
        }
예제 #2
0
        private static IContainer BuildContainer()
        {
            var pluginDir = Path.Combine(Assembly.GetExecutingAssembly().AssemblyDirectory(), "plugins");

            NyxBoot.With()
            .NyxHub()
            .AndPlugins(pluginDir)
            .Start();

            return(NyxBoot.Container);
        }