本文整理汇总了C#中XmlReader.IsXmlSpaceAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.IsXmlSpaceAttribute方法的具体用法?C# XmlReader.IsXmlSpaceAttribute怎么用?C# XmlReader.IsXmlSpaceAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.IsXmlSpaceAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessElement
private void ProcessElement(XmlReader xmlReader, StringBuilder output)
{
string currentIndentString = GetIndentString(xmlReader.Depth);
string elementName = xmlReader.Name;
// Calculate how element should be indented
if (!this.ElementProcessStatusStack.Peek().IsPreservingSpace)
{
// "Run" get special treatment to try to preserve spacing. Use xml:space='preserve' to make sure!
if (elementName.Equals("Run"))
{
this.ElementProcessStatusStack.Peek().Parent.IsSignificantWhiteSpace = true;
if ((output.Length == 0) || output.IsNewLine())
{
output.Append(currentIndentString);
}
}
else
{
this.ElementProcessStatusStack.Peek().Parent.IsSignificantWhiteSpace = false;
if ((output.Length == 0) || output.IsNewLine())
{
output.Append(currentIndentString);
}
else
{
output.Append(Environment.NewLine).Append(currentIndentString);
}
}
}
// Output the element itself
output.Append('<').Append(xmlReader.Name);
bool isEmptyElement = xmlReader.IsEmptyElement;
bool hasPutEndingBracketOnNewLine = false;
var list = new List<AttributeInfo>(xmlReader.AttributeCount);
if (xmlReader.HasAttributes)
{
while (xmlReader.MoveToNextAttribute())
{
string attributeName = xmlReader.Name;
string attributeValue = xmlReader.Value;
AttributeOrderRule orderRule = OrderRules.GetRuleFor(attributeName);
list.Add(new AttributeInfo(attributeName, attributeValue, orderRule));
// Check for xml:space as defined in http://www.w3.org/TR/2008/REC-xml-20081126/#sec-white-space
if (xmlReader.IsXmlSpaceAttribute())
{
this.ElementProcessStatusStack.Peek().IsPreservingSpace = (xmlReader.Value == "preserve");
}
}
if (this.Options.EnableAttributeReordering)
{
list.Sort(AttributeInfoComparison);
}
currentIndentString = this.GetIndentString(xmlReader.Depth);
var noLineBreakInAttributes = (list.Count <= this.Options.AttributesTolerance)
|| this.IsNoLineBreakElement(elementName);
var forceLineBreakInAttributes = false;
// Root element?
if (this.ElementProcessStatusStack.Count == 2)
{
switch (this.Options.RootElementLineBreakRule)
{
case LineBreakRule.Default:
break;
case LineBreakRule.Always:
noLineBreakInAttributes = false;
forceLineBreakInAttributes = true;
break;
case LineBreakRule.Never:
noLineBreakInAttributes = true;
break;
default:
throw new ArgumentOutOfRangeException();
}
}
// No need to break attributes
if (noLineBreakInAttributes)
{
foreach (var attrInfo in list)
{
output.Append(' ').Append(attrInfo.ToSingleLineString());
}
this.ElementProcessStatusStack.Peek().IsMultlineStartTag = false;
}
// Need to break attributes
else
{
IList<String> attributeLines = new List<String>();
var currentLineBuffer = new StringBuilder();
//.........这里部分代码省略.........