/// <summary> /// Constructor. Set the path of the directory and create a provider for each /// configuration file. /// </summary> public ControllerConfigurationManager(string path) { mainPath = path; dictionary = new Dictionary<string, XmlConfigProvider>(); foreach (string file in Directory.GetFiles(mainPath, "*.xml")) { XmlConfigProvider provider = new XmlConfigProvider(file); dictionary.Add(Path.GetFileNameWithoutExtension(file), provider); } }
/// <summary> /// Create a new configuration file using the default configuration as a model. /// When we get or set a value and the corrisponding provider is not found, this /// means that it's a new controller and thus a new configuration should be created. /// </summary> private void CreateNewConfiguration(string directory, string name) { string defaultFile = Path.Combine(directory, "default_controller.xml"); string newFile = Path.Combine(directory, name + ".xml"); File.Copy(defaultFile, newFile); XmlConfigProvider provider = new XmlConfigProvider(newFile); dictionary.Add(Path.GetFileNameWithoutExtension(newFile), provider); }