当前位置: 首页>>代码示例>>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;未经允许,请勿转载。