/// <summary> /// Loads a file for configuration. /// </summary> /// <param name="filename">file name to load from</param> /// <param name="version">expected version (optional)</param> /// <returns>Loaded configuration instance</returns> public static dynamic Load(string filename, string version = null) { if(Instance == null) Instance = new XmlConfiguration(); //XML file, create an input stream and parse // StreamReader sr = null; try { sr = new StreamReader(filename); ParseXML(sr.BaseStream, version); } finally { if(sr != null) sr.Close(); } //set the filename _FileNames.Add(filename); return Instance; }
/// <summary> /// Reloads the configuration from the same file to /// reflect any changes that might have occurred. If the /// initial configuration was loaded from a stream this /// has no effect /// </summary> /// <returns>Reloaded configuration instance</returns> public static dynamic ReLoad() { if (_FileNames.Count > 0) { Instance = new XmlConfiguration(); foreach (string fileName in _FileNames) { Load(fileName, Version); } } return Instance; }