public static Bootstrapper CreateBootstrapper() { try { var bootstrapper = new Bootstrapper(); Logger.Info("Creating startup configuration"); var result = bootstrapper.RunStartupConfiguration(); Logger.Info("Startup configuration finished"); return result; } catch (FluentConfigurationException exception) { Logger.Fatal("Fatal error: Database configuration mismatch", exception); throw; } catch (Exception exception) { Logger.Fatal("Fatal error: unable to initialize environment", exception); throw; } catch { Logger.Fatal("Fatal error: does not know whats going on"); throw; } }
static bool ResolveExecutor(Bootstrapper container) { _recipeExecutor = container.Container.Resolve<IRecipeExecutor>(); if (_recipeExecutor == null) { System.Console.WriteLine("Fatal error, could not find valid recipe executor. Aborting."); return false; } return true; }
/* static string MatrixPath { get { return IcsEditor.Properties.Settings.Default.MatrixPath; } } static IRepository<SalesItem> _salesItemRepository; public static IRepository<SalesItem> SalesItemRepository { get { if (_salesItemRepository == null) { var repository = new RepositoryMatrix<SalesItem> {DataPath = MatrixPath}; _salesItemRepository = repository; } return _salesItemRepository; // ?? (_salesItemRepository = Container.Resolve<IRepository<SalesItem>>()); } } */ /* static void SettingChanging(object sender, SettingChangingEventArgs settingChangingEventArgs) { if (settingChangingEventArgs.SettingName != "MatrixPath") return; var salesItems = _salesItemRepository as RepositoryMatrix<SalesItem>; if (salesItems == null) return; if (settingChangingEventArgs.NewValue.ToString() != salesItems.DataPath) salesItems.Clear(); } */ protected override void OnStartup(StartupEventArgs e) { // Zum Debuggen und Profilen der Sql-Statements: (Reference nicht vergessen) // HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize(); // Zum Debuggen von Datenbindungsfehlern //PresentationTraceSources.DataBindingSource.Listeners.Add(new ConsoleTraceListener()); //PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Critical | SourceLevels.Error | SourceLevels.Warning; // | SourceLevels.All; FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(System.Windows.Markup.XmlLanguage.GetLanguage(System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag))); base.OnStartup(e); var splashscreen = new SplashScreen(@"Resources\Splashscreen.png"); splashscreen.Show(true); var window = new MainWindow(); try { Bootstrapper = Bootstrapper.CreateBootstrapper(); } catch (FluentConfigurationException) { splashscreen.Close(new TimeSpan()); MessageBox.Show("Fatal error: Database configuration mismatch.", "Configuration error", MessageBoxButton.OK); Shutdown(-1); return; } catch(Exception exception) { splashscreen.Close(new TimeSpan()); MessageBox.Show(String.Format("Fatal error: unable to initialize environment.\n{0}", exception.Message) , "Configuration error", MessageBoxButton.OK); Shutdown(-2); return; } // IcsEditor.Properties.Settings.Default.SettingChanging += SettingChanging; // Create the ViewModel to which the main window binds. var viewModel = Bootstrapper.Container.Resolve<MainWindowViewModel>(); // When the ViewModel asks to be closed, // close the window. EventHandler handler = null; handler = delegate { viewModel.RequestClose -= handler; window.Close(); }; viewModel.RequestClose += handler; // Allow all controls in the window to // bind to the ViewModel by setting the // DataContext, which propagates down // the element tree. window.DataContext = viewModel; window.Show(); if (!EditSettings.ValidateMatrixPath(ConfigurationManager.AppSettings["MatrixPath"])) MessageBox.Show("Warning: path to matrix data is not valid! Please check your application settings.", "Configuration error", MessageBoxButton.OK); }