public Message Request(Message message, TimeSpan timeout)
        {
            CorrelationCallbackMessageProperty property = null;
            TimeoutHelper helper   = new TimeoutHelper(timeout);
            Message       message2 = message;

            this.contextProtocol.OnOutgoingMessage(message, null);
            if ((message != null) && CorrelationCallbackMessageProperty.TryGet(message, out property))
            {
                ContextExchangeCorrelationHelper.AddOutgoingCorrelationCallbackData(property, message, true);
                if (property.IsFullyDefined)
                {
                    message2 = property.FinalizeCorrelation(message, helper.RemainingTime());
                }
            }
            Message message3 = null;

            try
            {
                message3 = base.InnerChannel.Request(message2, timeout);
                if (message3 != null)
                {
                    this.contextProtocol.OnIncomingMessage(message3);
                }
            }
            finally
            {
                if ((message != null) && !object.ReferenceEquals(message, message2))
                {
                    message2.Close();
                }
            }
            return(message3);
        }
예제 #2
0
        public void Send(Message message, TimeSpan timeout)
        {
            CorrelationCallbackMessageProperty property = null;
            TimeoutHelper helper   = new TimeoutHelper(timeout);
            Message       message2 = message;

            if (message != null)
            {
                this.ContextProtocol.OnOutgoingMessage(message, null);
                if (CorrelationCallbackMessageProperty.TryGet(message, out property))
                {
                    ContextExchangeCorrelationHelper.AddOutgoingCorrelationCallbackData(property, message, this.IsClient);
                    if (property.IsFullyDefined)
                    {
                        message2 = property.FinalizeCorrelation(message, helper.RemainingTime());
                    }
                }
            }
            try
            {
                base.InnerChannel.Send(message2, helper.RemainingTime());
            }
            finally
            {
                if ((message != null) && !object.ReferenceEquals(message, message2))
                {
                    message2.Close();
                }
            }
        }
예제 #3
0
        public void Send(Message message, TimeSpan timeout)
        {
            CorrelationCallbackMessageProperty callback = null;
            TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
            Message       sendMessage   = message;

            if (message != null)
            {
                this.ContextProtocol.OnOutgoingMessage(message, null);
                if (CorrelationCallbackMessageProperty.TryGet(message, out callback))
                {
                    ContextExchangeCorrelationHelper.AddOutgoingCorrelationCallbackData(callback, message, this.IsClient);
                    if (callback.IsFullyDefined)
                    {
                        sendMessage = callback.FinalizeCorrelation(message, timeoutHelper.RemainingTime());
                    }
                }
            }

            try
            {
                this.InnerChannel.Send(sendMessage, timeoutHelper.RemainingTime());
            }
            finally
            {
                if (message != null && !object.ReferenceEquals(message, sendMessage))
                {
                    sendMessage.Close();
                }
            }
        }
        public Message Request(Message message, TimeSpan timeout)
        {
            CorrelationCallbackMessageProperty callback = null;
            TimeoutHelper timeoutHelper  = new TimeoutHelper(timeout);
            Message       requestMessage = message;

            this.contextProtocol.OnOutgoingMessage(message, null);
            if (message != null && CorrelationCallbackMessageProperty.TryGet(message, out callback))
            {
                ContextExchangeCorrelationHelper.AddOutgoingCorrelationCallbackData(callback, message, true);
                if (callback.IsFullyDefined)
                {
                    requestMessage = callback.FinalizeCorrelation(message, timeoutHelper.RemainingTime());
                }
            }

            Message response = null;

            try
            {
                response = this.InnerChannel.Request(requestMessage, timeout);
                if (response != null)
                {
                    this.contextProtocol.OnIncomingMessage(response);
                }
            }
            finally
            {
                if (message != null && !object.ReferenceEquals(message, requestMessage))
                {
                    requestMessage.Close();
                }
            }

            return(response);
        }