本文整理汇总了C#中System.Xml.XmlDictionaryReader.Close方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryReader.Close方法的具体用法?C# XmlDictionaryReader.Close怎么用?C# XmlDictionaryReader.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryReader
的用法示例。
在下文中一共展示了XmlDictionaryReader.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetReaderAtDetailContents11
public static XmlDictionaryReader GetReaderAtDetailContents11(string detailName, string detailNamespace, XmlDictionaryReader headerReader)
{
XmlDictionaryString namespaceUri = DXD.Wsrm11Dictionary.Namespace;
headerReader.ReadFullStartElement(XD.WsrmFeb2005Dictionary.SequenceFault, namespaceUri);
headerReader.Skip();
headerReader.ReadFullStartElement(XD.Message12Dictionary.FaultDetail, namespaceUri);
if (((headerReader.NodeType == XmlNodeType.Element) && !(headerReader.NamespaceURI != detailNamespace)) && !(headerReader.LocalName != detailName))
{
return headerReader;
}
headerReader.Close();
return null;
}
示例2: GetReaderAtDetailContentsFeb2005
public static XmlDictionaryReader GetReaderAtDetailContentsFeb2005(string detailName, string detailNamespace, XmlDictionaryReader headerReader)
{
XmlDictionaryReader reader;
try
{
WsrmFeb2005Dictionary dictionary = XD.WsrmFeb2005Dictionary;
XmlDictionaryString namespaceUri = dictionary.Namespace;
XmlBuffer buffer = null;
int sectionIndex = 0;
int depth = headerReader.Depth;
headerReader.ReadFullStartElement(dictionary.SequenceFault, namespaceUri);
while (headerReader.Depth > depth)
{
if (((headerReader.NodeType == XmlNodeType.Element) && (headerReader.NamespaceURI == detailNamespace)) && (headerReader.LocalName == detailName))
{
if (buffer != null)
{
return null;
}
buffer = new XmlBuffer(0x7fffffff);
try
{
sectionIndex = buffer.SectionCount;
buffer.OpenSection(headerReader.Quotas).WriteNode(headerReader, false);
continue;
}
finally
{
buffer.CloseSection();
}
}
if (headerReader.Depth == depth)
{
break;
}
headerReader.Read();
}
if (buffer == null)
{
return null;
}
buffer.Close();
reader = buffer.GetReader(sectionIndex);
}
finally
{
headerReader.Close();
}
return reader;
}
示例3: MessageNumberRolloverFault
public MessageNumberRolloverFault(FaultCode code, FaultReason reason, XmlDictionaryReader detailReader, ReliableMessagingVersion reliableMessagingVersion) : base(code, "MessageNumberRollover", reason, true, true)
{
try
{
base.SequenceID = WsrmUtilities.ReadIdentifier(detailReader, reliableMessagingVersion);
if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
{
ulong num;
detailReader.ReadStartElement(DXD.Wsrm11Dictionary.MaxMessageNumber, WsrmIndex.GetNamespace(reliableMessagingVersion));
if (!ulong.TryParse(detailReader.ReadContentAsString(), out num) || (num <= 0L))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidSequenceNumber", new object[] { num })));
}
detailReader.ReadEndElement();
}
}
finally
{
detailReader.Close();
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:21,代码来源:MessageNumberRolloverFault.cs
示例4: MessageNumberRolloverFault
public MessageNumberRolloverFault(FaultCode code, FaultReason reason, XmlDictionaryReader detailReader,
ReliableMessagingVersion reliableMessagingVersion)
: base(code, WsrmFeb2005Strings.MessageNumberRollover, reason, true, true)
{
try
{
this.SequenceID = WsrmUtilities.ReadIdentifier(detailReader, reliableMessagingVersion);
if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
{
detailReader.ReadStartElement(DXD.Wsrm11Dictionary.MaxMessageNumber,
WsrmIndex.GetNamespace(reliableMessagingVersion));
string maxMessageNumberString = detailReader.ReadContentAsString();
ulong maxMessageNumber;
if (!UInt64.TryParse(maxMessageNumberString, out maxMessageNumber)
|| (maxMessageNumber <= 0))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(
SR.GetString(SR.InvalidSequenceNumber, maxMessageNumber)));
}
// otherwise ignore value
detailReader.ReadEndElement();
}
}
finally
{
detailReader.Close();
}
}
示例5: ParseDetail
static UniqueId ParseDetail(XmlDictionaryReader reader, ReliableMessagingVersion reliableMessagingVersion)
{
try
{
return WsrmUtilities.ReadIdentifier(reader, reliableMessagingVersion);
}
finally
{
reader.Close();
}
}
示例6: GetSubcode
public static string GetSubcode(XmlDictionaryReader headerReader, ReliableMessagingVersion reliableMessagingVersion)
{
string localName = null;
try
{
string str3;
WsrmFeb2005Dictionary dictionary = XD.WsrmFeb2005Dictionary;
XmlDictionaryString namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);
headerReader.ReadStartElement(dictionary.SequenceFault, namespaceUri);
headerReader.ReadStartElement(dictionary.FaultCode, namespaceUri);
XmlUtil.ReadContentAsQName(headerReader, out localName, out str3);
if (str3 != WsrmIndex.GetNamespaceString(reliableMessagingVersion))
{
localName = null;
}
headerReader.ReadEndElement();
while (headerReader.IsStartElement())
{
headerReader.Skip();
}
headerReader.ReadEndElement();
}
finally
{
headerReader.Close();
}
return localName;
}
示例7: GetHeaderId
void GetHeaderId(
XmlDictionaryReader reader,
SecurityIdGenerator securityIdGenerator,
bool closeReader,
out string headerId,
out bool idInserted)
{
// Look if the header already has a discovery Id attribute defined
headerId = reader.GetAttribute(ProtocolStrings.IdAttributeName, this.DiscoveryInfo.DiscoveryNamespace);
if (closeReader)
{
reader.Close();
}
idInserted = false;
if (String.IsNullOrEmpty(headerId))
{
// The header doesn't contain a d:Id, so generate one.
headerId = securityIdGenerator.GenerateId();
idInserted = true;
}
}
示例8: ReadString
public void ReadString ()
{
reader = CreateReader ("\"true\"");
Assert.AreEqual (ReadState.Initial, reader.ReadState, "#1");
reader.Read (); // dummy root element
Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#2");
Assert.AreEqual (XmlNodeType.Element, reader.NodeType, "#2-1");
Assert.AreEqual ("root", reader.LocalName, "#2-2");
Assert.AreEqual ("string", reader.GetAttribute ("type"), "#2-3");
reader.Read (); // content (number)
Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#3");
Assert.AreEqual (XmlNodeType.Text, reader.NodeType, "#3-1");
Assert.AreEqual ("true", reader.Value, "#3-2");
reader.Read (); // endelement
Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#4");
Assert.AreEqual (XmlNodeType.EndElement, reader.NodeType, "#4-1");
reader.Read (); // endoffile
Assert.AreEqual (ReadState.EndOfFile, reader.ReadState, "#5");
reader.Close ();
Assert.AreEqual (ReadState.Closed, reader.ReadState, "#6");
}
示例9: ReadStateArray
public void ReadStateArray ()
{
reader = CreateReader ("[]");
Assert.AreEqual (ReadState.Initial, reader.ReadState, "#1");
reader.Read (); // element
Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#2");
reader.Read (); // endelement
Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#3");
reader.Read (); // endoffile
Assert.AreEqual (ReadState.EndOfFile, reader.ReadState, "#4");
reader.Close ();
Assert.AreEqual (ReadState.Closed, reader.ReadState, "#5");
}
示例10: ReadNull
public void ReadNull ()
{
reader = CreateReader ("null");
Assert.AreEqual (ReadState.Initial, reader.ReadState, "#1");
reader.Read (); // dummy root element
Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#2");
Assert.AreEqual (XmlNodeType.Element, reader.NodeType, "#2-1");
Assert.AreEqual ("root", reader.LocalName, "#2-2");
// When it is null, the value is never given and the reader is skipped to the end element.
reader.Read (); // endlement
Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#3");
Assert.AreEqual (XmlNodeType.EndElement, reader.NodeType, "#3-1");
reader.Read (); // endoffile
Assert.AreEqual (ReadState.EndOfFile, reader.ReadState, "#4");
reader.Close ();
Assert.AreEqual (ReadState.Closed, reader.ReadState, "#4");
}
示例11: ReadStateEmpty2
public void ReadStateEmpty2 ()
{
reader = CreateReader (" ");
Assert.AreEqual (ReadState.Initial, reader.ReadState, "#1");
reader.Read ();
Assert.AreEqual (ReadState.EndOfFile, reader.ReadState, "#2");
reader.Close ();
Assert.AreEqual (ReadState.Closed, reader.ReadState, "#3");
}
示例12: CloseAndMoveToFirstAttribute
// hmm... [ExpectedException (typeof (InvalidOperationException))]
public void CloseAndMoveToFirstAttribute ()
{
reader = CreateReader ("{}");
reader.Close ();
reader.MoveToFirstAttribute ();
}
示例13: CloseAndRead
// hmm... [ExpectedException (typeof (InvalidOperationException))]
public void CloseAndRead ()
{
reader = CreateReader ("{}");
reader.Close ();
reader.Read ();
}
示例14: GetReaderAtDetailContentsFeb2005
public static XmlDictionaryReader GetReaderAtDetailContentsFeb2005(string detailName, string detailNamespace,
XmlDictionaryReader headerReader)
{
try
{
WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary;
XmlDictionaryString wsrmNs = wsrmFeb2005Dictionary.Namespace;
XmlBuffer buffer = null;
int index = 0;
int depth = headerReader.Depth;
headerReader.ReadFullStartElement(wsrmFeb2005Dictionary.SequenceFault, wsrmNs);
while (headerReader.Depth > depth)
{
if ((headerReader.NodeType == XmlNodeType.Element)
&& (headerReader.NamespaceURI == detailNamespace)
&& (headerReader.LocalName == detailName))
{
if (buffer != null)
{
return null;
}
buffer = new XmlBuffer(int.MaxValue);
try
{
index = buffer.SectionCount;
XmlDictionaryWriter writer = buffer.OpenSection(headerReader.Quotas);
// WriteNode moves the reader to the next sibling.
writer.WriteNode(headerReader, false);
}
finally
{
buffer.CloseSection();
}
}
else
{
if (headerReader.Depth == depth)
break;
headerReader.Read();
}
}
// Ensure at least one detail is found;
if (buffer == null)
{
return null;
}
// Close causes a state change. It moves the buffer from Created to Reading.
buffer.Close();
XmlDictionaryReader detailReader = buffer.GetReader(index);
return detailReader;
}
finally
{
headerReader.Close();
}
}
示例15: CloseTwice
public void CloseTwice ()
{
reader = CreateReader ("{}");
reader.Close ();
reader.Close ();
}