static void ReadData(XmlReader reader, SmartCultureInfoCollection newCollection) { string languageCode = string.Empty; string englishName = string.Empty; string nativeName = string.Empty; bool isRightToLeft = false; //Read the child nodes if (reader.ReadToDescendant("languageCode")) { languageCode = reader.ReadElementContentAsString(); } if (reader.ReadToNextSibling("englishName")) { englishName = reader.ReadElementContentAsString(); } if (reader.ReadToNextSibling("nativeName")) { nativeName = reader.ReadElementContentAsString(); } if (reader.ReadToNextSibling("isRightToLeft")) { isRightToLeft = reader.ReadElementContentAsBoolean(); } newCollection.AddCultureInfo(new SmartCultureInfo(languageCode, englishName, nativeName, isRightToLeft)); }
static void ReadElements(XmlReader reader, SmartCultureInfoCollection newCollection) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == "CultureInfo") { ReadData(reader, newCollection); } } }
bool LoadAvailableCultures() { TextAsset availableCulturesXML = Resources.Load(LanguageRuntimeData.AvailableCulturesFilePath()) as TextAsset; if (availableCulturesXML == null) { Debug.LogError("Не удалось загрузить доступные языки! Файл не найден!"); return(false); } availableLanguages = SmartCultureInfoCollection.Deserialize(availableCulturesXML); return(true); }
public static SmartCultureInfoCollection Deserialize(TextAsset xmlFile) { if (xmlFile == null) { return(null); } SmartCultureInfoCollection newCollection = new SmartCultureInfoCollection(); using (StringReader stringReader = new StringReader(xmlFile.text)) { using (XmlReader reader = XmlReader.Create(stringReader)) { ReadElements(reader, newCollection); } } return(newCollection); }