Ejemplo n.º 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            AppDomain.CurrentDomain.UnhandledException += onAppDomainUnhandledException;

            base.OnStartup(e);

            m_connectionString = ConfigurationManager.ConnectionStrings["default"].ConnectionString;

            var window = new MainWindow();
            var mainViewModel = new MainViewModel();
            ILogger logger = mainViewModel;
            var repository = new Repository(m_connectionString, logger );
            var vmRuelect = new RuelectViewModel(logger)
                                {
                                    Repository = repository,
                                    Downloader = new FileDownloader()
                                };
            var vmKartaitogov = new KartaitogovViewModel(logger)
                                    {
                                        Repository = repository,
                                        Downloader = new FileDownloader()
                                    };
            var vmAnalyze = new AnalyzeViewModel(logger)
                                {
                                    Repository = repository
                                };
            window.DataContext = mainViewModel;
            ((TabItem)window.tabs.Items[0]).DataContext = vmRuelect;
            ((TabItem)window.tabs.Items[1]).DataContext = vmKartaitogov;
            ((TabItem)window.tabs.Items[2]).DataContext = vmAnalyze;

            TaskScheduler.UnobservedTaskException += (s, ea) =>
                                                     	{
                                                            logger.LogError("UnobservedTaskException: " + ea.Exception.GetBaseException().ToString());
                                                            // prevent app crashing:
                                                            ea.SetObserved();
                                                     	};

            Application.Current.MainWindow = window;
            runInitialChecks(logger);
            window.Show();
        }
Ejemplo n.º 2
0
 RuelectViewModel createViewModel()
 {
     var logger = new Logger();
     var repo = new Repository(m_connectionString, logger);
     repo.Downloader = new MockDownloader(new byte[10]);
     var viewModel = new RuelectViewModel(logger);
     viewModel.Repository = repo;
     return viewModel;
 }