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")); }
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; })); }
public Task <byte[]> SendRequestGetResponseAsByteArray(CommunicationInfo commInfo, Uri uri, HttpContent content) { return(Task.Run(() => SendRequest(commInfo, uri, content).Result.ReadAsByteArrayAsync())); }
public Task <Stream> SendRequestGetResponseAsStream(CommunicationInfo commInfo, Uri uri, HttpContent content) { return (Task.Run(() => SendRequest(commInfo, uri, content).Result.ReadAsStreamAsync())); }
public Task <string> SendRequestGetResponseAsStringAsync(CommunicationInfo commInfo, Uri uri, HttpContent content) { return(SendRequestAsync(commInfo, uri, content).Result.ReadAsStringAsync()); }
private void AddCommunicationInfoForMethod(string methodName, CommunicationInfo communicationInfo) { m_uriTemplateDictionary.Add(methodName, communicationInfo); }