本文整理汇总了C#中System.Xml.XmlDictionaryReader.MoveToAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryReader.MoveToAttribute方法的具体用法?C# XmlDictionaryReader.MoveToAttribute怎么用?C# XmlDictionaryReader.MoveToAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryReader
的用法示例。
在下文中一共展示了XmlDictionaryReader.MoveToAttribute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsJsonLocalName
internal static bool IsJsonLocalName(XmlDictionaryReader reader, string elementName)
{
if (reader.IsStartElement(JsonGlobals.itemDictionaryString, JsonGlobals.itemDictionaryString))
{
if (reader.MoveToAttribute(JsonGlobals.itemString))
{
return (reader.Value == elementName);
}
}
return false;
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:11,代码来源:DataContractJsonSerializerOperationFormatter.cs
示例2: 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;
}
}
示例3: DeserializeParameter
private object DeserializeParameter(XmlDictionaryReader reader, PartInfo part)
{
if (reader.AttributeCount > 0 &&
reader.MoveToAttribute(_xsiNilLocalName.Value, _xsiNilNamespace.Value) &&
reader.ReadContentAsBoolean())
{
reader.Skip();
return null;
}
return part.ReadValue(reader);
}
示例4: 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;
}
示例5: GetRequiredBase64Attribute
internal static byte[] GetRequiredBase64Attribute(XmlDictionaryReader reader, XmlDictionaryString name, XmlDictionaryString ns)
{
if (!reader.MoveToAttribute(name.Value, ns == null ? null : ns.Value))
{
OnRequiredAttributeMissing(name.Value, ns == null ? null : ns.Value);
}
byte[] value = reader.ReadContentAsBase64();
if (value == null || value.Length == 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new XmlException(SR.Format(SR.EmptyBase64Attribute, name, ns)));
}
return value;
}
示例6: 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)));
}
}
示例7: 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" })));
}
}