2using System.Collections.Generic;
16 private static readonly SortedDictionary<string, string> countryByCode =
new SortedDictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
17 private static readonly SortedDictionary<string, string> codeByCountry =
new SortedDictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
19 internal static void Load()
23 XmlDocument Doc =
new XmlDocument();
26 foreach (XmlNode N
in Doc.DocumentElement.ChildNodes)
28 if (N is XmlElement E && E.LocalName ==
"Entry")
33 if (!
string.IsNullOrEmpty(Code) && !
string.IsNullOrEmpty(Country))
35 countryByCode[Code] = Country;
36 codeByCountry[Country] = Code;
54 string[] Result =
new string[countryByCode.Count];
55 countryByCode.Keys.CopyTo(Result, 0);
67 string[] Result =
new string[codeByCountry.Count];
68 codeByCountry.Keys.CopyTo(Result, 0);
82 return countryByCode.TryGetValue(Code, out Country);
92 public static bool TryGetCode(
string Country, out
string Code)
94 return codeByCountry.TryGetValue(Country, out Code);
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Static class managing the runtime environment of the IoT Gateway.
static string AppDataFolder
Application data folder.
Data in accordance with ISO 3166
static string[] Countries
Registered ISO-3166-1 Country Names
static string[] Codes
Registered ISO-3166-1 Country Codes
static bool TryGetCode(string Country, out string Code)
Tries to get the ISO 3166-1 Country Code from a Country Name. String comparisons are case-insensitive...
static bool TryGetCountry(string Code, out string Country)
Tries to get the Country Name from a ISO 3166-1 Country Code. String comparisons are case-insensitive...