private static Uri GetCompleteUri(CommunicationInfo commInfo, string xslPath, params object[] args)
        {
            var uriTemplate = commInfo.UriTemplate;

            if (!string.IsNullOrEmpty(xslPath))
            {
                uriTemplate = AddXslParam(uriTemplate, xslPath);
            }
            return(SetParamsToUri(uriTemplate, args));
        }
        private static StringContent GetContentKeyValuePairs(CommunicationInfo commInfo, string xslPath, params object[] args)
        {
            var contentTemplate = commInfo.ContentTemplate;

            if (!string.IsNullOrEmpty(xslPath))
            {
                contentTemplate = AddXslParam(contentTemplate, xslPath);
            }
            var contentPairString = SetParamsToStringTemplate(contentTemplate, args);

            return(new StringContent(contentPairString, Encoding.UTF8, "application/x-www-form-urlencoded"));
        }
示例#3
0
        public Task <HttpContent> SendRequest(CommunicationInfo commInfo, Uri uri, HttpContent content)
        {
            var httpRequestMessage = new HttpRequestMessage(new HttpMethod(commInfo.Method.GetStringValue()), uri);

            if (commInfo.Method.Equals(HttpMethodType.Post) || commInfo.Method.Equals(HttpMethodType.Put))
            {
                httpRequestMessage.Content = content;
            }


            return(Task.Run(() => m_httpClient.SendAsync(httpRequestMessage))
                   .ContinueWith(task =>
            {
                //var message = Task.Run(() => task.Result.Content.ReadAsStringAsync()).Result; //content message for debug purposes
                task.Result.EnsureSuccessStatusCode();
                return task.Result.Content;
            }));
        }
示例#4
0
 public Task <byte[]> SendRequestGetResponseAsByteArray(CommunicationInfo commInfo, Uri uri, HttpContent content)
 {
     return(Task.Run(() => SendRequest(commInfo, uri, content).Result.ReadAsByteArrayAsync()));
 }
示例#5
0
 public Task <Stream> SendRequestGetResponseAsStream(CommunicationInfo commInfo, Uri uri, HttpContent content)
 {
     return
         (Task.Run(() => SendRequest(commInfo, uri, content).Result.ReadAsStreamAsync()));
 }
示例#6
0
 public Task <string> SendRequestGetResponseAsStringAsync(CommunicationInfo commInfo, Uri uri, HttpContent content)
 {
     return(SendRequestAsync(commInfo, uri, content).Result.ReadAsStringAsync());
 }
示例#7
0
 private void AddCommunicationInfoForMethod(string methodName, CommunicationInfo communicationInfo)
 {
     m_uriTemplateDictionary.Add(methodName, communicationInfo);
 }