/// <summary>
        /// Updates the existing container with the additional UI references.
        /// </summary>
        /// <remarks>
        /// Note that this method only adds references to UI controls and UI
        /// related classes / interfaces. Additional references for the
        /// core needs to be added via a different path.
        /// </remarks>
        /// <seealso cref="UserInterfaceBootstrapper"/>
        /// <seealso cref="KernelBootstrapper"/>
        private void UpdateContainer()
        {
            var builder = new ContainerBuilder();

            {
                builder.RegisterModule(new CommonUIModule());

                // Get all the registrations from Apollo.UI.Wpf
                var commonUiAssembly = typeof(Observable).Assembly;
                builder.RegisterAssemblyTypes(commonUiAssembly)
                .Where(t => t.FullName.EndsWith("Presenter", StringComparison.Ordinal) && t.IsClass && !t.IsAbstract)
                .InstancePerDependency()
                .PropertiesAutowired();
                builder.RegisterAssemblyTypes(commonUiAssembly)
                .Where(
                    t => (t.FullName.EndsWith("View", StringComparison.Ordinal) || t.FullName.EndsWith("Window", StringComparison.Ordinal)) &&
                    t.IsClass &&
                    !t.IsAbstract)
                .InstancePerDependency()
                .AsImplementedInterfaces();
                builder.RegisterAssemblyTypes(commonUiAssembly)
                .Where(t => t.FullName.EndsWith("Command", StringComparison.Ordinal) && t.IsClass && !t.IsAbstract)
                .InstancePerDependency();
                builder.RegisterAssemblyTypes(commonUiAssembly)
                .Where(t => t.FullName.EndsWith("EventListener", StringComparison.Ordinal) && t.IsClass && !t.IsAbstract)
                .SingleInstance();

                // Get the registrations from the current assembly
                var localAssembly = GetType().Assembly;
                builder.RegisterAssemblyTypes(localAssembly)
                .Where(t => t.FullName.EndsWith("Presenter", StringComparison.Ordinal) && t.IsClass && !t.IsAbstract)
                .InstancePerDependency()
                .PropertiesAutowired();
                builder.RegisterAssemblyTypes(localAssembly)
                .Where(
                    t => (t.FullName.EndsWith("View", StringComparison.Ordinal) || t.FullName.EndsWith("Window", StringComparison.Ordinal)) &&
                    t.IsClass &&
                    !t.IsAbstract)
                .InstancePerDependency()
                .AsImplementedInterfaces();
                builder.RegisterAssemblyTypes(localAssembly)
                .Where(t => t.FullName.EndsWith("Command", StringComparison.Ordinal) && t.IsClass && !t.IsAbstract)
                .InstancePerDependency();

                builder.Register(c => new DispatcherContextWrapper(Application.Current.Dispatcher))
                .As <IContextAware>();

                var key = SrcOnlyExceptionHandlingUtilities.ReportingPublicKey();
                builder.RegisterModule(new FeedbackReportingModule(() => key));
            }

            builder.Update(m_Container);
        }
Beispiel #2
0
        /// <summary>
        /// Override to add registrations to the container.
        /// </summary>
        /// <param name="builder">The builder through which components can be registered.</param>
        /// <remarks>
        /// Note that the ContainerBuilder parameter is not the same one
        /// that the module is being registered by (i.e. it can have its own defaults).
        /// </remarks>
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            // Register the global application objects
            {
                // Utilities
                builder.Register((c, p) => new ExceptionHandler(
                                     p.TypedAs <ExceptionProcessor[]>()))
                .As <ExceptionHandler>();

                builder.Register(c => new XmlConfiguration(
                                     CommunicationConfigurationKeys.ToCollection()
                                     .Append(DiagnosticsConfigurationKeys.ToCollection())
                                     .ToList(),
                                     ExplorerConstants.ConfigurationSectionApplicationSettings))
                .As <IConfiguration>();

                builder.Register(c => new NotificationReportingHub())
                .As <ICollectNotifications>()
                .SingleInstance();

                builder.Register(c => new ProgressReportingHub())
                .As <ICollectProgressReports>()
                .SingleInstance();

                builder.Register(c => new StepBasedProgressTracker())
                .OnActivated(
                    a =>
                {
                    var hub = a.Context.Resolve <ICollectProgressReports>();
                    hub.AddReporter(a.Instance);
                })
                .As <ITrackSteppingProgress>()
                .As <ITrackProgress>();

                RSAParameters rsaParameters = SrcOnlyExceptionHandlingUtilities.ReportingPublicKey();
                builder.RegisterModule(new FeedbackReportingModule(() => rsaParameters));

                RegisterLoggers(builder);
                RegisterProfiler(builder);
                RegisterDiagnostics(builder);
                RegisterAppDomainBuilder(builder);
                RegisterTimeline(builder);
            }
        }