您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

43 行
1.7 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Xml.Linq;
  6. using System.Threading.Tasks;
  7. using System.IO;
  8. namespace importer
  9. {
  10. public class XMLData
  11. {
  12. private static Dictionary<string, string> _cclookup;
  13. public static Dictionary<string, string> CCLookup { get { return _cclookup; } set { _cclookup = value; } }
  14. private static Dictionary<string, int> _intervalLookup;
  15. public static Dictionary<string, int> IntervalLookup { get { return _intervalLookup; } set { _intervalLookup = value; } }
  16. public static void BuildIntervalLookup()
  17. {
  18. string dir = Global.StorageDir;
  19. _intervalLookup = new Dictionary<string, int>();
  20. string intervalLookupPath = Path.Combine(dir, "IntervalData.xml");
  21. var doc = XDocument.Load(intervalLookupPath);
  22. var rootNodes = doc.Root.DescendantNodes().OfType<XElement>();
  23. Dictionary<string, string> dic = rootNodes.ToDictionary(n => n.Name.ToString(), n => n.Value);
  24. foreach (KeyValuePair<string, string> kvp in dic)
  25. {
  26. _intervalLookup.Add(kvp.Key.Replace("ZZ", ""), int.Parse(kvp.Value));
  27. }
  28. }
  29. public static void BuildCCLookup(string os)
  30. {
  31. string dir = Global.StorageDir;
  32. string ccLookupPath = Path.Combine(dir, "CCAddresses.xml");
  33. _cclookup = new Dictionary<string, string>();
  34. var doc = XDocument.Load(ccLookupPath);
  35. var rootNodes = doc.Root.DescendantNodes().OfType<XElement>();
  36. _cclookup = rootNodes.ToDictionary(n => n.Name.ToString(), n => n.Value);
  37. }
  38. }
  39. }