SeekToLineStart() приватный Метод

private SeekToLineStart ( ) : void
Результат void
Пример #1
0
        // Skip over the current element and copy until the next element.
        // This function removes the one blank line that would otherwise
        // be inserted by simply skipping and copying to the next element
        // in a situation like this:
        //
        //      <!-- end of previous configSection -->
        //      <configSectionToDelete>
        //          <content />
        //          <moreContent />
        //      </configSectionToDelete>
        //      <!-- end of configSectionToDelete -->
        //      <nextConfigSection />
        internal bool SkipAndCopyReaderToNextElement(XmlUtilWriter utilWriter, bool limitDepth)
        {
            Debug.Assert(Reader.NodeType == XmlNodeType.Element, "_reader.NodeType == XmlNodeType.Element");

            // If the last line before the element is not blank, then we do not have to
            // remove the blank line.
            if (!utilWriter.IsLastLineBlank)
            {
                Reader.Skip();
                return(CopyReaderToNextElement(utilWriter, limitDepth));
            }

            // Set the depth if we limit copying to this depth
            int depth = limitDepth ? Reader.Depth : 0;

            // Skip over the element
            Reader.Skip();

            int lineNumberOfEndElement = Reader.LineNumber;

            // Read until we hit a a non-whitespace node or reach the end
            while (!Reader.EOF)
            {
                if (Reader.NodeType != XmlNodeType.Whitespace)
                {
                    //
                    // If the next non-whitepace node is on another line,
                    // seek back to the beginning of the current blank line,
                    // skip a blank line of whitespace, and copy the remaining whitespace.
                    //
                    if (Reader.LineNumber > lineNumberOfEndElement)
                    {
                        utilWriter.SeekToLineStart();
                        utilWriter.AppendWhiteSpace(lineNumberOfEndElement + 1, 1, LineNumber, TrueLinePosition);
                    }

                    break;
                }

                Reader.Read();
            }

            // Copy nodes until we've reached the desired depth, or until we hit an element.
            while (!Reader.EOF)
            {
                if (Reader.NodeType == XmlNodeType.Element)
                {
                    break;
                }

                if (Reader.Depth < depth)
                {
                    break;
                }

                CopyXmlNode(utilWriter);
            }

            return(!Reader.EOF);
        }
Пример #2
0
        internal bool SkipAndCopyReaderToNextElement(XmlUtilWriter utilWriter, bool limitDepth)
        {
            int depth;

            if (!utilWriter.IsLastLineBlank)
            {
                this._reader.Skip();
                return(this.CopyReaderToNextElement(utilWriter, limitDepth));
            }
            if (limitDepth)
            {
                depth = this._reader.Depth;
            }
            else
            {
                depth = 0;
            }
            this._reader.Skip();
            int lineNumber = this._reader.LineNumber;

            while (!this._reader.EOF)
            {
                if (this._reader.NodeType != XmlNodeType.Whitespace)
                {
                    if (this._reader.LineNumber > lineNumber)
                    {
                        utilWriter.SeekToLineStart();
                        utilWriter.AppendWhiteSpace(lineNumber + 1, 1, this.LineNumber, this.TrueLinePosition);
                    }
                    break;
                }
                this._reader.Read();
            }
            while (!this._reader.EOF)
            {
                if ((this._reader.NodeType == XmlNodeType.Element) || (this._reader.Depth < depth))
                {
                    break;
                }
                this.CopyXmlNode(utilWriter);
            }
            return(!this._reader.EOF);
        }
Пример #3
0
        //
        // Skip over the current element and copy until the next element.
        // This function removes the one blank line that would otherwise
        // be inserted by simply skipping and copying to the next element
        // in a situation like this:
        //
        //      <!-- end of previous configSection -->
        //      <configSectionToDelete>
        //          <content />
        //          <moreContent />
        //      </configSectionToDelete>
        //      <!-- end of configSectionToDelete -->
        //      <nextConfigSection />
        //
        internal bool SkipAndCopyReaderToNextElement(XmlUtilWriter utilWriter, bool limitDepth) {
            Debug.Assert(_reader.NodeType == XmlNodeType.Element, "_reader.NodeType == XmlNodeType.Element");

            // If the last line before the element is not blank, then we do not have to
            // remove the blank line.
            if (!utilWriter.IsLastLineBlank) {
                _reader.Skip();
                return CopyReaderToNextElement(utilWriter, limitDepth);
            }

            // Set the depth if we limit copying to this depth
            int depth;
            if (limitDepth) {
                depth = _reader.Depth;
            }
            else {
                depth = 0;
            }

            // Skip over the element
            _reader.Skip();

            int lineNumberOfEndElement = _reader.LineNumber;

            // Read until we hit a a non-whitespace node or reach the end
            while (!_reader.EOF) {
                if (_reader.NodeType != XmlNodeType.Whitespace) {
                    //
                    // If the next non-whitepace node is on another line,
                    // seek back to the beginning of the current blank line,
                    // skip a blank line of whitespace, and copy the remaining whitespace.
                    //
                    if (_reader.LineNumber > lineNumberOfEndElement) {
                        utilWriter.SeekToLineStart();
                        utilWriter.AppendWhiteSpace(lineNumberOfEndElement + 1, 1, LineNumber, TrueLinePosition);
                    }

                    break;
                }

                _reader.Read();
            }

            // Copy nodes until we've reached the desired depth, or until we hit an element.
            while (!_reader.EOF) {
                if (_reader.NodeType == XmlNodeType.Element)
                    break;

                if (_reader.Depth < depth) {
                    break;
                }

                CopyXmlNode(utilWriter);
            };

            return !_reader.EOF;
        }
 internal bool SkipAndCopyReaderToNextElement(XmlUtilWriter utilWriter, bool limitDepth)
 {
     int depth;
     if (!utilWriter.IsLastLineBlank)
     {
         this._reader.Skip();
         return this.CopyReaderToNextElement(utilWriter, limitDepth);
     }
     if (limitDepth)
     {
         depth = this._reader.Depth;
     }
     else
     {
         depth = 0;
     }
     this._reader.Skip();
     int lineNumber = this._reader.LineNumber;
     while (!this._reader.EOF)
     {
         if (this._reader.NodeType != XmlNodeType.Whitespace)
         {
             if (this._reader.LineNumber > lineNumber)
             {
                 utilWriter.SeekToLineStart();
                 utilWriter.AppendWhiteSpace(lineNumber + 1, 1, this.LineNumber, this.TrueLinePosition);
             }
             break;
         }
         this._reader.Read();
     }
     while (!this._reader.EOF)
     {
         if ((this._reader.NodeType == XmlNodeType.Element) || (this._reader.Depth < depth))
         {
             break;
         }
         this.CopyXmlNode(utilWriter);
     }
     return !this._reader.EOF;
 }