本文整理汇总了C#中System.Xml.XmlDictionaryReader.MoveToNextAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryReader.MoveToNextAttribute方法的具体用法?C# XmlDictionaryReader.MoveToNextAttribute怎么用?C# XmlDictionaryReader.MoveToNextAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryReader
的用法示例。
在下文中一共展示了XmlDictionaryReader.MoveToNextAttribute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteElementNode
void WriteElementNode(XmlDictionaryReader reader, bool defattr)
{
XmlDictionaryString localName;
XmlDictionaryString namespaceUri;
if (reader.TryGetLocalNameAsDictionaryString(out localName) && reader.TryGetNamespaceUriAsDictionaryString(out namespaceUri))
{
WriteStartElement(reader.Prefix, localName, namespaceUri);
}
else
{
WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
}
if (defattr || (!reader.IsDefault && (reader.SchemaInfo == null || !reader.SchemaInfo.IsDefault)))
{
if (reader.MoveToFirstAttribute())
{
do
{
if (reader.TryGetLocalNameAsDictionaryString(out localName) && reader.TryGetNamespaceUriAsDictionaryString(out namespaceUri))
{
WriteStartAttribute(reader.Prefix, localName, namespaceUri);
}
else
{
WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
}
while (reader.ReadAttributeValue())
{
if (reader.NodeType == XmlNodeType.EntityReference)
{
WriteEntityRef(reader.Name);
}
else
{
WriteTextNode(reader, true);
}
}
WriteEndAttribute();
}
while (reader.MoveToNextAttribute());
reader.MoveToElement();
}
}
if (reader.IsEmptyElement)
{
WriteEndElement();
}
}
示例2: WriteElementNode
private void WriteElementNode(XmlDictionaryReader reader, bool defattr)
{
XmlDictionaryString str;
XmlDictionaryString str2;
if (reader.TryGetLocalNameAsDictionaryString(out str) && reader.TryGetNamespaceUriAsDictionaryString(out str2))
{
this.WriteStartElement(reader.Prefix, str, str2);
}
else
{
this.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
}
if ((defattr || (!reader.IsDefault && ((reader.SchemaInfo == null) || !reader.SchemaInfo.IsDefault))) && reader.MoveToFirstAttribute())
{
do
{
if (reader.TryGetLocalNameAsDictionaryString(out str) && reader.TryGetNamespaceUriAsDictionaryString(out str2))
{
this.WriteStartAttribute(reader.Prefix, str, str2);
}
else
{
this.WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
}
while (reader.ReadAttributeValue())
{
if (reader.NodeType == XmlNodeType.EntityReference)
{
this.WriteEntityRef(reader.Name);
}
else
{
this.WriteTextNode(reader, true);
}
}
this.WriteEndAttribute();
}
while (reader.MoveToNextAttribute());
reader.MoveToElement();
}
if (reader.IsEmptyElement)
{
this.WriteEndElement();
}
}
示例3: ReadOtherAttributes
private static List<System.Xml.XmlNode> ReadOtherAttributes(XmlDictionaryReader reader, XmlDictionaryString ns)
{
int attributeCount = reader.AttributeCount;
if (attributeCount == 0)
{
return null;
}
XmlDocument document = new XmlDocument();
List<System.Xml.XmlNode> list = new List<System.Xml.XmlNode>(attributeCount);
reader.MoveToFirstAttribute();
do
{
System.Xml.XmlNode item = document.ReadNode(reader);
if ((item == null) || (item.NamespaceURI == ns.Value))
{
throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext")));
}
list.Add(item);
}
while (reader.MoveToNextAttribute());
reader.MoveToElement();
return list;
}
示例4: ReadAttributes
public static XmlAttributeHolder[] ReadAttributes(XmlDictionaryReader reader, ref int maxSizeOfHeaders)
{
if (reader.AttributeCount == 0)
{
return emptyArray;
}
XmlAttributeHolder[] holderArray = new XmlAttributeHolder[reader.AttributeCount];
reader.MoveToFirstAttribute();
for (int i = 0; i < holderArray.Length; i++)
{
string namespaceURI = reader.NamespaceURI;
string localName = reader.LocalName;
string prefix = reader.Prefix;
string s = string.Empty;
while (reader.ReadAttributeValue())
{
if (s.Length == 0)
{
s = reader.Value;
}
else
{
s = s + reader.Value;
}
}
Deduct(prefix, ref maxSizeOfHeaders);
Deduct(localName, ref maxSizeOfHeaders);
Deduct(namespaceURI, ref maxSizeOfHeaders);
Deduct(s, ref maxSizeOfHeaders);
holderArray[i] = new XmlAttributeHolder(prefix, localName, namespaceURI, s);
reader.MoveToNextAttribute();
}
reader.MoveToElement();
return holderArray;
}
示例5: ReadAttributes
public static XmlAttributeHolder[] ReadAttributes(XmlDictionaryReader reader, ref int maxSizeOfHeaders)
{
if (reader.AttributeCount == 0)
return emptyArray;
XmlAttributeHolder[] attributes = new XmlAttributeHolder[reader.AttributeCount];
reader.MoveToFirstAttribute();
for (int i = 0; i < attributes.Length; i++)
{
string ns = reader.NamespaceURI;
string localName = reader.LocalName;
string prefix = reader.Prefix;
string value = string.Empty;
while (reader.ReadAttributeValue())
{
if (value.Length == 0)
value = reader.Value;
else
value += reader.Value;
}
Deduct(prefix, ref maxSizeOfHeaders);
Deduct(localName, ref maxSizeOfHeaders);
Deduct(ns, ref maxSizeOfHeaders);
Deduct(value, ref maxSizeOfHeaders);
attributes[i] = new XmlAttributeHolder(prefix, localName, ns, value);
reader.MoveToNextAttribute();
}
reader.MoveToElement();
return attributes;
}
示例6: MoveToElementSimpleDummyRoot
public void MoveToElementSimpleDummyRoot ()
{
reader = CreateReader ("1234");
reader.Read (); // element
Assert.IsTrue (reader.MoveToFirstAttribute (), "#1");
Assert.IsTrue (reader.MoveToElement (), "#1-1");
Assert.IsTrue (reader.MoveToFirstAttribute (), "#2");
Assert.IsTrue (reader.ReadAttributeValue (), "#2-1");
Assert.IsTrue (reader.MoveToElement (), "#2-2");
Assert.IsTrue (reader.MoveToFirstAttribute (), "#3");
Assert.IsFalse (reader.MoveToNextAttribute (), "#3-1");
Assert.IsTrue (reader.MoveToElement (), "#3-2");
}
示例7: MoveToAttributeSimpleDummyRoot
public void MoveToAttributeSimpleDummyRoot ()
{
reader = CreateReader ("1234");
Assert.IsFalse (reader.MoveToFirstAttribute (), "#1");
reader.Read (); // element
Assert.IsTrue (reader.MoveToFirstAttribute (), "#2");
Assert.AreEqual ("type", reader.LocalName, "#3");
Assert.AreEqual ("number", reader.Value, "#4");
Assert.IsTrue (reader.ReadAttributeValue (), "#5");
Assert.AreEqual ("number", reader.Value, "#6");
Assert.IsFalse (reader.MoveToNextAttribute (), "#7");
Assert.IsTrue (reader.MoveToFirstAttribute (), "#8");
Assert.IsFalse (reader.MoveToNextAttribute (), "#9");
}
示例8: MoveToAttributeArray
public void MoveToAttributeArray ()
{
reader = CreateReader ("[]");
Assert.IsFalse (reader.MoveToFirstAttribute (), "#1");
reader.Read (); // element
Assert.IsTrue (reader.MoveToFirstAttribute (), "#2");
Assert.AreEqual ("type", reader.LocalName, "#3");
Assert.AreEqual ("array", reader.Value, "#4");
Assert.IsTrue (reader.ReadAttributeValue (), "#5");
Assert.AreEqual ("array", reader.Value, "#6");
Assert.IsFalse (reader.MoveToNextAttribute (), "#7");
Assert.IsTrue (reader.MoveToFirstAttribute (), "#8");
Assert.IsFalse (reader.MoveToNextAttribute (), "#9");
}
示例9: StructureOf
/// <summary>Structure of a JSON document as a structure useable for lookups</summary>
private IEnumerable<KeyValuePair<string, string>> StructureOf(XmlDictionaryReader input)
{
var path = new List<string>();
do
{
if (XmlNodeType.Text == input.NodeType)
{
yield return new KeyValuePair<string, string>(string.Join("\\", path), input.Value);
}
else if (XmlNodeType.Element == input.NodeType)
{
var name = input.LocalName;
input.MoveToFirstAttribute();
do
{
if ("item" == input.LocalName) name = input.Value;
} while (input.MoveToNextAttribute());
input.MoveToElement();
path.Add(name);
}
else if (XmlNodeType.EndElement == input.NodeType)
{
path.RemoveAt(path.Count - 1);
}
} while (input.Read());
}