protected override void Arrange()
        {
            base.Arrange();

            File.Delete(MainConfigurationFile);
            File.Delete(SatelliteConfigurationSourcePath);

            var builder = new ConfigurationSourceBuilder();

            var configurationSettings = new ConfigurationSourceSection();

            configurationSettings.SelectedSource = "System Configuration";
            configurationSettings.Sources.Add(new FileConfigurationSourceElement(SatelliteSourceName, SatelliteConfigurationSourcePath));
            configurationSettings.Sources.Add(new SystemConfigurationSourceElement("System Configuration"));
            builder.AddSection(ConfigurationSourceSection.SectionName, configurationSettings);

            builder.ConfigureExceptionHandling()
            .GivenPolicyWithName("policy")
            .ForExceptionType <Exception>();

            var source = new DesignDictionaryConfigurationSource();

            builder.UpdateConfigurationWithReplace(source);

            ConfigurationSource = Container.Resolve <ConfigurationSourceModel>();
            ConfigurationSource.Load(source);
        }
        protected override void Arrange()
        {
            base.Arrange();

            File.Delete(MainConfigurationFile);
            File.Delete(SatelliteConfigurationSourcePath);

            var builder = new ConfigurationSourceBuilder();

            var configurationSettings = new ConfigurationSourceSection();

            configurationSettings.SelectedSource = "System Configuration";
            configurationSettings.Sources.Add(new FileConfigurationSourceElement(SatelliteSourceName, SatelliteConfigurationSourcePath));
            configurationSettings.Sources.Add(new SystemConfigurationSourceElement("System Configuration"));
            builder.AddSection(ConfigurationSourceSection.SectionName, configurationSettings);

            builder.ConfigureCaching()
            .ForCacheManagerNamed("TestCacheManager")
            .StoreInMemory();

            var source = new DesignDictionaryConfigurationSource();

            builder.UpdateConfigurationWithReplace(source);

            ConfigurationSource = Container.Resolve <ConfigurationSourceModel>();
            ConfigurationSource.Load(source);
        }
Пример #3
0
 /// <summary>
 /// Tries to load a configuration from XML. If none or corrupt XML found, a default
 /// Configuration is loaded.
 /// </summary>
 /// <param name="errorDelegation">Delegation called when no or corrupt XML is found.</param>
 public Configuration(ErrorDelegation errorDelegation)
 {
     this.errorDelegation = errorDelegation;
     try
     {
         Configuration loadedConfiguration = ConfigurationSource.Load();
         this.Recipients = loadedConfiguration.Recipients;
         this.Background = loadedConfiguration.Background;
         this.Database   = loadedConfiguration.Database;
         this.Password   = loadedConfiguration.Password;
         this.Server     = loadedConfiguration.Server;
         this.Table      = loadedConfiguration.Table;
         this.Color      = loadedConfiguration.Color;
         this.User       = loadedConfiguration.User;
         this.Font       = loadedConfiguration.Font;
         this.Logo       = loadedConfiguration.Logo;
         this.Row        = loadedConfiguration.Row;
     }
     catch
     {
         errorDelegation(ERROR_LOADING_CONFIGURATION);
         new Configuration();
     }
 }