internal static void Load() { try { XmlDocument Doc = new XmlDocument(); using (MemoryStream ms = new MemoryStream(Waher.Content.Resources.LoadResource( typeof(PersonalNumberSchemes).Namespace + ".PersonalNumberSchemes.xml"))) { Doc.Load(ms); } foreach (XmlNode N in Doc.DocumentElement.ChildNodes) { if (N is XmlElement E && E.LocalName == "Entry") { string Country = XML.Attribute(E, "country"); string DisplayString = XML.Attribute(E, "displayString"); string Variable = null; Expression Pattern = null; Expression Check = null; Expression Normalize = null; try { foreach (XmlNode N2 in E.ChildNodes) { if (N2 is XmlElement E2) { switch (E2.LocalName) { case "Pattern": Pattern = new Expression(E2.InnerText); Variable = XML.Attribute(E2, "variable"); break; case "Check": Check = new Expression(E2.InnerText); break; case "Normalize": Normalize = new Expression(E2.InnerText); break; } } } } catch (Exception ex) { Log.Critical(ex); continue; } if (Pattern is null || string.IsNullOrEmpty(Variable) || string.IsNullOrEmpty(DisplayString)) { continue; } if (!schemesByCode.TryGetValue(Country, out LinkedList <PersonalNumberScheme> Schemes)) { Schemes = new LinkedList <PersonalNumberScheme>(); schemesByCode[Country] = Schemes; } Schemes.AddLast(new PersonalNumberScheme(Variable, DisplayString, Pattern, Check, Normalize)); } } } catch (Exception ex) { Log.Critical(ex); } }