< Summary

Class:Azure.Core.XmlWriterContent
Assembly:Azure.AI.TextAnalytics
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\AutoRest\XmlWriterContent.cs
Covered lines:0
Uncovered lines:18
Coverable lines:18
Total lines:53
Line coverage:0% (0 of 18)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-0%100%
get_XmlWriter()-0%100%
WriteToAsync()-0%100%
WriteTo(...)-0%100%
TryComputeLength(...)-0%100%
Dispose()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\AutoRest\XmlWriterContent.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4#nullable enable
 5
 6using System.IO;
 7using System.Text;
 8using System.Threading;
 9using System.Threading.Tasks;
 10using System.Xml;
 11
 12namespace Azure.Core
 13{
 14    internal class XmlWriterContent : RequestContent
 15    {
 16        private readonly MemoryStream _stream;
 17        private readonly RequestContent _content;
 18
 019        public XmlWriterContent()
 20        {
 021            _stream = new MemoryStream();
 022            _content = Create(_stream);
 023            XmlWriter = new XmlTextWriter(_stream, Encoding.UTF8);
 024        }
 25
 026        public XmlWriter XmlWriter { get; }
 27
 28        public override async Task WriteToAsync(Stream stream, CancellationToken cancellation)
 29        {
 030            XmlWriter.Flush();
 031            await _content.WriteToAsync(stream, cancellation).ConfigureAwait(false);
 032        }
 33
 34        public override void WriteTo(Stream stream, CancellationToken cancellation)
 35        {
 036            XmlWriter.Flush();
 037            _content.WriteTo(stream, cancellation);
 038        }
 39
 40        public override bool TryComputeLength(out long length)
 41        {
 042            XmlWriter.Flush();
 043            length = _stream.Length;
 044            return true;
 45        }
 46
 47        public override void Dispose()
 48        {
 049            _content.Dispose();
 050            XmlWriter.Dispose();
 051        }
 52    }
 53}