BudgetAnalyser.CompositionRoot.Compose C# (CSharp) Method

Compose() private method

private Compose ( ) : void
return void
        public void Compose()
        {
            var builder = new ContainerBuilder();
            var engineAssembly = typeof(StatementModel).GetTypeInfo().Assembly;
            var storageAssembly = typeof(IFileEncryptor).GetTypeInfo().Assembly;
            var thisAssembly = GetType().GetTypeInfo().Assembly;

            builder.RegisterAssemblyTypes(thisAssembly).AsSelf();

            ComposeTypesWithDefaultImplementations(storageAssembly, builder);
            ComposeTypesWithDefaultImplementations(engineAssembly, builder);
            ComposeTypesWithDefaultImplementations(thisAssembly, builder);

            // Register Messenger Singleton from MVVM Light
            builder.RegisterType<ConcurrentMessenger>().As<IMessenger>().SingleInstance().WithParameter("defaultMessenger", Messenger.Default);

            // Registrations from Rees.Wpf - There are no automatic registrations in this assembly.
            RegistrationsForReesWpf(builder);

            AllLocalNonAutomaticRegistrations(builder);

            BuildApplicationObjectGraph(builder, engineAssembly, thisAssembly, storageAssembly);
        }

Usage Example

Beispiel #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            // Ensure the current culture passed into bindings is the OS culture.
            // By default, WPF uses en-US as the culture, regardless of the system settings.
            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            DispatcherUnhandledException += OnDispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException += OnCurrentDomainUnhandledException;

            Current.Exit += OnApplicationExit;

            var compositionRoot = new CompositionRoot();
            compositionRoot.Compose(this);
            this.logger = compositionRoot.Logger;

            this.logger.LogAlways(() => "=========== Budget Analyser Starting ===========");
            this.logger.LogAlways(() => compositionRoot.ShellController.DashboardController.VersionString);
            var initialisableShell = compositionRoot.ShellController as IInitializableController;
            if (initialisableShell != null)
            {
                initialisableShell.Initialize();
            }

            compositionRoot.ShellWindow.DataContext = compositionRoot.ShellController;
            this.logger.LogInfo(() => "Initialisation finished.");
            compositionRoot.ShellWindow.Show();
        }