static World() { cityNames_ = new XmlDocument(); cityNames_.LoadXml(RailNation.Properties.Resources.cityNames); LangIds li = (LangIds)Enum.Parse(typeof(LangIds), Config.COUNTRY_ID); try { string path = String.Format("//tu[contains(@tuid,'_{0}')]/tuv/seg", (int)li); XmlNodeList names = cityNames_.SelectNodes(path); townNameCount_ = names.Count; } catch (Exception e) { Trace.TraceError("Error counting city names, {0}", e); } }
public static string getCityName(int id) { id += seedForTowns_; if (id > townNameCount_) { id -= townNameCount_; } LangIds li = (LangIds)Enum.Parse(typeof(LangIds), Config.COUNTRY_ID); string path = String.Format("//tu[@tuid='IDS_CITY_NAME_{0:000}_{1}']/tuv/seg", id, (int)li); XmlNode node = cityNames_.SelectSingleNode(path); if (node == null) { Trace.TraceWarning("Failed to find city name number {0} (seed is {1}", (id - seedForTowns_), seedForTowns_); } return(node != null ? node.InnerText : String.Format("City {0}", id)); }