public void Merge_ThrowsWhenChangesArePrevented() { var settings = new SettingsHolder(); var mergeFrom = new SettingsHolder(); settings.PreventChanges(); Assert.Throws<ConfigurationErrorsException>(() => settings.Merge(mergeFrom)); }
/// <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()); }