using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; using System.IO; namespace PWAPPv2.Source.Config { public class Configuration { private Dictionary values; public Configuration(string file) { values = new Dictionary(); if(!File.Exists(file)) { throw new ConfigFileNotFoundException(); } string f = File.ReadAllText(file); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(f); XmlNodeList xmlNodeList = xmlDoc.DocumentElement.ChildNodes; foreach (XmlNode xmlNode in xmlNodeList) { values.Add(xmlNode.Name, xmlNode.InnerText); } } public string Get(string key) { try { return values[key]; } catch { throw new ConfigValueNotFoundException(); } } } public class ConfigFileNotFoundException : Exception { } public class ConfigValueNotFoundException: Exception { } }