Beispiel #1
0
        public ConfigCollection LoadOnInit()
        {
            var configs = new ConfigCollection();

            InitializeCollection(configs);
            return(configs);
        }
Beispiel #2
0
 public ConfigRepository(IConfigLoader configLoader, string systemConfigKey, string appConfigKey)
 {
     this.configLoader    = configLoader;
     configurations       = configLoader.LoadOnInit();
     this.systemConfigKey = systemConfigKey;
     this.appConfigKey    = appConfigKey;
 }
Beispiel #3
0
 public void InitializeCollection(ConfigCollection configs)
 {
     foreach (var loader in this)
     {
         loader.InitializeCollection(configs);
     }
 }
Beispiel #4
0
 public void InitializeCollection(ConfigCollection configs)
 {
     if (LoadAllFilesOnInit)
     {
         LoadConfigsIntoCollection("*", configs);
     }
 }
Beispiel #5
0
 private void LoadConfigsIntoCollection(string pattern, ConfigCollection configs)
 {
     try {
         LoadConfigsIntoCollectionFromFiles(pattern, configs);
     }catch (Exception ex) {
         throw new ConfiguratorException(string.Format("Error while loading XML configuration for the config with pattern '{0}'", pattern), ex);
     }
 }
Beispiel #6
0
        public IConfig Load(string configKey)
        {
            var configs = new ConfigCollection();

            LoadConfigsIntoCollection(configKey, configs);
            if (configs.Contains(configKey))
            {
                return(configs[configKey]);
            }
            return(null);
        }
Beispiel #7
0
 private void LoadConfigsIntoCollectionFromFiles(string pattern, ConfigCollection configs)
 {
     if (pattern.IndexOfAny(IllegalPathCharacters) < 0)
     {
         var files = GetFiles(pattern);
         foreach (var file in files)
         {
             var configFromFile = FileConfigFactory.Create(file, AddFileWatchers);
             if (!configs.Contains(configFromFile.ConfigKey))
             {
                 configs.Add(configFromFile);
             }
         }
     }
 }