Beispiel #1
0
        /// <summary>
        /// Provides an instance to a startable bus.
        /// </summary>
        public IStartableBus CreateBus()
        {
            Initialize();

            if (!Configurer.HasComponent <IStartableBus>())
            {
                Instance.UnicastBus();
            }

            return(Builder.Build <IStartableBus>());
        }
Beispiel #2
0
        /// <summary>
        /// Finalizes the configuration by invoking all initialisers.
        /// </summary>
        public void Initialize()
        {
            if (initialized)
            {
                return;
            }

            ForAllTypes <IWantToRunWhenConfigurationIsComplete>(t => Configurer.ConfigureComponent(t, DependencyLifecycle.InstancePerCall));

            ForAllTypes <IWantToRunWhenBusStartsAndStops>(t => Configurer.ConfigureComponent(t, DependencyLifecycle.InstancePerCall));

            InvokeBeforeConfigurationInitializers();

            ActivateAndInvoke <Config.INeedInitialization>(t => t.Init());

            ActivateAndInvoke <INeedInitialization>(t => t.Init());

            ActivateAndInvoke <IWantToRunBeforeConfigurationIsFinalized>(t => t.Run());

            ForAllTypes <INeedToInstallSomething <Windows> >(t => Instance.Configurer.ConfigureComponent(t, DependencyLifecycle.InstancePerCall));

            //lockdown the settings
            SettingsHolder.PreventChanges();

            ActivateAndInvoke <IFinalizeConfiguration>(t => t.FinalizeConfiguration());

            initialized = true;

            if (ConfigurationComplete != null)
            {
                ConfigurationComplete();
            }

            Builder.BuildAll <IWantToRunWhenConfigurationIsComplete>()
            .ToList()
            .ForEach(o => o.Run());
        }