private void HandleHttpHeader(HttpWebRequest request)
        {
            Dictionary <string, string> dic = null;
            var handler = RestClient.ContextSetting;

            if (handler != null)
            {
                dic = handler();
            }
            if (dic == null)
            {
                return;
            }
            Dictionary <string, string> .Enumerator iterator = dic.GetEnumerator();
            while (iterator.MoveNext())
            {
                string val = iterator.Current.Value;
                if (val == null)
                {
                    continue;
                }
                val = HeaderContextHelper.EncryptAndSign(val);
                request.Headers[HeaderContextHelper.BuildKey(iterator.Current.Key)] = val;
            }
        }
        public object BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            Dictionary <string, string> dic = null;
            var handler = ServiceFactory.ContextSetting;

            if (handler != null)
            {
                dic = handler();
            }
            if (dic == null)
            {
                return(null);
            }
            Dictionary <string, string> .Enumerator iterator = dic.GetEnumerator();
            HttpRequestMessageProperty hrmp = null;

            if (m_IsWebHttpBinding)
            {
                hrmp = request.Properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
                if (hrmp == null)
                {
                    hrmp = new HttpRequestMessageProperty();
                    request.Properties.Add(HttpRequestMessageProperty.Name, hrmp);
                }
            }
            while (iterator.MoveNext())
            {
                string val = iterator.Current.Value;
                if (val == null)
                {
                    continue;
                }
                val = HeaderContextHelper.EncryptAndSign(val);
                if (m_IsWebHttpBinding)
                {
                    hrmp.Headers.Add(HeaderContextHelper.BuildKey(iterator.Current.Key), val);
                }
                else
                {
                    MessageHeader clientHeader = MessageHeader.CreateHeader(HeaderContextHelper.BuildKey(iterator.Current.Key), string.Empty, val);
                    request.Headers.Add(clientHeader);
                }
            }
            return(null);
        }