本文整理汇总了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;
}
示例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;
}