PageBlobClient
The  PageBlobClient allows you to manipulate Azure
             Storage page blobs.
            
             Page blobs are a collection of 512-byte pages optimized for random
             read and write operations. To create a page blob, you initialize the
             page blob and specify the maximum size the page blob will grow. To add
             or update the contents of a page blob, you write a page or pages by
             specifying an offset and a range that align to 512-byte page
             boundaries.  A write to a page blob can overwrite just one page, some
             pages, or up to 4 MB of the page blob.  Writes to page blobs happen
             in-place and are immediately committed to the blob. The maximum size
             for a page blob is 8 TB.
             
                using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Storage.Blobs.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace Azure.Storage.Blobs.Specialized
{
    public class PageBlobClient : BlobBaseClient
    {
        private readonly PageBlobRestClient _pageBlobRestClient;
        public virtual int PageBlobPageBytes => 512;
        public virtual int PageBlobMaxUploadPagesBytes => 4194304;
        internal virtual PageBlobRestClient PageBlobRestClient => _pageBlobRestClient;
        protected PageBlobClient()
        {
        }
        public PageBlobClient(string connectionString, string blobContainerName, string blobName)
            : base(connectionString, blobContainerName, blobName)
        {
            _pageBlobRestClient = BuildPageBlobRestClient(_uri);
        }
        public PageBlobClient(string connectionString, string blobContainerName, string blobName, BlobClientOptions options)
            : base(connectionString, blobContainerName, blobName, options)
        {
            _pageBlobRestClient = BuildPageBlobRestClient(_uri);
            AssertNoClientSideEncryption(options);
        }
        public PageBlobClient(Uri blobUri, BlobClientOptions options = null)
            : base(blobUri, options)
        {
            _pageBlobRestClient = BuildPageBlobRestClient(blobUri);
            AssertNoClientSideEncryption(options);
        }
        public PageBlobClient(Uri blobUri, StorageSharedKeyCredential credential, BlobClientOptions options = null)
            : base(blobUri, credential, options)
        {
            _pageBlobRestClient = BuildPageBlobRestClient(blobUri);
            AssertNoClientSideEncryption(options);
        }
        public PageBlobClient(Uri blobUri, AzureSasCredential credential, BlobClientOptions options = null)
            : base(blobUri, credential, options)
        {
            _pageBlobRestClient = BuildPageBlobRestClient(blobUri);
            AssertNoClientSideEncryption(options);
        }
        public PageBlobClient(Uri blobUri, TokenCredential credential, BlobClientOptions options = null)
            : base(blobUri, credential, options)
        {
            _pageBlobRestClient = BuildPageBlobRestClient(blobUri);
            AssertNoClientSideEncryption(options);
        }
        internal PageBlobClient(Uri blobUri, BlobClientConfiguration clientConfiguration)
            : base(blobUri, clientConfiguration, null)
        {
            _pageBlobRestClient = BuildPageBlobRestClient(blobUri);
        }
        private static void AssertNoClientSideEncryption(BlobClientOptions options)
        {
            if (options?._clientSideEncryptionOptions != null)
                throw Errors.ClientSideEncryption.TypeNotSupported(typeof(PageBlobClient));
        }
        private PageBlobRestClient BuildPageBlobRestClient(Uri blobUri)
        {
            return new PageBlobRestClient(_clientConfiguration.ClientDiagnostics, _clientConfiguration.Pipeline, blobUri.AbsoluteUri, _clientConfiguration.Version.ToVersionString());
        }
        public new PageBlobClient WithSnapshot(string snapshot)
        {
            return (PageBlobClient)WithSnapshotCore(snapshot);
        }
        protected sealed override BlobBaseClient WithSnapshotCore(string snapshot)
        {
            return new PageBlobClient(new BlobUriBuilder(Uri) {
                Snapshot = snapshot
            }.ToUri(), ClientConfiguration);
        }
        public new PageBlobClient WithVersion(string versionId)
        {
            return new PageBlobClient(new BlobUriBuilder(Uri) {
                VersionId = versionId
            }.ToUri(), ClientConfiguration);
        }
        public new PageBlobClient WithCustomerProvidedKey(CustomerProvidedKey? customerProvidedKey)
        {
            BlobClientConfiguration blobClientConfiguration = BlobClientConfiguration.DeepCopy(ClientConfiguration);
            blobClientConfiguration.CustomerProvidedKey = customerProvidedKey;
            return new PageBlobClient(Uri, blobClientConfiguration);
        }
        public new PageBlobClient WithEncryptionScope(string encryptionScope)
        {
            BlobClientConfiguration blobClientConfiguration = BlobClientConfiguration.DeepCopy(ClientConfiguration);
            blobClientConfiguration.EncryptionScope = encryptionScope;
            return new PageBlobClient(Uri, blobClientConfiguration);
        }
        public virtual Response<BlobContentInfo> Create(long size, PageBlobCreateOptions options, CancellationToken cancellationToken = default(CancellationToken))
        {
            return CreateInternal(size, options?.SequenceNumber, options?.HttpHeaders, options?.Metadata, options?.Tags, options?.Conditions, options?.ImmutabilityPolicy, options?.LegalHold, options?.PremiumPageBlobAccessTier, false, cancellationToken, null).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<CreateAsync>d__23))]
        public virtual Task<Response<BlobContentInfo>> CreateAsync(long size, PageBlobCreateOptions options, CancellationToken cancellationToken = default(CancellationToken))
        {
            <CreateAsync>d__23 stateMachine = default(<CreateAsync>d__23);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.size = size;
            stateMachine.options = options;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual Response<BlobContentInfo> Create(long size, long? sequenceNumber = default(long?), BlobHttpHeaders httpHeaders = null, IDictionary<string, string> metadata = null, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return CreateInternal(size, sequenceNumber, httpHeaders, metadata, null, conditions, null, null, null, false, cancellationToken, null).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<CreateAsync>d__25))]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual Task<Response<BlobContentInfo>> CreateAsync(long size, long? sequenceNumber = default(long?), BlobHttpHeaders httpHeaders = null, IDictionary<string, string> metadata = null, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            <CreateAsync>d__25 stateMachine = default(<CreateAsync>d__25);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.size = size;
            stateMachine.sequenceNumber = sequenceNumber;
            stateMachine.httpHeaders = httpHeaders;
            stateMachine.metadata = metadata;
            stateMachine.conditions = conditions;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        public virtual Response<BlobContentInfo> CreateIfNotExists(long size, PageBlobCreateOptions options, CancellationToken cancellationToken = default(CancellationToken))
        {
            return CreateIfNotExistsInternal(size, options?.SequenceNumber, options?.HttpHeaders, options?.Metadata, options?.Tags, options?.ImmutabilityPolicy, options?.LegalHold, options?.PremiumPageBlobAccessTier, false, cancellationToken).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<CreateIfNotExistsAsync>d__27))]
        public virtual Task<Response<BlobContentInfo>> CreateIfNotExistsAsync(long size, PageBlobCreateOptions options, CancellationToken cancellationToken = default(CancellationToken))
        {
            <CreateIfNotExistsAsync>d__27 stateMachine = default(<CreateIfNotExistsAsync>d__27);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.size = size;
            stateMachine.options = options;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual Response<BlobContentInfo> CreateIfNotExists(long size, long? sequenceNumber = default(long?), BlobHttpHeaders httpHeaders = null, IDictionary<string, string> metadata = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return CreateIfNotExistsInternal(size, sequenceNumber, httpHeaders, metadata, null, null, null, null, false, cancellationToken).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<CreateIfNotExistsAsync>d__29))]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual Task<Response<BlobContentInfo>> CreateIfNotExistsAsync(long size, long? sequenceNumber = default(long?), BlobHttpHeaders httpHeaders = null, IDictionary<string, string> metadata = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            <CreateIfNotExistsAsync>d__29 stateMachine = default(<CreateIfNotExistsAsync>d__29);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.size = size;
            stateMachine.sequenceNumber = sequenceNumber;
            stateMachine.httpHeaders = httpHeaders;
            stateMachine.metadata = metadata;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [AsyncStateMachine(typeof(<CreateIfNotExistsInternal>d__30))]
        private Task<Response<BlobContentInfo>> CreateIfNotExistsInternal(long size, long? sequenceNumber, BlobHttpHeaders httpHeaders, IDictionary<string, string> metadata, IDictionary<string, string> tags, BlobImmutabilityPolicy immutabilityPolicy, bool? legalHold, PremiumPageBlobAccessTier? premiumPageBlobAccessTier, bool async, CancellationToken cancellationToken)
        {
            <CreateIfNotExistsInternal>d__30 stateMachine = default(<CreateIfNotExistsInternal>d__30);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.size = size;
            stateMachine.sequenceNumber = sequenceNumber;
            stateMachine.httpHeaders = httpHeaders;
            stateMachine.metadata = metadata;
            stateMachine.tags = tags;
            stateMachine.immutabilityPolicy = immutabilityPolicy;
            stateMachine.legalHold = legalHold;
            stateMachine.premiumPageBlobAccessTier = premiumPageBlobAccessTier;
            stateMachine.async = async;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [AsyncStateMachine(typeof(<CreateInternal>d__31))]
        private Task<Response<BlobContentInfo>> CreateInternal(long size, long? sequenceNumber, BlobHttpHeaders httpHeaders, IDictionary<string, string> metadata, IDictionary<string, string> tags, PageBlobRequestConditions conditions, BlobImmutabilityPolicy immutabilityPolicy, bool? legalHold, PremiumPageBlobAccessTier? premiumPageBlobAccessTier, bool async, CancellationToken cancellationToken, string operationName = null)
        {
            <CreateInternal>d__31 stateMachine = default(<CreateInternal>d__31);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.size = size;
            stateMachine.sequenceNumber = sequenceNumber;
            stateMachine.httpHeaders = httpHeaders;
            stateMachine.metadata = metadata;
            stateMachine.tags = tags;
            stateMachine.conditions = conditions;
            stateMachine.immutabilityPolicy = immutabilityPolicy;
            stateMachine.legalHold = legalHold;
            stateMachine.premiumPageBlobAccessTier = premiumPageBlobAccessTier;
            stateMachine.async = async;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.operationName = operationName;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual Response<PageInfo> UploadPages(Stream content, long offset, byte[] transactionalContentHash, PageBlobRequestConditions conditions, IProgress<long> progressHandler, CancellationToken cancellationToken)
        {
            return UploadPagesInternal(content, offset, transactionalContentHash.ToValidationOptions(), conditions, progressHandler, false, cancellationToken).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<UploadPagesAsync>d__33))]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual Task<Response<PageInfo>> UploadPagesAsync(Stream content, long offset, byte[] transactionalContentHash, PageBlobRequestConditions conditions, IProgress<long> progressHandler, CancellationToken cancellationToken)
        {
            <UploadPagesAsync>d__33 stateMachine = default(<UploadPagesAsync>d__33);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.content = content;
            stateMachine.offset = offset;
            stateMachine.transactionalContentHash = transactionalContentHash;
            stateMachine.conditions = conditions;
            stateMachine.progressHandler = progressHandler;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        public virtual Response<PageInfo> UploadPages(Stream content, long offset, PageBlobUploadPagesOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return UploadPagesInternal(content, offset, options?.TransferValidation, options?.Conditions, options?.ProgressHandler, false, cancellationToken).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<UploadPagesAsync>d__35))]
        public virtual Task<Response<PageInfo>> UploadPagesAsync(Stream content, long offset, PageBlobUploadPagesOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            <UploadPagesAsync>d__35 stateMachine = default(<UploadPagesAsync>d__35);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.content = content;
            stateMachine.offset = offset;
            stateMachine.options = options;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [AsyncStateMachine(typeof(<UploadPagesInternal>d__36))]
        internal Task<Response<PageInfo>> UploadPagesInternal(Stream content, long offset, UploadTransferValidationOptions transferValidationOverride, PageBlobRequestConditions conditions, IProgress<long> progressHandler, bool async, CancellationToken cancellationToken)
        {
            <UploadPagesInternal>d__36 stateMachine = default(<UploadPagesInternal>d__36);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.content = content;
            stateMachine.offset = offset;
            stateMachine.transferValidationOverride = transferValidationOverride;
            stateMachine.conditions = conditions;
            stateMachine.progressHandler = progressHandler;
            stateMachine.async = async;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        public virtual Response<PageInfo> ClearPages(HttpRange range, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return ClearPagesInternal(range, conditions, false, cancellationToken).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<ClearPagesAsync>d__38))]
        public virtual Task<Response<PageInfo>> ClearPagesAsync(HttpRange range, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            <ClearPagesAsync>d__38 stateMachine = default(<ClearPagesAsync>d__38);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.range = range;
            stateMachine.conditions = conditions;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [AsyncStateMachine(typeof(<ClearPagesInternal>d__39))]
        private Task<Response<PageInfo>> ClearPagesInternal(HttpRange range, PageBlobRequestConditions conditions, bool async, CancellationToken cancellationToken)
        {
            <ClearPagesInternal>d__39 stateMachine = default(<ClearPagesInternal>d__39);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.range = range;
            stateMachine.conditions = conditions;
            stateMachine.async = async;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        public virtual Pageable<PageRangeItem> GetAllPageRanges(GetPageRangesOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return new GetPageRangesAsyncCollection(false, this, options?.Range, options?.Snapshot, null, null, options?.Conditions, "PageBlobClient.GetAllPageRanges").ToSyncCollection(cancellationToken);
        }
        public virtual AsyncPageable<PageRangeItem> GetAllPageRangesAsync(GetPageRangesOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return new GetPageRangesAsyncCollection(false, this, options?.Range, options?.Snapshot, null, null, options?.Conditions, "PageBlobClient.GetAllPageRanges").ToAsyncCollection(cancellationToken);
        }
        [AsyncStateMachine(typeof(<GetAllPageRangesInteral>d__42))]
        internal Task<ResponseWithHeaders<PageList, PageBlobGetPageRangesHeaders>> GetAllPageRangesInteral(string marker, int? pageSizeHint, HttpRange? range, string snapshot, PageBlobRequestConditions conditions, bool async, CancellationToken cancellationToken)
        {
            <GetAllPageRangesInteral>d__42 stateMachine = default(<GetAllPageRangesInteral>d__42);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<ResponseWithHeaders<PageList, PageBlobGetPageRangesHeaders>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.marker = marker;
            stateMachine.pageSizeHint = pageSizeHint;
            stateMachine.range = range;
            stateMachine.snapshot = snapshot;
            stateMachine.conditions = conditions;
            stateMachine.async = async;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual Response<PageRangesInfo> GetPageRanges(HttpRange? range = default(HttpRange?), string snapshot = null, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return GetPageRangesInternal(range, snapshot, conditions, false, cancellationToken).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<GetPageRangesAsync>d__44))]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual Task<Response<PageRangesInfo>> GetPageRangesAsync(HttpRange? range = default(HttpRange?), string snapshot = null, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            <GetPageRangesAsync>d__44 stateMachine = default(<GetPageRangesAsync>d__44);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageRangesInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.range = range;
            stateMachine.snapshot = snapshot;
            stateMachine.conditions = conditions;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [AsyncStateMachine(typeof(<GetPageRangesInternal>d__45))]
        private Task<Response<PageRangesInfo>> GetPageRangesInternal(HttpRange? range, string snapshot, PageBlobRequestConditions conditions, bool async, CancellationToken cancellationToken)
        {
            <GetPageRangesInternal>d__45 stateMachine = default(<GetPageRangesInternal>d__45);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageRangesInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.range = range;
            stateMachine.snapshot = snapshot;
            stateMachine.conditions = conditions;
            stateMachine.async = async;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        public virtual Pageable<PageRangeItem> GetAllPageRangesDiff(GetPageRangesDiffOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return new GetPageRangesAsyncCollection(true, this, options?.Range, options?.Snapshot, options?.PreviousSnapshot, null, options?.Conditions, "PageBlobClient.GetAllPageRangesDiff").ToSyncCollection(cancellationToken);
        }
        public virtual AsyncPageable<PageRangeItem> GetAllPageRangesDiffAsync(GetPageRangesDiffOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return new GetPageRangesAsyncCollection(true, this, options?.Range, options?.Snapshot, options?.PreviousSnapshot, null, options?.Conditions, "PageBlobClient.GetAllPageRangesDiff").ToAsyncCollection(cancellationToken);
        }
        [AsyncStateMachine(typeof(<GetAllPageRangesDiffInternal>d__48))]
        internal Task<ResponseWithHeaders<PageList, PageBlobGetPageRangesDiffHeaders>> GetAllPageRangesDiffInternal(string marker, int? pageSizeHint, HttpRange? range, string snapshot, string previousSnapshot, Uri previousSnapshotUri, PageBlobRequestConditions conditions, bool async, string operationName, CancellationToken cancellationToken)
        {
            <GetAllPageRangesDiffInternal>d__48 stateMachine = default(<GetAllPageRangesDiffInternal>d__48);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<ResponseWithHeaders<PageList, PageBlobGetPageRangesDiffHeaders>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.marker = marker;
            stateMachine.pageSizeHint = pageSizeHint;
            stateMachine.range = range;
            stateMachine.snapshot = snapshot;
            stateMachine.previousSnapshot = previousSnapshot;
            stateMachine.previousSnapshotUri = previousSnapshotUri;
            stateMachine.conditions = conditions;
            stateMachine.async = async;
            stateMachine.operationName = operationName;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual Response<PageRangesInfo> GetPageRangesDiff(HttpRange? range = default(HttpRange?), string snapshot = null, string previousSnapshot = null, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return GetPageRangesDiffInternal(range, snapshot, previousSnapshot, null, conditions, false, "PageBlobClient.GetPageRangesDiff", cancellationToken).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<GetPageRangesDiffAsync>d__50))]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual Task<Response<PageRangesInfo>> GetPageRangesDiffAsync(HttpRange? range = default(HttpRange?), string snapshot = null, string previousSnapshot = null, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            <GetPageRangesDiffAsync>d__50 stateMachine = default(<GetPageRangesDiffAsync>d__50);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageRangesInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.range = range;
            stateMachine.snapshot = snapshot;
            stateMachine.previousSnapshot = previousSnapshot;
            stateMachine.conditions = conditions;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [AsyncStateMachine(typeof(<GetPageRangesDiffInternal>d__51))]
        private Task<Response<PageRangesInfo>> GetPageRangesDiffInternal(HttpRange? range, string snapshot, string previousSnapshot, Uri previousSnapshotUri, PageBlobRequestConditions conditions, bool async, string operationName, CancellationToken cancellationToken)
        {
            <GetPageRangesDiffInternal>d__51 stateMachine = default(<GetPageRangesDiffInternal>d__51);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageRangesInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.range = range;
            stateMachine.snapshot = snapshot;
            stateMachine.previousSnapshot = previousSnapshot;
            stateMachine.previousSnapshotUri = previousSnapshotUri;
            stateMachine.conditions = conditions;
            stateMachine.async = async;
            stateMachine.operationName = operationName;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        public virtual Response<PageRangesInfo> GetManagedDiskPageRangesDiff(HttpRange? range = default(HttpRange?), string snapshot = null, Uri previousSnapshotUri = null, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return GetPageRangesDiffInternal(range, snapshot, null, previousSnapshotUri, conditions, false, "PageBlobClient.GetManagedDiskPageRangesDiff", cancellationToken).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<GetManagedDiskPageRangesDiffAsync>d__53))]
        public virtual Task<Response<PageRangesInfo>> GetManagedDiskPageRangesDiffAsync(HttpRange? range = default(HttpRange?), string snapshot = null, Uri previousSnapshotUri = null, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            <GetManagedDiskPageRangesDiffAsync>d__53 stateMachine = default(<GetManagedDiskPageRangesDiffAsync>d__53);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageRangesInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.range = range;
            stateMachine.snapshot = snapshot;
            stateMachine.previousSnapshotUri = previousSnapshotUri;
            stateMachine.conditions = conditions;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        public virtual Response<PageBlobInfo> Resize(long size, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return ResizeInternal(size, conditions, false, cancellationToken).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<ResizeAsync>d__55))]
        public virtual Task<Response<PageBlobInfo>> ResizeAsync(long size, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            <ResizeAsync>d__55 stateMachine = default(<ResizeAsync>d__55);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageBlobInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.size = size;
            stateMachine.conditions = conditions;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [AsyncStateMachine(typeof(<ResizeInternal>d__56))]
        private Task<Response<PageBlobInfo>> ResizeInternal(long size, PageBlobRequestConditions conditions, bool async, CancellationToken cancellationToken)
        {
            <ResizeInternal>d__56 stateMachine = default(<ResizeInternal>d__56);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageBlobInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.size = size;
            stateMachine.conditions = conditions;
            stateMachine.async = async;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        public virtual Response<PageBlobInfo> UpdateSequenceNumber(SequenceNumberAction action, long? sequenceNumber = default(long?), PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return UpdateSequenceNumberInternal(action, sequenceNumber, conditions, false, cancellationToken).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<UpdateSequenceNumberAsync>d__58))]
        public virtual Task<Response<PageBlobInfo>> UpdateSequenceNumberAsync(SequenceNumberAction action, long? sequenceNumber = default(long?), PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            <UpdateSequenceNumberAsync>d__58 stateMachine = default(<UpdateSequenceNumberAsync>d__58);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageBlobInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.action = action;
            stateMachine.sequenceNumber = sequenceNumber;
            stateMachine.conditions = conditions;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [AsyncStateMachine(typeof(<UpdateSequenceNumberInternal>d__59))]
        private Task<Response<PageBlobInfo>> UpdateSequenceNumberInternal(SequenceNumberAction action, long? sequenceNumber, PageBlobRequestConditions conditions, bool async, CancellationToken cancellationToken)
        {
            <UpdateSequenceNumberInternal>d__59 stateMachine = default(<UpdateSequenceNumberInternal>d__59);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageBlobInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.action = action;
            stateMachine.sequenceNumber = sequenceNumber;
            stateMachine.conditions = conditions;
            stateMachine.async = async;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        public virtual CopyFromUriOperation StartCopyIncremental(Uri sourceUri, string snapshot, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            Response<BlobCopyInfo> val = StartCopyIncrementalInternal(sourceUri, snapshot, conditions, false, cancellationToken).EnsureCompleted();
            return new CopyFromUriOperation(this, val.get_Value().CopyId, val.GetRawResponse(), cancellationToken);
        }
        [AsyncStateMachine(typeof(<StartCopyIncrementalAsync>d__61))]
        public virtual Task<CopyFromUriOperation> StartCopyIncrementalAsync(Uri sourceUri, string snapshot, PageBlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            <StartCopyIncrementalAsync>d__61 stateMachine = default(<StartCopyIncrementalAsync>d__61);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<CopyFromUriOperation>.Create();
            stateMachine.<>4__this = this;
            stateMachine.sourceUri = sourceUri;
            stateMachine.snapshot = snapshot;
            stateMachine.conditions = conditions;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [AsyncStateMachine(typeof(<StartCopyIncrementalInternal>d__62))]
        private Task<Response<BlobCopyInfo>> StartCopyIncrementalInternal(Uri sourceUri, string snapshot, PageBlobRequestConditions conditions, bool async, CancellationToken cancellationToken)
        {
            <StartCopyIncrementalInternal>d__62 stateMachine = default(<StartCopyIncrementalInternal>d__62);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobCopyInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.sourceUri = sourceUri;
            stateMachine.snapshot = snapshot;
            stateMachine.conditions = conditions;
            stateMachine.async = async;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        public virtual Response<PageInfo> UploadPagesFromUri(Uri sourceUri, HttpRange sourceRange, HttpRange range, PageBlobUploadPagesFromUriOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return UploadPagesFromUriInternal(sourceUri, sourceRange, range, options?.SourceContentHash, options?.DestinationConditions, options?.SourceConditions, options?.SourceAuthentication, options?.SourceShareTokenIntent, false, cancellationToken).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<UploadPagesFromUriAsync>d__64))]
        public virtual Task<Response<PageInfo>> UploadPagesFromUriAsync(Uri sourceUri, HttpRange sourceRange, HttpRange range, PageBlobUploadPagesFromUriOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            <UploadPagesFromUriAsync>d__64 stateMachine = default(<UploadPagesFromUriAsync>d__64);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.sourceUri = sourceUri;
            stateMachine.sourceRange = sourceRange;
            stateMachine.range = range;
            stateMachine.options = options;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual Response<PageInfo> UploadPagesFromUri(Uri sourceUri, HttpRange sourceRange, HttpRange range, byte[] sourceContentHash, PageBlobRequestConditions conditions, PageBlobRequestConditions sourceConditions, CancellationToken cancellationToken)
        {
            return UploadPagesFromUriInternal(sourceUri, sourceRange, range, sourceContentHash, conditions, sourceConditions, null, null, false, cancellationToken).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<UploadPagesFromUriAsync>d__66))]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual Task<Response<PageInfo>> UploadPagesFromUriAsync(Uri sourceUri, HttpRange sourceRange, HttpRange range, byte[] sourceContentHash, PageBlobRequestConditions conditions, PageBlobRequestConditions sourceConditions, CancellationToken cancellationToken)
        {
            <UploadPagesFromUriAsync>d__66 stateMachine = default(<UploadPagesFromUriAsync>d__66);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.sourceUri = sourceUri;
            stateMachine.sourceRange = sourceRange;
            stateMachine.range = range;
            stateMachine.sourceContentHash = sourceContentHash;
            stateMachine.conditions = conditions;
            stateMachine.sourceConditions = sourceConditions;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [AsyncStateMachine(typeof(<UploadPagesFromUriInternal>d__67))]
        private Task<Response<PageInfo>> (Uri sourceUri, HttpRange sourceRange, HttpRange range, byte[] sourceContentHash, PageBlobRequestConditions conditions, PageBlobRequestConditions sourceConditions, HttpAuthorization sourceAuthentication, FileShareTokenIntent? sourceTokenIntent, bool async, CancellationToken cancellationToken)
        {
            <UploadPagesFromUriInternal>d__67 stateMachine = default(<UploadPagesFromUriInternal>d__67);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<PageInfo>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.sourceUri = sourceUri;
            stateMachine.sourceRange = sourceRange;
            stateMachine.range = range;
            stateMachine.sourceContentHash = sourceContentHash;
            stateMachine.conditions = conditions;
            stateMachine.sourceConditions = sourceConditions;
            stateMachine.sourceAuthentication = sourceAuthentication;
            stateMachine.sourceTokenIntent = sourceTokenIntent;
            stateMachine.async = async;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        public virtual Stream OpenWrite(bool overwrite, long position, PageBlobOpenWriteOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            return OpenWriteInternal(overwrite, position, options, false, cancellationToken).EnsureCompleted();
        }
        [AsyncStateMachine(typeof(<OpenWriteAsync>d__69))]
        public virtual Task<Stream> OpenWriteAsync(bool overwrite, long position, PageBlobOpenWriteOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            <OpenWriteAsync>d__69 stateMachine = default(<OpenWriteAsync>d__69);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Stream>.Create();
            stateMachine.<>4__this = this;
            stateMachine.overwrite = overwrite;
            stateMachine.position = position;
            stateMachine.options = options;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [AsyncStateMachine(typeof(<OpenWriteInternal>d__70))]
        private Task<Stream> OpenWriteInternal(bool overwrite, long position, PageBlobOpenWriteOptions options, bool async, CancellationToken cancellationToken)
        {
            <OpenWriteInternal>d__70 stateMachine = default(<OpenWriteInternal>d__70);
            stateMachine.<>t__builder = AsyncTaskMethodBuilder<Stream>.Create();
            stateMachine.<>4__this = this;
            stateMachine.overwrite = overwrite;
            stateMachine.position = position;
            stateMachine.options = options;
            stateMachine.async = async;
            stateMachine.cancellationToken = cancellationToken;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
    }
}