Esempio n. 1
0
        public XmlParserTagInfo Clone()
        {
            XmlParserTagInfo clone = this.MemberwiseClone() as XmlParserTagInfo;

            clone.cursor = cursor.Clone();
            return(clone);
        }
Esempio n. 2
0
        /// <summary>
        /// Removes the last entry from the path.
        /// </summary>
        /// <returns></returns>
        public XmlParserTagInfo RemoveLastEntry()
        {
            XmlParserTagInfo lastEntry = _path[_path.Count - 1];

            _path.RemoveAt(_path.Count - 1);
            return(lastEntry);
        }
Esempio n. 3
0
        public void RefreshDataFromOldParser(XmlParser oldParser)
        {
            XmlParserTagInfo currentTag = CurrentState.Current.Clone();

            CurrentState.RefreshDataFromOldParser(oldParser);
            MoveToNextTag();
            CurrentState.Current.IsBoundaryElement = currentTag.IsBoundaryElement;
        }
Esempio n. 4
0
        public override bool Equals(object obj)
        {
            XmlParserTagInfo other = obj as XmlParserTagInfo;

            if (other == null)
            {
                return(false);
            }

            return((StartPosition == other.StartPosition) && (EndPosition == other.EndPosition) && (Name == other.Name));
        }
Esempio n. 5
0
 /// <summary>
 /// Appends the tag as the last path entry.
 /// </summary>
 /// <param name="entry"></param>
 public void Append(XmlParserTagInfo entry)
 {
     _path.Add(entry);
 }
Esempio n. 6
0
        /// <summary>
        /// Updates the current state after a successful move.
        /// </summary>
        /// <returns>Return whether the parser is still in valid state (true) or not (false).</returns>
        bool UpdateState(IXmlTagParsingStrategy parsingStrategy)
        {
            // Find the end of the current tag.
            if (!parsingStrategy.FindEndOfTag(_xml, _cursor))
            {
                // Tag is not closed.
                return(Invalidate());
            }

            // Fit cursor to exact tag boundaries.
            while (_cursor.EndPosition > _cursor.StartPosition && _xml[_cursor.EndPosition - 1] != '>')
            {
                _cursor.EndPosition--;
            }

            if (_cursor.EndPosition <= _cursor.StartPosition)
            {
                return(Invalidate());
            }

            XmlParserTagInfo currentTag = Current;

            if (currentTag != XmlParserTagInfo.NullTag && !(currentTag.IsEmptyElement || currentTag.IsElementClosingTag))
            {
                _path.Append(currentTag);
            }


            bool isElementClosingTag = false;
            bool isEmptyElement      = false;

            // Determine whether the current tag is an element closing tag.
            if (IsClosingTag(Cursor.StartPosition))
            {
                isElementClosingTag = true;
            }
            else
            {
                // Determine whether the current element is empty (no children).
                if (_xml[Cursor.EndPosition - 2] == '/')
                {
                    isEmptyElement = true;
                }
            }

            string currentTagName;

            if (!GetTagName(Cursor.StartPosition, out currentTagName))
            {
                return(Invalidate());
            }

            currentTag = new XmlParserTagInfo(_cursor, currentTagName);
            currentTag.IsEmptyElement      = isEmptyElement;
            currentTag.IsElementClosingTag = isElementClosingTag;
            Current = currentTag;

            if (isElementClosingTag)
            {
                XmlParserTagInfo tag = _path.RemoveLastEntry();
                Debug.Assert(tag.Name == currentTagName, "Popped tag name '" + tag.Name + "' is not as expected: '" + currentTagName + "'");
                Current.IsBoundaryElement = tag.IsBoundaryElement;
            }

            return(true);
        }