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

PageBlobWriteStream

using Azure.Storage.Blobs.Models; using Azure.Storage.Blobs.Specialized; using Azure.Storage.Shared; using System; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; namespace Azure.Storage.Blobs { internal class PageBlobWriteStream : StorageWriteStream { private readonly PageBlobClient _pageBlobClient; private readonly PageBlobRequestConditions _conditions; private long _writeIndex; public PageBlobWriteStream(PageBlobClient pageBlobClient, long bufferSize, long position, PageBlobRequestConditions conditions, IProgress<long> progressHandler, UploadTransferValidationOptions transferValidation) : base(position, bufferSize, progressHandler, transferValidation, null, null) { ValidateBufferSize(bufferSize); ValidatePosition(position); _pageBlobClient = pageBlobClient; _conditions = (conditions ?? new PageBlobRequestConditions()); _writeIndex = position; } [AsyncStateMachine(typeof(<AppendInternal>d__4))] protected override Task AppendInternal(UploadTransferValidationOptions validationOptions, bool async, CancellationToken cancellationToken) { <AppendInternal>d__4 stateMachine = default(<AppendInternal>d__4); stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create(); stateMachine.<>4__this = this; stateMachine.validationOptions = validationOptions; stateMachine.async = async; stateMachine.cancellationToken = cancellationToken; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } protected override void ValidateBufferSize(long bufferSize) { if (bufferSize < 1) throw new ArgumentOutOfRangeException("bufferSize", "Must be greater than or equal to 1"); DefaultInterpolatedStringHandler defaultInterpolatedStringHandler; if (bufferSize > 4194304) { defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(27, 1); defaultInterpolatedStringHandler.AppendLiteral("Must less than or equal to "); defaultInterpolatedStringHandler.AppendFormatted(4194304); throw new ArgumentOutOfRangeException("bufferSize", defaultInterpolatedStringHandler.ToStringAndClear()); } if (bufferSize % 512 != 0) { defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(22, 1); defaultInterpolatedStringHandler.AppendLiteral("Must be a multiple of "); defaultInterpolatedStringHandler.AppendFormatted(512); throw new ArgumentOutOfRangeException("bufferSize", defaultInterpolatedStringHandler.ToStringAndClear()); } } private static void ValidatePosition(long position) { if (position % 512 != 0) { DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(22, 1); defaultInterpolatedStringHandler.AppendLiteral("Must be a multiple of "); defaultInterpolatedStringHandler.AppendFormatted(512); throw new ArgumentOutOfRangeException("position", defaultInterpolatedStringHandler.ToStringAndClear()); } } } }