Example #1
0
        public TestHttpRequestMessageProperty EchoHttpRequestMessageProperty()
        {
            object obj;
            MessageProperties properties = new MessageProperties(OperationContext.Current.IncomingMessageProperties);
            if (properties.TryGetValue(HttpRequestMessageProperty.Name, out obj))
            {
                HttpRequestMessageProperty property = (HttpRequestMessageProperty)obj;
                if (property != null)
                {
                    TestHttpRequestMessageProperty testProperty = new TestHttpRequestMessageProperty();
                    testProperty.SuppressEntityBody = property.SuppressEntityBody;
                    testProperty.Method = property.Method;
                    testProperty.QueryString = property.QueryString;

                    WebHeaderCollection collection = property.Headers;
                    foreach (string s in collection.AllKeys)
                    {
                        string[] values = collection.GetValues(s);
                        testProperty.Headers.Add(s, String.Join(",", values));
                    }
                    return testProperty;
                }
            }

            return null;
        }
Example #2
0
        public Dictionary<string, string> ValidateMessagePropertyHeaders()
        {
            Dictionary<string, string> headerCollection = new Dictionary<string, string>();
            try
            {
                HttpRequestMessageProperty property;
                object obj;
                MessageProperties properties = new MessageProperties(OperationContext.Current.IncomingMessageProperties);
                if (properties.TryGetValue(HttpRequestMessageProperty.Name, out obj))
                {
                    property = obj as HttpRequestMessageProperty;
                    WebHeaderCollection collection = property.Headers;

                    string[] headers = collection.AllKeys;
                    foreach (string s in headers)
                    {
                        string[] values = collection.GetValues(s);
                        headerCollection.Add(s, String.Join(",", values));
                    }
                }
                else
                {
                    headerCollection.Add("ERROR", "No HttpRequestMessageProperty was found!");
                }
            }
            catch (Exception ex)
            {
                headerCollection.Add("ERROR", string.Format("An exception was thrown: {0}", ex.Message));
            }

            return headerCollection;
        }
Example #3
0
        public Dictionary <string, string> ValidateMessagePropertyHeaders()
        {
            Dictionary <string, string> headerCollection = new Dictionary <string, string>();

            try
            {
                HttpRequestMessageProperty property;
                object            obj;
                MessageProperties properties = new MessageProperties(OperationContext.Current.IncomingMessageProperties);
                if (properties.TryGetValue(HttpRequestMessageProperty.Name, out obj))
                {
                    property = obj as HttpRequestMessageProperty;
                    WebHeaderCollection collection = property.Headers;

                    string[] headers = collection.AllKeys;
                    foreach (string s in headers)
                    {
                        string[] values = collection.GetValues(s);
                        headerCollection.Add(s, String.Join(",", values));
                    }
                }
                else
                {
                    headerCollection.Add("ERROR", "No HttpRequestMessageProperty was found!");
                }
            }
            catch (Exception ex)
            {
                headerCollection.Add("ERROR", string.Format("An exception was thrown: {0}", ex.Message));
            }

            return(headerCollection);
        }
Example #4
0
        public TestHttpRequestMessageProperty EchoHttpRequestMessageProperty()
        {
            object            obj;
            MessageProperties properties = new MessageProperties(OperationContext.Current.IncomingMessageProperties);

            if (properties.TryGetValue(HttpRequestMessageProperty.Name, out obj))
            {
                HttpRequestMessageProperty property = (HttpRequestMessageProperty)obj;
                if (property != null)
                {
                    TestHttpRequestMessageProperty testProperty = new TestHttpRequestMessageProperty();
                    testProperty.SuppressEntityBody = property.SuppressEntityBody;
                    testProperty.Method             = property.Method;
                    testProperty.QueryString        = property.QueryString;

                    WebHeaderCollection collection = property.Headers;
                    foreach (string s in collection.AllKeys)
                    {
                        string[] values = collection.GetValues(s);
                        testProperty.Headers.Add(s, String.Join(",", values));
                    }
                    return(testProperty);
                }
            }

            return(null);
        }
        /// <summary>
        /// 生成当前请求日志对象
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public QZ.RealTimeRequestLogService.RequestLog LogInccomingRequest(Message req)
        {
            var oc = System.ServiceModel.OperationContext.Current;

            QZ.RealTimeRequestLogService.RequestLog log = new RealTimeRequestLogService.RequestLog();
            //log.Ip = ip;
            MessageProperties mps = req.Properties;

            object obj;

            if (mps.TryGetValue("Via", out obj))
            {
                Uri uri = (Uri)obj;
                log.Url     = uri.PathAndQuery;
                log.FullUrl = uri.OriginalString;
            }

            if (mps.TryGetValue("httpRequest", out obj))
            {
                HttpRequestMessageProperty http = (HttpRequestMessageProperty)obj;
                log.Headers   = http.Headers.ToString();
                log.Method    = http.Method;
                log.UserAgent = http.Headers[System.Net.HttpRequestHeader.UserAgent];
            }

            if (mps.TryGetValue("System.ServiceModel.Channels.RemoteEndpointMessageProperty", out obj))
            {
                RemoteEndpointMessageProperty ep = (RemoteEndpointMessageProperty)obj;
                log.Ip = string.Format("{0}:{1}", ep.Address, ep.Port);
            }

            if (mps.TryGetValue("UriTemplateMatchResults", out obj))
            {
                UriTemplateMatch utm = (UriTemplateMatch)obj;
                log.UrlTemplate = utm.Template.ToString();
            }

            if (mps.TryGetValue("HttpOperationName", out obj))
            {
                log.ActionName = (string)obj;
            }


            log.Form = GetRequestBody(req);

            return(log);
        }
Example #6
0
        static internal void SetActivityId(MessageProperties properties)
        {
            Guid activityId;

            if ((null != properties) && properties.TryGetValue(TraceUtility.E2EActivityId, out activityId))
            {
                DiagnosticTraceBase.ActivityId = activityId;
            }
        }
Example #7
0
        private static T GetProperty <T>(MessageProperties properties, string propertyName) where T : class
        {
            if (properties.TryGetValue(propertyName, out var value))
            {
                return(value as T);
            }

            return(null);
        }
 bool MatchInternal(MessageProperties messageProperties)
 {
     object value;
     if (messageProperties.TryGetValue(EndpointNameKey, out value))
     {
         string messageEndpoint = value.ToString();
         return string.Equals(messageEndpoint, this.endpointName, StringComparison.Ordinal);
     }
     return false;
 }
        bool MatchInternal(MessageProperties messageProperties)
        {
            object value;

            if (messageProperties.TryGetValue(EndpointNameKey, out value))
            {
                string messageEndpoint = value.ToString();
                return(string.Equals(messageEndpoint, this.endpointName, StringComparison.Ordinal));
            }
            return(false);
        }
        internal static bool TryGetValue <TProperty>(this MessageProperties messageProperties, string name, out TProperty property)
        {
            object obj2;

            if (messageProperties.TryGetValue(name, out obj2))
            {
                property = (TProperty)obj2;
                return(true);
            }
            property = default(TProperty);
            return(false);
        }
 /// <summary>
 /// Checks if the HTTP method used is POST.
 /// </summary>
 /// <param name="properties">Properties for which the HTTP method is to be checked.</param>
 /// <returns><c>true</c> if the <paramref name="properties"/> specifies HTTP POST method.</returns>
 public static bool IsHttpPOSTMethod(MessageProperties properties)
 {
     object property;
     if (properties.TryGetValue(MessageUtility.HttpRequestName, out property))
     {
         HttpRequestMessageProperty httpMessageProperty = property as HttpRequestMessageProperty;
         if (httpMessageProperty != null && httpMessageProperty.Method.Equals(MessageUtility.HttpPostMethodName, StringComparison.OrdinalIgnoreCase))
         {
             return true;
         }
     }
     return false;
 }
 public static bool TryGet(MessageProperties properties, out BufferedReceiveMessageProperty property)
 {
     object obj2 = null;
     if (properties.TryGetValue("BufferedReceiveMessageProperty", out obj2))
     {
         property = obj2 as BufferedReceiveMessageProperty;
     }
     else
     {
         property = null;
     }
     return (property != null);
 }
Example #13
0
 private static void AddPropertiesToPropagate(
     this MessageProperties messageProperties,
     string propertiesToPropagateKey,
     IEnumerable <PropertyValuePair> propertiesToPropagate)
 {
     if (!propertiesToPropagate.Any())
     {
         return;
     }
     messageProperties[propertiesToPropagateKey] = messageProperties.TryGetValue(propertiesToPropagateKey, out var existingPropertiesToPropagate)
                                                   // Merge gives precedence to values coming from propertiesToPropagate over those coming from existingPropertiesToPropagate
                         ? propertiesToPropagate.Merge((List <PropertyValuePair>)existingPropertiesToPropagate)
                         : propertiesToPropagate.ToList();
 }
Example #14
0
        /// <summary>
        /// Checks if the HTTP method used is POST.
        /// </summary>
        /// <param name="properties">Properties for which the HTTP method is to be checked.</param>
        /// <returns><c>true</c> if the <paramref name="properties"/> specifies HTTP POST method.</returns>
        public static bool IsHttpPOSTMethod(MessageProperties properties)
        {
            object property;

            if (properties.TryGetValue(MessageUtility.HttpRequestName, out property))
            {
                HttpRequestMessageProperty httpMessageProperty = property as HttpRequestMessageProperty;
                if (httpMessageProperty != null && httpMessageProperty.Method.Equals(MessageUtility.HttpPostMethodName, StringComparison.OrdinalIgnoreCase))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #15
0
        internal static bool TryGet(MessageProperties messageProperties, out BrokeredMessageProperty property)
        {
            object obj;
            bool   flag = messageProperties.TryGetValue(BrokeredMessageProperty.Name, out obj);

            if (!flag)
            {
                property = null;
            }
            else
            {
                property = (BrokeredMessageProperty)obj;
            }
            return(flag);
        }
        public static bool TryGet(MessageProperties properties, out BufferedReceiveMessageProperty property)
        {
            Fx.Assert(properties != null, "The MessageProperties parameter is null");

            object value = null;
            if (properties.TryGetValue(PropertyName, out value))
            {
                property = value as BufferedReceiveMessageProperty;
            }
            else
            {
                property = null;
            }
            return property != null;
        }
        public static bool TryGet(MessageProperties properties, out ReceiveContext property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            property = null;
            object foundProperty;
            if (properties.TryGetValue(Name, out foundProperty))
            {
                property = (ReceiveContext)foundProperty;
                return true;
            }
            return false;
        }
Example #18
0
        private JsonRpcResponse <object> CreateResponse(object result)
        {
            var jsonResponse = new JsonRpcResponse <object>();

            jsonResponse.Result = result;

            object            messageId;
            MessageProperties inMsgProperties = OperationContext.Current.IncomingMessageProperties;

            if (inMsgProperties.TryGetValue(DispatcherUtils.MessageIdKey, out messageId))
            {
                jsonResponse.Id = messageId;
            }

            return(jsonResponse);
        }
 public static bool TryGet(MessageProperties properties, out ContextMessageProperty contextMessageProperty)
 {
     if (properties == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
     }
     object obj2 = null;
     if (properties.TryGetValue("ContextMessageProperty", out obj2))
     {
         contextMessageProperty = obj2 as ContextMessageProperty;
     }
     else
     {
         contextMessageProperty = null;
     }
     return (contextMessageProperty != null);
 }
        internal static bool TryGet(MessageProperties properties, out ChannelBindingMessageProperty property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(properties));
            }

            property = null;

            if (properties.TryGetValue(ChannelBindingMessageProperty.Name, out object value))
            {
                property = value as ChannelBindingMessageProperty;
                return(property != null);
            }

            return(false);
        }
Example #21
0
        public MessageInspector_CustomHeaderAuthentication.ResultObject <string> UserGetAuthToken()
        {
            MessageInspector_CustomHeaderAuthentication.ResultObject <string> resultObject = null;

            try
            {
                HttpRequestMessageProperty property;
                object            obj;
                MessageProperties properties = new MessageProperties(OperationContext.Current.IncomingMessageProperties);
                if (properties.TryGetValue(HttpRequestMessageProperty.Name, out obj))
                {
                    property = obj as HttpRequestMessageProperty;
                    WebHeaderCollection collection = property.Headers;
                    string authValue = collection.Get(Enum.GetName(typeof(HttpRequestHeader), HttpRequestHeader.Authorization));

                    if (authValue == "Not Allowed")
                    {
                        resultObject = MessageInspector_CustomHeaderAuthentication.ResultObject <string> .CreateFailureObject <string>();

                        resultObject.Result = resultObject.ResultMessage;
                    }
                    else if (authValue == "Allow")
                    {
                        resultObject = MessageInspector_CustomHeaderAuthentication.ResultObject <string> .CreateSuccessObject <string>();

                        resultObject.Result = resultObject.ResultMessage;
                    }
                }
                else
                {
                    resultObject = MessageInspector_CustomHeaderAuthentication.ResultObject <string> .CreateFailureObject <string>();

                    resultObject.Result        = "ERROR";
                    resultObject.ResultMessage = "No HttpRequestMessageProperty was found on the incoming Message.";
                }
            }
            catch (Exception ex)
            {
                resultObject = MessageInspector_CustomHeaderAuthentication.ResultObject <string> .CreateFailureObject <string>();

                resultObject.Result        = ex.ToString();
                resultObject.ResultMessage = ex.Message;
            }

            return(resultObject);
        }
        public static bool TryGet(MessageProperties properties, out ChannelBindingMessageProperty property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            property = null;
            object value;

            if (properties.TryGetValue(ChannelBindingMessageProperty.Name, out value))
            {
                property = value as ChannelBindingMessageProperty;
                return property != null;
            }

            return false;
        }
        public static bool TryGet(MessageProperties properties, out NetworkInterfaceMessageProperty property)
        {
            if (properties == null)
            {
                throw FxTrace.Exception.ArgumentNull("properties");
            }

            object value = null;
            if (properties.TryGetValue(PropertyName, out value))
            {
                property = value as NetworkInterfaceMessageProperty;
            }
            else
            {
                property = null;
            }
            return property != null;
        }
Example #24
0
        /// <summary>
        /// Gets the ImpersonateOnSerializingReplyMessageProperty property from MessageProperties.
        /// </summary>
        /// <param name="properties">The MessagePropeties object.</param>
        /// <param name="property">An output paramter to hold the ImpersonateOnSerializingReplyMessageProperty property.</param>
        /// <returns>True if the ImpersonateOnSerializingReplyMessageProperty property was found.</returns>
        public static bool TryGet(MessageProperties properties, out ImpersonateOnSerializingReplyMessageProperty property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(properties));
            }

            if (properties.TryGetValue(PropertyName, out object value))
            {
                property = value as ImpersonateOnSerializingReplyMessageProperty;
            }
            else
            {
                property = null;
            }

            return(property != null);
        }
        /// <summary>
        /// Gets the ImpersonateOnSerializingReplyMessageProperty property from MessageProperties.
        /// </summary>
        /// <param name="properties">The MessagePropeties object.</param>
        /// <param name="property">An output paramter to hold the ImpersonateOnSerializingReplyMessageProperty property.</param>
        /// <returns>True if the ImpersonateOnSerializingReplyMessageProperty property was found.</returns>
        public static bool TryGet(MessageProperties properties, out ImpersonateOnSerializingReplyMessageProperty property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            object value = null;
            if (properties.TryGetValue(PropertyName, out value))
            {
                property = value as ImpersonateOnSerializingReplyMessageProperty;
            }
            else
            {
                property = null;
            }

            return property != null;
        }
        /// <summary>
        /// Changes a HTTP GET into a POST.
        /// </summary>
        /// <param name="properties">Properties for which the HTTP method is to be changed.</param>
        public static void MakeHttpPOSTMethod(MessageProperties properties)
        {
            object property;
            HttpRequestMessageProperty httpMessageProperty = null;

            if (properties.TryGetValue(MessageUtility.HttpRequestName, out property))
            {
                httpMessageProperty = property as HttpRequestMessageProperty;
            }

            if (httpMessageProperty == null)
            {
                httpMessageProperty = new HttpRequestMessageProperty();
                properties.Add(MessageUtility.HttpRequestName, httpMessageProperty);
            }

            httpMessageProperty.Method = MessageUtility.HttpPostMethodName;
            httpMessageProperty.SuppressEntityBody = false;
        }
Example #27
0
        /// <summary>
        /// Changes a HTTP GET into a POST.
        /// </summary>
        /// <param name="properties">Properties for which the HTTP method is to be changed.</param>
        public static void MakeHttpPOSTMethod(MessageProperties properties)
        {
            object property;
            HttpRequestMessageProperty httpMessageProperty = null;

            if (properties.TryGetValue(MessageUtility.HttpRequestName, out property))
            {
                httpMessageProperty = property as HttpRequestMessageProperty;
            }

            if (httpMessageProperty == null)
            {
                httpMessageProperty = new HttpRequestMessageProperty();
                properties.Add(MessageUtility.HttpRequestName, httpMessageProperty);
            }

            httpMessageProperty.Method             = MessageUtility.HttpPostMethodName;
            httpMessageProperty.SuppressEntityBody = false;
        }
Example #28
0
        public MessageInspector_CustomHeaderAuthentication.ResultObject<string> UserGetAuthToken()
        {
            MessageInspector_CustomHeaderAuthentication.ResultObject<string> resultObject = null;

            try
            {
                HttpRequestMessageProperty property;
                object obj;
                MessageProperties properties = new MessageProperties(OperationContext.Current.IncomingMessageProperties);
                if (properties.TryGetValue(HttpRequestMessageProperty.Name, out obj))
                {
                    property = obj as HttpRequestMessageProperty;
                    WebHeaderCollection collection = property.Headers;
                    string authValue = collection.Get(Enum.GetName(typeof(HttpRequestHeader), HttpRequestHeader.Authorization));

                    if (authValue == "Not Allowed")
                    {
                        resultObject = MessageInspector_CustomHeaderAuthentication.ResultObject<string>.CreateFailureObject<string>();
                        resultObject.Result = resultObject.ResultMessage;
                    }
                    else if (authValue == "Allow")
                    {
                        resultObject = MessageInspector_CustomHeaderAuthentication.ResultObject<string>.CreateSuccessObject<string>();
                        resultObject.Result = resultObject.ResultMessage;
                    }
                }
                else
                {
                    resultObject = MessageInspector_CustomHeaderAuthentication.ResultObject<string>.CreateFailureObject<string>();
                    resultObject.Result = "ERROR";
                    resultObject.ResultMessage = "No HttpRequestMessageProperty was found on the incoming Message.";
                }
            }
            catch (Exception ex)
            {
                resultObject = MessageInspector_CustomHeaderAuthentication.ResultObject<string>.CreateFailureObject<string>();
                resultObject.Result = ex.ToString();
                resultObject.ResultMessage = ex.Message;
            }

            return resultObject;
        }
        public void BeforeSendReply(ref Message reply, object correlationState)
        {
            if (DEBUG && correlationState != null)
            {
                QZ.RealTimeRequestLogService.RequestLog rt = (QZ.RealTimeRequestLogService.RequestLog)correlationState;
                TimeSpan ts = DateTime.Now - rt.Time;
                rt.TotalSpend = ts.Milliseconds;

                if (reply != null)
                {
                    MessageProperties mp = reply.Properties;

                    object obj;

                    if (mp.TryGetValue("httpResponse", out obj))
                    {
                        System.ServiceModel.Channels.HttpResponseMessageProperty wh = (System.ServiceModel.Channels.HttpResponseMessageProperty)obj;
                        rt.ResponseHeader      = wh.Headers.ToString();
                        rt.ResponseContentType = wh.Headers[System.Net.HttpResponseHeader.ContentType];
                        rt.ResponseStatusCode  = (int)wh.StatusCode;
                        rt.ResponseStatusStr   = wh.StatusCode.ToString();
                    }

                    if (rt.ResponseStatusCode == 200)
                    {
                        rt.Response = GetReponseBody(reply);
                    }
                    else
                    {
                        rt.Response = string.Empty;
                    }
                }
                else
                {
                    rt.ResponseStatusStr = "no reply message captured, unable to read the response infomation.";
                }
                QZ.RealTimeRequestLogService.RealTimeRequestLog.AppendLog(rt);
            }
        }
            static void FilterProperties(MessageProperties destination)
            {
                // We have the clear out the HTTP Req/Resp props, so we don't accidentally
                // tell the outbound binding to use whatever Content-Type/Method/QueryString
                // that the inboudnd message/response used.  Otherwise BasicHttp<->WsHttp won't work.
                object incomingHttpRequest;

                if (destination.TryGetValue(HttpRequestMessageProperty.Name, out incomingHttpRequest))
                {
                    //Store the inbound value for later retoration
                    destination[IncomingHttpRequestName] = incomingHttpRequest;
                    destination.Remove(HttpRequestMessageProperty.Name);
                }
                destination.Remove(HttpResponseMessageProperty.Name);

                //Preserve the Via on the outbound message, HTTP Context using cookies looks at this value
                //on the original request when sending the response "Set-Cookie" header.
                Uri incomingVia = destination.Via;

                if (incomingVia != null)
                {
                    destination[IncomingViaName] = incomingVia;
                }
            }
 public static bool TryGet(MessageProperties properties, out CorrelationMessageProperty property)
 {
     if (properties == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
     }
     object obj2 = null;
     if (properties.TryGetValue("CorrelationMessageProperty", out obj2))
     {
         property = obj2 as CorrelationMessageProperty;
     }
     else
     {
         property = null;
     }
     return (property != null);
 }
Example #32
0
 static internal void SetActivityId(MessageProperties properties)
 {
     Guid activityId;
     if ((null != properties) && properties.TryGetValue(TraceUtility.E2EActivityId, out activityId))
     {
         DiagnosticTraceBase.ActivityId = activityId;
     }
 }
 public static bool TryGet(MessageProperties properties, out CorrelationDataMessageProperty property)
 {
     object obj2 = null;
     if (properties.TryGetValue("CorrelationDataMessageProperty", out obj2))
     {
         property = obj2 as CorrelationDataMessageProperty;
     }
     else
     {
         property = null;
     }
     return (property != null);
 }
 public static bool TryGet(MessageProperties properties, out CorrelationDataMessageProperty property)
 {
     object value = null;
     if (properties.TryGetValue(PropertyName, out value))
     {
         property = value as CorrelationDataMessageProperty;
     }
     else
     {
         property = null;
     }
     return property != null;
 }
Example #35
0
        internal static object TryGetValue(this MessageProperties properties, string key)
        {
            object obj;

            return(properties.TryGetValue(key, out obj) ? obj : null);
        }
Example #36
0
 /// <summary>
 /// Gets the property with the specified name.
 /// </summary>
 /// <typeparam name="TProperty"></typeparam>
 /// <param name="self"></param>
 /// <param name="name"></param>
 /// <returns></returns>
 public static TProperty GetValue <TProperty>(this MessageProperties self, string name)
     where TProperty : class
 {
     return(self.TryGetValue(name, out var value) ? (TProperty)value : null);
 }
            static void FilterProperties(MessageProperties destination)
            {
                // We have the clear out the HTTP Req/Resp props, so we don't accidentally
                // tell the outbound binding to use whatever Content-Type/Method/QueryString
                // that the inboudnd message/response used.  Otherwise BasicHttp<->WsHttp won't work.
                object incomingHttpRequest;
                if (destination.TryGetValue(HttpRequestMessageProperty.Name, out incomingHttpRequest))
                {
                    //Store the inbound value for later retoration
                    destination[IncomingHttpRequestName] = incomingHttpRequest;
                    destination.Remove(HttpRequestMessageProperty.Name);
                }
                destination.Remove(HttpResponseMessageProperty.Name);

                //Preserve the Via on the outbound message, HTTP Context using cookies looks at this value
                //on the original request when sending the response "Set-Cookie" header.
                Uri incomingVia = destination.Via;
                if (incomingVia != null)
                {
                    destination[IncomingViaName] = incomingVia;
                }
            }
        public static bool TryGet(MessageProperties properties, out CallbackContextMessageProperty contextMessageProperty)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            object value = null;
            if (properties.TryGetValue(PropertyName, out value))
            {
                contextMessageProperty = value as CallbackContextMessageProperty;
            }
            else
            {
                contextMessageProperty = null;
            }

            return contextMessageProperty != null;
        }
 bool TryGetRequestReplyCorrelationInstanceKey(MessageProperties messageProperties, out InstanceKey instanceKey)
 {
     instanceKey = null;
     CorrelationMessageProperty correlationMessageProperty;
     if (messageProperties.TryGetValue<CorrelationMessageProperty>(CorrelationMessageProperty.Name, out correlationMessageProperty))
     {
         foreach (InstanceKey key in correlationMessageProperty.TransientCorrelations)
         {
             InstanceValue value;
             if (key.Metadata.TryGetValue(WorkflowServiceNamespace.RequestReplyCorrelation, out value))
             {
                 instanceKey = key;
                 break;
             }
         }
     }
     return instanceKey != null;
 }