コード例 #1
0
        public static async Task <HttpOperationResult <string> > TryReceiveAsStringAsync(this Task <HttpResponseMessage> requestTask)
        {
            var result = new HttpOperationResult <string>();

            try
            {
                result.ResponseMessage = await requestTask.ConfigureAwait(false);

                result.Data = await result.ResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                result.Exception = ex;
            }
            return(result);
        }