using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using System.Threading.Tasks; using System.IO; namespace importer { public class XMLData { private static Dictionary _cclookup; public static Dictionary CCLookup { get { return _cclookup; } set { _cclookup = value; } } private static Dictionary _intervalLookup; public static Dictionary IntervalLookup { get { return _intervalLookup; } set { _intervalLookup = value; } } public static void BuildIntervalLookup() { string dir = Global.StorageDir; _intervalLookup = new Dictionary(); string intervalLookupPath = Path.Combine(dir, "IntervalData.xml"); var doc = XDocument.Load(intervalLookupPath); var rootNodes = doc.Root.DescendantNodes().OfType(); Dictionary dic = rootNodes.ToDictionary(n => n.Name.ToString(), n => n.Value); foreach (KeyValuePair kvp in dic) { _intervalLookup.Add(kvp.Key.Replace("ZZ", ""), int.Parse(kvp.Value)); } } public static void BuildCCLookup(string os) { string dir = Global.StorageDir; string ccLookupPath = Path.Combine(dir, "CCAddresses.xml"); _cclookup = new Dictionary(); var doc = XDocument.Load(ccLookupPath); var rootNodes = doc.Root.DescendantNodes().OfType(); _cclookup = rootNodes.ToDictionary(n => n.Name.ToString(), n => n.Value); } } }