本文整理汇总了C#中System.Xml.XmlDictionaryReader.MoveToElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryReader.MoveToElement方法的具体用法?C# XmlDictionaryReader.MoveToElement怎么用?C# XmlDictionaryReader.MoveToElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryReader
的用法示例。
在下文中一共展示了XmlDictionaryReader.MoveToElement方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsStartObject
public override bool IsStartObject(XmlDictionaryReader reader)
{
if (reader == null)
{
throw new ArgumentNullException("reader");
}
reader.MoveToElement();
return reader.IsStartElement();
}
示例2: IsStartObject
public override bool IsStartObject(XmlDictionaryReader reader)
{
if (reader == null)
{
throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));
}
reader.MoveToElement();
if (this.rootName != null)
{
return reader.IsStartElement(this.rootName, this.rootNamespace);
}
return reader.IsStartElement();
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:XmlSerializerObjectSerializer.cs
示例3: 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();
}
}
示例4: WriteNode
public virtual void WriteNode (XmlDictionaryReader reader,
bool defattr)
{
if (reader == null)
throw new ArgumentNullException ("reader");
switch (reader.NodeType) {
case XmlNodeType.Element:
// gratuitously copied from System.XML/System.Xml/XmlWriter.cs:WriteNode(XmlReader,bool)
// as there doesn't seem to be a way to hook into attribute writing w/o handling Element.
XmlDictionaryString ename, ens;
if (reader.TryGetLocalNameAsDictionaryString (out ename) && reader.TryGetLocalNameAsDictionaryString (out ens))
WriteStartElement (reader.Prefix, ename, ens);
else
WriteStartElement (reader.Prefix, reader.LocalName, reader.NamespaceURI);
// Well, I found that MS.NET took this way, since
// there was a error-prone SgmlReader that fails
// MoveToNextAttribute().
if (reader.HasAttributes) {
for (int i = 0; i < reader.AttributeCount; i++) {
reader.MoveToAttribute (i);
WriteAttribute (reader, defattr);
}
reader.MoveToElement ();
}
if (reader.IsEmptyElement)
WriteEndElement ();
else {
int depth = reader.Depth;
reader.Read ();
if (reader.NodeType != XmlNodeType.EndElement) {
do {
WriteNode (reader, defattr);
} while (depth < reader.Depth);
}
WriteFullEndElement ();
}
reader.Read ();
break;
case XmlNodeType.Attribute:
case XmlNodeType.Text:
WriteTextNode (reader, defattr);
break;
default:
base.WriteNode (reader, defattr);
break;
}
}
示例5: 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();
}
}
示例6: 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;
}
示例7: GetAttributeAsUniqueId
private static UniqueId GetAttributeAsUniqueId(XmlDictionaryReader reader, string name, string ns)
{
if (!reader.MoveToAttribute(name, ns))
{
return null;
}
UniqueId id = reader.ReadContentAsUniqueId();
reader.MoveToElement();
return id;
}
示例8: IsStartObject
public override bool IsStartObject(XmlDictionaryReader reader)
{
if (reader == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));
reader.MoveToElement();
if (_rootName != null)
{
return reader.IsStartElement(_rootName, _rootNamespace);
}
else
{
return reader.IsStartElement();
}
}
示例9: 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;
}
示例10: ReadAck
// February 2005 - Reads Identifier, AcknowledgementRange, Nack
// 1.1 - Reads Identifier, AcknowledgementRange, None, Final, Nack
internal static void ReadAck(ReliableMessagingVersion reliableMessagingVersion,
XmlDictionaryReader reader, out UniqueId sequenceId, out SequenceRangeCollection rangeCollection,
out bool final)
{
WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary;
XmlDictionaryString wsrmNs = WsrmIndex.GetNamespace(reliableMessagingVersion);
reader.ReadStartElement(wsrmFeb2005Dictionary.SequenceAcknowledgement, wsrmNs);
reader.ReadStartElement(wsrmFeb2005Dictionary.Identifier, wsrmNs);
sequenceId = reader.ReadContentAsUniqueId();
reader.ReadEndElement();
bool allowZero = reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005;
rangeCollection = SequenceRangeCollection.Empty;
while (reader.IsStartElement(wsrmFeb2005Dictionary.AcknowledgementRange, wsrmNs))
{
reader.MoveToAttribute(WsrmFeb2005Strings.Lower);
Int64 lower = WsrmUtilities.ReadSequenceNumber(reader, allowZero);
reader.MoveToAttribute(WsrmFeb2005Strings.Upper);
Int64 upper = WsrmUtilities.ReadSequenceNumber(reader, allowZero);
if (lower < 0 || lower > upper
|| ((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005) && (lower == 0 && upper > 0))
|| ((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) && (lower == 0)))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new XmlException(SR.GetString(SR.InvalidSequenceRange, lower, upper)));
}
rangeCollection = rangeCollection.MergeWith(new SequenceRange(lower, upper));
reader.MoveToElement();
WsrmUtilities.ReadEmptyElement(reader);
}
bool validAck = rangeCollection.Count > 0;
final = false;
bool wsrm11 = reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11;
if (wsrm11)
{
Wsrm11Dictionary wsrm11Dictionary = DXD.Wsrm11Dictionary;
if (reader.IsStartElement(wsrm11Dictionary.None, wsrmNs))
{
if (validAck)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(
SR.GetString(SR.UnexpectedXmlChildNode, reader.Name, reader.NodeType,
wsrmFeb2005Dictionary.SequenceAcknowledgement)));
}
WsrmUtilities.ReadEmptyElement(reader);
validAck = true;
}
if (reader.IsStartElement(wsrm11Dictionary.Final, wsrmNs))
{
if (!validAck)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(
SR.GetString(SR.UnexpectedXmlChildNode, reader.Name, reader.NodeType,
wsrmFeb2005Dictionary.SequenceAcknowledgement)));
}
WsrmUtilities.ReadEmptyElement(reader);
final = true;
}
}
bool foundNack = false;
while (reader.IsStartElement(wsrmFeb2005Dictionary.Nack, wsrmNs))
{
if (validAck)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(
SR.GetString(SR.UnexpectedXmlChildNode, reader.Name, reader.NodeType,
MessageStrings.Body)));
}
reader.ReadStartElement();
WsrmUtilities.ReadSequenceNumber(reader, true);
reader.ReadEndElement();
foundNack = true;
}
if (!validAck && !foundNack)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(
SR.GetString(SR.UnexpectedXmlChildNode, reader.Name, reader.NodeType,
MessageStrings.Body)));
}
}
示例11: 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;
}
示例12: 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");
}
示例13: 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());
}
示例14: ReadAck
internal static void ReadAck(ReliableMessagingVersion reliableMessagingVersion, XmlDictionaryReader reader, out UniqueId sequenceId, out SequenceRangeCollection rangeCollection, out bool final)
{
WsrmFeb2005Dictionary dictionary = XD.WsrmFeb2005Dictionary;
XmlDictionaryString namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);
reader.ReadStartElement(dictionary.SequenceAcknowledgement, namespaceUri);
reader.ReadStartElement(dictionary.Identifier, namespaceUri);
sequenceId = reader.ReadContentAsUniqueId();
reader.ReadEndElement();
bool allowZero = reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005;
rangeCollection = SequenceRangeCollection.Empty;
while (reader.IsStartElement(dictionary.AcknowledgementRange, namespaceUri))
{
reader.MoveToAttribute("Lower");
long lower = WsrmUtilities.ReadSequenceNumber(reader, allowZero);
reader.MoveToAttribute("Upper");
long upper = WsrmUtilities.ReadSequenceNumber(reader, allowZero);
if ((((lower < 0L) || (lower > upper)) || (((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005) && (lower == 0L)) && (upper > 0L))) || ((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) && (lower == 0L)))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidSequenceRange", new object[] { lower, upper })));
}
rangeCollection = rangeCollection.MergeWith(new SequenceRange(lower, upper));
reader.MoveToElement();
WsrmUtilities.ReadEmptyElement(reader);
}
bool flag2 = rangeCollection.Count > 0;
final = false;
if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
{
Wsrm11Dictionary dictionary2 = DXD.Wsrm11Dictionary;
if (reader.IsStartElement(dictionary2.None, namespaceUri))
{
if (flag2)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, dictionary.SequenceAcknowledgement })));
}
WsrmUtilities.ReadEmptyElement(reader);
flag2 = true;
}
if (reader.IsStartElement(dictionary2.Final, namespaceUri))
{
if (!flag2)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, dictionary.SequenceAcknowledgement })));
}
WsrmUtilities.ReadEmptyElement(reader);
final = true;
}
}
bool flag4 = false;
while (reader.IsStartElement(dictionary.Nack, namespaceUri))
{
if (flag2)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, "Body" })));
}
reader.ReadStartElement();
WsrmUtilities.ReadSequenceNumber(reader, true);
reader.ReadEndElement();
flag4 = true;
}
if (!flag2 && !flag4)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, "Body" })));
}
}