Example #1
0
 private Message ValidateMessage(Message message)
 {
     if (this.validateHeader && (message != null))
     {
         PacketRoutableHeader.ValidateMessage(message);
     }
     return(message);
 }
Example #2
0
                private bool HandleReceiveRequestComplete(IAsyncResult result)
                {
                    this.context = this.OnEndReceiveRequest(result);
                    if (this.context == null)
                    {
                        return(true);
                    }
                    bool         flag    = false;
                    IAsyncResult result2 = null;

                    try
                    {
                        this.message = this.context.RequestMessage;
                        this.message.Properties.Add(RequestContextMessageProperty.Name, new RequestContextMessageProperty(this.context));
                        if (this.validateHeader)
                        {
                            PacketRoutableHeader.ValidateMessage(this.message);
                        }
                        try
                        {
                            result2 = this.context.BeginReply(null, this.timeoutHelper.RemainingTime(), onReply, this);
                            flag    = true;
                        }
                        catch (CommunicationException exception)
                        {
                            if (DiagnosticUtility.ShouldTraceInformation)
                            {
                                DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
                            }
                        }
                        catch (TimeoutException exception2)
                        {
                            if (DiagnosticUtility.ShouldTraceInformation)
                            {
                                DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
                            }
                        }
                    }
                    finally
                    {
                        if (!flag)
                        {
                            this.context.Abort();
                            if (this.message != null)
                            {
                                this.message.Close();
                                this.message = null;
                            }
                        }
                    }
                    return((result2 == null) || (result2.CompletedSynchronously && this.HandleReplyComplete(result2)));
                }
Example #3
0
            private Message ProcessContext(RequestContext context, TimeSpan timeout)
            {
                if (context == null)
                {
                    return(null);
                }
                bool    flag           = false;
                Message requestMessage = null;

                try
                {
                    requestMessage = context.RequestMessage;
                    requestMessage.Properties.Add(RequestContextMessageProperty.Name, new RequestContextMessageProperty(context));
                    if (this.validateHeader)
                    {
                        PacketRoutableHeader.ValidateMessage(requestMessage);
                    }
                    try
                    {
                        context.Reply(null, new TimeoutHelper(timeout).RemainingTime());
                        flag = true;
                    }
                    catch (CommunicationException exception)
                    {
                        if (DiagnosticUtility.ShouldTraceInformation)
                        {
                            DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
                        }
                    }
                    catch (TimeoutException exception2)
                    {
                        if (DiagnosticUtility.ShouldTraceInformation)
                        {
                            DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
                        }
                    }
                }
                finally
                {
                    if (!flag)
                    {
                        context.Abort();
                        if (requestMessage != null)
                        {
                            requestMessage.Close();
                            requestMessage = null;
                        }
                    }
                }
                return(requestMessage);
            }