예제 #1
0
        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));
        }
예제 #2
0
 static void ReadElements(XmlReader reader, SmartCultureInfoCollection newCollection)
 {
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element && reader.Name == "CultureInfo")
         {
             ReadData(reader, newCollection);
         }
     }
 }
예제 #3
0
        bool LoadAvailableCultures()
        {
            TextAsset availableCulturesXML = Resources.Load(LanguageRuntimeData.AvailableCulturesFilePath()) as TextAsset;

            if (availableCulturesXML == null)
            {
                Debug.LogError("Не удалось загрузить доступные языки! Файл не найден!");
                return(false);
            }

            availableLanguages = SmartCultureInfoCollection.Deserialize(availableCulturesXML);

            return(true);
        }
예제 #4
0
        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);
        }