<PackageReference Include="Azure.Storage.Blobs" Version="12.25.0-beta.1" />

Utf8JsonRequestContent

using Azure.Core; using System.IO; using System.Runtime.CompilerServices; using System.Text.Json; using System.Threading; using System.Threading.Tasks; namespace Azure.Storage.Common { internal class Utf8JsonRequestContent { private readonly MemoryStream _stream; private readonly RequestContent _content; public Utf8JsonWriter JsonWriter { get; } public Utf8JsonRequestContent() : this() { _stream = new MemoryStream(); _content = RequestContent.Create((Stream)_stream); JsonWriter = new Utf8JsonWriter(_stream, default(JsonWriterOptions)); } [AsyncStateMachine(typeof(<WriteToAsync>d__6))] public override Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default(CancellationToken)) { <WriteToAsync>d__6 stateMachine = default(<WriteToAsync>d__6); stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create(); stateMachine.<>4__this = this; stateMachine.stream = stream; stateMachine.cancellationToken = cancellationToken; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } public override void WriteTo(Stream stream, CancellationToken cancellationToken = default(CancellationToken)) { JsonWriter.Flush(); _content.WriteTo(stream, cancellationToken); } public override bool TryComputeLength(out long length) { length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; return true; } public override void Dispose() { JsonWriter.Dispose(); _content.Dispose(); _stream.Dispose(); } } }