コード例 #1
0
ファイル: CustomMessage.cs プロジェクト: romambler/dotNext
        private protected static async Task <T> ParseResponse <T>(HttpResponseMessage response, MessageReader <T> reader, CancellationToken token)
        {
            var contentType = new ContentType(response.Content.Headers.ContentType.ToString());
            var name        = ParseHeader <IEnumerable <string> >(MessageNameHeader, response.Headers.TryGetValues);

            using (var content = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
                using (var message = new InboundMessageContent(content, true, name, contentType))
                    return(await reader(message, token).ConfigureAwait(false));
        }
コード例 #2
0
            internal static async Task <TResponse> FromResponseAsync <TResponse>(HttpResponseMessage response,
                                                                                 MessageReader <TResponse> reader)
            {
                var contentType = new ContentType(response.Content.Headers.ContentType.ToString());
                var name        = ParseHeader <IEnumerable <string> >(MessageNameHeader, response.Headers.TryGetValues);

                using (var content = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
                    using (var message = new InboundMessageContent(content, true, name, contentType))
                        return(await reader(message).ConfigureAwait(false));
            }