Exemple #1
0
        private void Load(XmlReader xmlReader)
        {
            items = new List <XmlItem>();
            List <XmlItem> active = header;

            headless = true;

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.XmlDeclaration:
                {
                    XmlItem item = new XmlDeclarationItem();
                    item.Load(xmlReader);
                    active.Add(item);
                }
                break;

                case XmlNodeType.Comment:
                {
                    XmlItem item = new CommentItem();
                    item.Load(xmlReader);
                    active.Add(item);
                }
                break;

                case XmlNodeType.Whitespace:
                {
                    XmlItem item = new WhitespaceItem();
                    item.Load(xmlReader);
                    active.Add(item);
                }
                break;

                case XmlNodeType.Element:
                {
                    if (xmlReader.Name == "string_table")
                    {
                        headless = false;
                        LoadItems(xmlReader.ReadSubtree(), true);
                    }
                    else
                    {
                        LoadItems(xmlReader, false);
                    }
                    active = footer;
                }
                break;

                default:
                    break;
                }
                ;
            }
        }
Exemple #2
0
        public override void Load(XmlReader xmlReader)
        {
            //! Read root node
            xmlReader.Read();
            id = xmlReader.GetAttribute("id");

            List <XmlItem> cw = new List <XmlItem>();

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Comment:
                {
                    XmlItem item = new CommentItem();
                    item.Load(xmlReader);
                    cw.Add(item);
                }
                break;

                case XmlNodeType.Whitespace:
                {
                    XmlItem item = new WhitespaceItem();
                    item.Load(xmlReader);
                    cw.Add(item);
                }
                break;

                case XmlNodeType.Element:
                {
                    string name = xmlReader.Name;
                    xmlReader.Read();        //! Move to content

                    string value = fromXml(xmlReader.Value);
                    if (name != "rus" && (value == null || value == "==="))
                    {
                        value        = "===" + _texts["rus"].orig;
                        _texts[name] = new LangItem(value, false);
                    }
                    else
                    {
                        _texts[name] = new LangItem(value, true);
                    }
                    cw_lang[name] = cw;
                    cw            = new List <XmlItem>();
                }
                break;

                default:
                    break;
                }
                ;
            }
            cw_post = cw;
            CheckTranslation();
        }
Exemple #3
0
        private void LoadItems(XmlReader xmlReader, bool isStringTable)
        {
            bool skipFirstRead = !isStringTable;

            if (isStringTable)
            {
                xmlReader.Read();//! Skip root node
            }
            while (skipFirstRead || xmlReader.Read())
            {
                skipFirstRead = false;
                XmlItem item = null;
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Comment:
                {
                    item = new CommentItem();
                    item.Load(xmlReader);
                }
                break;

                case XmlNodeType.Element:
                {
                    item = new Item(this);
                    item.Load(xmlReader.ReadSubtree());
                }
                break;

                case XmlNodeType.Whitespace:
                {
                    item = new WhitespaceItem();
                    item.Load(xmlReader);
                }
                break;

                case XmlNodeType.EndElement:
                    continue;

                case XmlNodeType.Text:
                {
                    item = new TextItem();
                    item.Load(xmlReader);
                }
                break;

                default:
                    throw new XmlException("Unsupported xml element " + xmlReader.NodeType.ToString());
                }
                ;

                items.Add(item);
            }
        }