static OleTxTransactionHeader ReadFrom(XmlDictionaryReader reader)
        {
            WsatExtendedInformation info = null;

            if (reader.IsStartElement(XD.OleTxTransactionExternalDictionary.OleTxTransaction,
                                      XD.OleTxTransactionExternalDictionary.Namespace))
            {
                string identifier = reader.GetAttribute(XD.CoordinationExternalDictionary.Identifier, CoordinationNamespace);

                if (!string.IsNullOrEmpty(identifier))
                {
                    // Verify identifier is really a URI
                    Uri uri;
                    if (!Uri.TryCreate(identifier, UriKind.Absolute, out uri))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.InvalidWsatExtendedInfo)));
                    }
                }

                string attr = reader.GetAttribute(XD.CoordinationExternalDictionary.Expires, CoordinationNamespace);

                uint timeout = 0;
                if (!string.IsNullOrEmpty(attr))
                {
                    try
                    {
                        timeout = XmlConvert.ToUInt32(attr);
                    }
                    catch (FormatException e)
                    {
                        DiagnosticUtility.TraceHandledException(e, TraceEventType.Error);
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.InvalidWsatExtendedInfo), e));
                    }
                    catch (OverflowException e)
                    {
                        DiagnosticUtility.TraceHandledException(e, TraceEventType.Error);
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.InvalidWsatExtendedInfo), e));
                    }
                }

                if (!string.IsNullOrEmpty(identifier) || timeout != 0)
                {
                    info = new WsatExtendedInformation(identifier, timeout);
                }
            }

            reader.ReadFullStartElement(XD.OleTxTransactionExternalDictionary.OleTxTransaction,
                                        XD.OleTxTransactionExternalDictionary.Namespace);

            byte[] propagationToken = ReadPropagationTokenElement(reader);

            // Skip extensibility elements...
            while (reader.IsStartElement())
            {
                reader.Skip();
            }
            reader.ReadEndElement();

            return(new OleTxTransactionHeader(propagationToken, info));
        }
        public override Transaction UnmarshalTransaction()
        {
            Transaction tx;

            if (WsatIncomingTransactionCache.Find(this.context.Identifier, out tx))
                return tx;

            tx = this.wsatProxy.UnmarshalTransaction(this);

            // Cache extended information for subsequent marshal operations
            WsatExtendedInformation info = new WsatExtendedInformation(context.Identifier, context.Expires);
            info.TryCache(tx);

            // Cache the unmarshalled transaction for subsequent unmarshal operations
            WsatIncomingTransactionCache.Cache(this.context.Identifier, tx);

            return tx;
        }
        public override Transaction UnmarshalTransaction()
        {
            Transaction tx;

            if (WsatIncomingTransactionCache.Find(this.context.Identifier, out tx))
            {
                return(tx);
            }

            tx = this.wsatProxy.UnmarshalTransaction(this);

            // Cache extended information for subsequent marshal operations
            WsatExtendedInformation info = new WsatExtendedInformation(context.Identifier, context.Expires);

            info.TryCache(tx);

            // Cache the unmarshalled transaction for subsequent unmarshal operations
            WsatIncomingTransactionCache.Cache(this.context.Identifier, tx);

            return(tx);
        }
 public OleTxTransactionHeader(byte[] propagationToken, WsatExtendedInformation wsatInfo)
 {
     this.propagationToken = propagationToken;
     this.wsatInfo         = wsatInfo;
 }
 public OleTxTransactionHeader(byte[] propagationToken, WsatExtendedInformation wsatInfo)
 {
     this.propagationToken = propagationToken;
     this.wsatInfo = wsatInfo;
 }
        static OleTxTransactionHeader ReadFrom(XmlDictionaryReader reader)
        {
            WsatExtendedInformation info = null;

            if (reader.IsStartElement(XD.OleTxTransactionExternalDictionary.OleTxTransaction,
                                      XD.OleTxTransactionExternalDictionary.Namespace))
            {
                string identifier = reader.GetAttribute(XD.CoordinationExternalDictionary.Identifier, CoordinationNamespace);

                if (!string.IsNullOrEmpty(identifier))
                {
                    // Verify identifier is really a URI
                    Uri uri;
                    if (!Uri.TryCreate(identifier, UriKind.Absolute, out uri))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.InvalidWsatExtendedInfo)));
                    }
                }

                string attr = reader.GetAttribute(XD.CoordinationExternalDictionary.Expires, CoordinationNamespace);

                uint timeout = 0;
                if (!string.IsNullOrEmpty(attr))
                {
                    try
                    {
                        timeout = XmlConvert.ToUInt32(attr);
                    }
                    catch (FormatException e)
                    {
                        DiagnosticUtility.TraceHandledException(e, TraceEventType.Error);
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.InvalidWsatExtendedInfo), e));
                    }
                    catch (OverflowException e)
                    {
                        DiagnosticUtility.TraceHandledException(e, TraceEventType.Error);
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.InvalidWsatExtendedInfo), e));
                    }
                }

                if (!string.IsNullOrEmpty(identifier) || timeout != 0)
                {
                    info = new WsatExtendedInformation(identifier, timeout);
                }
            }

            reader.ReadFullStartElement(XD.OleTxTransactionExternalDictionary.OleTxTransaction,
                                        XD.OleTxTransactionExternalDictionary.Namespace);

            byte[] propagationToken = ReadPropagationTokenElement(reader);

            // Skip extensibility elements...
            while (reader.IsStartElement())
            {
                reader.Skip();
            }
            reader.ReadEndElement();

            return new OleTxTransactionHeader(propagationToken, info);
        }