System.Configuration.XmlUtilWriter.SeekToLineStart C# (CSharp) Метод

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

private SeekToLineStart ( ) : void
Результат void
        internal void SeekToLineStart() {
            Debug.Assert(_isLastLineBlank, "_isLastLineBlank");
            RestoreStreamCheckpoint(_lineStartCheckpoint);
        }

Usage Example

Пример #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);
        }
All Usage Examples Of System.Configuration.XmlUtilWriter::SeekToLineStart