本文整理汇总了C#中System.Xml.XmlDictionaryReader.ReadElementContentAsGuid方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryReader.ReadElementContentAsGuid方法的具体用法?C# XmlDictionaryReader.ReadElementContentAsGuid怎么用?C# XmlDictionaryReader.ReadElementContentAsGuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryReader
的用法示例。
在下文中一共展示了XmlDictionaryReader.ReadElementContentAsGuid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadFrom
private static void ReadFrom(CoordinationContext that, XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString ns, Microsoft.Transactions.Wsat.Protocol.ProtocolVersion protocolVersion)
{
try
{
Uri uri;
CoordinationXmlDictionaryStrings strings = CoordinationXmlDictionaryStrings.Version(protocolVersion);
AtomicTransactionStrings strings2 = AtomicTransactionStrings.Version(protocolVersion);
reader.ReadFullStartElement(localName, strings.Namespace);
reader.MoveToStartElement(strings.Identifier, strings.Namespace);
that.unknownIdentifierAttributes = ReadOtherAttributes(reader, strings.Namespace);
that.contextId = reader.ReadElementContentAsString().Trim();
if ((that.contextId.Length == 0) || (that.contextId.Length > 0x100))
{
throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext")));
}
if (!Uri.TryCreate(that.contextId, UriKind.Absolute, out uri))
{
throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext")));
}
if (reader.IsStartElement(strings.Expires, strings.Namespace))
{
that.unknownExpiresAttributes = ReadOtherAttributes(reader, strings.Namespace);
int num = reader.ReadElementContentAsInt();
if (num < 0)
{
throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext")));
}
that.expiration = (uint) num;
that.expiresPresent = true;
}
reader.MoveToStartElement(strings.CoordinationType, strings.Namespace);
if (reader.ReadElementContentAsString().Trim() != strings2.Namespace)
{
throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext")));
}
that.registrationRef = EndpointAddress.ReadFrom(MessagingVersionHelper.AddressingVersion(protocolVersion), reader, strings.RegistrationService, strings.Namespace);
if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.IsolationLevel, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
{
that.isoLevel = (System.Transactions.IsolationLevel) reader.ReadElementContentAsInt();
if (((that.IsolationLevel < System.Transactions.IsolationLevel.Serializable) || (that.IsolationLevel > System.Transactions.IsolationLevel.Unspecified)) || (that.IsolationLevel == System.Transactions.IsolationLevel.Snapshot))
{
throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext")));
}
}
if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.IsolationFlags, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
{
that.isoFlags = (System.ServiceModel.Transactions.IsolationFlags) reader.ReadElementContentAsInt();
}
if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.Description, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
{
that.description = reader.ReadElementContentAsString().Trim();
}
if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.LocalTransactionId, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
{
that.localTxId = reader.ReadElementContentAsGuid();
}
if (OleTxTransactionHeader.IsStartPropagationTokenElement(reader))
{
that.propToken = OleTxTransactionHeader.ReadPropagationTokenElement(reader);
}
if (reader.IsStartElement())
{
XmlDocument document = new XmlDocument();
that.unknownData = new List<System.Xml.XmlNode>(5);
while (reader.IsStartElement())
{
System.Xml.XmlNode item = document.ReadNode(reader);
that.unknownData.Add(item);
}
}
reader.ReadEndElement();
}
catch (XmlException exception)
{
throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"), exception));
}
}
示例2: ReadFrom
static WsatRegistrationHeader ReadFrom(XmlDictionaryReader reader)
{
reader.ReadFullStartElement(XD.DotNetAtomicTransactionExternalDictionary.RegisterInfo,
XD.DotNetAtomicTransactionExternalDictionary.Namespace);
reader.MoveToStartElement(XD.DotNetAtomicTransactionExternalDictionary.LocalTransactionId,
XD.DotNetAtomicTransactionExternalDictionary.Namespace);
// TransactionId
Guid transactionId = reader.ReadElementContentAsGuid();
if (transactionId == Guid.Empty)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new XmlException(SR.GetString(SR.InvalidRegistrationHeaderTransactionId)));
}
// ContextId
string contextId;
if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.ContextId,
XD.DotNetAtomicTransactionExternalDictionary.Namespace))
{
Uri uri;
contextId = reader.ReadElementContentAsString().Trim();
if (contextId.Length == 0 ||
contextId.Length > CoordinationContext.MaxIdentifierLength ||
!Uri.TryCreate(contextId, UriKind.Absolute, out uri))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new XmlException(SR.GetString(SR.InvalidRegistrationHeaderIdentifier)));
}
}
else
{
contextId = null;
}
// TokenId
string tokenId;
if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.TokenId,
XD.DotNetAtomicTransactionExternalDictionary.Namespace))
{
tokenId = reader.ReadElementContentAsString().Trim();
if (tokenId.Length == 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new XmlException(SR.GetString(SR.InvalidRegistrationHeaderTokenId)));
}
}
else
{
tokenId = null;
}
// Skip unknown elements
while (reader.IsStartElement())
{
reader.Skip();
}
reader.ReadEndElement();
return new WsatRegistrationHeader(transactionId, contextId, tokenId);
}
示例3: ReadFrom
public static void ReadFrom(XmlDictionaryReader reader, out Guid enlistment, out ControlProtocol protocol)
{
try
{
if (reader.IsEmptyElement || !reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.Enlistment, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
{
throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnlistmentHeaderException(Microsoft.Transactions.SR.GetString("InvalidEnlistmentHeader")));
}
string attribute = reader.GetAttribute(XD.DotNetAtomicTransactionExternalDictionary.Protocol, XD.DotNetAtomicTransactionExternalDictionary.Namespace);
if (attribute == null)
{
protocol = ControlProtocol.None;
}
else
{
protocol = (ControlProtocol) XmlConvert.ToInt32(attribute.Trim());
if ((protocol != ControlProtocol.Durable2PC) && (protocol != ControlProtocol.Volatile2PC))
{
throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnlistmentHeaderException(Microsoft.Transactions.SR.GetString("InvalidEnlistmentHeader")));
}
}
enlistment = reader.ReadElementContentAsGuid();
}
catch (FormatException exception)
{
Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning);
throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnlistmentHeaderException(Microsoft.Transactions.SR.GetString("InvalidEnlistmentHeader"), exception));
}
catch (OverflowException exception2)
{
Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Warning);
throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnlistmentHeaderException(Microsoft.Transactions.SR.GetString("InvalidEnlistmentHeader"), exception2));
}
catch (XmlException exception3)
{
Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception3, TraceEventType.Warning);
throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnlistmentHeaderException(Microsoft.Transactions.SR.GetString("InvalidEnlistmentHeader"), exception3));
}
}
示例4: ReadFrom
private void ReadFrom(XmlDictionaryReader reader)
{
try
{
reader.ReadFullStartElement(this.coordinationXmlDictionaryStrings.Register, this.coordinationXmlDictionaryStrings.Namespace);
reader.MoveToStartElement(this.coordinationXmlDictionaryStrings.Protocol, this.coordinationXmlDictionaryStrings.Namespace);
this.Protocol = WSAtomicTransactionStrings.WellKnownNameToProtocol(reader.ReadElementContentAsString().Trim(), this.protocolVersion);
if (this.Protocol == ControlProtocol.None)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody")));
}
this.ParticipantProtocolService = EndpointAddress.ReadFrom(MessagingVersionHelper.AddressingVersion(this.protocolVersion), reader, this.coordinationXmlDictionaryStrings.ParticipantProtocolService, this.coordinationXmlDictionaryStrings.Namespace);
if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.Loopback, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
{
this.Loopback = reader.ReadElementContentAsGuid();
}
while (reader.IsStartElement())
{
reader.Skip();
}
reader.ReadEndElement();
}
catch (XmlException exception)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody"), exception));
}
}
示例5: ReadFrom
private static WsatRegistrationHeader ReadFrom(XmlDictionaryReader reader)
{
string str;
string str2;
reader.ReadFullStartElement(XD.DotNetAtomicTransactionExternalDictionary.RegisterInfo, XD.DotNetAtomicTransactionExternalDictionary.Namespace);
reader.MoveToStartElement(XD.DotNetAtomicTransactionExternalDictionary.LocalTransactionId, XD.DotNetAtomicTransactionExternalDictionary.Namespace);
Guid transactionId = reader.ReadElementContentAsGuid();
if (transactionId == Guid.Empty)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidRegistrationHeaderTransactionId")));
}
if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.ContextId, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
{
Uri uri;
str = reader.ReadElementContentAsString().Trim();
if (((str.Length == 0) || (str.Length > 0x100)) || !Uri.TryCreate(str, UriKind.Absolute, out uri))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidRegistrationHeaderIdentifier")));
}
}
else
{
str = null;
}
if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.TokenId, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
{
str2 = reader.ReadElementContentAsString().Trim();
if (str2.Length == 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidRegistrationHeaderTokenId")));
}
}
else
{
str2 = null;
}
while (reader.IsStartElement())
{
reader.Skip();
}
reader.ReadEndElement();
return new WsatRegistrationHeader(transactionId, str, str2);
}