本文整理汇总了C#中System.Xml.XmlDictionaryWriter.WriteWhitespace方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryWriter.WriteWhitespace方法的具体用法?C# XmlDictionaryWriter.WriteWhitespace怎么用?C# XmlDictionaryWriter.WriteWhitespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryWriter
的用法示例。
在下文中一共展示了XmlDictionaryWriter.WriteWhitespace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteTo
public void WriteTo(XmlDictionaryWriter writer, DictionaryManager dictionaryManager)
{
bool isEmptyElement;
if (writer == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("writer"));
}
if (!this.MoveToFirst())
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.IdentityModel.SR.GetString("XmlTokenBufferIsEmpty")));
}
int num = 0;
int num2 = -1;
bool flag = true;
Label_0040:
switch (this.NodeType)
{
case XmlNodeType.Element:
isEmptyElement = this.IsEmptyElement;
num++;
if (flag)
{
if (this.excludedElementDepth.HasValue)
{
int? excludedElementDepth = this.excludedElementDepth;
int num3 = num - 1;
if (!((excludedElementDepth.GetValueOrDefault() == num3) && excludedElementDepth.HasValue))
{
break;
}
}
if ((this.LocalName == this.excludedElement) && (this.NamespaceUri == this.excludedElementNamespace))
{
flag = false;
num2 = num;
}
}
break;
case XmlNodeType.Text:
if (flag)
{
writer.WriteString(this.Value);
}
goto Label_01AD;
case XmlNodeType.CDATA:
if (flag)
{
writer.WriteCData(this.Value);
}
goto Label_01AD;
case XmlNodeType.Comment:
if (flag)
{
writer.WriteComment(this.Value);
}
goto Label_01AD;
case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
if (flag)
{
writer.WriteWhitespace(this.Value);
}
goto Label_01AD;
case XmlNodeType.EndElement:
goto Label_0152;
default:
goto Label_01AD;
}
if (flag)
{
writer.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceUri);
}
if (this.MoveToFirstAttribute())
{
do
{
if (flag)
{
writer.WriteAttributeString(this.Prefix, this.LocalName, this.NamespaceUri, this.Value);
}
}
while (this.MoveToNextAttribute());
}
if (!isEmptyElement)
{
goto Label_01AD;
}
Label_0152:
if (flag)
{
writer.WriteEndElement();
}
else if (num2 == num)
{
//.........这里部分代码省略.........
示例2: WriteTo
public void WriteTo(XmlDictionaryWriter writer, DictionaryManager dictionaryManager)
{
if (writer == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("writer"));
}
if (!MoveToFirst())
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.XmlTokenBufferIsEmpty)));
}
int depth = 0;
int recordedDepth = -1;
bool include = true;
do
{
switch (this.NodeType)
{
case XmlNodeType.Element:
bool isEmpty = this.IsEmptyElement;
depth++;
if (include
&& (null == excludedElementDepth || excludedElementDepth == (depth - 1))
&& this.LocalName == this.excludedElement
&& this.NamespaceUri == this.excludedElementNamespace)
{
include = false;
recordedDepth = depth;
}
if (include)
{
writer.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceUri);
}
if (MoveToFirstAttribute())
{
do
{
if (include)
{
writer.WriteAttributeString(this.Prefix, this.LocalName, this.NamespaceUri, this.Value);
}
}
while (MoveToNextAttribute());
}
if (isEmpty)
{
goto case XmlNodeType.EndElement;
}
break;
case XmlNodeType.EndElement:
if (include)
{
writer.WriteEndElement();
}
else if (recordedDepth == depth)
{
include = true;
recordedDepth = -1;
}
depth--;
break;
case XmlNodeType.CDATA:
if (include)
{
writer.WriteCData(this.Value);
}
break;
case XmlNodeType.Comment:
if (include)
{
writer.WriteComment(this.Value);
}
break;
case XmlNodeType.Text:
if (include)
{
writer.WriteString(this.Value);
}
break;
case XmlNodeType.SignificantWhitespace:
case XmlNodeType.Whitespace:
if (include)
{
writer.WriteWhitespace(this.Value);
}
break;
case XmlNodeType.DocumentType:
case XmlNodeType.XmlDeclaration:
break;
}
}
while (MoveToNext());
}
示例3: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
try
{
do
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
for (int i = 0; i < reader.AttributeCount; i++)
{
reader.MoveToAttribute(i);
writer.WriteAttributeString(reader.LocalName, reader.NamespaceURI, reader.Value.Replace(sourcePattern, targetPattern));
}
reader.MoveToElement();
if (reader.IsEmptyElement)
{
writer.WriteEndElement();
}
break;
case XmlNodeType.Text:
writer.WriteString(reader.Value.Replace(sourcePattern, targetPattern));
break;
case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
writer.WriteWhitespace(reader.Value);
break;
case XmlNodeType.CDATA:
writer.WriteCData(reader.Value);
break;
case XmlNodeType.EntityReference:
writer.WriteEntityRef(reader.Name);
break;
case XmlNodeType.XmlDeclaration:
case XmlNodeType.ProcessingInstruction:
writer.WriteProcessingInstruction(reader.Name, reader.Value);
break;
case XmlNodeType.DocumentType:
writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
break;
case XmlNodeType.Comment:
writer.WriteComment(reader.Value);
break;
case XmlNodeType.EndElement:
writer.WriteFullEndElement();
break;
}
}
while (reader.Read());
writer.Flush();
}
catch (Exception ex)
{
Console.WriteLine(ex);
throw;
}
}