< Summary

Class:Azure.Core.Http.Multipart.MultipartSectionStreamExtensions
Assembly:Azure.Storage.Blobs.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs.Batch\src\Shared\MultipartSectionStreamExtensions.cs
Covered lines:0
Uncovered lines:14
Coverable lines:14
Total lines:53
Line coverage:0% (0 of 14)
Covered branches:0
Total branches:8
Branch coverage:0% (0 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
ReadAsStringAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs.Batch\src\Shared\MultipartSectionStreamExtensions.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// Copied from https://github.com/aspnet/AspNetCore/tree/master/src/Http/WebUtilities/src
 5
 6using System;
 7using System.IO;
 8using System.Text;
 9using System.Threading.Tasks;
 10
 11#pragma warning disable CA1806 // Didn't check TryParse
 12#pragma warning disable IDE0018 // Inline declaration
 13
 14namespace Azure.Core.Http.Multipart
 15{
 16    /// <summary>
 17    /// Various extension methods for dealing with the section body stream
 18    /// </summary>
 19    internal static class MultipartSectionStreamExtensions
 20    {
 21        /// <summary>
 22        /// Reads the body of the section as a string
 23        /// </summary>
 24        /// <param name="section">The section to read from</param>
 25        /// <returns>The body steam as string</returns>
 26        public static async Task<string> ReadAsStringAsync(this MultipartSection section)
 27        {
 028            if (section == null)
 29            {
 030                throw new ArgumentNullException(nameof(section));
 31            }
 32
 33            MediaTypeHeaderValue sectionMediaType;
 034            MediaTypeHeaderValue.TryParse(section.ContentType, out sectionMediaType);
 35
 036            Encoding streamEncoding = sectionMediaType?.Encoding;
 037            if (streamEncoding == null || streamEncoding == Encoding.UTF7)
 38            {
 039                streamEncoding = Encoding.UTF8;
 40            }
 41
 042            using (var reader = new StreamReader(
 043                section.Body,
 044                streamEncoding,
 045                detectEncodingFromByteOrderMarks: true,
 046                bufferSize: 1024,
 047                leaveOpen: true))
 48            {
 049                return await reader.ReadToEndAsync().ConfigureAwait(false);
 50            }
 051        }
 52    }
 53}

Methods/Properties

ReadAsStringAsync()