コード例 #1
0
        private void PreloadConfigFiles()
        {
            if (!File.Exists(PreloadFile))
                return;

            var configFile = new ConfigFile(PreloadFile);
            if (configFile.Namespaces.Count == 0)
                return;

            var filenames = configFile.Namespaces[0].GetProperty("preload").Values;

            foreach (var filename in filenames)
                Load(filename);
        }
コード例 #2
0
        /// <summary>
        ///     Loads a new configuration file.
        /// </summary>
        /// 
        /// <param name="filename">The file to load from.</param>
        /// 
        /// <exception cref="NamespaceClashException">
        ///     If a namespace clash occurs.
        /// </exception>
        /// 
        /// <exception cref="PropertyClashException">
        ///     If a property clash occurs.
        /// </exception>
        /// 
        /// <exception cref="InvalidConfigFileException">
        ///     If the configuration file is invalid.
        /// </exception>
        /// 
        /// <exception cref="UnknownFormatException">
        ///     If the format of the configuration file is unkown.
        /// </exception>
        /// 
        /// <exception cref="IOException">
        ///     If an I/O error occurs.
        /// </exception>
        /// 
        /// <exception cref="NullReferenceException">
        ///     If the filename argument is null.
        /// </exception>
        public IConfigFile Load(string filename)
        {
            if (string.IsNullOrWhiteSpace(filename))
                throw new ArgumentNullException("filename");

            if (!_configFileLookup.ContainsKey(filename))
            {
                var configFile = new ConfigFile(filename);
                _configFileLookup.Add(filename, configFile);
                InsertNewNamespaces(configFile.Namespaces);
                return configFile;
            }

            return (ConfigFile) _configFileLookup[filename];
        }