예제 #1
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            try
            {
                ResourceLocator.RegisterDependencies(AdapterDelegate);
            }
            catch (Exception)
            {
                await new MessageBoxProvider().ShowMessageBoxOk("Unable to find one or more plugins, terminating.",
                                                                "Error");
                Current.Shutdown();
            }

            try
            {
                _configuration =
                    JsonConvert.DeserializeObject <AppConfiguration>(File.ReadAllText(@"configuration.json"));
            }
            catch (Exception ex)
            {
                _configuration = new AppConfiguration
                {
                    LogErrors  = true,
                    LogWarning = true,
                    LogInfo    = false,
                };
                ResourceLocator.Logger.Log($"Unable to find configuration file, using default one.\n{ex}", LogSeverity.Warning);
            }


            base.OnStartup(e);
        }
예제 #2
0
        static async Task Main(string[] args)
        {
            ResourceLocator.RegisterDependencies(AdapterDelegate);
            _viewModel = ResourceLocator.BrowserViewModel;

            //System.Console.WriteLine("Input assembly path you'd like to load:");
            //var path = System.Console.ReadLine();

            _viewModel.PropertyChanged += ViewModelOnPropertyChanged;
            _viewModel.LoadTestAssemblyCommand.Execute(null);

            while (true)
            {
                var resp = System.Console.ReadLine();
                if (resp == "back")
                {
                    if (_backStack.Any())
                    {
                        _viewModel.TreeViewItemSelectedCommand.Execute(_backStack.Pop());
                    }
                    else
                    {
                        WriteNodes(_viewModel.Items);
                    }
                }
                else if (resp == "quit")
                {
                    return;
                }
                else if (int.TryParse(resp, out int number))
                {
                    try
                    {
                        NodeViewModelBase node;
                        if (_backStack.Any())
                        {
                            node = _viewModel.NodeViewModelBase.Children.ElementAt(number);
                        }
                        else
                        {
                            node = _viewModel.Items[number];
                        }

                        if (_viewModel.NodeViewModelBase != null)
                        {
                            _backStack.Push(_viewModel.NodeViewModelBase);
                        }

                        _viewModel.TreeViewItemSelectedCommand.Execute(node);
                    }
                    catch
                    {
                        System.Console.WriteLine("There's no index at such index.");
                    }
                }
            }
        }