Beispiel #1
0
                    private async Task <HttpResponseMessage> CreateHttpResponseAsync(ReceiveResponse receiveResponse)
                    {
                        var httpResponseMessage = new HttpResponseMessage((HttpStatusCode)receiveResponse.StatusCode);

                        httpResponseMessage.Content = new StringContent(await receiveResponse.ReadBodyAsStringAsync().ConfigureAwait(false));
                        return(httpResponseMessage);
                    }
        public static async Task <T> ReadBodyAsJsonAsync <T>(this ReceiveResponse response)
        {
            // The first stream attached to a ReceiveRequest is always the ReceiveRequest body.
            // Any additional streams must be defined within the body or they will not be
            // attached properly when processing activities.
            try
            {
                T      returnValue   = default(T);
                string streamContent = await response.ReadBodyAsStringAsync().ConfigureAwait(false);

                if (streamContent != null)
                {
                    returnValue = JsonConvert.DeserializeObject <T>(streamContent);
                }
                return(returnValue);
            }
            catch (Exception ex)
            {
                throw;
            }
        }