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));
}
}