當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlUtilWriter.SeekToLineStart方法代碼示例

本文整理匯總了C#中System.Configuration.XmlUtilWriter.SeekToLineStart方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlUtilWriter.SeekToLineStart方法的具體用法?C# XmlUtilWriter.SeekToLineStart怎麽用?C# XmlUtilWriter.SeekToLineStart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Configuration.XmlUtilWriter的用法示例。


在下文中一共展示了XmlUtilWriter.SeekToLineStart方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SkipAndCopyReaderToNextElement

        //
        // 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;
        }
開發者ID:gbarnett,項目名稱:shared-source-cli-2.0,代碼行數:71,代碼來源:xmlutil.cs

示例2: SkipAndCopyReaderToNextElement

 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;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:41,代碼來源:XmlUtil.cs


注:本文中的System.Configuration.XmlUtilWriter.SeekToLineStart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。