예제 #1
0
        /// <summary>
        /// Downloads the blob from IBodyBlob as a string
        /// </summary>
        /// <param name="bodyBlob">IBodyBlob object containing the blob to download</param>
        /// <returns>String result from the Blob</returns>
        public static async Task <string> DownloadBlobAsStringAsync(this IBodyBlob bodyBlob)
        {
            var responseMessage = await DownloadBlobAsync(bodyBlob);

            var respStr = await responseMessage.Content.ReadAsStringAsync();

            return(respStr);
        }
예제 #2
0
        /// <summary>
        /// Downloads the blob from the IBodyBlob
        /// </summary>
        /// <param name="bodyBlob">IBodyBlob object containing the blob to download</param>
        /// <returns>Standard HttpResponseMessage for manual parsing</returns>
        /// <exception cref="System.ArgumentNullException">Thrown when BlobUri is null or empty</exception>
        public static Task <HttpResponseMessage> DownloadBlobAsync(this IBodyBlob bodyBlob)
        {
            if (string.IsNullOrEmpty(bodyBlob?.BlobUri))
            {
                throw new ArgumentNullException();
            }

            return(_httpClient.GetAsync(bodyBlob.BlobUri));
        }
예제 #3
0
        /// <summary>
        /// Downloads the blob from IBodyBlob and converts the returned Json into the specified class
        /// </summary>
        /// <param name="bodyBlob">IBodyBlob object containing the blob to download</param>
        /// <typeparam name="T">Type to convert the Json to</typeparam>
        public static async Task <T> DownloadBlobAsync <T>(this IBodyBlob bodyBlob)
        {
            var respStr = await DownloadBlobAsStringAsync(bodyBlob);

            return(JsonConvert.DeserializeObject <T>(respStr));
        }