From b4699d38f6583a2cb4136586e687f04c7784fae8 Mon Sep 17 00:00:00 2001 From: jehine-MSFT Date: Wed, 6 Apr 2016 13:36:27 -0700 Subject: [PATCH] Storage Client Library 7.0.0 --- .gitignore | 3 + BreakingChanges.txt | 22 + CONTRIBUTING.md | 2 +- .../Blob/CloudAppendBlob.cs | 311 +++---- Lib/ClassLibraryCommon/Blob/CloudBlob.cs | 457 ++++------ .../Blob/CloudBlobClient.cs | 122 +-- .../Blob/CloudBlobContainer.cs | 293 +++--- .../Blob/CloudBlobDirectory.cs | 22 +- Lib/ClassLibraryCommon/Blob/CloudBlockBlob.cs | 344 +++---- Lib/ClassLibraryCommon/Blob/CloudPageBlob.cs | 507 +++++----- Lib/ClassLibraryCommon/Blob/ICloudBlob.cs | 113 +-- .../Protocol/BlobHttpWebRequestFactory.cs | 31 + Lib/ClassLibraryCommon/File/CloudFile.cs | 473 +++++----- .../File/CloudFileClient.cs | 62 +- .../File/CloudFileDirectory.cs | 141 +-- Lib/ClassLibraryCommon/File/CloudFileShare.cs | 185 ++-- Lib/ClassLibraryCommon/Queue/CloudQueue.cs | 306 +++---- .../Queue/CloudQueueClient.cs | 78 +- Lib/ClassLibraryCommon/Table/CloudTable.cs | 225 ++--- .../Table/CloudTableClient.cs | 78 +- .../TableOperationHttpRequestFactory.cs | 43 +- .../TableOperationHttpResponseParsers.cs | 18 + .../Table/TableBatchOperation.cs | 34 +- .../Table/TableOperation.cs | 4 +- Lib/ClassLibraryCommon/Table/TableQuery.cs | 22 +- .../Table/TableQueryNonGeneric.cs | 4 +- Lib/Common/Auth/StorageCredentials.cs | 50 +- Lib/Common/Blob/BlobRequestOptions.cs | 119 ++- Lib/Common/Blob/BlobWriteStreamBase.cs | 4 - Lib/Common/Blob/CloudAppendBlob.Common.cs | 13 +- Lib/Common/Blob/CloudBlob.Common.cs | 9 - Lib/Common/Blob/CloudBlobClient.Common.cs | 119 +-- Lib/Common/Blob/CloudBlobContainer.Common.cs | 12 +- Lib/Common/Blob/CloudBlobDirectory.Common.cs | 13 +- Lib/Common/Blob/CloudBlockBlob.Common.cs | 13 +- Lib/Common/Blob/CloudPageBlob.Common.cs | 13 +- Lib/Common/Blob/PageDiffRange.cs | 47 + Lib/Common/Blob/PageRange.cs | 2 +- .../Protocol/GetPageDiffRangesResponse.cs | 128 +++ Lib/Common/CloudStorageAccount.cs | 6 +- .../Core/Auth/SharedAccessSignatureHelper.cs | 5 + Lib/Common/Core/Executor/ExecutionState.cs | 4 +- Lib/Common/Core/Executor/RESTCommand.cs | 4 +- .../Core/Executor/StorageCommandBase.cs | 4 - Lib/Common/Core/SR.cs | 4 + Lib/Common/Core/SasQueryBuilder.cs | 89 ++ Lib/Common/Core/UriQueryBuilder.cs | 44 +- Lib/Common/Core/Util/StreamExtensions.cs | 94 +- Lib/Common/File/CloudFile.Common.cs | 12 +- Lib/Common/File/CloudFileClient.Common.cs | 25 +- Lib/Common/File/CloudFileDirectory.Common.cs | 12 +- Lib/Common/File/CloudFileShare.Common.cs | 12 +- Lib/Common/File/FileRequestOptions.cs | 96 +- Lib/Common/File/FileWriteStreamBase.cs | 4 - .../File/Protocol/FileServiceProperties.cs | 9 +- Lib/Common/Queue/CloudQueue.Common.cs | 11 +- Lib/Common/Queue/CloudQueueClient.Common.cs | 94 +- Lib/Common/Queue/QueueRequestOptions.cs | 54 +- Lib/Common/Shared/Protocol/Constants.cs | 30 +- .../Shared/Protocol/LoggingProperties.cs | 16 + .../Shared/Protocol/MetricsProperties.cs | 16 + .../Shared/Protocol/ServiceProperties.cs | 50 +- Lib/Common/StorageException.cs | 13 +- Lib/Common/StorageExtendedErrorInformation.cs | 7 +- Lib/Common/Table/CloudTable.Common.cs | 12 +- Lib/Common/Table/CloudTableClient.Common.cs | 115 +-- Lib/Common/Table/DynamicTableEntity.cs | 2 - .../Table/TableBatchOperation.Common.cs | 17 +- Lib/Common/Table/TableOperation.Common.cs | 79 +- Lib/Common/Table/TablePayloadFormat.cs | 6 - Lib/Common/Table/TableQuery.Common.cs | 33 +- Lib/Common/Table/TableQueryGeneric.Common.cs | 33 +- Lib/Common/Table/TableRequestOptions.cs | 102 ++- .../Microsoft.WindowsAzure.Storage.csproj | 20 +- Lib/Portable/Properties/AssemblyInfo.cs | 6 +- Lib/WindowsDesktop/GlobalSuppressions.cs | 18 + .../Microsoft.WindowsAzure.Storage.csproj | 2 +- Lib/WindowsDesktop/Properties/AssemblyInfo.cs | 4 +- .../WindowsAzure.Storage.nuspec | 2 +- Lib/WindowsPhone/Properties/AssemblyInfo.cs | 4 +- Lib/WindowsPhoneRT/Properties/AssemblyInfo.cs | 4 +- ...rageAuthenticationHttpHandler.SharedKey.cs | 66 ++ .../StorageAuthenticationHttpHandler.cs | 79 ++ Lib/WindowsRuntime/Blob/BlobReadStream.cs | 2 +- Lib/WindowsRuntime/Blob/BlobWriteStream.cs | 10 +- .../Blob/BlobWriteStreamHelper.cs | 2 +- Lib/WindowsRuntime/Blob/CloudAppendBlob.cs | 591 +++--------- Lib/WindowsRuntime/Blob/CloudBlob.cs | 704 +++----------- Lib/WindowsRuntime/Blob/CloudBlobClient.cs | 232 +---- Lib/WindowsRuntime/Blob/CloudBlobContainer.cs | 567 ++---------- Lib/WindowsRuntime/Blob/CloudBlobDirectory.cs | 25 +- Lib/WindowsRuntime/Blob/CloudBlockBlob.cs | 516 ++--------- Lib/WindowsRuntime/Blob/CloudPageBlob.cs | 565 ++++-------- Lib/WindowsRuntime/Blob/ICloudBlob.cs | 212 +---- Lib/WindowsRuntime/Blob/ICloudBlobStream.cs | 16 +- .../Protocol/BlobHttpRequestMessageFactory.cs | 142 +-- .../ContainerHttpRequestMessageFactory.cs | 50 +- Lib/WindowsRuntime/Core/Executor/Executor.cs | 33 +- .../Core/StorageRequestMessage.cs | 41 + Lib/WindowsRuntime/ExceptionInfo.cs | 16 - Lib/WindowsRuntime/File/CloudFile.cs | 863 ++++-------------- Lib/WindowsRuntime/File/CloudFileClient.cs | 130 +-- Lib/WindowsRuntime/File/CloudFileDirectory.cs | 242 +---- Lib/WindowsRuntime/File/CloudFileShare.cs | 353 ++----- Lib/WindowsRuntime/File/FileReadStream.cs | 2 +- Lib/WindowsRuntime/File/FileWriteStream.cs | 6 +- .../File/FileWriteStreamHelper.cs | 2 +- Lib/WindowsRuntime/File/ICloudFileStream.cs | 23 +- .../DirectoryHttpRequestMessageFactory.cs | 28 +- .../Protocol/FileHttpRequestMessageFactory.cs | 70 +- .../ShareHttpRequestMessageFactory.cs | 48 +- .../Microsoft.WindowsAzure.Storage.csproj | 7 +- Lib/WindowsRuntime/Properties/AssemblyInfo.cs | 4 +- Lib/WindowsRuntime/Queue/CloudQueue.cs | 577 ++---------- Lib/WindowsRuntime/Queue/CloudQueueClient.cs | 171 +--- .../QueueHttpRequestMessageFactory.cs | 70 +- .../Shared/Protocol/HttpClientFactory.cs | 35 +- .../Protocol/HttpRequestMessageFactory.cs | 50 +- .../Protocol/RequestMessageExtensions.cs | 18 +- Lib/WindowsRuntime/Table/CloudTable.cs | 389 ++------ Lib/WindowsRuntime/Table/CloudTableClient.cs | 181 +--- .../Protocol/HttpRequestAdapterMessage.cs | 14 +- .../TableHttpRequestMessageFactory.cs | 35 +- .../TableOperationHttpRequestFactory.cs | 62 +- .../TableOperationHttpResponseParsers.cs | 21 +- .../Table/TableBatchOperation.cs | 48 +- Lib/WindowsRuntime/Table/TableOperation.cs | 39 +- Lib/WindowsRuntime/Table/TableQuery.cs | 41 +- Lib/WindowsRuntime/Table/TableQueryGeneric.cs | 36 +- README.md | 9 +- Test/ClassLibraryCommon/AccountSASTests.cs | 11 +- .../Blob/BlobAnalyticsUnitTests.cs | 67 +- .../Blob/BlobEncryptionTests.cs | 2 +- .../Blob/BlobUploadDownloadTest.cs | 144 ++- Test/ClassLibraryCommon/Blob/LeaseTests.cs | 14 +- Test/ClassLibraryCommon/Blob/SASTests.cs | 25 + .../File/FileAnalyticsUnitTests.cs | 2 +- .../File/FileUploadDownloadTest.cs | 54 +- .../Queue/QueueAnalyticsUnitTests.cs | 8 +- .../Table/CloudTableClientTests.cs | 36 + .../Table/SAS/TableSasUnitTests.cs | 4 +- .../Table/TableAnalyticsUnitTests.cs | 8 +- .../Table/TableBatchOperationTest.cs | 67 +- .../Table/TableEntityEncryptionTests.cs | 12 - .../Table/TableQueryGenericTests.cs | 62 +- .../Table/TableQueryTests.cs | 55 +- .../Table/TableQueryableTests.cs | 141 +-- Test/Common/TestBase.Common.cs | 11 +- Test/Common/TestHelper.Common.cs | 27 +- .../WindowsDesktop/Properties/AssemblyInfo.cs | 4 +- .../DataServices/SAS/TableSasUnitTests.cs | 2 +- .../DataServices/TableEntityUnitTests.cs | 14 - .../TableServiceQueryUnitTests.cs | 8 - Test/WindowsPhone/Properties/AssemblyInfo.cs | 4 +- .../WindowsPhone81/Properties/AssemblyInfo.cs | 4 +- .../Blob/BlobAnalyticsUnitTests.cs | 2 +- .../Blob/BlobUploadDownloadTest.cs | 4 +- .../Blob/CloudBlobContainerTest.cs | 2 - Test/WindowsPhoneCommon/Blob/LeaseTests.cs | 40 +- .../File/FileUploadDownloadTest.cs | 4 +- .../Queue/QueueAnalyticsUnitTests.cs | 2 +- .../Table/CloudTableCRUDUnitTaskTests.cs | 9 - .../Table/CloudTableClientTaskTest.cs | 4 - .../Table/TableAnalyticsUnitTaskTests.cs | 2 +- .../Table/TableBatchOperationTaskTest.cs | 28 - .../Table/TableOperationUnitTaskTests.cs | 20 - .../Table/TableQueryGenericTaskTests.cs | 11 - .../Table/TableQueryTaskTests.cs | 11 - .../Properties/AssemblyInfo.cs | 4 +- Test/WindowsRuntime/AccountSasTests.cs | 216 ++--- .../Blob/BlobAnalyticsUnitTests.cs | 6 +- .../Blob/BlobCancellationUnitTests.cs | 18 +- .../WindowsRuntime/Blob/BlobReadStreamTest.cs | 84 +- Test/WindowsRuntime/Blob/BlobStreamTests.cs | 40 +- Test/WindowsRuntime/Blob/BlobTestBase.cs | 8 +- .../Blob/BlobUploadDownloadTest.cs | 199 +++- .../Blob/BlobWriteStreamTest.cs | 60 +- .../Blob/CloudAppendBlobTest.cs | 120 +-- .../Blob/CloudBlobClientTest.cs | 26 +- .../Blob/CloudBlobContainerTest.cs | 31 +- .../Blob/CloudBlobDirectoryTest.cs | 16 +- Test/WindowsRuntime/Blob/CloudBlobTest.cs | 12 +- .../WindowsRuntime/Blob/CloudBlockBlobTest.cs | 126 +-- Test/WindowsRuntime/Blob/CloudPageBlobTest.cs | 132 +-- Test/WindowsRuntime/Blob/CopyBlobTest.cs | 14 +- Test/WindowsRuntime/Blob/LeaseTests.cs | 54 +- Test/WindowsRuntime/Blob/MD5FlagsTest.cs | 52 +- .../WindowsRuntime/Blob/MemoryOutputStream.cs | 41 +- Test/WindowsRuntime/Blob/SASTests.cs | 46 +- Test/WindowsRuntime/Core/LoggingTests.cs | 2 +- .../Core/MultiBufferMemoryStreamTests.cs | 4 +- .../WindowsRuntime/Core/RetryPoliciesTests.cs | 4 - Test/WindowsRuntime/Core/SecondaryTests.cs | 6 +- .../File/CloudFileClientTest.cs | 12 +- .../File/CloudFileDirectoryTest.cs | 20 +- .../File/CloudFileServiceTest.cs | 2 +- .../WindowsRuntime/File/CloudFileShareTest.cs | 36 +- Test/WindowsRuntime/File/CloudFileTest.cs | 74 +- Test/WindowsRuntime/File/CopyFileTest.cs | 6 +- Test/WindowsRuntime/File/FileMD5FlagsTest.cs | 28 +- .../WindowsRuntime/File/FileReadStreamTest.cs | 39 +- Test/WindowsRuntime/File/FileSASTests.cs | 6 +- Test/WindowsRuntime/File/FileStreamTests.cs | 40 +- Test/WindowsRuntime/File/FileTestBase.cs | 4 +- .../File/FileUploadDownloadTest.cs | 113 ++- .../File/FileWriteStreamTest.cs | 20 +- ...crosoft.WindowsAzure.StorageRT.Test.csproj | 9 +- .../WindowsRuntime/Properties/AssemblyInfo.cs | 4 +- .../Queue/CloudQueueMessageTest.cs | 4 +- Test/WindowsRuntime/Queue/CloudQueueTest.cs | 6 +- .../Queue/QueueAnalyticsUnitTests.cs | 6 +- .../Table/CloudTableCRUDUnitTests.cs | 14 +- .../Table/CloudTableClientTest.cs | 6 +- .../Table/SAS/TableSasFunctionalTests.cs | 2 +- .../Table/SAS/TableSasUnitTests.cs | 42 +- .../Table/TableAnalyticsUnitTests.cs | 6 +- .../Table/TableBatchOperationTest.cs | 93 +- .../Table/TableEntitySerializationTests.cs | 4 +- .../Table/TableEscapingTests.cs | 4 +- .../Table/TableOperationUnitTests.cs | 4 +- .../Table/TableQueryGenericTests.cs | 66 +- Test/WindowsRuntime/Table/TableQueryTests.cs | 67 +- Test/WindowsRuntime/TestBase.cs | 97 ++ Test/WindowsRuntime/TestHelper.cs | 27 + changelog.txt | 30 + 225 files changed, 6344 insertions(+), 9852 deletions(-) create mode 100644 Lib/Common/Blob/PageDiffRange.cs create mode 100644 Lib/Common/Blob/Protocol/GetPageDiffRangesResponse.cs create mode 100644 Lib/Common/Core/SasQueryBuilder.cs create mode 100644 Lib/WindowsRuntime/Auth/Protocol/StorageAuthenticationHttpHandler.SharedKey.cs create mode 100644 Lib/WindowsRuntime/Auth/Protocol/StorageAuthenticationHttpHandler.cs create mode 100644 Lib/WindowsRuntime/Core/StorageRequestMessage.cs diff --git a/.gitignore b/.gitignore index a1614a183..be4001bfc 100644 --- a/.gitignore +++ b/.gitignore @@ -118,6 +118,9 @@ Test/Common/TestConfigurations.xml # Test Results TestResults/ +# Test Config +Test/Common/TestConfigurations.xml + # Mac development .DS_Store diff --git a/BreakingChanges.txt b/BreakingChanges.txt index 2bb731861..797991552 100644 --- a/BreakingChanges.txt +++ b/BreakingChanges.txt @@ -1,7 +1,29 @@ Tracking Breaking Changes since 6.0 +- All: Support for 2015-07-08 REST version. Please see our REST API documentation and blogs for information about the related added features. If you are using the Storage Emulator, please update to Emulator version 4.3. +- All (WinRT): All apis now return Task objects instead of IAsync* objects. Please see our blog post for more info. - All: TestConfigurations.xml has been deleted and added to the .gitignore file to keep users from accidentally leaking their credentials. To continue running tests, simply add the same file back after you get the latest code. +- All: Virtualized all service call APIs and unsealed their classes. +- All: Updated the UserAgent string to match the Azure Storage standard. - All: The dnx and net target frameworks have been unified, and DNXCore target framework has been renamed to Dotnet5.4. All DNX4.5.1 projects will take a dependency on the regular Windows Desktop dll. +- All: Windows Runtime no longer uses WrappedStorageExceptions or HResults. Catch StorageException and check HTTP status code instead. +- All: SetServiceProperties APIs no longer instantiates Logging, HourMetrics, MinuteMetrics, or Cors instance variables. New LoggingProperties, MetricsProperties, and CorsProperties objects will need to be set for those variables before they can be assigned. +- All: LoggingProperties and MetricsProperties Version now defaults to "1.0" or Constants.AnalyticsConstants.MetricsVersionV1 or LoggingVersionV1. +- All: Removed deprecated SharedKeyLiteAuthenticationHandler, use SharedKeyAuthenticationHandler instead. +- All: Removed deprecated request options setters on the *Client class object in favor of setting request options on Client's DefaultRequestOptions object. +- All: When creating a SAS token with a non-null SharedAccessProtocol, only valid enum values are permitted. All other values will now throw an ArgumentException. +- Blobs: Removed deprecated (Begin/End)StartCopyFromBlob(Async) APIs in favor of using (Begin/End)StartCopy(Async) APIs. +- Blobs: Removed deprecated GetSubdirectoryReference API in favor of GetDirectoryReference. +- Blobs: Removed FileMode parameter for UploadFromFile* and AppendFromFile* APIs since there is only 1 valid option (FileMode.Open). +- Blobs: When downloading blob to local file fails, file created for download will be cleaned up. +- Blobs: proposedLeaseId for minimum AcquireLease API overloads defaults to null. +- Tables: Removed deprecated AtomPub payloadFormat support. +- Tables: Fixed a bug in table batch where storage exceptions resulted in operation contexts with incorrect HttpStatusMessage. +- Tables: Batching validation was added for batch sizes exceeding 100 operations. +- Tables: Batching validation was added for null partition keys and row keys. +- Tables: Removed deprecated overloads for Table.Retrieve APIs. +- Files: When downloading file to local system file fails, file created for download will be cleaned up. +- Queues: Removed deprecated EndBeginClear API in favor of EndClear. Tracking Breaking Changes since 5.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2f47fde3d..f73f212e3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,7 +3,7 @@ If you intend to contribute to the project, please make sure you've followed the The Azure Storage development team uses Visual Studio so instructions will be tailored to that preference. However, any preferred IDE or other toolset should be usable. ### Install -* .Net 4.5.1 +* .Net 4.0 * Visual Studio 2013. If you want to work with the CoreCLR SDK, you will need Visual Studio 2015. Note not all of the non-CoreCLR SDKs work in VS 2015, so you may need to develop with both 2013 and 2015 if you take a dependency on multiple runtimes. * [StyleCop](http://stylecop.codeplex.com/) checks your code’s style – spacing, comments, etc. You can run this from the Tools menu in Visual Studio or by right clicking the project/folder you’d like to run it on. * Clone the source code from GitHub. diff --git a/Lib/ClassLibraryCommon/Blob/CloudAppendBlob.cs b/Lib/ClassLibraryCommon/Blob/CloudAppendBlob.cs index c3cf8f186..7e3def7ae 100644 --- a/Lib/ClassLibraryCommon/Blob/CloudAppendBlob.cs +++ b/Lib/ClassLibraryCommon/Blob/CloudAppendBlob.cs @@ -37,7 +37,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// Represents an append blob, a type of blob where blocks of data are always committed to the end of the blob. /// - public sealed partial class CloudAppendBlob : CloudBlob, ICloudBlob + public partial class CloudAppendBlob : CloudBlob, ICloudBlob { #if SYNC /// @@ -55,7 +55,7 @@ public sealed partial class CloudAppendBlob : CloudBlob, ICloudBlob /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public CloudBlobStream OpenWrite(bool createNew, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual CloudBlobStream OpenWrite(bool createNew, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, this.BlobType, this.ServiceClient, false); @@ -123,7 +123,7 @@ public CloudBlobStream OpenWrite(bool createNew, AccessCondition accessCondition /// ranging from between 16 KB and 4 MB inclusive. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginOpenWrite(bool createNew, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginOpenWrite(bool createNew, AsyncCallback callback, object state) { return this.BeginOpenWrite(createNew, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -146,7 +146,7 @@ public ICancellableAsyncResult BeginOpenWrite(bool createNew, AsyncCallback call /// [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Needed to ensure exceptions are not thrown on threadpool threads.")] [DoesServiceRequest] - public ICancellableAsyncResult BeginOpenWrite(bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginOpenWrite(bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, this.BlobType, this.ServiceClient, false); @@ -255,7 +255,7 @@ public ICancellableAsyncResult BeginOpenWrite(bool createNew, AccessCondition ac /// /// An that references the pending asynchronous operation. /// A object. - public CloudBlobStream EndOpenWrite(IAsyncResult asyncResult) + public virtual CloudBlobStream EndOpenWrite(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; storageAsyncResult.End(); @@ -274,7 +274,7 @@ public CloudBlobStream EndOpenWrite(IAsyncResult asyncResult) /// ranging from between 16 KB and 4 MB inclusive. /// [DoesServiceRequest] - public Task OpenWriteAsync(bool createNew) + public virtual Task OpenWriteAsync(bool createNew) { return this.OpenWriteAsync(createNew, CancellationToken.None); } @@ -291,7 +291,7 @@ public Task OpenWriteAsync(bool createNew) /// ranging from between 16 KB and 4 MB inclusive. /// [DoesServiceRequest] - public Task OpenWriteAsync(bool createNew, CancellationToken cancellationToken) + public virtual Task OpenWriteAsync(bool createNew, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginOpenWrite, this.EndOpenWrite, createNew, cancellationToken); } @@ -311,7 +311,7 @@ public Task OpenWriteAsync(bool createNew, CancellationToken ca /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task OpenWriteAsync(bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task OpenWriteAsync(bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.OpenWriteAsync(createNew, accessCondition, options, operationContext, CancellationToken.None); } @@ -332,7 +332,7 @@ public Task OpenWriteAsync(bool createNew, AccessCondition acce /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task OpenWriteAsync(bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task OpenWriteAsync(bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginOpenWrite, this.EndOpenWrite, createNew, accessCondition, options, operationContext, cancellationToken); } @@ -352,7 +352,7 @@ public Task OpenWriteAsync(bool createNew, AccessCondition acce /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public void UploadFromStream(Stream source, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromStream(Stream source, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.UploadFromStreamHelper(source, null /* length */, true /* createNew */, accessCondition, options, operationContext); } @@ -371,7 +371,7 @@ public void UploadFromStream(Stream source, AccessCondition accessCondition = nu /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public void UploadFromStream(Stream source, long length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromStream(Stream source, long length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.UploadFromStreamHelper(source, length, true /* createNew */, accessCondition, options, operationContext); } @@ -388,7 +388,7 @@ public void UploadFromStream(Stream source, long length, AccessCondition accessC /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public void AppendFromStream(Stream source, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void AppendFromStream(Stream source, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.UploadFromStreamHelper(source, null /* length */, false /* createNew */, accessCondition, options, operationContext); } @@ -406,7 +406,7 @@ public void AppendFromStream(Stream source, AccessCondition accessCondition = nu /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public void AppendFromStream(Stream source, long length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void AppendFromStream(Stream source, long length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.UploadFromStreamHelper(source, length, false /* createNew */, accessCondition, options, operationContext); } @@ -462,7 +462,7 @@ internal void UploadFromStreamHelper(Stream source, long? length, bool createNew /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, null /* length */, true /* createNew */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -483,7 +483,7 @@ public ICancellableAsyncResult BeginUploadFromStream(Stream source, AsyncCallbac /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, null /* length */, true /* createNew */, accessCondition, options, operationContext, callback, state); } @@ -502,7 +502,7 @@ public ICancellableAsyncResult BeginUploadFromStream(Stream source, AccessCondit /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, length, true /* createNew */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -524,7 +524,7 @@ public ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, length, true /* createNew */, accessCondition, options, operationContext, callback, state); } @@ -540,7 +540,7 @@ public ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginAppendFromStream(Stream source, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAppendFromStream(Stream source, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, null /* length */, false /* createNew */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -560,7 +560,7 @@ public ICancellableAsyncResult BeginAppendFromStream(Stream source, AsyncCallbac /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginAppendFromStream(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAppendFromStream(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, null /* length */, false /* createNew */, accessCondition, options, operationContext, callback, state); } @@ -577,7 +577,7 @@ public ICancellableAsyncResult BeginAppendFromStream(Stream source, AccessCondit /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginAppendFromStream(Stream source, long length, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAppendFromStream(Stream source, long length, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, length, false /* createNew */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -598,7 +598,7 @@ public ICancellableAsyncResult BeginAppendFromStream(Stream source, long length, /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginAppendFromStream(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAppendFromStream(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, length, false /* createNew */, accessCondition, options, operationContext, callback, state); } @@ -722,7 +722,7 @@ internal ICancellableAsyncResult BeginUploadFromStreamHelper(Stream source, long /// Ends an asynchronous operation to upload a stream to an append blob. /// /// An that references the pending asynchronous operation. - public void EndUploadFromStream(IAsyncResult asyncResult) + public virtual void EndUploadFromStream(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; storageAsyncResult.End(); @@ -732,7 +732,7 @@ public void EndUploadFromStream(IAsyncResult asyncResult) /// Ends an asynchronous operation to append a stream to an append blob. /// /// An that references the pending asynchronous operation. - public void EndAppendFromStream(IAsyncResult asyncResult) + public virtual void EndAppendFromStream(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; storageAsyncResult.End(); @@ -748,7 +748,7 @@ public void EndAppendFromStream(IAsyncResult asyncResult) /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source) + public virtual Task UploadFromStreamAsync(Stream source) { return this.UploadFromStreamAsync(source, CancellationToken.None); } @@ -763,7 +763,7 @@ public Task UploadFromStreamAsync(Stream source) /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, cancellationToken); } @@ -782,7 +782,7 @@ public Task UploadFromStreamAsync(Stream source, CancellationToken cancellationT /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsync(source, accessCondition, options, operationContext, CancellationToken.None); } @@ -802,7 +802,7 @@ public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, accessCondition, options, operationContext, cancellationToken); } @@ -817,7 +817,7 @@ public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length) + public virtual Task UploadFromStreamAsync(Stream source, long length) { return this.UploadFromStreamAsync(source, length, CancellationToken.None); } @@ -833,7 +833,7 @@ public Task UploadFromStreamAsync(Stream source, long length) /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, long length, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, length, cancellationToken); } @@ -853,7 +853,7 @@ public Task UploadFromStreamAsync(Stream source, long length, CancellationToken /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsync(source, length, accessCondition, options, operationContext, CancellationToken.None); } @@ -874,7 +874,7 @@ public Task UploadFromStreamAsync(Stream source, long length, AccessCondition ac /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, length, accessCondition, options, operationContext, cancellationToken); } @@ -888,7 +888,7 @@ public Task UploadFromStreamAsync(Stream source, long length, AccessCondition ac /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source) + public virtual Task AppendFromStreamAsync(Stream source) { return this.AppendFromStreamAsync(source, CancellationToken.None); } @@ -903,7 +903,7 @@ public Task AppendFromStreamAsync(Stream source) /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source, CancellationToken cancellationToken) + public virtual Task AppendFromStreamAsync(Stream source, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAppendFromStream, this.EndAppendFromStream, source, cancellationToken); } @@ -921,7 +921,7 @@ public Task AppendFromStreamAsync(Stream source, CancellationToken cancellationT /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AppendFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.AppendFromStreamAsync(source, accessCondition, options, operationContext, CancellationToken.None); } @@ -940,7 +940,7 @@ public Task AppendFromStreamAsync(Stream source, AccessCondition accessCondition /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AppendFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAppendFromStream, this.EndAppendFromStream, source, accessCondition, options, operationContext, cancellationToken); } @@ -955,7 +955,7 @@ public Task AppendFromStreamAsync(Stream source, AccessCondition accessCondition /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source, long length) + public virtual Task AppendFromStreamAsync(Stream source, long length) { return this.AppendFromStreamAsync(source, length, CancellationToken.None); } @@ -971,7 +971,7 @@ public Task AppendFromStreamAsync(Stream source, long length) /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source, long length, CancellationToken cancellationToken) + public virtual Task AppendFromStreamAsync(Stream source, long length, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAppendFromStream, this.EndAppendFromStream, source, length, cancellationToken); } @@ -990,7 +990,7 @@ public Task AppendFromStreamAsync(Stream source, long length, CancellationToken /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AppendFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.AppendFromStreamAsync(source, length, accessCondition, options, operationContext, CancellationToken.None); } @@ -1010,7 +1010,7 @@ public Task AppendFromStreamAsync(Stream source, long length, AccessCondition ac /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AppendFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAppendFromStream, this.EndAppendFromStream, source, length, accessCondition, options, operationContext, cancellationToken); } @@ -1021,7 +1021,6 @@ public Task AppendFromStreamAsync(Stream source, long length, AccessCondition ac /// Uploads a file to an append blob. If the blob already exists, it will be overwritten. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. @@ -1031,11 +1030,11 @@ public Task AppendFromStreamAsync(Stream source, long length, AccessCondition ac /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public void UploadFromFile(string path, FileMode mode, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromFile(string path, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("path", path); - using (FileStream fileStream = new FileStream(path, mode, FileAccess.Read)) + using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { this.UploadFromStream(fileStream, accessCondition, options, operationContext); } @@ -1045,7 +1044,6 @@ public void UploadFromFile(string path, FileMode mode, AccessCondition accessCon /// Appends a file to an append blob. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. @@ -1054,11 +1052,11 @@ public void UploadFromFile(string path, FileMode mode, AccessCondition accessCon /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public void AppendFromFile(string path, FileMode mode, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void AppendFromFile(string path, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("path", path); - using (FileStream fileStream = new FileStream(path, mode, FileAccess.Read)) + using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { this.AppendFromStream(fileStream, accessCondition, options, operationContext); } @@ -1069,26 +1067,24 @@ public void AppendFromFile(string path, FileMode mode, AccessCondition accessCon /// Begins an asynchronous operation to upload a file to an append blob. If the blob already exists, it will be overwritten. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// To append data to an append blob that already exists, see . + /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromFile(string path, AsyncCallback callback, object state) { - return this.BeginUploadFromFile(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); + return this.BeginUploadFromFile(path, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } /// /// Begins an asynchronous operation to upload a file to an append blob. If the blob already exists, it will be overwritten. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. @@ -1098,14 +1094,14 @@ public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, A /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// To append data to an append blob that already exists, see . + /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromFile(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("path", path); - FileStream fileStream = new FileStream(path, mode, FileAccess.Read); + FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state) { OperationState = fileStream @@ -1128,7 +1124,6 @@ public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, A /// Begins an asynchronous operation to append a file to an append blob. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. @@ -1137,16 +1132,15 @@ public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, A /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginAppendFromFile(string path, FileMode mode, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAppendFromFile(string path, AsyncCallback callback, object state) { - return this.BeginAppendFromFile(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); + return this.BeginAppendFromFile(path, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } /// /// Begins an asynchronous operation to append a file to an append blob. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. @@ -1158,11 +1152,11 @@ public ICancellableAsyncResult BeginAppendFromFile(string path, FileMode mode, A /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginAppendFromFile(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAppendFromFile(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("path", path); - FileStream fileStream = new FileStream(path, mode, FileAccess.Read); + FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state) { OperationState = fileStream @@ -1221,7 +1215,7 @@ private void UploadFromFileCallback(IAsyncResult asyncResult) /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// - public void EndUploadFromFile(IAsyncResult asyncResult) + public virtual void EndUploadFromFile(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -1234,7 +1228,7 @@ public void EndUploadFromFile(IAsyncResult asyncResult) /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// - public void EndAppendFromFile(IAsyncResult asyncResult) + public virtual void EndAppendFromFile(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -1245,40 +1239,37 @@ public void EndAppendFromFile(IAsyncResult asyncResult) /// Initiates an asynchronous operation to upload a file to an append blob. If the blob already exists, it will be overwritten. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A object that represents the asynchronous operation. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. - /// To append data to an append blob that already exists, see . + /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode) + public virtual Task UploadFromFileAsync(string path) { - return this.UploadFromFileAsync(path, mode, CancellationToken.None); + return this.UploadFromFileAsync(path, CancellationToken.None); } /// /// Initiates an asynchronous operation to upload a file to an append blob. If the blob already exists, it will be overwritten. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. - /// To append data to an append blob that already exists, see . + /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, CancellationToken cancellationToken) + public virtual Task UploadFromFileAsync(string path, CancellationToken cancellationToken) { - return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, mode, cancellationToken); + return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, cancellationToken); } /// /// Initiates an asynchronous operation to upload a file to an append blob. If the blob already exists, it will be overwritten. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. @@ -1286,19 +1277,18 @@ public Task UploadFromFileAsync(string path, FileMode mode, CancellationToken ca /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// To append data to an append blob that already exists, see . + /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { - return this.UploadFromFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); + return this.UploadFromFileAsync(path, accessCondition, options, operationContext, CancellationToken.None); } /// /// Initiates an asynchronous operation to upload a file to an append blob. If the blob already exists, it will be overwritten. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. @@ -1307,50 +1297,47 @@ public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition acce /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// To append data to an append blob that already exists, see . + /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { - return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, mode, accessCondition, options, operationContext, cancellationToken); + return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, accessCondition, options, operationContext, cancellationToken); } /// /// Initiates an asynchronous operation to append a file to an append blob. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A object that represents the asynchronous operation. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// [DoesServiceRequest] - public Task AppendFromFileAsync(string path, FileMode mode) + public virtual Task AppendFromFileAsync(string path) { - return this.AppendFromFileAsync(path, mode, CancellationToken.None); + return this.AppendFromFileAsync(path, CancellationToken.None); } /// /// Initiates an asynchronous operation to append a file to an append blob. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// [DoesServiceRequest] - public Task AppendFromFileAsync(string path, FileMode mode, CancellationToken cancellationToken) + public virtual Task AppendFromFileAsync(string path, CancellationToken cancellationToken) { - return AsyncExtensions.TaskFromVoidApm(this.BeginAppendFromFile, this.EndAppendFromFile, path, mode, cancellationToken); + return AsyncExtensions.TaskFromVoidApm(this.BeginAppendFromFile, this.EndAppendFromFile, path, cancellationToken); } /// /// Initiates an asynchronous operation to append a file to an append blob. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. @@ -1360,16 +1347,15 @@ public Task AppendFromFileAsync(string path, FileMode mode, CancellationToken ca /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AppendFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { - return this.AppendFromFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); + return this.AppendFromFileAsync(path, accessCondition, options, operationContext, CancellationToken.None); } /// /// Initiates an asynchronous operation to append a file to an append blob. Recommended only for single-writer scenarios. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. @@ -1380,9 +1366,9 @@ public Task AppendFromFileAsync(string path, FileMode mode, AccessCondition acce /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AppendFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { - return AsyncExtensions.TaskFromVoidApm(this.BeginAppendFromFile, this.EndAppendFromFile, path, mode, accessCondition, options, operationContext, cancellationToken); + return AsyncExtensions.TaskFromVoidApm(this.BeginAppendFromFile, this.EndAppendFromFile, path, accessCondition, options, operationContext, cancellationToken); } #endif @@ -1402,7 +1388,7 @@ public Task AppendFromFileAsync(string path, FileMode mode, AccessCondition acce /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public void UploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("buffer", buffer); @@ -1426,7 +1412,7 @@ public void UploadFromByteArray(byte[] buffer, int index, int count, AccessCondi /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public void AppendFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void AppendFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("buffer", buffer); @@ -1451,7 +1437,7 @@ public void AppendFromByteArray(byte[] buffer, int index, int count, AccessCondi /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AsyncCallback callback, object state) { return this.BeginUploadFromByteArray(buffer, index, count, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1474,7 +1460,7 @@ public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("buffer", buffer); @@ -1489,7 +1475,7 @@ public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// - public void EndUploadFromByteArray(IAsyncResult asyncResult) + public virtual void EndUploadFromByteArray(IAsyncResult asyncResult) { this.EndUploadFromStream(asyncResult); } @@ -1507,7 +1493,7 @@ public void EndUploadFromByteArray(IAsyncResult asyncResult) /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginAppendFromByteArray(byte[] buffer, int index, int count, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAppendFromByteArray(byte[] buffer, int index, int count, AsyncCallback callback, object state) { return this.BeginAppendFromByteArray(buffer, index, count, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1529,7 +1515,7 @@ public ICancellableAsyncResult BeginAppendFromByteArray(byte[] buffer, int index /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginAppendFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAppendFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("buffer", buffer); @@ -1541,7 +1527,7 @@ public ICancellableAsyncResult BeginAppendFromByteArray(byte[] buffer, int index /// Ends an asynchronous operation to append the contents of a byte array to an append blob. Recommended only for single-writer scenarios. /// /// An that references the pending asynchronous operation. - public void EndAppendFromByteArray(IAsyncResult asyncResult) + public virtual void EndAppendFromByteArray(IAsyncResult asyncResult) { this.EndAppendFromStream(asyncResult); } @@ -1559,7 +1545,7 @@ public void EndAppendFromByteArray(IAsyncResult asyncResult) /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) { return this.UploadFromByteArrayAsync(buffer, index, count, CancellationToken.None); } @@ -1577,7 +1563,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromByteArray, this.EndUploadFromByteArray, buffer, index, count, cancellationToken); } @@ -1598,7 +1584,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, Cancel /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromByteArrayAsync(buffer, index, count, accessCondition, options, operationContext, CancellationToken.None); } @@ -1620,7 +1606,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, Access /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromByteArray, this.EndUploadFromByteArray, buffer, index, count, accessCondition, options, operationContext, cancellationToken); } @@ -1636,7 +1622,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, Access /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// [DoesServiceRequest] - public Task AppendFromByteArrayAsync(byte[] buffer, int index, int count) + public virtual Task AppendFromByteArrayAsync(byte[] buffer, int index, int count) { return this.AppendFromByteArrayAsync(buffer, index, count, CancellationToken.None); } @@ -1653,7 +1639,7 @@ public Task AppendFromByteArrayAsync(byte[] buffer, int index, int count) /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// [DoesServiceRequest] - public Task AppendFromByteArrayAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken) + public virtual Task AppendFromByteArrayAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAppendFromByteArray, this.EndAppendFromByteArray, buffer, index, count, cancellationToken); } @@ -1673,7 +1659,7 @@ public Task AppendFromByteArrayAsync(byte[] buffer, int index, int count, Cancel /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AppendFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.AppendFromByteArrayAsync(buffer, index, count, accessCondition, options, operationContext, CancellationToken.None); } @@ -1694,7 +1680,7 @@ public Task AppendFromByteArrayAsync(byte[] buffer, int index, int count, Access /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AppendFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAppendFromByteArray, this.EndAppendFromByteArray, buffer, index, count, accessCondition, options, operationContext, cancellationToken); } @@ -1715,7 +1701,7 @@ public Task AppendFromByteArrayAsync(byte[] buffer, int index, int count, Access /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public void UploadText(string content, Encoding encoding = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadText(string content, Encoding encoding = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("content", content); @@ -1736,7 +1722,7 @@ public void UploadText(string content, Encoding encoding = null, AccessCondition /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public void AppendText(string content, Encoding encoding = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void AppendText(string content, Encoding encoding = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("content", content); @@ -1757,7 +1743,7 @@ public void AppendText(string content, Encoding encoding = null, AccessCondition /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadText(string content, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadText(string content, AsyncCallback callback, object state) { return this.BeginUploadText(content, null /* encoding */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1779,7 +1765,7 @@ public ICancellableAsyncResult BeginUploadText(string content, AsyncCallback cal /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadText(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadText(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("content", content); @@ -1792,7 +1778,7 @@ public ICancellableAsyncResult BeginUploadText(string content, Encoding encoding /// because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario. /// /// An that references the pending asynchronous operation. - public void EndUploadText(IAsyncResult asyncResult) + public virtual void EndUploadText(IAsyncResult asyncResult) { this.EndUploadFromByteArray(asyncResult); } @@ -1806,7 +1792,7 @@ public void EndUploadText(IAsyncResult asyncResult) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginAppendText(string content, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAppendText(string content, AsyncCallback callback, object state) { return this.BeginAppendText(content, null /* encoding */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1827,7 +1813,7 @@ public ICancellableAsyncResult BeginAppendText(string content, AsyncCallback cal /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginAppendText(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAppendText(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("content", content); @@ -1840,7 +1826,7 @@ public ICancellableAsyncResult BeginAppendText(string content, Encoding encoding /// because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario. /// /// An that references the pending asynchronous operation. - public void EndAppendText(IAsyncResult asyncResult) + public virtual void EndAppendText(IAsyncResult asyncResult) { this.EndAppendFromByteArray(asyncResult); } @@ -1856,7 +1842,7 @@ public void EndAppendText(IAsyncResult asyncResult) /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadTextAsync(string content) + public virtual Task UploadTextAsync(string content) { return this.UploadTextAsync(content, CancellationToken.None); } @@ -1873,7 +1859,7 @@ public Task UploadTextAsync(string content) /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadTextAsync(string content, CancellationToken cancellationToken) + public virtual Task UploadTextAsync(string content, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadText, this.EndUploadText, content, cancellationToken); } @@ -1893,7 +1879,7 @@ public Task UploadTextAsync(string content, CancellationToken cancellationToken) /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadTextAsync(content, encoding, accessCondition, options, operationContext, CancellationToken.None); } @@ -1914,7 +1900,7 @@ public Task UploadTextAsync(string content, Encoding encoding, AccessCondition a /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadText, this.EndUploadText, content, encoding, accessCondition, options, operationContext, cancellationToken); } @@ -1926,7 +1912,7 @@ public Task UploadTextAsync(string content, Encoding encoding, AccessCondition a /// A string containing the text to upload. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AppendTextAsync(string content) + public virtual Task AppendTextAsync(string content) { return this.AppendTextAsync(content, CancellationToken.None); } @@ -1939,7 +1925,7 @@ public Task AppendTextAsync(string content) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AppendTextAsync(string content, CancellationToken cancellationToken) + public virtual Task AppendTextAsync(string content, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAppendText, this.EndAppendText, content, cancellationToken); } @@ -1958,7 +1944,7 @@ public Task AppendTextAsync(string content, CancellationToken cancellationToken) /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AppendTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.AppendTextAsync(content, encoding, accessCondition, options, operationContext, CancellationToken.None); } @@ -1978,7 +1964,7 @@ public Task AppendTextAsync(string content, Encoding encoding, AccessCondition a /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AppendTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAppendText, this.EndAppendText, content, encoding, accessCondition, options, operationContext, cancellationToken); } @@ -1993,7 +1979,7 @@ public Task AppendTextAsync(string content, Encoding encoding, AccessCondition a /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void CreateOrReplace(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void CreateOrReplace(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.AppendBlob, this.ServiceClient); @@ -2012,7 +1998,7 @@ public void CreateOrReplace(AccessCondition accessCondition = null, BlobRequestO /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateOrReplace(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateOrReplace(AsyncCallback callback, object state) { return this.BeginCreateOrReplace(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2028,7 +2014,7 @@ public ICancellableAsyncResult BeginCreateOrReplace(AsyncCallback callback, obje /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateOrReplace(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateOrReplace(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.AppendBlob, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2043,7 +2029,7 @@ public ICancellableAsyncResult BeginCreateOrReplace(AccessCondition accessCondit /// Ends an asynchronous operation to create an append blob. /// /// An that references the pending asynchronous operation. - public void EndCreateOrReplace(IAsyncResult asyncResult) + public virtual void EndCreateOrReplace(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -2055,7 +2041,7 @@ public void EndCreateOrReplace(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateOrReplaceAsync() + public virtual Task CreateOrReplaceAsync() { return this.CreateOrReplaceAsync(CancellationToken.None); } @@ -2067,7 +2053,7 @@ public Task CreateOrReplaceAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateOrReplaceAsync(CancellationToken cancellationToken) + public virtual Task CreateOrReplaceAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreateOrReplace, this.EndCreateOrReplace, cancellationToken); } @@ -2081,7 +2067,7 @@ public Task CreateOrReplaceAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateOrReplaceAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateOrReplaceAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.CreateOrReplaceAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -2096,7 +2082,7 @@ public Task CreateOrReplaceAsync(AccessCondition accessCondition, BlobRequestOpt /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateOrReplaceAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateOrReplaceAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreateOrReplace, this.EndCreateOrReplace, accessCondition, options, operationContext, cancellationToken); } @@ -2119,7 +2105,7 @@ public Task CreateOrReplaceAsync(AccessCondition accessCondition, BlobRequestOpt /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public long AppendBlock(Stream blockData, string contentMD5 = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual long AppendBlock(Stream blockData, string contentMD5 = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("blockData", blockData); @@ -2182,7 +2168,7 @@ public long AppendBlock(Stream blockData, string contentMD5 = null, AccessCondit /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginAppendBlock(Stream blockData, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAppendBlock(Stream blockData, AsyncCallback callback, object state) { return this.BeginAppendBlock(blockData, null /* contentMD5 */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2202,7 +2188,7 @@ public ICancellableAsyncResult BeginAppendBlock(Stream blockData, AsyncCallback /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginAppendBlock(Stream blockData, string contentMD5, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAppendBlock(Stream blockData, string contentMD5, AsyncCallback callback, object state) { return this.BeginAppendBlock(blockData, contentMD5, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2226,7 +2212,7 @@ public ICancellableAsyncResult BeginAppendBlock(Stream blockData, string content /// [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Needed to ensure exceptions are not thrown on threadpool threads.")] [DoesServiceRequest] - public ICancellableAsyncResult BeginAppendBlock(Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAppendBlock(Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("blockData", blockData); @@ -2335,7 +2321,7 @@ private void AppendBlockHandler(Stream blockData, string contentMD5, AccessCondi /// Ends an asynchronous operation to commit a new block of data to the end of the blob. /// /// An that references the pending asynchronous operation. - public long EndAppendBlock(IAsyncResult asyncResult) + public virtual long EndAppendBlock(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; @@ -2368,7 +2354,7 @@ public long EndAppendBlock(IAsyncResult asyncResult) /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public Task AppendBlockAsync(Stream blockData, string contentMD5 = null) + public virtual Task AppendBlockAsync(Stream blockData, string contentMD5 = null) { return this.AppendBlockAsync(blockData, contentMD5, CancellationToken.None); } @@ -2387,7 +2373,7 @@ public Task AppendBlockAsync(Stream blockData, string contentMD5 = null) /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public Task AppendBlockAsync(Stream blockData, string contentMD5, CancellationToken cancellationToken) + public virtual Task AppendBlockAsync(Stream blockData, string contentMD5, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginAppendBlock, this.EndAppendBlock, blockData, contentMD5, cancellationToken); } @@ -2408,7 +2394,7 @@ public Task AppendBlockAsync(Stream blockData, string contentMD5, Cancella /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public Task AppendBlockAsync(Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AppendBlockAsync(Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.AppendBlockAsync(blockData, contentMD5, accessCondition, options, operationContext, CancellationToken.None); } @@ -2430,7 +2416,7 @@ public Task AppendBlockAsync(Stream blockData, string contentMD5, AccessCo /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public Task AppendBlockAsync(Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AppendBlockAsync(Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginAppendBlock, this.EndAppendBlock, blockData, contentMD5, accessCondition, options, operationContext, cancellationToken); } @@ -2445,7 +2431,8 @@ public Task AppendBlockAsync(Stream blockData, string contentMD5, AccessCo /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. /// The contents of the blob, as a string. - public string DownloadText(Encoding encoding = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + [DoesServiceRequest] + public virtual string DownloadText(Encoding encoding = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { using (SyncMemoryStream stream = new SyncMemoryStream()) { @@ -2462,7 +2449,8 @@ public string DownloadText(Encoding encoding = null, AccessCondition accessCondi /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. - public ICancellableAsyncResult BeginDownloadText(AsyncCallback callback, object state) + [DoesServiceRequest] + public virtual ICancellableAsyncResult BeginDownloadText(AsyncCallback callback, object state) { return this.BeginDownloadText(null /* encoding */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2477,7 +2465,8 @@ public ICancellableAsyncResult BeginDownloadText(AsyncCallback callback, object /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. - public ICancellableAsyncResult BeginDownloadText(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + [DoesServiceRequest] + public virtual ICancellableAsyncResult BeginDownloadText(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { SyncMemoryStream stream = new SyncMemoryStream(); StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state) { OperationState = Tuple.Create(stream, encoding) }; @@ -2522,7 +2511,7 @@ private void DownloadTextCallback(IAsyncResult asyncResult) /// /// An that references the pending asynchronous operation. /// The contents of the blob, as a string. - public string EndDownloadText(IAsyncResult asyncResult) + public virtual string EndDownloadText(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -2535,7 +2524,7 @@ public string EndDownloadText(IAsyncResult asyncResult) /// /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadTextAsync() + public virtual Task DownloadTextAsync() { return this.DownloadTextAsync(CancellationToken.None); } @@ -2546,7 +2535,7 @@ public Task DownloadTextAsync() /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadTextAsync(CancellationToken cancellationToken) + public virtual Task DownloadTextAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadText, this.EndDownloadText, cancellationToken); } @@ -2560,7 +2549,7 @@ public Task DownloadTextAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadTextAsync(encoding, accessCondition, options, operationContext, CancellationToken.None); } @@ -2575,7 +2564,7 @@ public Task DownloadTextAsync(Encoding encoding, AccessCondition accessC /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadText, this.EndDownloadText, encoding, accessCondition, options, operationContext, cancellationToken); } @@ -2596,7 +2585,7 @@ public Task DownloadTextAsync(Encoding encoding, AccessCondition accessC /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public string StartCopy(CloudAppendBlob source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual string StartCopy(CloudAppendBlob source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { return this.StartCopy(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); } @@ -2610,7 +2599,7 @@ public string StartCopy(CloudAppendBlob source, AccessCondition sourceAccessCond /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(CloudAppendBlob source, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(CloudAppendBlob source, AsyncCallback callback, object state) { return this.BeginStartCopy(CloudBlob.SourceBlobToUri(source), callback, state); } @@ -2627,7 +2616,7 @@ public ICancellableAsyncResult BeginStartCopy(CloudAppendBlob source, AsyncCallb /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(CloudAppendBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(CloudAppendBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginStartCopy(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, callback, state); } @@ -2639,7 +2628,7 @@ public ICancellableAsyncResult BeginStartCopy(CloudAppendBlob source, AccessCond /// A object. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudAppendBlob source) + public virtual Task StartCopyAsync(CloudAppendBlob source) { return this.StartCopyAsync(source, CancellationToken.None); } @@ -2651,7 +2640,7 @@ public Task StartCopyAsync(CloudAppendBlob source) /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudAppendBlob source, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudAppendBlob source, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, cancellationToken); } @@ -2666,7 +2655,7 @@ public Task StartCopyAsync(CloudAppendBlob source, CancellationToken can /// An object that represents the context for the current operation. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudAppendBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(CloudAppendBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } @@ -2682,7 +2671,7 @@ public Task StartCopyAsync(CloudAppendBlob source, AccessCondition sourc /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudAppendBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudAppendBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); } @@ -2698,7 +2687,7 @@ public Task StartCopyAsync(CloudAppendBlob source, AccessCondition sourc /// An object that represents the context for the current operation. /// A object that is a blob snapshot. [DoesServiceRequest] - public CloudAppendBlob CreateSnapshot(IDictionary metadata = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual CloudAppendBlob CreateSnapshot(IDictionary metadata = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.AppendBlob, this.ServiceClient); @@ -2716,7 +2705,7 @@ public CloudAppendBlob CreateSnapshot(IDictionary metadata = nul /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateSnapshot(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateSnapshot(AsyncCallback callback, object state) { return this.BeginCreateSnapshot(null /* metadata */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2732,7 +2721,7 @@ public ICancellableAsyncResult BeginCreateSnapshot(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateSnapshot(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateSnapshot(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.AppendBlob, this.ServiceClient); @@ -2749,7 +2738,7 @@ public ICancellableAsyncResult BeginCreateSnapshot(IDictionary m /// /// An that references the pending asynchronous operation. /// A object that is a blob snapshot. - public CloudAppendBlob EndCreateSnapshot(IAsyncResult asyncResult) + public virtual CloudAppendBlob EndCreateSnapshot(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -2760,7 +2749,7 @@ public CloudAppendBlob EndCreateSnapshot(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateSnapshotAsync() + public virtual Task CreateSnapshotAsync() { return this.CreateSnapshotAsync(CancellationToken.None); } @@ -2771,7 +2760,7 @@ public Task CreateSnapshotAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateSnapshotAsync(CancellationToken cancellationToken) + public virtual Task CreateSnapshotAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateSnapshot, this.EndCreateSnapshot, cancellationToken); } @@ -2785,7 +2774,7 @@ public Task CreateSnapshotAsync(CancellationToken cancellationT /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.CreateSnapshotAsync(metadata, accessCondition, options, operationContext, CancellationToken.None); } @@ -2800,7 +2789,7 @@ public Task CreateSnapshotAsync(IDictionary met /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateSnapshot, this.EndCreateSnapshot, metadata, accessCondition, options, operationContext, cancellationToken); } diff --git a/Lib/ClassLibraryCommon/Blob/CloudBlob.cs b/Lib/ClassLibraryCommon/Blob/CloudBlob.cs index 0b7a7afd0..dd23c8297 100644 --- a/Lib/ClassLibraryCommon/Blob/CloudBlob.cs +++ b/Lib/ClassLibraryCommon/Blob/CloudBlob.cs @@ -48,7 +48,7 @@ public partial class CloudBlob : IListBlobItem /// number of bytes to buffer when reading from the stream. The value must be at least 16 KB. /// [DoesServiceRequest] - public Stream OpenRead(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual Stream OpenRead(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.FetchAttributes(accessCondition, options, operationContext); AccessCondition streamAccessCondition = AccessCondition.CloneConditionWithETag(accessCondition, this.Properties.ETag); @@ -72,7 +72,7 @@ public Stream OpenRead(AccessCondition accessCondition = null, BlobRequestOption /// number of bytes to buffer when reading from the stream. The value must be at least 16 KB. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginOpenRead(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginOpenRead(AsyncCallback callback, object state) { return this.BeginOpenRead(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -95,7 +95,7 @@ public ICancellableAsyncResult BeginOpenRead(AsyncCallback callback, object stat /// number of bytes to buffer when reading from the stream. The value must be at least 16 KB. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginOpenRead(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginOpenRead(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state); @@ -135,7 +135,7 @@ public ICancellableAsyncResult BeginOpenRead(AccessCondition accessCondition, Bl /// method must be called exactly once for every call. /// Failing to end the read process before beginning another read process can cause unexpected behavior. /// - public Stream EndOpenRead(IAsyncResult asyncResult) + public virtual Stream EndOpenRead(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; storageAsyncResult.End(); @@ -156,7 +156,7 @@ public Stream EndOpenRead(IAsyncResult asyncResult) /// number of bytes to buffer when reading from the stream. The value must be at least 16 KB. /// [DoesServiceRequest] - public Task OpenReadAsync() + public virtual Task OpenReadAsync() { return this.OpenReadAsync(CancellationToken.None); } @@ -175,7 +175,7 @@ public Task OpenReadAsync() /// number of bytes to buffer when reading from the stream. The value must be at least 16 KB. /// [DoesServiceRequest] - public Task OpenReadAsync(CancellationToken cancellationToken) + public virtual Task OpenReadAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginOpenRead, this.EndOpenRead, cancellationToken); } @@ -196,7 +196,7 @@ public Task OpenReadAsync(CancellationToken cancellationToken) /// number of bytes to buffer when reading from the stream. The value must be at least 16 KB. /// [DoesServiceRequest] - public Task OpenReadAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task OpenReadAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.OpenReadAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -218,7 +218,7 @@ public Task OpenReadAsync(AccessCondition accessCondition, BlobRequestOp /// number of bytes to buffer when reading from the stream. The value must be at least 16 KB. /// [DoesServiceRequest] - public Task OpenReadAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task OpenReadAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginOpenRead, this.EndOpenRead, accessCondition, options, operationContext, cancellationToken); } @@ -232,7 +232,7 @@ public Task OpenReadAsync(AccessCondition accessCondition, BlobRequestOp /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void DownloadToStream(Stream target, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void DownloadToStream(Stream target, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.DownloadRangeToStream(target, null /* offset */, null /* length */, accessCondition, options, operationContext); } @@ -246,7 +246,7 @@ public void DownloadToStream(Stream target, AccessCondition accessCondition = nu /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadToStream(Stream target, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadToStream(Stream target, AsyncCallback callback, object state) { return this.BeginDownloadToStream(target, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -262,7 +262,7 @@ public ICancellableAsyncResult BeginDownloadToStream(Stream target, AsyncCallbac /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadToStream(Stream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadToStream(Stream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginDownloadRangeToStream(target, null /* offset */, null /* length */, accessCondition, options, operationContext, callback, state); } @@ -271,7 +271,7 @@ public ICancellableAsyncResult BeginDownloadToStream(Stream target, AccessCondit /// Ends an asynchronous operation to download the contents of a blob to a stream. /// /// An that references the pending asynchronous operation. - public void EndDownloadToStream(IAsyncResult asyncResult) + public virtual void EndDownloadToStream(IAsyncResult asyncResult) { this.EndDownloadRangeToStream(asyncResult); } @@ -283,7 +283,7 @@ public void EndDownloadToStream(IAsyncResult asyncResult) /// A object representing the target stream. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target) + public virtual Task DownloadToStreamAsync(Stream target) { return this.DownloadToStreamAsync(target, CancellationToken.None); } @@ -295,7 +295,7 @@ public Task DownloadToStreamAsync(Stream target) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target, CancellationToken cancellationToken) + public virtual Task DownloadToStreamAsync(Stream target, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDownloadToStream, this.EndDownloadToStream, target, cancellationToken); } @@ -309,7 +309,7 @@ public Task DownloadToStreamAsync(Stream target, CancellationToken cancellationT /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadToStreamAsync(target, accessCondition, options, operationContext, CancellationToken.None); } @@ -324,7 +324,7 @@ public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDownloadToStream, this.EndDownloadToStream, target, accessCondition, options, operationContext, cancellationToken); } @@ -340,13 +340,14 @@ public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void DownloadToFile(string path, FileMode mode, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void DownloadToFile(string path, FileMode mode, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("path", path); + FileStream fileStream = new FileStream(path, mode, FileAccess.Write); try { - using (FileStream fileStream = new FileStream(path, mode, FileAccess.Write)) + using (fileStream) { this.DownloadToStream(fileStream, accessCondition, options, operationContext); } @@ -380,7 +381,7 @@ public void DownloadToFile(string path, FileMode mode, AccessCondition accessCon /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadToFile(string path, FileMode mode, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadToFile(string path, FileMode mode, AsyncCallback callback, object state) { return this.BeginDownloadToFile(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -397,7 +398,7 @@ public ICancellableAsyncResult BeginDownloadToFile(string path, FileMode mode, A /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadToFile(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadToFile(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("path", path); @@ -478,7 +479,7 @@ private void DownloadToFileCallback(IAsyncResult asyncResult) /// Ends an asynchronous operation to download the contents of a blob to a file. /// /// An that references the pending asynchronous operation. - public void EndDownloadToFile(IAsyncResult asyncResult) + public virtual void EndDownloadToFile(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -492,7 +493,7 @@ public void EndDownloadToFile(IAsyncResult asyncResult) /// A enumeration value that determines how to open or create the file. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode) + public virtual Task DownloadToFileAsync(string path, FileMode mode) { return this.DownloadToFileAsync(path, mode, CancellationToken.None); } @@ -505,7 +506,7 @@ public Task DownloadToFileAsync(string path, FileMode mode) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode, CancellationToken cancellationToken) + public virtual Task DownloadToFileAsync(string path, FileMode mode, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDownloadToFile, this.EndDownloadToFile, path, mode, cancellationToken); } @@ -520,7 +521,7 @@ public Task DownloadToFileAsync(string path, FileMode mode, CancellationToken ca /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadToFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); } @@ -536,7 +537,7 @@ public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition acce /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDownloadToFile, this.EndDownloadToFile, path, mode, accessCondition, options, operationContext, cancellationToken); } @@ -553,7 +554,7 @@ public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition acce /// An object that represents the context for the current operation. /// The total number of bytes read into the buffer. [DoesServiceRequest] - public int DownloadToByteArray(byte[] target, int index, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual int DownloadToByteArray(byte[] target, int index, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { return this.DownloadRangeToByteArray(target, index, null /* blobOffset */, null /* length */, accessCondition, options, operationContext); } @@ -568,7 +569,7 @@ public int DownloadToByteArray(byte[] target, int index, AccessCondition accessC /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadToByteArray(byte[] target, int index, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadToByteArray(byte[] target, int index, AsyncCallback callback, object state) { return this.BeginDownloadToByteArray(target, index, null /* accessCondition */, null /* options */, null /*operationContext */, callback, state); } @@ -585,7 +586,7 @@ public ICancellableAsyncResult BeginDownloadToByteArray(byte[] target, int index /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadToByteArray(byte[] target, int index, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadToByteArray(byte[] target, int index, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginDownloadRangeToByteArray(target, index, null /* blobOffset */, null /* length */, accessCondition, options, operationContext, callback, state); } @@ -595,7 +596,7 @@ public ICancellableAsyncResult BeginDownloadToByteArray(byte[] target, int index /// /// An that references the pending asynchronous operation. /// The total number of bytes read into the buffer. - public int EndDownloadToByteArray(IAsyncResult asyncResult) + public virtual int EndDownloadToByteArray(IAsyncResult asyncResult) { return this.EndDownloadRangeToByteArray(asyncResult); } @@ -608,7 +609,7 @@ public int EndDownloadToByteArray(IAsyncResult asyncResult) /// The starting offset in the byte array. /// A object of type int that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadToByteArrayAsync(byte[] target, int index) + public virtual Task DownloadToByteArrayAsync(byte[] target, int index) { return this.DownloadToByteArrayAsync(target, index, CancellationToken.None); } @@ -621,7 +622,7 @@ public Task DownloadToByteArrayAsync(byte[] target, int index) /// A to observe while waiting for a task to complete. /// A object of type int that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadToByteArrayAsync(byte[] target, int index, CancellationToken cancellationToken) + public virtual Task DownloadToByteArrayAsync(byte[] target, int index, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadToByteArray, this.EndDownloadToByteArray, target, index, cancellationToken); } @@ -636,7 +637,7 @@ public Task DownloadToByteArrayAsync(byte[] target, int index, Cancellation /// An object that represents the context for the current operation. /// A object of type int that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadToByteArrayAsync(target, index, accessCondition, options, operationContext, CancellationToken.None); } @@ -652,7 +653,7 @@ public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondit /// A to observe while waiting for a task to complete. /// A object of type int that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadToByteArray, this.EndDownloadToByteArray, target, index, accessCondition, options, operationContext, cancellationToken); } @@ -669,7 +670,7 @@ public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondit /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void DownloadRangeToStream(Stream target, long? offset, long? length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void DownloadRangeToStream(Stream target, long? offset, long? length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("target", target); @@ -691,7 +692,7 @@ public void DownloadRangeToStream(Stream target, long? offset, long? length, Acc /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadRangeToStream(Stream target, long? offset, long? length, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadRangeToStream(Stream target, long? offset, long? length, AsyncCallback callback, object state) { return this.BeginDownloadRangeToStream(target, offset, length, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -709,7 +710,7 @@ public ICancellableAsyncResult BeginDownloadRangeToStream(Stream target, long? o /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadRangeToStream(Stream target, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadRangeToStream(Stream target, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("target", target); @@ -726,7 +727,7 @@ public ICancellableAsyncResult BeginDownloadRangeToStream(Stream target, long? o /// Ends an asynchronous operation to download a range of bytes from a blob to a stream. /// /// An that references the pending asynchronous operation. - public void EndDownloadRangeToStream(IAsyncResult asyncResult) + public virtual void EndDownloadRangeToStream(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -740,7 +741,7 @@ public void EndDownloadRangeToStream(IAsyncResult asyncResult) /// The length of the data to download from the blob, in bytes. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length) + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length) { return this.DownloadRangeToStreamAsync(target, offset, length, CancellationToken.None); } @@ -754,7 +755,7 @@ public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, CancellationToken cancellationToken) + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDownloadRangeToStream, this.EndDownloadRangeToStream, target, offset, length, cancellationToken); } @@ -770,7 +771,7 @@ public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadRangeToStreamAsync(target, offset, length, accessCondition, options, operationContext, CancellationToken.None); } @@ -787,7 +788,7 @@ public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDownloadRangeToStream, this.EndDownloadRangeToStream, target, offset, length, accessCondition, options, operationContext, cancellationToken); } @@ -806,7 +807,7 @@ public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length /// An object that represents the context for the current operation. /// The total number of bytes read into the buffer. [DoesServiceRequest] - public int DownloadRangeToByteArray(byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual int DownloadRangeToByteArray(byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { using (SyncMemoryStream stream = new SyncMemoryStream(target, index)) { @@ -827,7 +828,7 @@ public int DownloadRangeToByteArray(byte[] target, int index, long? blobOffset, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadRangeToByteArray(byte[] target, int index, long? blobOffset, long? length, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadRangeToByteArray(byte[] target, int index, long? blobOffset, long? length, AsyncCallback callback, object state) { return this.BeginDownloadRangeToByteArray(target, index, blobOffset, length, null /* accesCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -846,7 +847,7 @@ public ICancellableAsyncResult BeginDownloadRangeToByteArray(byte[] target, int /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadRangeToByteArray(byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadRangeToByteArray(byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { SyncMemoryStream stream = new SyncMemoryStream(target, index); StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state) { OperationState = stream }; @@ -892,7 +893,7 @@ private void DownloadRangeToByteArrayCallback(IAsyncResult asyncResult) /// /// An that references the pending asynchronous operation. /// The total number of bytes read into the buffer. - public int EndDownloadRangeToByteArray(IAsyncResult asyncResult) + public virtual int EndDownloadRangeToByteArray(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -909,7 +910,7 @@ public int EndDownloadRangeToByteArray(IAsyncResult asyncResult) /// The length of the data to download from the blob, in bytes. /// A object of type int that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length) + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length) { return this.DownloadRangeToByteArrayAsync(target, index, blobOffset, length, CancellationToken.None); } @@ -924,7 +925,7 @@ public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? b /// A to observe while waiting for a task to complete. /// A object of type int that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length, CancellationToken cancellationToken) + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadRangeToByteArray, this.EndDownloadRangeToByteArray, target, index, blobOffset, length, cancellationToken); } @@ -941,7 +942,7 @@ public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? b /// An object that represents the context for the current operation. /// A object of type int that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadRangeToByteArrayAsync(target, index, blobOffset, length, accessCondition, options, operationContext, CancellationToken.None); } @@ -959,7 +960,7 @@ public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? b /// A to observe while waiting for a task to complete. /// A object of type int that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadRangeToByteArray, this.EndDownloadRangeToByteArray, target, index, blobOffset, length, accessCondition, options, operationContext, cancellationToken); } @@ -973,7 +974,7 @@ public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? b /// An object that represents the context for the current operation. /// true if the blob exists. [DoesServiceRequest] - public bool Exists(BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual bool Exists(BlobRequestOptions options = null, OperationContext operationContext = null) { return this.Exists(false, options, operationContext); } @@ -1002,7 +1003,7 @@ private bool Exists(bool primaryOnly, BlobRequestOptions options, OperationConte /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) { return this.BeginExists(null /* options */, null /* operationContext */, callback, state); } @@ -1016,7 +1017,7 @@ public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginExists(false, options, operationContext, callback, state); } @@ -1046,7 +1047,7 @@ private ICancellableAsyncResult BeginExists(bool primaryOnly, BlobRequestOptions /// /// An that references the pending asynchronous operation. /// true if the blob exists. - public bool EndExists(IAsyncResult asyncResult) + public virtual bool EndExists(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -1057,7 +1058,7 @@ public bool EndExists(IAsyncResult asyncResult) /// /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync() + public virtual Task ExistsAsync() { return this.ExistsAsync(CancellationToken.None); } @@ -1068,7 +1069,7 @@ public Task ExistsAsync() /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync(CancellationToken cancellationToken) + public virtual Task ExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, cancellationToken); } @@ -1080,7 +1081,7 @@ public Task ExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext) + public virtual Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext) { return this.ExistsAsync(options, operationContext, CancellationToken.None); } @@ -1093,7 +1094,7 @@ public Task ExistsAsync(BlobRequestOptions options, OperationContext opera /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, options, operationContext, cancellationToken); } @@ -1107,7 +1108,7 @@ public Task ExistsAsync(BlobRequestOptions options, OperationContext opera /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void FetchAttributes(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void FetchAttributes(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); Executor.ExecuteSync( @@ -1124,7 +1125,7 @@ public void FetchAttributes(AccessCondition accessCondition = null, BlobRequestO /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, object state) { return this.BeginFetchAttributes(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1139,7 +1140,7 @@ public ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, obje /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1154,7 +1155,7 @@ public ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondit /// Ends an asynchronous operation to populate the blob's properties and metadata. /// /// An that references the pending asynchronous operation. - public void EndFetchAttributes(IAsyncResult asyncResult) + public virtual void EndFetchAttributes(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1165,7 +1166,7 @@ public void EndFetchAttributes(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task FetchAttributesAsync() + public virtual Task FetchAttributesAsync() { return this.FetchAttributesAsync(CancellationToken.None); } @@ -1176,7 +1177,7 @@ public Task FetchAttributesAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task FetchAttributesAsync(CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginFetchAttributes, this.EndFetchAttributes, cancellationToken); } @@ -1189,7 +1190,7 @@ public Task FetchAttributesAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.FetchAttributesAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -1203,7 +1204,7 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOpt /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginFetchAttributes, this.EndFetchAttributes, accessCondition, options, operationContext, cancellationToken); } @@ -1217,7 +1218,7 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOpt /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetMetadata(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void SetMetadata(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); @@ -1235,7 +1236,7 @@ public void SetMetadata(AccessCondition accessCondition = null, BlobRequestOptio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object state) { return this.BeginSetMetadata(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1250,7 +1251,7 @@ public ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object s /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); @@ -1266,7 +1267,7 @@ public ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, /// Ends an asynchronous operation to update the blob's metadata. /// /// An that references the pending asynchronous operation. - public void EndSetMetadata(IAsyncResult asyncResult) + public virtual void EndSetMetadata(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1277,7 +1278,7 @@ public void EndSetMetadata(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetMetadataAsync() + public virtual Task SetMetadataAsync() { return this.SetMetadataAsync(CancellationToken.None); } @@ -1288,7 +1289,7 @@ public Task SetMetadataAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetMetadataAsync(CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetMetadata, this.EndSetMetadata, cancellationToken); } @@ -1301,7 +1302,7 @@ public Task SetMetadataAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.SetMetadataAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -1315,7 +1316,7 @@ public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetMetadata, this.EndSetMetadata, accessCondition, options, operationContext, cancellationToken); } @@ -1329,7 +1330,7 @@ public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetProperties(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void SetProperties(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); @@ -1347,7 +1348,7 @@ public void SetProperties(AccessCondition accessCondition = null, BlobRequestOpt /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetProperties(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetProperties(AsyncCallback callback, object state) { return this.BeginSetProperties(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1362,7 +1363,7 @@ public ICancellableAsyncResult BeginSetProperties(AsyncCallback callback, object /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetProperties(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetProperties(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); @@ -1378,7 +1379,7 @@ public ICancellableAsyncResult BeginSetProperties(AccessCondition accessConditio /// Ends an asynchronous operation to update the blob's properties. /// /// An that references the pending asynchronous operation. - public void EndSetProperties(IAsyncResult asyncResult) + public virtual void EndSetProperties(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1389,7 +1390,7 @@ public void EndSetProperties(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPropertiesAsync() + public virtual Task SetPropertiesAsync() { return this.SetPropertiesAsync(CancellationToken.None); } @@ -1400,7 +1401,7 @@ public Task SetPropertiesAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPropertiesAsync(CancellationToken cancellationToken) + public virtual Task SetPropertiesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetProperties, this.EndSetProperties, cancellationToken); } @@ -1413,7 +1414,7 @@ public Task SetPropertiesAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.SetPropertiesAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -1427,7 +1428,7 @@ public Task SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptio /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetProperties, this.EndSetProperties, accessCondition, options, operationContext, cancellationToken); } @@ -1442,7 +1443,7 @@ public Task SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptio /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Delete(DeleteSnapshotsOption deleteSnapshotsOption = DeleteSnapshotsOption.None, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void Delete(DeleteSnapshotsOption deleteSnapshotsOption = DeleteSnapshotsOption.None, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); Executor.ExecuteSync( @@ -1459,7 +1460,7 @@ public void Delete(DeleteSnapshotsOption deleteSnapshotsOption = DeleteSnapshots /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) { return this.BeginDelete(DeleteSnapshotsOption.None, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1475,7 +1476,7 @@ public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1490,7 +1491,7 @@ public ICancellableAsyncResult BeginDelete(DeleteSnapshotsOption deleteSnapshots /// Ends an asynchronous operation to delete the blob. /// /// An that references the pending asynchronous operation. - public void EndDelete(IAsyncResult asyncResult) + public virtual void EndDelete(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1501,7 +1502,7 @@ public void EndDelete(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync() + public virtual Task DeleteAsync() { return this.DeleteAsync(CancellationToken.None); } @@ -1512,7 +1513,7 @@ public Task DeleteAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync(CancellationToken cancellationToken) + public virtual Task DeleteAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, cancellationToken); } @@ -1526,7 +1527,7 @@ public Task DeleteAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DeleteAsync(deleteSnapshotsOption, accessCondition, options, operationContext, CancellationToken.None); } @@ -1541,7 +1542,7 @@ public Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondi /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, deleteSnapshotsOption, accessCondition, options, operationContext, cancellationToken); } @@ -1557,7 +1558,7 @@ public Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondi /// An object that represents the context for the current operation. /// true if the blob did already exist and was deleted; otherwise false. [DoesServiceRequest] - public bool DeleteIfExists(DeleteSnapshotsOption deleteSnapshotsOption = DeleteSnapshotsOption.None, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual bool DeleteIfExists(DeleteSnapshotsOption deleteSnapshotsOption = DeleteSnapshotsOption.None, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1602,7 +1603,7 @@ public bool DeleteIfExists(DeleteSnapshotsOption deleteSnapshotsOption = DeleteS /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) { return this.BeginDeleteIfExists(DeleteSnapshotsOption.None, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1618,7 +1619,7 @@ public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1721,7 +1722,7 @@ private void DeleteIfExistsHandler(DeleteSnapshotsOption deleteSnapshotsOption, /// /// An that references the pending asynchronous operation. /// true if the blob did already exist and was deleted; otherwise, false. - public bool EndDeleteIfExists(IAsyncResult asyncResult) + public virtual bool EndDeleteIfExists(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -1734,7 +1735,7 @@ public bool EndDeleteIfExists(IAsyncResult asyncResult) /// /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync() + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(CancellationToken.None); } @@ -1745,7 +1746,7 @@ public Task DeleteIfExistsAsync() /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, cancellationToken); } @@ -1759,7 +1760,7 @@ public Task DeleteIfExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DeleteIfExistsAsync(deleteSnapshotsOption, accessCondition, options, operationContext, CancellationToken.None); } @@ -1774,7 +1775,7 @@ public Task DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOptio /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, deleteSnapshotsOption, accessCondition, options, operationContext, cancellationToken); } @@ -1793,7 +1794,7 @@ public Task DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOptio /// An object that represents the context for the current operation. /// The ID of the acquired lease. [DoesServiceRequest] - public string AcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual string AcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.ExecuteSync( @@ -1814,7 +1815,7 @@ public string AcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AccessCo /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginAcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AsyncCallback callback, object state) { return this.BeginAcquireLease(leaseTime, proposedLeaseId, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1833,7 +1834,7 @@ public ICancellableAsyncResult BeginAcquireLease(TimeSpan? leaseTime, string pro /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginAcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1849,7 +1850,7 @@ public ICancellableAsyncResult BeginAcquireLease(TimeSpan? leaseTime, string pro /// /// An IAsyncResult that references the pending asynchronous operation. /// The ID of the acquired lease. - public string EndAcquireLease(IAsyncResult asyncResult) + public virtual string EndAcquireLease(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -1864,7 +1865,7 @@ public string EndAcquireLease(IAsyncResult asyncResult) /// A string representing the proposed lease ID for the new lease, or null if no lease ID is proposed. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId) + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId = null) { return this.AcquireLeaseAsync(leaseTime, proposedLeaseId, CancellationToken.None); } @@ -1879,7 +1880,7 @@ public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseI /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, CancellationToken cancellationToken) + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginAcquireLease, this.EndAcquireLease, leaseTime, proposedLeaseId, cancellationToken); } @@ -1896,7 +1897,7 @@ public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseI /// An object that represents the context for the current operation. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.AcquireLeaseAsync(leaseTime, proposedLeaseId, accessCondition, options, operationContext, CancellationToken.None); } @@ -1914,7 +1915,7 @@ public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseI /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginAcquireLease, this.EndAcquireLease, leaseTime, proposedLeaseId, accessCondition, options, operationContext, cancellationToken); } @@ -1928,7 +1929,7 @@ public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseI /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void RenewLease(AccessCondition accessCondition, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void RenewLease(AccessCondition accessCondition, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); Executor.ExecuteSync( @@ -1946,7 +1947,7 @@ public void RenewLease(AccessCondition accessCondition, BlobRequestOptions optio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginRenewLease(AccessCondition accessCondition, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginRenewLease(AccessCondition accessCondition, AsyncCallback callback, object state) { return this.BeginRenewLease(accessCondition, null /* options */, null /* operationContext */, callback, state); } @@ -1961,7 +1962,7 @@ public ICancellableAsyncResult BeginRenewLease(AccessCondition accessCondition, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginRenewLease(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginRenewLease(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1976,7 +1977,7 @@ public ICancellableAsyncResult BeginRenewLease(AccessCondition accessCondition, /// Ends an asynchronous operation to renew a lease on this blob. /// /// An that references the pending asynchronous operation. - public void EndRenewLease(IAsyncResult asyncResult) + public virtual void EndRenewLease(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1988,7 +1989,7 @@ public void EndRenewLease(IAsyncResult asyncResult) /// An object that represents the condition that must be met in order for the request to proceed, including a required lease ID. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition) + public virtual Task RenewLeaseAsync(AccessCondition accessCondition) { return this.RenewLeaseAsync(accessCondition, CancellationToken.None); } @@ -2000,7 +2001,7 @@ public Task RenewLeaseAsync(AccessCondition accessCondition) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition, CancellationToken cancellationToken) + public virtual Task RenewLeaseAsync(AccessCondition accessCondition, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginRenewLease, this.EndRenewLease, accessCondition, cancellationToken); } @@ -2013,7 +2014,7 @@ public Task RenewLeaseAsync(AccessCondition accessCondition, CancellationToken c /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.RenewLeaseAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -2027,7 +2028,7 @@ public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginRenewLease, this.EndRenewLease, accessCondition, options, operationContext, cancellationToken); } @@ -2043,7 +2044,7 @@ public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions /// An object that represents the context for the current operation. /// The new lease ID. [DoesServiceRequest] - public string ChangeLease(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual string ChangeLease(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.ExecuteSync( @@ -2062,7 +2063,7 @@ public string ChangeLease(string proposedLeaseId, AccessCondition accessConditio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginChangeLease(string proposedLeaseId, AccessCondition accessCondition, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginChangeLease(string proposedLeaseId, AccessCondition accessCondition, AsyncCallback callback, object state) { return this.BeginChangeLease(proposedLeaseId, accessCondition, null /* options */, null /* operationContext */, callback, state); } @@ -2078,7 +2079,7 @@ public ICancellableAsyncResult BeginChangeLease(string proposedLeaseId, AccessCo /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginChangeLease(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginChangeLease(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2094,7 +2095,7 @@ public ICancellableAsyncResult BeginChangeLease(string proposedLeaseId, AccessCo /// /// An that references the pending asynchronous operation. /// The new lease ID. - public string EndChangeLease(IAsyncResult asyncResult) + public virtual string EndChangeLease(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -2107,7 +2108,7 @@ public string EndChangeLease(IAsyncResult asyncResult) /// An object that represents the condition that must be met in order for the request to proceed, including a required lease ID. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition) + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition) { return this.ChangeLeaseAsync(proposedLeaseId, accessCondition, CancellationToken.None); } @@ -2120,7 +2121,7 @@ public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition acc /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, CancellationToken cancellationToken) + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginChangeLease, this.EndChangeLease, proposedLeaseId, accessCondition, cancellationToken); } @@ -2134,7 +2135,7 @@ public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition acc /// An object that represents the context for the current operation. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.ChangeLeaseAsync(proposedLeaseId, accessCondition, options, operationContext, CancellationToken.None); } @@ -2149,7 +2150,7 @@ public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition acc /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginChangeLease, this.EndChangeLease, proposedLeaseId, accessCondition, options, operationContext, cancellationToken); } @@ -2163,7 +2164,7 @@ public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition acc /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void ReleaseLease(AccessCondition accessCondition, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void ReleaseLease(AccessCondition accessCondition, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); Executor.ExecuteSync( @@ -2181,7 +2182,7 @@ public void ReleaseLease(AccessCondition accessCondition, BlobRequestOptions opt /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginReleaseLease(AccessCondition accessCondition, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginReleaseLease(AccessCondition accessCondition, AsyncCallback callback, object state) { return this.BeginReleaseLease(accessCondition, null /* options */, null /* operationContext */, callback, state); } @@ -2196,7 +2197,7 @@ public ICancellableAsyncResult BeginReleaseLease(AccessCondition accessCondition /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginReleaseLease(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginReleaseLease(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2211,7 +2212,7 @@ public ICancellableAsyncResult BeginReleaseLease(AccessCondition accessCondition /// Ends an asynchronous operation to release the lease on this blob. /// /// An IAsyncResult that references the pending asynchronous operation. - public void EndReleaseLease(IAsyncResult asyncResult) + public virtual void EndReleaseLease(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -2223,7 +2224,7 @@ public void EndReleaseLease(IAsyncResult asyncResult) /// An object that represents the condition that must be met in order for the request to proceed, including a required lease ID. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition) + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition) { return this.ReleaseLeaseAsync(accessCondition, CancellationToken.None); } @@ -2235,7 +2236,7 @@ public Task ReleaseLeaseAsync(AccessCondition accessCondition) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition, CancellationToken cancellationToken) + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginReleaseLease, this.EndReleaseLease, accessCondition, cancellationToken); } @@ -2248,7 +2249,7 @@ public Task ReleaseLeaseAsync(AccessCondition accessCondition, CancellationToken /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.ReleaseLeaseAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -2262,7 +2263,7 @@ public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOption /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginReleaseLease, this.EndReleaseLease, accessCondition, options, operationContext, cancellationToken); } @@ -2280,7 +2281,7 @@ public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOption /// An object that represents the context for the current operation. /// A representing the amount of time before the lease ends, to the second. [DoesServiceRequest] - public TimeSpan BreakLease(TimeSpan? breakPeriod = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual TimeSpan BreakLease(TimeSpan? breakPeriod = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.ExecuteSync( @@ -2300,7 +2301,7 @@ public TimeSpan BreakLease(TimeSpan? breakPeriod = null, AccessCondition accessC /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginBreakLease(TimeSpan? breakPeriod, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginBreakLease(TimeSpan? breakPeriod, AsyncCallback callback, object state) { return this.BeginBreakLease(breakPeriod, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2318,7 +2319,7 @@ public ICancellableAsyncResult BeginBreakLease(TimeSpan? breakPeriod, AsyncCallb /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginBreakLease(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginBreakLease(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2334,7 +2335,7 @@ public ICancellableAsyncResult BeginBreakLease(TimeSpan? breakPeriod, AccessCond /// /// An IAsyncResult that references the pending asynchronous operation. /// A representing the amount of time before the lease ends, to the second. - public TimeSpan EndBreakLease(IAsyncResult asyncResult) + public virtual TimeSpan EndBreakLease(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -2348,7 +2349,7 @@ public TimeSpan EndBreakLease(IAsyncResult asyncResult) /// or zero for infinite leases. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task BreakLeaseAsync(TimeSpan? breakPeriod) + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod) { return this.BreakLeaseAsync(breakPeriod, CancellationToken.None); } @@ -2362,7 +2363,7 @@ public Task BreakLeaseAsync(TimeSpan? breakPeriod) /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task BreakLeaseAsync(TimeSpan? breakPeriod, CancellationToken cancellationToken) + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginBreakLease, this.EndBreakLease, breakPeriod, cancellationToken); } @@ -2378,7 +2379,7 @@ public Task BreakLeaseAsync(TimeSpan? breakPeriod, CancellationToken c /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.BreakLeaseAsync(breakPeriod, accessCondition, options, operationContext, CancellationToken.None); } @@ -2395,146 +2396,12 @@ public Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition acc /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginBreakLease, this.EndBreakLease, breakPeriod, accessCondition, options, operationContext, cancellationToken); } #endif -#if SYNC - /// - /// Begins an operation to start copying another blob's contents, properties, and metadata to this blob. - /// - /// The of the source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. If null, default options are applied to the request. - /// An object that represents the context for the current operation. - /// The copy ID associated with the copy operation. - /// - /// This method fetches the blob's ETag, last-modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// - [Obsolete("Deprecated this method in favor of StartCopy.")] - [DoesServiceRequest] - public string StartCopyFromBlob(Uri source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) - { - return this.StartCopy(source, sourceAccessCondition, destAccessCondition, options, operationContext); - } -#endif - - /// - /// Begins an asynchronous operation to start copying another blob's contents, properties, and metadata to this blob. - /// - /// The of the source blob. - /// An delegate that will receive notification when the asynchronous operation completes. - /// A user-defined object that will be passed to the callback delegate. - /// An that references the asynchronous operation. - [Obsolete("Deprecated this method in favor of BeginStartCopy.")] - [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopyFromBlob(Uri source, AsyncCallback callback, object state) - { - return this.BeginStartCopy(source, null /* sourceAccessCondition */, null /* destAccessCondition */, null /* options */, null /* operationContext */, callback, state); - } - - /// - /// Begins an asynchronous operation to start copying another blob's contents, properties, and metadata to this blob. - /// - /// The of the source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// An delegate that will receive notification when the asynchronous operation completes. - /// A user-defined object that will be passed to the callback delegate. - /// An that references the asynchronous operation. - [Obsolete("Deprecated this method in favor of BeginStartCopy.")] - [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopyFromBlob(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) - { - return this.BeginStartCopy(source, sourceAccessCondition, destAccessCondition, options, operationContext, callback, state); - } - - /// - /// Ends an asynchronous operation to start copying another blob's contents, properties, and metadata to this blob. - /// - /// An that references the pending asynchronous operation. - /// A string containing the copy ID associated with the copy operation. - /// - /// This method fetches the blob's ETag, last-modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// - [Obsolete("Deprecated this method in favor of EndStartCopy.")] - public string EndStartCopyFromBlob(IAsyncResult asyncResult) - { - return Executor.EndExecuteAsync(asyncResult); - } - -#if TASK - /// - /// Initiates an asynchronous operation to start copying another blob's contents, properties, and metadata - /// to this blob. - /// - /// The of the source blob. - /// A object of type string that represents the asynchronous operation. - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(Uri source) - { - return this.StartCopyAsync(source, CancellationToken.None); - } - - /// - /// Initiates an asynchronous operation to start copying another blob's contents, properties, and metadata - /// to this blob. - /// - /// The of the source blob. - /// A to observe while waiting for a task to complete. - /// A object of type string that represents the asynchronous operation. - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(Uri source, CancellationToken cancellationToken) - { - return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, cancellationToken); - } - - /// - /// Initiates an asynchronous operation to start copying another blob's contents, properties, and metadata - /// to this blob. - /// - /// The of the source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// A object of type string that represents the asynchronous operation. - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); - } - - /// - /// Initiates an asynchronous operation to start copying another blob's contents, properties, and metadata - /// to this blob. - /// - /// The of the source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// A to observe while waiting for a task to complete. - /// A object of type string that represents the asynchronous operation. - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) - { - return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); - } - - #endif - #if SYNC /// /// Begins an operation to start copying another blob's contents, properties, and metadata to this blob. @@ -2550,7 +2417,7 @@ public Task StartCopyFromBlobAsync(Uri source, AccessCondition sourceAcc /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public string StartCopy(Uri source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual string StartCopy(Uri source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("source", source); this.attributes.AssertNoSnapshot(); @@ -2570,7 +2437,7 @@ public string StartCopy(Uri source, AccessCondition sourceAccessCondition = null /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(Uri source, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(Uri source, AsyncCallback callback, object state) { return this.BeginStartCopy(source, null /* sourceAccessCondition */, null /* destAccessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2587,7 +2454,7 @@ public ICancellableAsyncResult BeginStartCopy(Uri source, AsyncCallback callback /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("source", source); this.attributes.AssertNoSnapshot(); @@ -2609,7 +2476,7 @@ public ICancellableAsyncResult BeginStartCopy(Uri source, AccessCondition source /// This method fetches the blob's ETag, last-modified time, and part of the copy state. /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// - public string EndStartCopy(IAsyncResult asyncResult) + public virtual string EndStartCopy(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -2622,7 +2489,7 @@ public string EndStartCopy(IAsyncResult asyncResult) /// The of the source blob. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(Uri source) + public virtual Task StartCopyAsync(Uri source) { return this.StartCopyAsync(source, CancellationToken.None); } @@ -2635,7 +2502,7 @@ public Task StartCopyAsync(Uri source) /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(Uri source, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(Uri source, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, cancellationToken); } @@ -2651,7 +2518,7 @@ public Task StartCopyAsync(Uri source, CancellationToken cancellationTok /// An object that represents the context for the current operation. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } @@ -2668,7 +2535,7 @@ public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondi /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); } @@ -2684,7 +2551,7 @@ public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondi /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void AbortCopy(string copyId, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void AbortCopy(string copyId, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); Executor.ExecuteSync( @@ -2702,7 +2569,7 @@ public void AbortCopy(string copyId, AccessCondition accessCondition = null, Blo /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginAbortCopy(string copyId, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAbortCopy(string copyId, AsyncCallback callback, object state) { return this.BeginAbortCopy(copyId, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2718,7 +2585,7 @@ public ICancellableAsyncResult BeginAbortCopy(string copyId, AsyncCallback callb /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginAbortCopy(string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAbortCopy(string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2733,7 +2600,7 @@ public ICancellableAsyncResult BeginAbortCopy(string copyId, AccessCondition acc /// Ends an asynchronous operation to abort an ongoing blob copy operation. /// /// An that references the pending asynchronous operation. - public void EndAbortCopy(IAsyncResult asyncResult) + public virtual void EndAbortCopy(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -2745,7 +2612,7 @@ public void EndAbortCopy(IAsyncResult asyncResult) /// A string identifying the copy operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AbortCopyAsync(string copyId) + public virtual Task AbortCopyAsync(string copyId) { return this.AbortCopyAsync(copyId, CancellationToken.None); } @@ -2757,7 +2624,7 @@ public Task AbortCopyAsync(string copyId) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AbortCopyAsync(string copyId, CancellationToken cancellationToken) + public virtual Task AbortCopyAsync(string copyId, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAbortCopy, this.EndAbortCopy, copyId, cancellationToken); } @@ -2771,7 +2638,7 @@ public Task AbortCopyAsync(string copyId, CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.AbortCopyAsync(copyId, accessCondition, options, operationContext, CancellationToken.None); } @@ -2786,7 +2653,7 @@ public Task AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobR /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAbortCopy, this.EndAbortCopy, copyId, accessCondition, options, operationContext, cancellationToken); } @@ -2802,7 +2669,7 @@ public Task AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobR /// An object that represents the context for the current operation. /// A object that is a blob snapshot. [DoesServiceRequest] - public CloudBlob Snapshot(IDictionary metadata = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual CloudBlob Snapshot(IDictionary metadata = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); @@ -2820,7 +2687,7 @@ public CloudBlob Snapshot(IDictionary metadata = null, AccessCon /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSnapshot(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSnapshot(AsyncCallback callback, object state) { return this.BeginSnapshot(null /* metadata */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2836,7 +2703,7 @@ public ICancellableAsyncResult BeginSnapshot(AsyncCallback callback, object stat /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSnapshot(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSnapshot(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); @@ -2853,7 +2720,7 @@ public ICancellableAsyncResult BeginSnapshot(IDictionary metadat /// /// An that references the pending asynchronous operation. /// A object that is a blob snapshot. - public CloudBlob EndSnapshot(IAsyncResult asyncResult) + public virtual CloudBlob EndSnapshot(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -2864,7 +2731,7 @@ public CloudBlob EndSnapshot(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task SnapshotAsync() + public virtual Task SnapshotAsync() { return this.SnapshotAsync(CancellationToken.None); } @@ -2875,7 +2742,7 @@ public Task SnapshotAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task SnapshotAsync(CancellationToken cancellationToken) + public virtual Task SnapshotAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginSnapshot, this.EndSnapshot, cancellationToken); } @@ -2889,7 +2756,7 @@ public Task SnapshotAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task SnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task SnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.SnapshotAsync(metadata, accessCondition, options, operationContext, CancellationToken.None); } @@ -2904,7 +2771,7 @@ public Task SnapshotAsync(IDictionary metadata, Acces /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task SnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginSnapshot, this.EndSnapshot, metadata, accessCondition, options, operationContext, cancellationToken); } diff --git a/Lib/ClassLibraryCommon/Blob/CloudBlobClient.cs b/Lib/ClassLibraryCommon/Blob/CloudBlobClient.cs index 076433a49..0ea61a587 100644 --- a/Lib/ClassLibraryCommon/Blob/CloudBlobClient.cs +++ b/Lib/ClassLibraryCommon/Blob/CloudBlobClient.cs @@ -38,7 +38,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// The service client encapsulates the endpoint or endpoints for the Blob service. If the service client will be used for authenticated access, /// it also encapsulates the credentials for accessing the storage account. - public sealed partial class CloudBlobClient + public partial class CloudBlobClient { private IAuthenticationHandler authenticationHandler; @@ -107,7 +107,7 @@ internal IAuthenticationHandler AuthenticationHandler /// An object that represents the context for the current operation. /// An enumerable collection of objects that are retrieved lazily. [DoesServiceRequest] - public IEnumerable ListContainers(string prefix = null, ContainerListingDetails detailsIncluded = ContainerListingDetails.None, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual IEnumerable ListContainers(string prefix = null, ContainerListingDetails detailsIncluded = ContainerListingDetails.None, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this); return CommonUtility.LazyEnumerable( @@ -121,7 +121,7 @@ public IEnumerable ListContainers(string prefix = null, Cont /// A object returned by a previous listing operation. /// A object. [DoesServiceRequest] - public ContainerResultSegment ListContainersSegmented(BlobContinuationToken currentToken) + public virtual ContainerResultSegment ListContainersSegmented(BlobContinuationToken currentToken) { return this.ListContainersSegmented(null /* prefix */, ContainerListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } @@ -133,7 +133,7 @@ public ContainerResultSegment ListContainersSegmented(BlobContinuationToken curr /// A object returned by a previous listing operation. /// A object. [DoesServiceRequest] - public ContainerResultSegment ListContainersSegmented(string prefix, BlobContinuationToken currentToken) + public virtual ContainerResultSegment ListContainersSegmented(string prefix, BlobContinuationToken currentToken) { return this.ListContainersSegmented(prefix, ContainerListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } @@ -150,7 +150,7 @@ public ContainerResultSegment ListContainersSegmented(string prefix, BlobContinu /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public ContainerResultSegment ListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual ContainerResultSegment ListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this); ResultSegment resultSegment = this.ListContainersSegmentedCore(prefix, detailsIncluded, maxResults, currentToken, modifiedOptions, operationContext); @@ -186,7 +186,7 @@ private ResultSegment ListContainersSegmentedCore(string pre /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListContainersSegmented(BlobContinuationToken continuationToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListContainersSegmented(BlobContinuationToken continuationToken, AsyncCallback callback, object state) { return this.BeginListContainersSegmented(null /* prefix */, ContainerListingDetails.None, null /* maxResults */, continuationToken, null /* options */, null /* operationContext */, callback, state); } @@ -200,7 +200,7 @@ public ICancellableAsyncResult BeginListContainersSegmented(BlobContinuationToke /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListContainersSegmented(string prefix, BlobContinuationToken continuationToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListContainersSegmented(string prefix, BlobContinuationToken continuationToken, AsyncCallback callback, object state) { return this.BeginListContainersSegmented(prefix, ContainerListingDetails.None, null /* maxResults */, continuationToken, null /* options */, null /* operationContext */, callback, state); } @@ -220,7 +220,7 @@ public ICancellableAsyncResult BeginListContainersSegmented(string prefix, BlobC /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken continuationToken, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListContainersSegmented(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken continuationToken, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this); return Executor.BeginExecuteAsync( @@ -236,7 +236,7 @@ public ICancellableAsyncResult BeginListContainersSegmented(string prefix, Conta /// /// An that references the pending asynchronous operation. /// A object. - public ContainerResultSegment EndListContainersSegmented(IAsyncResult asyncResult) + public virtual ContainerResultSegment EndListContainersSegmented(IAsyncResult asyncResult) { ResultSegment resultSegment = Executor.EndExecuteAsync>(asyncResult); return new ContainerResultSegment(resultSegment.Results, (BlobContinuationToken)resultSegment.ContinuationToken); @@ -249,7 +249,7 @@ public ContainerResultSegment EndListContainersSegmented(IAsyncResult asyncResul /// A object returned by a previous listing operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListContainersSegmentedAsync(BlobContinuationToken continuationToken) + public virtual Task ListContainersSegmentedAsync(BlobContinuationToken continuationToken) { return this.ListContainersSegmentedAsync(continuationToken, CancellationToken.None); } @@ -261,7 +261,7 @@ public Task ListContainersSegmentedAsync(BlobContinuatio /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListContainersSegmentedAsync(BlobContinuationToken continuationToken, CancellationToken cancellationToken) + public virtual Task ListContainersSegmentedAsync(BlobContinuationToken continuationToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListContainersSegmented, this.EndListContainersSegmented, continuationToken, cancellationToken); } @@ -273,7 +273,7 @@ public Task ListContainersSegmentedAsync(BlobContinuatio /// A object returned by a previous listing operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListContainersSegmentedAsync(string prefix, BlobContinuationToken continuationToken) + public virtual Task ListContainersSegmentedAsync(string prefix, BlobContinuationToken continuationToken) { return this.ListContainersSegmentedAsync(prefix, continuationToken, CancellationToken.None); } @@ -286,7 +286,7 @@ public Task ListContainersSegmentedAsync(string prefix, /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListContainersSegmentedAsync(string prefix, BlobContinuationToken continuationToken, CancellationToken cancellationToken) + public virtual Task ListContainersSegmentedAsync(string prefix, BlobContinuationToken continuationToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListContainersSegmented, this.EndListContainersSegmented, prefix, continuationToken, cancellationToken); } @@ -303,7 +303,7 @@ public Task ListContainersSegmentedAsync(string prefix, /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken continuationToken, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken continuationToken, BlobRequestOptions options, OperationContext operationContext) { return this.ListContainersSegmentedAsync(prefix, detailsIncluded, maxResults, continuationToken, options, operationContext, CancellationToken.None); } @@ -321,7 +321,7 @@ public Task ListContainersSegmentedAsync(string prefix, /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken continuationToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken continuationToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListContainersSegmented, this.EndListContainersSegmented, prefix, detailsIncluded, maxResults, continuationToken, options, operationContext, cancellationToken); } @@ -338,7 +338,7 @@ public Task ListContainersSegmentedAsync(string prefix, /// An object that represents the context for the current operation. /// An enumerable collection of objects that implement and are retrieved lazily. [DoesServiceRequest] - public IEnumerable ListBlobs(string prefix, bool useFlatBlobListing = false, BlobListingDetails blobListingDetails = BlobListingDetails.None, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual IEnumerable ListBlobs(string prefix, bool useFlatBlobListing = false, BlobListingDetails blobListingDetails = BlobListingDetails.None, BlobRequestOptions options = null, OperationContext operationContext = null) { string containerName; string listingPrefix; @@ -356,7 +356,7 @@ public IEnumerable ListBlobs(string prefix, bool useFlatBlobListi /// A object returned by a previous listing operation. /// A object. [DoesServiceRequest] - public BlobResultSegment ListBlobsSegmented(string prefix, BlobContinuationToken currentToken) + public virtual BlobResultSegment ListBlobsSegmented(string prefix, BlobContinuationToken currentToken) { return this.ListBlobsSegmented(prefix, false, BlobListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } @@ -375,7 +375,7 @@ public BlobResultSegment ListBlobsSegmented(string prefix, BlobContinuationToken /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public BlobResultSegment ListBlobsSegmented(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) + public virtual BlobResultSegment ListBlobsSegmented(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) { string containerName; string listingPrefix; @@ -396,7 +396,7 @@ public BlobResultSegment ListBlobsSegmented(string prefix, bool useFlatBlobListi /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListBlobsSegmented(string prefix, BlobContinuationToken currentToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListBlobsSegmented(string prefix, BlobContinuationToken currentToken, AsyncCallback callback, object state) { return this.BeginListBlobsSegmented(prefix, false, BlobListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */, callback, state); } @@ -418,7 +418,7 @@ public ICancellableAsyncResult BeginListBlobsSegmented(string prefix, BlobContin /// An that references the asynchronous operation. [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Needed to ensure exceptions are not thrown on threadpool threads.")] [DoesServiceRequest] - public ICancellableAsyncResult BeginListBlobsSegmented(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListBlobsSegmented(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { string containerName; string listingPrefix; @@ -460,7 +460,7 @@ public ICancellableAsyncResult BeginListBlobsSegmented(string prefix, bool useFl /// /// An that references the pending asynchronous operation. /// A object. - public BlobResultSegment EndListBlobsSegmented(IAsyncResult asyncResult) + public virtual BlobResultSegment EndListBlobsSegmented(IAsyncResult asyncResult) { StorageAsyncResult result = (StorageAsyncResult)asyncResult; result.End(); @@ -476,7 +476,7 @@ public BlobResultSegment EndListBlobsSegmented(IAsyncResult asyncResult) /// A object returned by a previous listing operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken) + public virtual Task ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken) { return this.ListBlobsSegmentedAsync(prefix, currentToken, CancellationToken.None); } @@ -490,7 +490,7 @@ public Task ListBlobsSegmentedAsync(string prefix, BlobContin /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken, CancellationToken cancellationToken) + public virtual Task ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListBlobsSegmented, this.EndListBlobsSegmented, prefix, currentToken, cancellationToken); } @@ -509,7 +509,7 @@ public Task ListBlobsSegmentedAsync(string prefix, BlobContin /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) { return this.ListBlobsSegmentedAsync(prefix, useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext, CancellationToken.None); } @@ -529,7 +529,7 @@ public Task ListBlobsSegmentedAsync(string prefix, bool useFl /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListBlobsSegmented, this.EndListBlobsSegmented, prefix, useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext, cancellationToken); } @@ -545,7 +545,7 @@ public Task ListBlobsSegmentedAsync(string prefix, bool useFl /// An object that represents the context for the current operation. /// An object. [DoesServiceRequest] - public ICloudBlob GetBlobReferenceFromServer(Uri blobUri, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual ICloudBlob GetBlobReferenceFromServer(Uri blobUri, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("blobUri", blobUri); return this.GetBlobReferenceFromServer(new StorageUri(blobUri), accessCondition, options, operationContext); @@ -560,7 +560,7 @@ public ICloudBlob GetBlobReferenceFromServer(Uri blobUri, AccessCondition access /// An object that represents the context for the current operation. /// An object. [DoesServiceRequest] - public ICloudBlob GetBlobReferenceFromServer(StorageUri blobUri, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual ICloudBlob GetBlobReferenceFromServer(StorageUri blobUri, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("blobUri", blobUri); @@ -580,7 +580,7 @@ public ICloudBlob GetBlobReferenceFromServer(StorageUri blobUri, AccessCondition /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetBlobReferenceFromServer(Uri blobUri, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetBlobReferenceFromServer(Uri blobUri, AsyncCallback callback, object state) { return this.BeginGetBlobReferenceFromServer(blobUri, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -596,7 +596,7 @@ public ICancellableAsyncResult BeginGetBlobReferenceFromServer(Uri blobUri, Asyn /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetBlobReferenceFromServer(Uri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetBlobReferenceFromServer(Uri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("blobUri", blobUri); return this.BeginGetBlobReferenceFromServer(new StorageUri(blobUri), accessCondition, options, operationContext, callback, state); @@ -613,7 +613,7 @@ public ICancellableAsyncResult BeginGetBlobReferenceFromServer(Uri blobUri, Acce /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetBlobReferenceFromServer(StorageUri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetBlobReferenceFromServer(StorageUri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("blobUri", blobUri); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this); @@ -630,7 +630,7 @@ public ICancellableAsyncResult BeginGetBlobReferenceFromServer(StorageUri blobUr /// /// An that references the pending asynchronous operation. /// An object. - public ICloudBlob EndGetBlobReferenceFromServer(IAsyncResult asyncResult) + public virtual ICloudBlob EndGetBlobReferenceFromServer(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -642,7 +642,7 @@ public ICloudBlob EndGetBlobReferenceFromServer(IAsyncResult asyncResult) /// A containing the URI of the blob. The service assumes this is the URI for the blob at the primary location. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetBlobReferenceFromServerAsync(Uri blobUri) + public virtual Task GetBlobReferenceFromServerAsync(Uri blobUri) { return this.GetBlobReferenceFromServerAsync(blobUri, CancellationToken.None); } @@ -654,7 +654,7 @@ public Task GetBlobReferenceFromServerAsync(Uri blobUri) /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetBlobReferenceFromServerAsync(Uri blobUri, CancellationToken cancellationToken) + public virtual Task GetBlobReferenceFromServerAsync(Uri blobUri, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetBlobReferenceFromServer, this.EndGetBlobReferenceFromServer, blobUri, cancellationToken); } @@ -668,7 +668,7 @@ public Task GetBlobReferenceFromServerAsync(Uri blobUri, Cancellatio /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetBlobReferenceFromServerAsync(Uri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task GetBlobReferenceFromServerAsync(Uri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.GetBlobReferenceFromServerAsync(blobUri, accessCondition, options, operationContext, CancellationToken.None); } @@ -683,7 +683,7 @@ public Task GetBlobReferenceFromServerAsync(Uri blobUri, AccessCondi /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetBlobReferenceFromServerAsync(Uri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetBlobReferenceFromServerAsync(Uri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetBlobReferenceFromServer, this.EndGetBlobReferenceFromServer, blobUri, accessCondition, options, operationContext, cancellationToken); } @@ -697,7 +697,7 @@ public Task GetBlobReferenceFromServerAsync(Uri blobUri, AccessCondi /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetBlobReferenceFromServerAsync(StorageUri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task GetBlobReferenceFromServerAsync(StorageUri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.GetBlobReferenceFromServerAsync(blobUri, accessCondition, options, operationContext, CancellationToken.None); } @@ -712,7 +712,7 @@ public Task GetBlobReferenceFromServerAsync(StorageUri blobUri, Acce /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetBlobReferenceFromServerAsync(StorageUri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetBlobReferenceFromServerAsync(StorageUri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetBlobReferenceFromServer, this.EndGetBlobReferenceFromServer, blobUri, accessCondition, options, operationContext, cancellationToken); } @@ -828,7 +828,7 @@ private RESTCommand GetBlobReferenceImpl(StorageUri blobUri, AccessC /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceProperties(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceProperties(AsyncCallback callback, object state) { return this.BeginGetServiceProperties(null /* requestOptions */, null /* operationContext */, callback, state); } @@ -842,7 +842,7 @@ public ICancellableAsyncResult BeginGetServiceProperties(AsyncCallback callback, /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceProperties(BlobRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceProperties(BlobRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = BlobRequestOptions.ApplyDefaults(requestOptions, BlobType.Unspecified, this); operationContext = operationContext ?? new OperationContext(); @@ -859,7 +859,7 @@ public ICancellableAsyncResult BeginGetServiceProperties(BlobRequestOptions requ /// /// An that references the pending asynchronous operation. /// A object. - public ServiceProperties EndGetServiceProperties(IAsyncResult asyncResult) + public virtual ServiceProperties EndGetServiceProperties(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -870,7 +870,7 @@ public ServiceProperties EndGetServiceProperties(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync() + public virtual Task GetServicePropertiesAsync() { return this.GetServicePropertiesAsync(CancellationToken.None); } @@ -881,7 +881,7 @@ public Task GetServicePropertiesAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync(CancellationToken cancellationToken) + public virtual Task GetServicePropertiesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceProperties, this.EndGetServiceProperties, cancellationToken); } @@ -893,7 +893,7 @@ public Task GetServicePropertiesAsync(CancellationToken cance /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync(BlobRequestOptions requestOptions, OperationContext operationContext) + public virtual Task GetServicePropertiesAsync(BlobRequestOptions requestOptions, OperationContext operationContext) { return this.GetServicePropertiesAsync(requestOptions, operationContext, CancellationToken.None); } @@ -906,7 +906,7 @@ public Task GetServicePropertiesAsync(BlobRequestOptions requ /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync(BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServicePropertiesAsync(BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceProperties, this.EndGetServiceProperties, requestOptions, operationContext, cancellationToken); } @@ -920,7 +920,7 @@ public Task GetServicePropertiesAsync(BlobRequestOptions requ /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public ServiceProperties GetServiceProperties(BlobRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual ServiceProperties GetServiceProperties(BlobRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = BlobRequestOptions.ApplyDefaults(requestOptions, BlobType.Unspecified, this); operationContext = operationContext ?? new OperationContext(); @@ -939,7 +939,7 @@ public ServiceProperties GetServiceProperties(BlobRequestOptions requestOptions /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties properties, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties properties, AsyncCallback callback, object state) { return this.BeginSetServiceProperties(properties, null /* requestOptions */, null /* operationContext */, callback, state); } @@ -954,7 +954,7 @@ public ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties prope /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties properties, BlobRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties properties, BlobRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = BlobRequestOptions.ApplyDefaults(requestOptions, BlobType.Unspecified, this); operationContext = operationContext ?? new OperationContext(); @@ -970,7 +970,7 @@ public ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties prope /// Ends an asynchronous operation to set service properties for the Blob service. /// /// An that references the pending asynchronous operation. - public void EndSetServiceProperties(IAsyncResult asyncResult) + public virtual void EndSetServiceProperties(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -982,7 +982,7 @@ public void EndSetServiceProperties(IAsyncResult asyncResult) /// A object. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties) { return this.SetServicePropertiesAsync(properties, CancellationToken.None); } @@ -994,7 +994,7 @@ public Task SetServicePropertiesAsync(ServiceProperties properties) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties, CancellationToken cancellationToken) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetServiceProperties, this.EndSetServiceProperties, properties, cancellationToken); } @@ -1007,7 +1007,7 @@ public Task SetServicePropertiesAsync(ServiceProperties properties, Cancellation /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties, BlobRequestOptions requestOptions, OperationContext operationContext) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, BlobRequestOptions requestOptions, OperationContext operationContext) { return this.SetServicePropertiesAsync(properties, requestOptions, operationContext, CancellationToken.None); } @@ -1021,7 +1021,7 @@ public Task SetServicePropertiesAsync(ServiceProperties properties, BlobRequestO /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties, BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetServiceProperties, this.EndSetServiceProperties, properties, requestOptions, operationContext, cancellationToken); } @@ -1035,7 +1035,7 @@ public Task SetServicePropertiesAsync(ServiceProperties properties, BlobRequestO /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetServiceProperties(ServiceProperties properties, BlobRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual void SetServiceProperties(ServiceProperties properties, BlobRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = BlobRequestOptions.ApplyDefaults(requestOptions, BlobType.Unspecified, this); operationContext = operationContext ?? new OperationContext(); @@ -1053,7 +1053,7 @@ public void SetServiceProperties(ServiceProperties properties, BlobRequestOption /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceStats(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceStats(AsyncCallback callback, object state) { return this.BeginGetServiceStats(null /* requestOptions */, null /* operationContext */, callback, state); } @@ -1067,7 +1067,7 @@ public ICancellableAsyncResult BeginGetServiceStats(AsyncCallback callback, obje /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceStats(BlobRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceStats(BlobRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = BlobRequestOptions.ApplyDefaults(requestOptions, BlobType.Unspecified, this); operationContext = operationContext ?? new OperationContext(); @@ -1084,7 +1084,7 @@ public ICancellableAsyncResult BeginGetServiceStats(BlobRequestOptions requestOp /// /// An that references the pending asynchronous operation. /// A object. - public ServiceStats EndGetServiceStats(IAsyncResult asyncResult) + public virtual ServiceStats EndGetServiceStats(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -1095,7 +1095,7 @@ public ServiceStats EndGetServiceStats(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServiceStatsAsync() + public virtual Task GetServiceStatsAsync() { return this.GetServiceStatsAsync(CancellationToken.None); } @@ -1106,7 +1106,7 @@ public Task GetServiceStatsAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServiceStatsAsync(CancellationToken cancellationToken) + public virtual Task GetServiceStatsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceStats, this.EndGetServiceStats, cancellationToken); } @@ -1118,7 +1118,7 @@ public Task GetServiceStatsAsync(CancellationToken cancellationTok /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServiceStatsAsync(BlobRequestOptions requestOptions, OperationContext operationContext) + public virtual Task GetServiceStatsAsync(BlobRequestOptions requestOptions, OperationContext operationContext) { return this.GetServiceStatsAsync(requestOptions, operationContext, CancellationToken.None); } @@ -1131,7 +1131,7 @@ public Task GetServiceStatsAsync(BlobRequestOptions requestOptions /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServiceStatsAsync(BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServiceStatsAsync(BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceStats, this.EndGetServiceStats, requestOptions, operationContext, cancellationToken); } @@ -1145,7 +1145,7 @@ public Task GetServiceStatsAsync(BlobRequestOptions requestOptions /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public ServiceStats GetServiceStats(BlobRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual ServiceStats GetServiceStats(BlobRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = BlobRequestOptions.ApplyDefaults(requestOptions, BlobType.Unspecified, this); operationContext = operationContext ?? new OperationContext(); diff --git a/Lib/ClassLibraryCommon/Blob/CloudBlobContainer.cs b/Lib/ClassLibraryCommon/Blob/CloudBlobContainer.cs index 7ceac388e..900d07f86 100644 --- a/Lib/ClassLibraryCommon/Blob/CloudBlobContainer.cs +++ b/Lib/ClassLibraryCommon/Blob/CloudBlobContainer.cs @@ -34,7 +34,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// Represents a container in the Windows Azure Blob service. /// - public sealed partial class CloudBlobContainer + public partial class CloudBlobContainer { #if SYNC /// @@ -43,7 +43,7 @@ public sealed partial class CloudBlobContainer /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Create(BlobRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual void Create(BlobRequestOptions requestOptions = null, OperationContext operationContext = null) { this.Create(BlobContainerPublicAccessType.Off, requestOptions, operationContext); } @@ -55,7 +55,7 @@ public void Create(BlobRequestOptions requestOptions = null, OperationContext op /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Create(BlobContainerPublicAccessType accessType, BlobRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual void Create(BlobContainerPublicAccessType accessType, BlobRequestOptions requestOptions = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(requestOptions, BlobType.Unspecified, this.ServiceClient); Executor.ExecuteSync( @@ -72,7 +72,7 @@ public void Create(BlobContainerPublicAccessType accessType, BlobRequestOptions /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) { return this.BeginCreate(null /* options */, null /* operationContext */, callback, state); } @@ -86,7 +86,7 @@ public ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginCreate(BlobContainerPublicAccessType.Off, options, operationContext, callback, state); } @@ -101,7 +101,7 @@ public ICancellableAsyncResult BeginCreate(BlobRequestOptions options, Operation /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -116,7 +116,7 @@ public ICancellableAsyncResult BeginCreate(BlobContainerPublicAccessType accessT /// Ends an asynchronous operation to create a container. /// /// An that references the pending asynchronous operation. - public void EndCreate(IAsyncResult asyncResult) + public virtual void EndCreate(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -127,7 +127,7 @@ public void EndCreate(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync() + public virtual Task CreateAsync() { return this.CreateAsync(CancellationToken.None); } @@ -138,7 +138,7 @@ public Task CreateAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync(CancellationToken cancellationToken) + public virtual Task CreateAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, cancellationToken); } @@ -151,7 +151,7 @@ public Task CreateAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext) { return this.CreateAsync(accessType, options, operationContext, CancellationToken.None); } @@ -165,7 +165,7 @@ public Task CreateAsync(BlobContainerPublicAccessType accessType, BlobRequestOpt /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, accessType, options, operationContext, cancellationToken); } @@ -177,8 +177,9 @@ public Task CreateAsync(BlobContainerPublicAccessType accessType, BlobRequestOpt /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// true if the container did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public bool CreateIfNotExists(BlobRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual bool CreateIfNotExists(BlobRequestOptions requestOptions = null, OperationContext operationContext = null) { return this.CreateIfNotExists(BlobContainerPublicAccessType.Off, requestOptions, operationContext); } @@ -190,8 +191,9 @@ public bool CreateIfNotExists(BlobRequestOptions requestOptions = null, Operatio /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// true if the container did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public bool CreateIfNotExists(BlobContainerPublicAccessType accessType, BlobRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual bool CreateIfNotExists(BlobContainerPublicAccessType accessType, BlobRequestOptions requestOptions = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(requestOptions, BlobType.Unspecified, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -236,8 +238,9 @@ public bool CreateIfNotExists(BlobContainerPublicAccessType accessType, BlobRequ /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, object state) { return this.BeginCreateIfNotExists(null /* options */, null /* operationContext */, callback, state); } @@ -250,8 +253,9 @@ public ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, ob /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateIfNotExists(BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateIfNotExists(BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginCreateIfNotExists(BlobContainerPublicAccessType.Off, options, operationContext, callback, state); } @@ -265,8 +269,9 @@ public ICancellableAsyncResult BeginCreateIfNotExists(BlobRequestOptions options /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateIfNotExists(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateIfNotExists(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -369,7 +374,7 @@ private void CreateIfNotExistsHandler(BlobContainerPublicAccessType accessType, /// /// An that references the pending asynchronous operation. /// true if the container did not already exist and was created; otherwise, false. - public bool EndCreateIfNotExists(IAsyncResult asyncResult) + public virtual bool EndCreateIfNotExists(IAsyncResult asyncResult) { StorageAsyncResult res = asyncResult as StorageAsyncResult; CommonUtility.AssertNotNull("AsyncResult", res); @@ -382,8 +387,9 @@ public bool EndCreateIfNotExists(IAsyncResult asyncResult) /// Initiates an asynchronous operation that creates the container if it does not already exist. /// /// A object that represents the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync() + public virtual Task CreateIfNotExistsAsync() { return this.CreateIfNotExistsAsync(CancellationToken.None); } @@ -393,8 +399,9 @@ public Task CreateIfNotExistsAsync() /// /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(CancellationToken cancellationToken) + public virtual Task CreateIfNotExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateIfNotExists, this.EndCreateIfNotExists, cancellationToken); } @@ -405,8 +412,9 @@ public Task CreateIfNotExistsAsync(CancellationToken cancellationToken) /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateIfNotExistsAsync(BlobRequestOptions options, OperationContext operationContext) { return this.CreateIfNotExistsAsync(options, operationContext, CancellationToken.None); } @@ -418,8 +426,9 @@ public Task CreateIfNotExistsAsync(BlobRequestOptions options, OperationCo /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateIfNotExistsAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateIfNotExists, this.EndCreateIfNotExists, options, operationContext, cancellationToken); } @@ -431,8 +440,9 @@ public Task CreateIfNotExistsAsync(BlobRequestOptions options, OperationCo /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateIfNotExistsAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext) { return this.CreateIfNotExistsAsync(accessType, options, operationContext, CancellationToken.None); } @@ -445,8 +455,9 @@ public Task CreateIfNotExistsAsync(BlobContainerPublicAccessType accessTyp /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateIfNotExistsAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateIfNotExists, this.EndCreateIfNotExists, accessType, options, operationContext, cancellationToken); } @@ -460,7 +471,7 @@ public Task CreateIfNotExistsAsync(BlobContainerPublicAccessType accessTyp /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Delete(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void Delete(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); Executor.ExecuteSync( @@ -477,7 +488,7 @@ public void Delete(AccessCondition accessCondition = null, BlobRequestOptions op /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) { return this.BeginDelete(null /* accessCondition */, null /* options */, null /*operationContext */, callback, state); } @@ -492,7 +503,7 @@ public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -507,7 +518,7 @@ public ICancellableAsyncResult BeginDelete(AccessCondition accessCondition, Blob /// Ends an asynchronous operation to delete a container. /// /// An that references the pending asynchronous operation. - public void EndDelete(IAsyncResult asyncResult) + public virtual void EndDelete(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -518,7 +529,7 @@ public void EndDelete(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync() + public virtual Task DeleteAsync() { return this.DeleteAsync(CancellationToken.None); } @@ -529,7 +540,7 @@ public Task DeleteAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync(CancellationToken cancellationToken) + public virtual Task DeleteAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, cancellationToken); } @@ -542,7 +553,7 @@ public Task DeleteAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DeleteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DeleteAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -556,7 +567,7 @@ public Task DeleteAsync(AccessCondition accessCondition, BlobRequestOptions opti /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, accessCondition, options, operationContext, cancellationToken); } @@ -571,7 +582,7 @@ public Task DeleteAsync(AccessCondition accessCondition, BlobRequestOptions opti /// An object that represents the context for the current operation. /// true if the container did not already exist and was created; otherwise false. [DoesServiceRequest] - public bool DeleteIfExists(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual bool DeleteIfExists(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -616,7 +627,7 @@ public bool DeleteIfExists(AccessCondition accessCondition = null, BlobRequestOp /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) { return this.BeginDeleteIfExists(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -631,7 +642,7 @@ public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -734,7 +745,7 @@ private void DeleteIfExistsHandler(AccessCondition accessCondition, BlobRequestO /// /// An that references the pending asynchronous operation. /// true if the container did not already exist and was created; otherwise, false. - public bool EndDeleteIfExists(IAsyncResult asyncResult) + public virtual bool EndDeleteIfExists(IAsyncResult asyncResult) { StorageAsyncResult res = asyncResult as StorageAsyncResult; CommonUtility.AssertNotNull("AsyncResult", res); @@ -748,7 +759,7 @@ public bool EndDeleteIfExists(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync() + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(CancellationToken.None); } @@ -759,7 +770,7 @@ public Task DeleteIfExistsAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, cancellationToken); } @@ -772,7 +783,7 @@ public Task DeleteIfExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DeleteIfExistsAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -786,7 +797,7 @@ public Task DeleteIfExistsAsync(AccessCondition accessCondition, BlobReque /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, accessCondition, options, operationContext, cancellationToken); } @@ -802,7 +813,7 @@ public Task DeleteIfExistsAsync(AccessCondition accessCondition, BlobReque /// An object that represents the context for the current operation. /// A reference to the blob. [DoesServiceRequest] - public ICloudBlob GetBlobReferenceFromServer(string blobName, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual ICloudBlob GetBlobReferenceFromServer(string blobName, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNullOrEmpty("blobName", blobName); StorageUri blobUri = NavigationHelper.AppendPathToUri(this.StorageUri, blobName); @@ -819,7 +830,7 @@ public ICloudBlob GetBlobReferenceFromServer(string blobName, AccessCondition ac /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetBlobReferenceFromServer(string blobName, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetBlobReferenceFromServer(string blobName, AsyncCallback callback, object state) { return this.BeginGetBlobReferenceFromServer(blobName, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -835,7 +846,7 @@ public ICancellableAsyncResult BeginGetBlobReferenceFromServer(string blobName, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetBlobReferenceFromServer(string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetBlobReferenceFromServer(string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNullOrEmpty("blobName", blobName); StorageUri blobUri = NavigationHelper.AppendPathToUri(this.StorageUri, blobName); @@ -848,7 +859,7 @@ public ICancellableAsyncResult BeginGetBlobReferenceFromServer(string blobName, /// /// An that references the pending asynchronous operation. /// A reference to the blob. - public ICloudBlob EndGetBlobReferenceFromServer(IAsyncResult asyncResult) + public virtual ICloudBlob EndGetBlobReferenceFromServer(IAsyncResult asyncResult) { return this.ServiceClient.EndGetBlobReferenceFromServer(asyncResult); } @@ -860,7 +871,7 @@ public ICloudBlob EndGetBlobReferenceFromServer(IAsyncResult asyncResult) /// A string containing the name of the blob. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task GetBlobReferenceFromServerAsync(string blobName) + public virtual Task GetBlobReferenceFromServerAsync(string blobName) { return this.GetBlobReferenceFromServerAsync(blobName, CancellationToken.None); } @@ -872,7 +883,7 @@ public Task GetBlobReferenceFromServerAsync(string blobName) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task GetBlobReferenceFromServerAsync(string blobName, CancellationToken cancellationToken) + public virtual Task GetBlobReferenceFromServerAsync(string blobName, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetBlobReferenceFromServer, this.EndGetBlobReferenceFromServer, blobName, cancellationToken); } @@ -886,7 +897,7 @@ public Task GetBlobReferenceFromServerAsync(string blobName, Cancell /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task GetBlobReferenceFromServerAsync(string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task GetBlobReferenceFromServerAsync(string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.GetBlobReferenceFromServerAsync(blobName, accessCondition, options, operationContext, CancellationToken.None); } @@ -901,7 +912,7 @@ public Task GetBlobReferenceFromServerAsync(string blobName, AccessC /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task GetBlobReferenceFromServerAsync(string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetBlobReferenceFromServerAsync(string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetBlobReferenceFromServer, this.EndGetBlobReferenceFromServer, blobName, accessCondition, options, operationContext, cancellationToken); } @@ -918,7 +929,7 @@ public Task GetBlobReferenceFromServerAsync(string blobName, AccessC /// An object that represents the context for the current operation. /// An enumerable collection of objects that implement and are retrieved lazily. [DoesServiceRequest] - public IEnumerable ListBlobs(string prefix = null, bool useFlatBlobListing = false, BlobListingDetails blobListingDetails = BlobListingDetails.None, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual IEnumerable ListBlobs(string prefix = null, bool useFlatBlobListing = false, BlobListingDetails blobListingDetails = BlobListingDetails.None, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return CommonUtility.LazyEnumerable( @@ -933,7 +944,7 @@ public IEnumerable ListBlobs(string prefix = null, bool useFlatBl /// A continuation token returned by a previous listing operation. /// A result segment containing objects that implement . [DoesServiceRequest] - public BlobResultSegment ListBlobsSegmented(BlobContinuationToken currentToken) + public virtual BlobResultSegment ListBlobsSegmented(BlobContinuationToken currentToken) { return this.ListBlobsSegmented(null /* prefix */, false, BlobListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } @@ -946,7 +957,7 @@ public BlobResultSegment ListBlobsSegmented(BlobContinuationToken currentToken) /// A continuation token returned by a previous listing operation. /// A result segment containing objects that implement . [DoesServiceRequest] - public BlobResultSegment ListBlobsSegmented(string prefix, BlobContinuationToken currentToken) + public virtual BlobResultSegment ListBlobsSegmented(string prefix, BlobContinuationToken currentToken) { return this.ListBlobsSegmented(prefix, false, BlobListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } @@ -965,7 +976,7 @@ public BlobResultSegment ListBlobsSegmented(string prefix, BlobContinuationToken /// An object that represents the context for the current operation. /// A result segment containing objects that implement . [DoesServiceRequest] - public BlobResultSegment ListBlobsSegmented(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) + public virtual BlobResultSegment ListBlobsSegmented(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); ResultSegment resultSegment = this.ListBlobsSegmentedCore(prefix, useFlatBlobListing, blobListingDetails, maxResults, currentToken, modifiedOptions, operationContext); @@ -1003,7 +1014,7 @@ private ResultSegment ListBlobsSegmentedCore(string prefix, bool /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListBlobsSegmented(BlobContinuationToken currentToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListBlobsSegmented(BlobContinuationToken currentToken, AsyncCallback callback, object state) { return this.BeginListBlobsSegmented(null /* prefix */, false, BlobListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */, callback, state); } @@ -1018,7 +1029,7 @@ public ICancellableAsyncResult BeginListBlobsSegmented(BlobContinuationToken cur /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListBlobsSegmented(string prefix, BlobContinuationToken currentToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListBlobsSegmented(string prefix, BlobContinuationToken currentToken, AsyncCallback callback, object state) { return this.BeginListBlobsSegmented(prefix, false, BlobListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */, callback, state); } @@ -1039,7 +1050,7 @@ public ICancellableAsyncResult BeginListBlobsSegmented(string prefix, BlobContin /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListBlobsSegmented(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListBlobsSegmented(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1056,7 +1067,7 @@ public ICancellableAsyncResult BeginListBlobsSegmented(string prefix, bool useFl /// /// An that references the pending asynchronous operation. /// A result segment containing objects that implement . - public BlobResultSegment EndListBlobsSegmented(IAsyncResult asyncResult) + public virtual BlobResultSegment EndListBlobsSegmented(IAsyncResult asyncResult) { ResultSegment resultSegment = Executor.EndExecuteAsync>(asyncResult); return new BlobResultSegment(resultSegment.Results, (BlobContinuationToken)resultSegment.ContinuationToken); @@ -1069,7 +1080,7 @@ public BlobResultSegment EndListBlobsSegmented(IAsyncResult asyncResult) /// /// A continuation token returned by a previous listing operation. [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(BlobContinuationToken currentToken) + public virtual Task ListBlobsSegmentedAsync(BlobContinuationToken currentToken) { return this.ListBlobsSegmentedAsync(currentToken, CancellationToken.None); } @@ -1081,7 +1092,7 @@ public Task ListBlobsSegmentedAsync(BlobContinuationToken cur /// A continuation token returned by a previous listing operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(BlobContinuationToken currentToken, CancellationToken cancellationToken) + public virtual Task ListBlobsSegmentedAsync(BlobContinuationToken currentToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListBlobsSegmented, this.EndListBlobsSegmented, currentToken, cancellationToken); } @@ -1093,7 +1104,7 @@ public Task ListBlobsSegmentedAsync(BlobContinuationToken cur /// A string containing the blob name prefix. /// A continuation token returned by a previous listing operation. [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken) + public virtual Task ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken) { return this.ListBlobsSegmentedAsync(prefix, currentToken, CancellationToken.None); } @@ -1106,7 +1117,7 @@ public Task ListBlobsSegmentedAsync(string prefix, BlobContin /// A continuation token returned by a previous listing operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken, CancellationToken cancellationToken) + public virtual Task ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListBlobsSegmented, this.EndListBlobsSegmented, prefix, currentToken, cancellationToken); } @@ -1125,7 +1136,7 @@ public Task ListBlobsSegmentedAsync(string prefix, BlobContin /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) { return this.ListBlobsSegmentedAsync(prefix, useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext, CancellationToken.None); } @@ -1145,7 +1156,7 @@ public Task ListBlobsSegmentedAsync(string prefix, bool useFl /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListBlobsSegmented, this.EndListBlobsSegmented, prefix, useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext, cancellationToken); } @@ -1160,7 +1171,7 @@ public Task ListBlobsSegmentedAsync(string prefix, bool useFl /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetPermissions(BlobContainerPermissions permissions, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void SetPermissions(BlobContainerPermissions permissions, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); Executor.ExecuteSync( @@ -1178,7 +1189,7 @@ public void SetPermissions(BlobContainerPermissions permissions, AccessCondition /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetPermissions(BlobContainerPermissions permissions, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetPermissions(BlobContainerPermissions permissions, AsyncCallback callback, object state) { return this.BeginSetPermissions(permissions, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1194,7 +1205,7 @@ public ICancellableAsyncResult BeginSetPermissions(BlobContainerPermissions perm /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetPermissions(BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetPermissions(BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1209,7 +1220,7 @@ public ICancellableAsyncResult BeginSetPermissions(BlobContainerPermissions perm /// Returns the result of an asynchronous request to set permissions for the container. /// /// An that references the pending asynchronous operation. - public void EndSetPermissions(IAsyncResult asyncResult) + public virtual void EndSetPermissions(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1221,7 +1232,7 @@ public void EndSetPermissions(IAsyncResult asyncResult) /// The permissions to apply to the container. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(BlobContainerPermissions permissions) + public virtual Task SetPermissionsAsync(BlobContainerPermissions permissions) { return this.SetPermissionsAsync(permissions, CancellationToken.None); } @@ -1233,7 +1244,7 @@ public Task SetPermissionsAsync(BlobContainerPermissions permissions) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(BlobContainerPermissions permissions, CancellationToken cancellationToken) + public virtual Task SetPermissionsAsync(BlobContainerPermissions permissions, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetPermissions, this.EndSetPermissions, permissions, cancellationToken); } @@ -1247,7 +1258,7 @@ public Task SetPermissionsAsync(BlobContainerPermissions permissions, Cancellati /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task SetPermissionsAsync(BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.SetPermissionsAsync(permissions, accessCondition, options, operationContext, CancellationToken.None); } @@ -1262,7 +1273,7 @@ public Task SetPermissionsAsync(BlobContainerPermissions permissions, AccessCond /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetPermissionsAsync(BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetPermissions, this.EndSetPermissions, permissions, accessCondition, options, operationContext, cancellationToken); } @@ -1277,7 +1288,7 @@ public Task SetPermissionsAsync(BlobContainerPermissions permissions, AccessCond /// An object that represents the context for the current operation. /// The container's permissions. [DoesServiceRequest] - public BlobContainerPermissions GetPermissions(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual BlobContainerPermissions GetPermissions(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.ExecuteSync( @@ -1294,7 +1305,7 @@ public BlobContainerPermissions GetPermissions(AccessCondition accessCondition = /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetPermissions(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetPermissions(AsyncCallback callback, object state) { return this.BeginGetPermissions(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1309,7 +1320,7 @@ public ICancellableAsyncResult BeginGetPermissions(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetPermissions(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetPermissions(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1325,7 +1336,7 @@ public ICancellableAsyncResult BeginGetPermissions(AccessCondition accessConditi /// /// An that references the pending asynchronous operation. /// The container's permissions. - public BlobContainerPermissions EndGetPermissions(IAsyncResult asyncResult) + public virtual BlobContainerPermissions EndGetPermissions(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -1336,7 +1347,7 @@ public BlobContainerPermissions EndGetPermissions(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync() + public virtual Task GetPermissionsAsync() { return this.GetPermissionsAsync(CancellationToken.None); } @@ -1347,7 +1358,7 @@ public Task GetPermissionsAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync(CancellationToken cancellationToken) + public virtual Task GetPermissionsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetPermissions, this.EndGetPermissions, cancellationToken); } @@ -1360,7 +1371,7 @@ public Task GetPermissionsAsync(CancellationToken canc /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task GetPermissionsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.GetPermissionsAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -1374,7 +1385,7 @@ public Task GetPermissionsAsync(AccessCondition access /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetPermissionsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetPermissions, this.EndGetPermissions, accessCondition, options, operationContext, cancellationToken); } @@ -1388,7 +1399,7 @@ public Task GetPermissionsAsync(AccessCondition access /// An object that represents the context for the current operation. /// true if the container exists. [DoesServiceRequest] - public bool Exists(BlobRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual bool Exists(BlobRequestOptions requestOptions = null, OperationContext operationContext = null) { return this.Exists(false, requestOptions, operationContext); } @@ -1416,7 +1427,7 @@ private bool Exists(bool primaryOnly, BlobRequestOptions requestOptions, Operati /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) { return this.BeginExists(null /* options */, null /* operationContext */, callback, state); } @@ -1430,7 +1441,7 @@ public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginExists(false, options, operationContext, callback, state); } @@ -1460,7 +1471,7 @@ private ICancellableAsyncResult BeginExists(bool primaryOnly, BlobRequestOptions /// /// An that references the pending asynchronous operation. /// true if the container exists. - public bool EndExists(IAsyncResult asyncResult) + public virtual bool EndExists(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -1471,7 +1482,7 @@ public bool EndExists(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync() + public virtual Task ExistsAsync() { return this.ExistsAsync(CancellationToken.None); } @@ -1482,7 +1493,7 @@ public Task ExistsAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync(CancellationToken cancellationToken) + public virtual Task ExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, cancellationToken); } @@ -1494,7 +1505,7 @@ public Task ExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext) + public virtual Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext) { return this.ExistsAsync(options, operationContext, CancellationToken.None); } @@ -1507,7 +1518,7 @@ public Task ExistsAsync(BlobRequestOptions options, OperationContext opera /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, options, operationContext, cancellationToken); } @@ -1521,7 +1532,7 @@ public Task ExistsAsync(BlobRequestOptions options, OperationContext opera /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void FetchAttributes(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void FetchAttributes(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); Executor.ExecuteSync( @@ -1538,7 +1549,7 @@ public void FetchAttributes(AccessCondition accessCondition = null, BlobRequestO /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, object state) { return this.BeginFetchAttributes(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1553,7 +1564,7 @@ public ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, obje /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1568,7 +1579,7 @@ public ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondit /// Ends an asynchronous operation to retrieve the container's attributes. /// /// An that references the pending asynchronous operation. - public void EndFetchAttributes(IAsyncResult asyncResult) + public virtual void EndFetchAttributes(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1579,7 +1590,7 @@ public void EndFetchAttributes(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task FetchAttributesAsync() + public virtual Task FetchAttributesAsync() { return this.FetchAttributesAsync(CancellationToken.None); } @@ -1590,7 +1601,7 @@ public Task FetchAttributesAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task FetchAttributesAsync(CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginFetchAttributes, this.EndFetchAttributes, cancellationToken); } @@ -1603,7 +1614,7 @@ public Task FetchAttributesAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.FetchAttributesAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -1617,7 +1628,7 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOpt /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginFetchAttributes, this.EndFetchAttributes, accessCondition, options, operationContext, cancellationToken); } @@ -1631,7 +1642,7 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOpt /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetMetadata(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void SetMetadata(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); Executor.ExecuteSync( @@ -1648,7 +1659,7 @@ public void SetMetadata(AccessCondition accessCondition = null, BlobRequestOptio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object state) { return this.BeginSetMetadata(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1663,7 +1674,7 @@ public ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object s /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1678,7 +1689,7 @@ public ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, /// Ends an asynchronous request operation to set user-defined metadata on the container. /// /// An that references the pending asynchronous operation. - public void EndSetMetadata(IAsyncResult asyncResult) + public virtual void EndSetMetadata(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1689,7 +1700,7 @@ public void EndSetMetadata(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetMetadataAsync() + public virtual Task SetMetadataAsync() { return this.SetMetadataAsync(CancellationToken.None); } @@ -1700,7 +1711,7 @@ public Task SetMetadataAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetMetadataAsync(CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetMetadata, this.EndSetMetadata, cancellationToken); } @@ -1713,7 +1724,7 @@ public Task SetMetadataAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.SetMetadataAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -1727,7 +1738,7 @@ public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetMetadata, this.EndSetMetadata, accessCondition, options, operationContext, cancellationToken); } @@ -1746,7 +1757,7 @@ public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions /// An object that represents the context for the current operation. /// The ID of the acquired lease. [DoesServiceRequest] - public string AcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual string AcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.ExecuteSync( @@ -1767,7 +1778,7 @@ public string AcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AccessCo /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginAcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AsyncCallback callback, object state) { return this.BeginAcquireLease(leaseTime, proposedLeaseId, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1786,7 +1797,7 @@ public ICancellableAsyncResult BeginAcquireLease(TimeSpan? leaseTime, string pro /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginAcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAcquireLease(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1802,7 +1813,7 @@ public ICancellableAsyncResult BeginAcquireLease(TimeSpan? leaseTime, string pro /// /// An IAsyncResult that references the pending asynchronous operation. /// The ID of the acquired lease. - public string EndAcquireLease(IAsyncResult asyncResult) + public virtual string EndAcquireLease(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -1817,7 +1828,7 @@ public string EndAcquireLease(IAsyncResult asyncResult) /// A string representing the proposed lease ID for the new lease, or null if no lease ID is proposed. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId) + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId = null) { return this.AcquireLeaseAsync(leaseTime, proposedLeaseId, CancellationToken.None); } @@ -1832,7 +1843,7 @@ public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseI /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, CancellationToken cancellationToken) + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginAcquireLease, this.EndAcquireLease, leaseTime, proposedLeaseId, cancellationToken); } @@ -1849,7 +1860,7 @@ public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseI /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.AcquireLeaseAsync(leaseTime, proposedLeaseId, accessCondition, options, operationContext, CancellationToken.None); } @@ -1867,7 +1878,7 @@ public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseI /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginAcquireLease, this.EndAcquireLease, leaseTime, proposedLeaseId, accessCondition, options, operationContext, cancellationToken); } @@ -1881,7 +1892,7 @@ public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseI /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void RenewLease(AccessCondition accessCondition, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void RenewLease(AccessCondition accessCondition, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); Executor.ExecuteSync( @@ -1899,7 +1910,7 @@ public void RenewLease(AccessCondition accessCondition, BlobRequestOptions optio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginRenewLease(AccessCondition accessCondition, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginRenewLease(AccessCondition accessCondition, AsyncCallback callback, object state) { return this.BeginRenewLease(accessCondition, null /* options */, null /* operationContext */, callback, state); } @@ -1914,7 +1925,7 @@ public ICancellableAsyncResult BeginRenewLease(AccessCondition accessCondition, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginRenewLease(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginRenewLease(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1929,7 +1940,7 @@ public ICancellableAsyncResult BeginRenewLease(AccessCondition accessCondition, /// Ends an asynchronous operation to renew a lease on this container. /// /// An IAsyncResult that references the pending asynchronous operation. - public void EndRenewLease(IAsyncResult asyncResult) + public virtual void EndRenewLease(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1941,7 +1952,7 @@ public void EndRenewLease(IAsyncResult asyncResult) /// An object that represents the condition that must be met in order for the request to proceed, including a required lease ID. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition) + public virtual Task RenewLeaseAsync(AccessCondition accessCondition) { return this.RenewLeaseAsync(accessCondition, CancellationToken.None); } @@ -1953,7 +1964,7 @@ public Task RenewLeaseAsync(AccessCondition accessCondition) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition, CancellationToken cancellationToken) + public virtual Task RenewLeaseAsync(AccessCondition accessCondition, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginRenewLease, this.EndRenewLease, accessCondition, cancellationToken); } @@ -1966,7 +1977,7 @@ public Task RenewLeaseAsync(AccessCondition accessCondition, CancellationToken c /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.RenewLeaseAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -1980,7 +1991,7 @@ public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginRenewLease, this.EndRenewLease, accessCondition, options, operationContext, cancellationToken); } @@ -1996,7 +2007,7 @@ public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions /// An object that represents the context for the current operation. /// The new lease ID. [DoesServiceRequest] - public string ChangeLease(string proposedLeaseId, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual string ChangeLease(string proposedLeaseId, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.ExecuteSync( @@ -2015,7 +2026,7 @@ public string ChangeLease(string proposedLeaseId, AccessCondition accessConditio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginChangeLease(string proposedLeaseId, AccessCondition accessCondition, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginChangeLease(string proposedLeaseId, AccessCondition accessCondition, AsyncCallback callback, object state) { return this.BeginChangeLease(proposedLeaseId, accessCondition, null /* options */, null /* operationContext */, callback, state); } @@ -2030,7 +2041,7 @@ public ICancellableAsyncResult BeginChangeLease(string proposedLeaseId, AccessCo /// An optional callback delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. - public ICancellableAsyncResult BeginChangeLease(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginChangeLease(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2046,7 +2057,7 @@ public ICancellableAsyncResult BeginChangeLease(string proposedLeaseId, AccessCo /// /// An IAsyncResult that references the pending asynchronous operation. /// The new lease ID. - public string EndChangeLease(IAsyncResult asyncResult) + public virtual string EndChangeLease(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -2059,7 +2070,7 @@ public string EndChangeLease(IAsyncResult asyncResult) /// An object that represents the condition that must be met in order for the request to proceed, including a required lease ID. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition) + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition) { return this.ChangeLeaseAsync(proposedLeaseId, accessCondition, CancellationToken.None); } @@ -2072,7 +2083,7 @@ public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition acc /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, CancellationToken cancellationToken) + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginChangeLease, this.EndChangeLease, proposedLeaseId, accessCondition, cancellationToken); } @@ -2086,7 +2097,7 @@ public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition acc /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.ChangeLeaseAsync(proposedLeaseId, accessCondition, options, operationContext, CancellationToken.None); } @@ -2101,7 +2112,7 @@ public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition acc /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginChangeLease, this.EndChangeLease, proposedLeaseId, accessCondition, options, operationContext, cancellationToken); } @@ -2115,7 +2126,7 @@ public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition acc /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void ReleaseLease(AccessCondition accessCondition, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void ReleaseLease(AccessCondition accessCondition, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); Executor.ExecuteSync( @@ -2133,7 +2144,7 @@ public void ReleaseLease(AccessCondition accessCondition, BlobRequestOptions opt /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginReleaseLease(AccessCondition accessCondition, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginReleaseLease(AccessCondition accessCondition, AsyncCallback callback, object state) { return this.BeginReleaseLease(accessCondition, null /* options */, null /* operationContext */, callback, state); } @@ -2148,7 +2159,7 @@ public ICancellableAsyncResult BeginReleaseLease(AccessCondition accessCondition /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginReleaseLease(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginReleaseLease(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2163,7 +2174,7 @@ public ICancellableAsyncResult BeginReleaseLease(AccessCondition accessCondition /// Ends an asynchronous operation to release the lease on this container. /// /// An IAsyncResult that references the pending asynchronous operation. - public void EndReleaseLease(IAsyncResult asyncResult) + public virtual void EndReleaseLease(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -2175,7 +2186,7 @@ public void EndReleaseLease(IAsyncResult asyncResult) /// An object that represents the condition that must be met in order for the request to proceed, including a required lease ID. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition) + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition) { return this.ReleaseLeaseAsync(accessCondition, CancellationToken.None); } @@ -2187,7 +2198,7 @@ public Task ReleaseLeaseAsync(AccessCondition accessCondition) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition, CancellationToken cancellationToken) + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginReleaseLease, this.EndReleaseLease, accessCondition, cancellationToken); } @@ -2200,7 +2211,7 @@ public Task ReleaseLeaseAsync(AccessCondition accessCondition, CancellationToken /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.ReleaseLeaseAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -2214,7 +2225,7 @@ public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOption /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginReleaseLease, this.EndReleaseLease, accessCondition, options, operationContext, cancellationToken); } @@ -2232,7 +2243,7 @@ public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOption /// An object that represents the context for the current operation. /// A representing the amount of time before the lease ends, to the second. [DoesServiceRequest] - public TimeSpan BreakLease(TimeSpan? breakPeriod = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual TimeSpan BreakLease(TimeSpan? breakPeriod = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.ExecuteSync( @@ -2252,7 +2263,7 @@ public TimeSpan BreakLease(TimeSpan? breakPeriod = null, AccessCondition accessC /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginBreakLease(TimeSpan? breakPeriod, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginBreakLease(TimeSpan? breakPeriod, AsyncCallback callback, object state) { return this.BeginBreakLease(breakPeriod, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2270,7 +2281,7 @@ public ICancellableAsyncResult BeginBreakLease(TimeSpan? breakPeriod, AsyncCallb /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginBreakLease(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginBreakLease(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2286,7 +2297,7 @@ public ICancellableAsyncResult BeginBreakLease(TimeSpan? breakPeriod, AccessCond /// /// An IAsyncResult that references the pending asynchronous operation. /// A representing the amount of time before the lease ends, to the second. - public TimeSpan EndBreakLease(IAsyncResult asyncResult) + public virtual TimeSpan EndBreakLease(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -2300,7 +2311,7 @@ public TimeSpan EndBreakLease(IAsyncResult asyncResult) /// or zero for infinite leases. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task BreakLeaseAsync(TimeSpan? breakPeriod) + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod) { return this.BreakLeaseAsync(breakPeriod, CancellationToken.None); } @@ -2314,7 +2325,7 @@ public Task BreakLeaseAsync(TimeSpan? breakPeriod) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task BreakLeaseAsync(TimeSpan? breakPeriod, CancellationToken cancellationToken) + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginBreakLease, this.EndBreakLease, breakPeriod, cancellationToken); } @@ -2330,7 +2341,7 @@ public Task BreakLeaseAsync(TimeSpan? breakPeriod, CancellationToken c /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.BreakLeaseAsync(breakPeriod, accessCondition, options, operationContext, CancellationToken.None); } @@ -2347,7 +2358,7 @@ public Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition acc /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginBreakLease, this.EndBreakLease, breakPeriod, accessCondition, options, operationContext, cancellationToken); } diff --git a/Lib/ClassLibraryCommon/Blob/CloudBlobDirectory.cs b/Lib/ClassLibraryCommon/Blob/CloudBlobDirectory.cs index 9e48dd8fa..441adec00 100644 --- a/Lib/ClassLibraryCommon/Blob/CloudBlobDirectory.cs +++ b/Lib/ClassLibraryCommon/Blob/CloudBlobDirectory.cs @@ -27,7 +27,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// Represents a virtual directory of blobs, designated by a delimiter character. /// /// Containers, which are encapsulated as objects, hold directories, and directories hold block blobs and page blobs. Directories can also contain sub-directories. - public sealed partial class CloudBlobDirectory + public partial class CloudBlobDirectory { #if SYNC /// @@ -39,7 +39,7 @@ public sealed partial class CloudBlobDirectory /// An object that represents the context for the current operation. /// An enumerable collection of objects that implement and are retrieved lazily. [DoesServiceRequest] - public IEnumerable ListBlobs(bool useFlatBlobListing = false, BlobListingDetails blobListingDetails = BlobListingDetails.None, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual IEnumerable ListBlobs(bool useFlatBlobListing = false, BlobListingDetails blobListingDetails = BlobListingDetails.None, BlobRequestOptions options = null, OperationContext operationContext = null) { return this.Container.ListBlobs(this.Prefix, useFlatBlobListing, blobListingDetails, options, operationContext); } @@ -51,7 +51,7 @@ public IEnumerable ListBlobs(bool useFlatBlobListing = false, Blo /// A object returned by a previous listing operation. /// A object. [DoesServiceRequest] - public BlobResultSegment ListBlobsSegmented(BlobContinuationToken currentToken) + public virtual BlobResultSegment ListBlobsSegmented(BlobContinuationToken currentToken) { return this.ListBlobsSegmented(false, BlobListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } @@ -69,7 +69,7 @@ public BlobResultSegment ListBlobsSegmented(BlobContinuationToken currentToken) /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public BlobResultSegment ListBlobsSegmented(bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) + public virtual BlobResultSegment ListBlobsSegmented(bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) { return this.Container.ListBlobsSegmented(this.Prefix, useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext); } @@ -84,7 +84,7 @@ public BlobResultSegment ListBlobsSegmented(bool useFlatBlobListing, BlobListing /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListBlobsSegmented(BlobContinuationToken currentToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListBlobsSegmented(BlobContinuationToken currentToken, AsyncCallback callback, object state) { return this.BeginListBlobsSegmented(false, BlobListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */, callback, state); } @@ -104,7 +104,7 @@ public ICancellableAsyncResult BeginListBlobsSegmented(BlobContinuationToken cur /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListBlobsSegmented(bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListBlobsSegmented(bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.Container.BeginListBlobsSegmented(this.Prefix, useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext, callback, state); } @@ -115,7 +115,7 @@ public ICancellableAsyncResult BeginListBlobsSegmented(bool useFlatBlobListing, /// /// An that references the pending asynchronous operation. /// A object. - public BlobResultSegment EndListBlobsSegmented(IAsyncResult asyncResult) + public virtual BlobResultSegment EndListBlobsSegmented(IAsyncResult asyncResult) { return this.Container.EndListBlobsSegmented(asyncResult); } @@ -128,7 +128,7 @@ public BlobResultSegment EndListBlobsSegmented(IAsyncResult asyncResult) /// A continuation token returned by a previous listing operation. /// A object of type . [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(BlobContinuationToken currentToken) + public virtual Task ListBlobsSegmentedAsync(BlobContinuationToken currentToken) { return this.ListBlobsSegmentedAsync(currentToken, CancellationToken.None); } @@ -141,7 +141,7 @@ public Task ListBlobsSegmentedAsync(BlobContinuationToken cur /// A to observe while waiting for a task to complete. /// A object of type . [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(BlobContinuationToken currentToken, CancellationToken cancellationToken) + public virtual Task ListBlobsSegmentedAsync(BlobContinuationToken currentToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListBlobsSegmented, this.EndListBlobsSegmented, currentToken, cancellationToken); } @@ -159,7 +159,7 @@ public Task ListBlobsSegmentedAsync(BlobContinuationToken cur /// An object that represents the context for the current operation. /// A object of type . [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ListBlobsSegmentedAsync(bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) { return this.ListBlobsSegmentedAsync(useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext, CancellationToken.None); } @@ -178,7 +178,7 @@ public Task ListBlobsSegmentedAsync(bool useFlatBlobListing, /// A to observe while waiting for a task to complete. /// A object of type . [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ListBlobsSegmentedAsync(bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListBlobsSegmented, this.EndListBlobsSegmented, useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext, cancellationToken); } diff --git a/Lib/ClassLibraryCommon/Blob/CloudBlockBlob.cs b/Lib/ClassLibraryCommon/Blob/CloudBlockBlob.cs index 3cc8e3d96..16ca64df1 100644 --- a/Lib/ClassLibraryCommon/Blob/CloudBlockBlob.cs +++ b/Lib/ClassLibraryCommon/Blob/CloudBlockBlob.cs @@ -37,7 +37,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// Represents a blob that is uploaded as a set of blocks. /// - public sealed partial class CloudBlockBlob : CloudBlob, ICloudBlob + public partial class CloudBlockBlob : CloudBlob, ICloudBlob { #if SYNC /// @@ -54,7 +54,8 @@ public sealed partial class CloudBlockBlob : CloudBlob, ICloudBlob /// To throw an exception if the blob exists instead of overwriting it, pass in an /// object generated using . /// - public CloudBlobStream OpenWrite(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + [DoesServiceRequest] + public virtual CloudBlobStream OpenWrite(AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, this.BlobType, this.ServiceClient, false); @@ -109,7 +110,8 @@ public CloudBlobStream OpenWrite(AccessCondition accessCondition = null, BlobReq /// ranging from between 16 KB and 4 MB inclusive. /// To throw an exception if the blob exists instead of overwriting it, see . /// - public ICancellableAsyncResult BeginOpenWrite(AsyncCallback callback, object state) + [DoesServiceRequest] + public virtual ICancellableAsyncResult BeginOpenWrite(AsyncCallback callback, object state) { return this.BeginOpenWrite(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -130,7 +132,8 @@ public ICancellableAsyncResult BeginOpenWrite(AsyncCallback callback, object sta /// To throw an exception if the blob exists instead of overwriting it, pass in an /// object generated using . /// - public ICancellableAsyncResult BeginOpenWrite(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + [DoesServiceRequest] + public virtual ICancellableAsyncResult BeginOpenWrite(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { this.attributes.AssertNoSnapshot(); @@ -208,7 +211,7 @@ public ICancellableAsyncResult BeginOpenWrite(AccessCondition accessCondition, B /// /// An that references the pending asynchronous operation. /// A to be used for writing to the blob. - public CloudBlobStream EndOpenWrite(IAsyncResult asyncResult) + public virtual CloudBlobStream EndOpenWrite(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; storageAsyncResult.End(); @@ -227,7 +230,7 @@ public CloudBlobStream EndOpenWrite(IAsyncResult asyncResult) /// To throw an exception if the blob exists instead of overwriting it, see . /// [DoesServiceRequest] - public Task OpenWriteAsync() + public virtual Task OpenWriteAsync() { return this.OpenWriteAsync(CancellationToken.None); } @@ -244,7 +247,7 @@ public Task OpenWriteAsync() /// To throw an exception if the blob exists instead of overwriting it, see . /// [DoesServiceRequest] - public Task OpenWriteAsync(CancellationToken cancellationToken) + public virtual Task OpenWriteAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginOpenWrite, this.EndOpenWrite, cancellationToken); } @@ -264,7 +267,7 @@ public Task OpenWriteAsync(CancellationToken cancellationToken) /// object generated using . /// [DoesServiceRequest] - public Task OpenWriteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task OpenWriteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.OpenWriteAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -285,7 +288,7 @@ public Task OpenWriteAsync(AccessCondition accessCondition, Blo /// object generated using . /// [DoesServiceRequest] - public Task OpenWriteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task OpenWriteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginOpenWrite, this.EndOpenWrite, accessCondition, options, operationContext, cancellationToken); } @@ -300,7 +303,7 @@ public Task OpenWriteAsync(AccessCondition accessCondition, Blo /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadFromStream(Stream source, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromStream(Stream source, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.UploadFromStreamHelper(source, null /* length */, accessCondition, options, operationContext); } @@ -314,7 +317,7 @@ public void UploadFromStream(Stream source, AccessCondition accessCondition = nu /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadFromStream(Stream source, long length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromStream(Stream source, long length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.UploadFromStreamHelper(source, length, accessCondition, options, operationContext); } @@ -431,7 +434,7 @@ internal void UploadFromStreamHelper(Stream source, long? length, AccessConditio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, null /* length */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -447,7 +450,7 @@ public ICancellableAsyncResult BeginUploadFromStream(Stream source, AsyncCallbac /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, null /* length */, accessCondition, options, operationContext, callback, state); } @@ -461,7 +464,7 @@ public ICancellableAsyncResult BeginUploadFromStream(Stream source, AccessCondit /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, length, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -478,7 +481,7 @@ public ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, length, accessCondition, options, operationContext, callback, state); } @@ -733,7 +736,7 @@ private void UploadFromStreamHandler(Stream source, long? length, string content /// Ends an asynchronous operation to upload a stream to a block blob. /// /// An that references the pending asynchronous operation. - public void EndUploadFromStream(IAsyncResult asyncResult) + public virtual void EndUploadFromStream(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; storageAsyncResult.End(); @@ -746,7 +749,7 @@ public void EndUploadFromStream(IAsyncResult asyncResult) /// A object providing the blob content. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source) + public virtual Task UploadFromStreamAsync(Stream source) { return this.UploadFromStreamAsync(source, CancellationToken.None); } @@ -758,7 +761,7 @@ public Task UploadFromStreamAsync(Stream source) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, cancellationToken); } @@ -772,7 +775,7 @@ public Task UploadFromStreamAsync(Stream source, CancellationToken cancellationT /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsync(source, accessCondition, options, operationContext, CancellationToken.None); } @@ -787,7 +790,7 @@ public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, accessCondition, options, operationContext, cancellationToken); } @@ -799,7 +802,7 @@ public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition /// The number of bytes to write from the source stream at its current position. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length) + public virtual Task UploadFromStreamAsync(Stream source, long length) { return this.UploadFromStreamAsync(source, length, CancellationToken.None); } @@ -812,7 +815,7 @@ public Task UploadFromStreamAsync(Stream source, long length) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, long length, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, length, cancellationToken); } @@ -827,7 +830,7 @@ public Task UploadFromStreamAsync(Stream source, long length, CancellationToken /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsync(source, length, accessCondition, options, operationContext, CancellationToken.None); } @@ -843,7 +846,7 @@ public Task UploadFromStreamAsync(Stream source, long length, AccessCondition ac /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, length, accessCondition, options, operationContext, cancellationToken); } @@ -854,16 +857,15 @@ public Task UploadFromStreamAsync(Stream source, long length, AccessCondition ac /// Uploads a file to the Blob service. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadFromFile(string path, FileMode mode, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromFile(string path, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("path", path); - using (FileStream fileStream = new FileStream(path, mode, FileAccess.Read)) + using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { this.UploadFromStream(fileStream, accessCondition, options, operationContext); } @@ -874,21 +876,19 @@ public void UploadFromFile(string path, FileMode mode, AccessCondition accessCon /// Begins an asynchronous operation to upload a file to a blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromFile(string path, AsyncCallback callback, object state) { - return this.BeginUploadFromFile(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); + return this.BeginUploadFromFile(path, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } /// /// Begins an asynchronous operation to upload a file to a blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. @@ -896,11 +896,11 @@ public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, A /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromFile(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("path", path); - FileStream fileStream = new FileStream(path, mode, FileAccess.Read); + FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state) { OperationState = fileStream @@ -956,7 +956,7 @@ private void UploadFromFileCallback(IAsyncResult asyncResult) /// Ends an asynchronous operation to upload a file to a blob. /// /// An that references the pending asynchronous operation. - public void EndUploadFromFile(IAsyncResult asyncResult) + public virtual void EndUploadFromFile(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -967,56 +967,52 @@ public void EndUploadFromFile(IAsyncResult asyncResult) /// Initiates an asynchronous operation to upload a file to a blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode) + public virtual Task UploadFromFileAsync(string path) { - return this.UploadFromFileAsync(path, mode, CancellationToken.None); + return this.UploadFromFileAsync(path, CancellationToken.None); } /// /// Initiates an asynchronous operation to upload a file to a blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, CancellationToken cancellationToken) + public virtual Task UploadFromFileAsync(string path, CancellationToken cancellationToken) { - return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, mode, cancellationToken); + return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, cancellationToken); } /// /// Initiates an asynchronous operation to upload a file to a blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { - return this.UploadFromFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); + return this.UploadFromFileAsync(path, accessCondition, options, operationContext, CancellationToken.None); } /// /// Initiates an asynchronous operation to upload a file to a blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { - return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, mode, accessCondition, options, operationContext, cancellationToken); + return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, accessCondition, options, operationContext, cancellationToken); } #endif @@ -1031,7 +1027,7 @@ public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition acce /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("buffer", buffer); @@ -1052,7 +1048,7 @@ public void UploadFromByteArray(byte[] buffer, int index, int count, AccessCondi /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AsyncCallback callback, object state) { return this.BeginUploadFromByteArray(buffer, index, count, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1070,7 +1066,7 @@ public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("buffer", buffer); @@ -1082,7 +1078,7 @@ public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index /// Ends an asynchronous operation to upload the contents of a byte array to a blob. /// /// An that references the pending asynchronous operation. - public void EndUploadFromByteArray(IAsyncResult asyncResult) + public virtual void EndUploadFromByteArray(IAsyncResult asyncResult) { this.EndUploadFromStream(asyncResult); } @@ -1096,7 +1092,7 @@ public void EndUploadFromByteArray(IAsyncResult asyncResult) /// The number of bytes to be written to the blob. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) { return this.UploadFromByteArrayAsync(buffer, index, count, CancellationToken.None); } @@ -1110,7 +1106,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromByteArray, this.EndUploadFromByteArray, buffer, index, count, cancellationToken); } @@ -1126,7 +1122,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, Cancel /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromByteArrayAsync(buffer, index, count, accessCondition, options, operationContext, CancellationToken.None); } @@ -1143,7 +1139,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, Access /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromByteArray, this.EndUploadFromByteArray, buffer, index, count, accessCondition, options, operationContext, cancellationToken); } @@ -1159,7 +1155,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, Access /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadText(string content, Encoding encoding = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadText(string content, Encoding encoding = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("content", content); @@ -1176,7 +1172,7 @@ public void UploadText(string content, Encoding encoding = null, AccessCondition /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadText(string content, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadText(string content, AsyncCallback callback, object state) { return this.BeginUploadText(content, null /* encoding */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1193,7 +1189,7 @@ public ICancellableAsyncResult BeginUploadText(string content, AsyncCallback cal /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadText(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadText(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("content", content); @@ -1205,7 +1201,7 @@ public ICancellableAsyncResult BeginUploadText(string content, Encoding encoding /// Ends an asynchronous operation to upload a string of text to a blob. /// /// An that references the pending asynchronous operation. - public void EndUploadText(IAsyncResult asyncResult) + public virtual void EndUploadText(IAsyncResult asyncResult) { this.EndUploadFromByteArray(asyncResult); } @@ -1217,7 +1213,7 @@ public void EndUploadText(IAsyncResult asyncResult) /// A string containing the text to upload. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadTextAsync(string content) + public virtual Task UploadTextAsync(string content) { return this.UploadTextAsync(content, CancellationToken.None); } @@ -1229,7 +1225,7 @@ public Task UploadTextAsync(string content) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadTextAsync(string content, CancellationToken cancellationToken) + public virtual Task UploadTextAsync(string content, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadText, this.EndUploadText, content, cancellationToken); } @@ -1244,7 +1240,7 @@ public Task UploadTextAsync(string content, CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadTextAsync(content, encoding, accessCondition, options, operationContext, CancellationToken.None); } @@ -1260,7 +1256,7 @@ public Task UploadTextAsync(string content, Encoding encoding, AccessCondition a /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadText, this.EndUploadText, content, encoding, accessCondition, options, operationContext, cancellationToken); } @@ -1275,7 +1271,8 @@ public Task UploadTextAsync(string content, Encoding encoding, AccessCondition a /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. /// The contents of the blob, as a string. - public string DownloadText(Encoding encoding = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + [DoesServiceRequest] + public virtual string DownloadText(Encoding encoding = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { using (SyncMemoryStream stream = new SyncMemoryStream()) { @@ -1292,7 +1289,8 @@ public string DownloadText(Encoding encoding = null, AccessCondition accessCondi /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. - public ICancellableAsyncResult BeginDownloadText(AsyncCallback callback, object state) + [DoesServiceRequest] + public virtual ICancellableAsyncResult BeginDownloadText(AsyncCallback callback, object state) { return this.BeginDownloadText(null /* encoding */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1307,7 +1305,8 @@ public ICancellableAsyncResult BeginDownloadText(AsyncCallback callback, object /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. - public ICancellableAsyncResult BeginDownloadText(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + [DoesServiceRequest] + public virtual ICancellableAsyncResult BeginDownloadText(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { SyncMemoryStream stream = new SyncMemoryStream(); StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state) { OperationState = Tuple.Create(stream, encoding) }; @@ -1352,7 +1351,7 @@ private void DownloadTextCallback(IAsyncResult asyncResult) /// /// An that references the pending asynchronous operation. /// The contents of the blob, as a string. - public string EndDownloadText(IAsyncResult asyncResult) + public virtual string EndDownloadText(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -1365,7 +1364,7 @@ public string EndDownloadText(IAsyncResult asyncResult) /// /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadTextAsync() + public virtual Task DownloadTextAsync() { return this.DownloadTextAsync(CancellationToken.None); } @@ -1376,7 +1375,7 @@ public Task DownloadTextAsync() /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadTextAsync(CancellationToken cancellationToken) + public virtual Task DownloadTextAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadText, this.EndDownloadText, cancellationToken); } @@ -1390,7 +1389,7 @@ public Task DownloadTextAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadTextAsync(encoding, accessCondition, options, operationContext, CancellationToken.None); } @@ -1405,7 +1404,7 @@ public Task DownloadTextAsync(Encoding encoding, AccessCondition accessC /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadText, this.EndDownloadText, encoding, accessCondition, options, operationContext, cancellationToken); } @@ -1428,7 +1427,7 @@ public Task DownloadTextAsync(Encoding encoding, AccessCondition accessC /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public void PutBlock(string blockId, Stream blockData, string contentMD5, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void PutBlock(string blockId, Stream blockData, string contentMD5, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("blockData", blockData); @@ -1499,7 +1498,7 @@ public void PutBlock(string blockId, Stream blockData, string contentMD5, Access /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginPutBlock(string blockId, Stream blockData, string contentMD5, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginPutBlock(string blockId, Stream blockData, string contentMD5, AsyncCallback callback, object state) { return this.BeginPutBlock(blockId, blockData, contentMD5, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1515,7 +1514,7 @@ public ICancellableAsyncResult BeginPutBlock(string blockId, Stream blockData, s /// An object that represents the context for the current operation. /// An enumerable collection of objects implementing . [DoesServiceRequest] - public IEnumerable DownloadBlockList(BlockListingFilter blockListingFilter = BlockListingFilter.Committed, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual IEnumerable DownloadBlockList(BlockListingFilter blockListingFilter = BlockListingFilter.Committed, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient); return Executor.ExecuteSync( @@ -1545,7 +1544,7 @@ public IEnumerable DownloadBlockList(BlockListingFilter blockList /// [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Needed to ensure exceptions are not thrown on threadpool threads.")] [DoesServiceRequest] - public ICancellableAsyncResult BeginPutBlock(string blockId, Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginPutBlock(string blockId, Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("blockData", blockData); @@ -1621,7 +1620,7 @@ public ICancellableAsyncResult BeginPutBlock(string blockId, Stream blockData, s /// Ends an asynchronous operation to upload a single block. /// /// An that references the pending asynchronous operation. - public void EndPutBlock(IAsyncResult asyncResult) + public virtual void EndPutBlock(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; @@ -1687,7 +1686,7 @@ private void PutBlockHandler(string blockId, Stream blockData, string contentMD5 /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public Task PutBlockAsync(string blockId, Stream blockData, string contentMD5) + public virtual Task PutBlockAsync(string blockId, Stream blockData, string contentMD5) { return this.PutBlockAsync(blockId, blockData, contentMD5, CancellationToken.None); } @@ -1707,7 +1706,7 @@ public Task PutBlockAsync(string blockId, Stream blockData, string contentMD5) /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public Task PutBlockAsync(string blockId, Stream blockData, string contentMD5, CancellationToken cancellationToken) + public virtual Task PutBlockAsync(string blockId, Stream blockData, string contentMD5, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginPutBlock, this.EndPutBlock, blockId, blockData, contentMD5, cancellationToken); } @@ -1729,7 +1728,7 @@ public Task PutBlockAsync(string blockId, Stream blockData, string contentMD5, C /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public Task PutBlockAsync(string blockId, Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task PutBlockAsync(string blockId, Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.PutBlockAsync(blockId, blockData, contentMD5, accessCondition, options, operationContext, CancellationToken.None); } @@ -1752,125 +1751,12 @@ public Task PutBlockAsync(string blockId, Stream blockData, string contentMD5, A /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public Task PutBlockAsync(string blockId, Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task PutBlockAsync(string blockId, Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginPutBlock, this.EndPutBlock, blockId, blockData, contentMD5, accessCondition, options, operationContext, cancellationToken); } #endif -#if SYNC - /// - /// Begins an operation to start copying another block blob's contents, properties, and metadata to this block blob. - /// - /// The of the source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. If null, default options are applied to the request. - /// An object that represents the context for the current operation. - /// The copy ID associated with the copy operation. - /// - /// This method fetches the blob's ETag, last-modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// - [Obsolete("Deprecated this method in favor of StartCopy.")] - [DoesServiceRequest] - public string StartCopyFromBlob(CloudBlockBlob source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) - { - return this.StartCopy(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); - } -#endif - - /// - /// Begins an asynchronous operation to start copying another block blob's contents, properties, and metadata to this block blob. - /// - /// A object. - /// An delegate that will receive notification when the asynchronous operation completes. - /// A user-defined object that will be passed to the callback delegate. - /// An that references the asynchronous operation. - [Obsolete("Deprecated this method in favor of BeginStartCopy.")] - [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopyFromBlob(CloudBlockBlob source, AsyncCallback callback, object state) - { - return this.BeginStartCopy(CloudBlob.SourceBlobToUri(source), callback, state); - } - - /// - /// Begins an asynchronous operation to start copying another block blob's contents, properties, and metadata to this block blob. - /// - /// A object. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// An delegate that will receive notification when the asynchronous operation completes. - /// A user-defined object that will be passed to the callback delegate. - /// An that references the asynchronous operation. - [Obsolete("Deprecated this method in favor of BeginStartCopy.")] - [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopyFromBlob(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) - { - return this.BeginStartCopy(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, callback, state); - } - -#if TASK - /// - /// Initiates an asynchronous operation to start copying another block blob's contents, properties, and metadata to this block blob. - /// - /// A object. - /// A object of type string that represents the asynchronous operation. - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(CloudBlockBlob source) - { - return this.StartCopyAsync(source, CancellationToken.None); - } - - /// - /// Initiates an asynchronous operation to start copying another block blob's contents, properties, and metadata to this block blob. - /// - /// A object. - /// A to observe while waiting for a task to complete. - /// A object of type string that represents the asynchronous operation. - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(CloudBlockBlob source, CancellationToken cancellationToken) - { - return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, cancellationToken); - } - - /// - /// Initiates an asynchronous operation to start copying another block blob's contents, properties, and metadata to this block blob. - /// - /// A object. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// A object of type string that represents the asynchronous operation. - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); - } - - /// - /// Initiates an asynchronous operation to start copying another block blob's contents, properties, and metadata to this block blob. - /// - /// A object. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// A to observe while waiting for a task to complete. - /// A object of type string that represents the asynchronous operation. - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) - { - return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); - } -#endif #if SYNC /// @@ -1887,7 +1773,7 @@ public Task StartCopyFromBlobAsync(CloudBlockBlob source, AccessConditio /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public string StartCopy(CloudFile source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual string StartCopy(CloudFile source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { return this.StartCopy(CloudFile.SourceFileToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); } @@ -1906,7 +1792,7 @@ public string StartCopy(CloudFile source, AccessCondition sourceAccessCondition /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public string StartCopy(CloudBlockBlob source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual string StartCopy(CloudBlockBlob source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { return this.StartCopy(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); } @@ -1920,7 +1806,7 @@ public string StartCopy(CloudBlockBlob source, AccessCondition sourceAccessCondi /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(CloudFile source, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(CloudFile source, AsyncCallback callback, object state) { return this.BeginStartCopy(CloudFile.SourceFileToUri(source), callback, state); } @@ -1933,7 +1819,7 @@ public ICancellableAsyncResult BeginStartCopy(CloudFile source, AsyncCallback ca /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(CloudBlockBlob source, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(CloudBlockBlob source, AsyncCallback callback, object state) { return this.BeginStartCopy(CloudBlob.SourceBlobToUri(source), callback, state); } @@ -1950,7 +1836,7 @@ public ICancellableAsyncResult BeginStartCopy(CloudBlockBlob source, AsyncCallba /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginStartCopy(CloudFile.SourceFileToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, callback, state); } @@ -1967,7 +1853,7 @@ public ICancellableAsyncResult BeginStartCopy(CloudFile source, AccessCondition /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginStartCopy(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, callback, state); } @@ -1979,7 +1865,7 @@ public ICancellableAsyncResult BeginStartCopy(CloudBlockBlob source, AccessCondi /// A object. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudFile source) + public virtual Task StartCopyAsync(CloudFile source) { return this.StartCopyAsync(source, CancellationToken.None); } @@ -1990,7 +1876,7 @@ public Task StartCopyAsync(CloudFile source) /// A object. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudBlockBlob source) + public virtual Task StartCopyAsync(CloudBlockBlob source) { return this.StartCopyAsync(source, CancellationToken.None); } @@ -2002,7 +1888,7 @@ public Task StartCopyAsync(CloudBlockBlob source) /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudFile source, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudFile source, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, cancellationToken); } @@ -2014,7 +1900,7 @@ public Task StartCopyAsync(CloudFile source, CancellationToken cancellat /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudBlockBlob source, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudBlockBlob source, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, cancellationToken); } @@ -2029,7 +1915,7 @@ public Task StartCopyAsync(CloudBlockBlob source, CancellationToken canc /// An object that represents the context for the current operation. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } @@ -2044,7 +1930,7 @@ public Task StartCopyAsync(CloudFile source, AccessCondition sourceAcces /// An object that represents the context for the current operation. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } @@ -2060,7 +1946,7 @@ public Task StartCopyAsync(CloudBlockBlob source, AccessCondition source /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); } @@ -2076,7 +1962,7 @@ public Task StartCopyAsync(CloudFile source, AccessCondition sourceAcces /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); } @@ -2090,7 +1976,7 @@ public Task StartCopyAsync(CloudBlockBlob source, AccessCondition source /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadBlockList(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadBlockList(AsyncCallback callback, object state) { return this.BeginDownloadBlockList(BlockListingFilter.Committed, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2108,7 +1994,7 @@ public ICancellableAsyncResult BeginDownloadBlockList(AsyncCallback callback, ob /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadBlockList(BlockListingFilter blockListingFilter, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadBlockList(BlockListingFilter blockListingFilter, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2125,7 +2011,7 @@ public ICancellableAsyncResult BeginDownloadBlockList(BlockListingFilter blockLi /// /// An that references the pending asynchronous operation. /// An enumerable collection of objects implementing . - public IEnumerable EndDownloadBlockList(IAsyncResult asyncResult) + public virtual IEnumerable EndDownloadBlockList(IAsyncResult asyncResult) { return Executor.EndExecuteAsync>(asyncResult); } @@ -2137,7 +2023,7 @@ public IEnumerable EndDownloadBlockList(IAsyncResult asyncResult) /// /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> DownloadBlockListAsync() + public virtual Task> DownloadBlockListAsync() { return this.DownloadBlockListAsync(CancellationToken.None); } @@ -2149,7 +2035,7 @@ public Task> DownloadBlockListAsync() /// A to observe while waiting for a task to complete. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> DownloadBlockListAsync(CancellationToken cancellationToken) + public virtual Task> DownloadBlockListAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadBlockList, this.EndDownloadBlockList, cancellationToken); } @@ -2165,7 +2051,7 @@ public Task> DownloadBlockListAsync(CancellationToken /// An object that represents the context for the current operation. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> DownloadBlockListAsync(BlockListingFilter blockListingFilter, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task> DownloadBlockListAsync(BlockListingFilter blockListingFilter, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadBlockListAsync(blockListingFilter, accessCondition, options, operationContext, CancellationToken.None); } @@ -2182,7 +2068,7 @@ public Task> DownloadBlockListAsync(BlockListingFilte /// A to observe while waiting for a task to complete. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> DownloadBlockListAsync(BlockListingFilter blockListingFilter, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> DownloadBlockListAsync(BlockListingFilter blockListingFilter, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadBlockList, this.EndDownloadBlockList, blockListingFilter, accessCondition, options, operationContext, cancellationToken); } @@ -2198,7 +2084,7 @@ public Task> DownloadBlockListAsync(BlockListingFilte /// An object that represents the context for the current operation. /// A object that is a blob snapshot. [DoesServiceRequest] - public CloudBlockBlob CreateSnapshot(IDictionary metadata = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual CloudBlockBlob CreateSnapshot(IDictionary metadata = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient); @@ -2216,7 +2102,7 @@ public CloudBlockBlob CreateSnapshot(IDictionary metadata = null /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateSnapshot(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateSnapshot(AsyncCallback callback, object state) { return this.BeginCreateSnapshot(null /* metadata */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2232,7 +2118,7 @@ public ICancellableAsyncResult BeginCreateSnapshot(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateSnapshot(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateSnapshot(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient); @@ -2249,7 +2135,7 @@ public ICancellableAsyncResult BeginCreateSnapshot(IDictionary m /// /// An that references the pending asynchronous operation. /// A object that is a blob snapshot. - public CloudBlockBlob EndCreateSnapshot(IAsyncResult asyncResult) + public virtual CloudBlockBlob EndCreateSnapshot(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -2260,7 +2146,7 @@ public CloudBlockBlob EndCreateSnapshot(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateSnapshotAsync() + public virtual Task CreateSnapshotAsync() { return this.CreateSnapshotAsync(CancellationToken.None); } @@ -2271,7 +2157,7 @@ public Task CreateSnapshotAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateSnapshotAsync(CancellationToken cancellationToken) + public virtual Task CreateSnapshotAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateSnapshot, this.EndCreateSnapshot, cancellationToken); } @@ -2285,7 +2171,7 @@ public Task CreateSnapshotAsync(CancellationToken cancellationTo /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.CreateSnapshotAsync(metadata, accessCondition, options, operationContext, CancellationToken.None); } @@ -2300,7 +2186,7 @@ public Task CreateSnapshotAsync(IDictionary meta /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateSnapshot, this.EndCreateSnapshot, metadata, accessCondition, options, operationContext, cancellationToken); } @@ -2315,7 +2201,7 @@ public Task CreateSnapshotAsync(IDictionary meta /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void PutBlockList(IEnumerable blockList, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void PutBlockList(IEnumerable blockList, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient); IEnumerable items = blockList.Select(i => new PutBlockListItem(i, BlockSearchMode.Latest)); @@ -2334,7 +2220,7 @@ public void PutBlockList(IEnumerable blockList, AccessCondition accessCo /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginPutBlockList(IEnumerable blockList, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginPutBlockList(IEnumerable blockList, AsyncCallback callback, object state) { return this.BeginPutBlockList(blockList, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2350,7 +2236,7 @@ public ICancellableAsyncResult BeginPutBlockList(IEnumerable blockList, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginPutBlockList(IEnumerable blockList, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginPutBlockList(IEnumerable blockList, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient); IEnumerable items = blockList.Select(i => new PutBlockListItem(i, BlockSearchMode.Latest)); @@ -2366,7 +2252,7 @@ public ICancellableAsyncResult BeginPutBlockList(IEnumerable blockList, /// Ends an asynchronous operation to upload a list of blocks to a new or existing blob. /// /// An that references the pending asynchronous operation. - public void EndPutBlockList(IAsyncResult asyncResult) + public virtual void EndPutBlockList(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -2378,7 +2264,7 @@ public void EndPutBlockList(IAsyncResult asyncResult) /// An enumerable collection of block IDs, as Base64-encoded strings. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task PutBlockListAsync(IEnumerable blockList) + public virtual Task PutBlockListAsync(IEnumerable blockList) { return this.PutBlockListAsync(blockList, CancellationToken.None); } @@ -2390,7 +2276,7 @@ public Task PutBlockListAsync(IEnumerable blockList) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task PutBlockListAsync(IEnumerable blockList, CancellationToken cancellationToken) + public virtual Task PutBlockListAsync(IEnumerable blockList, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginPutBlockList, this.EndPutBlockList, blockList, cancellationToken); } @@ -2404,7 +2290,7 @@ public Task PutBlockListAsync(IEnumerable blockList, CancellationToken c /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task PutBlockListAsync(IEnumerable blockList, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task PutBlockListAsync(IEnumerable blockList, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.PutBlockListAsync(blockList, accessCondition, options, operationContext, CancellationToken.None); } @@ -2419,7 +2305,7 @@ public Task PutBlockListAsync(IEnumerable blockList, AccessCondition acc /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task PutBlockListAsync(IEnumerable blockList, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task PutBlockListAsync(IEnumerable blockList, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginPutBlockList, this.EndPutBlockList, blockList, accessCondition, options, operationContext, cancellationToken); } diff --git a/Lib/ClassLibraryCommon/Blob/CloudPageBlob.cs b/Lib/ClassLibraryCommon/Blob/CloudPageBlob.cs index a5f08d6f3..d69695b46 100644 --- a/Lib/ClassLibraryCommon/Blob/CloudPageBlob.cs +++ b/Lib/ClassLibraryCommon/Blob/CloudPageBlob.cs @@ -34,7 +34,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// Represents a Windows Azure page blob. /// - public sealed partial class CloudPageBlob : CloudBlob, ICloudBlob + public partial class CloudPageBlob : CloudBlob, ICloudBlob { #if SYNC /// @@ -53,7 +53,7 @@ public sealed partial class CloudPageBlob : CloudBlob, ICloudBlob /// object generated using . /// [DoesServiceRequest] - public CloudBlobStream OpenWrite(long? size, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual CloudBlobStream OpenWrite(long? size, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, this.BlobType, this.ServiceClient, false); @@ -123,7 +123,7 @@ public CloudBlobStream OpenWrite(long? size, AccessCondition accessCondition = n /// To throw an exception if the blob exists instead of overwriting it, see . /// [DoesServiceRequest] - public ICancellableAsyncResult BeginOpenWrite(long? size, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginOpenWrite(long? size, AsyncCallback callback, object state) { return this.BeginOpenWrite(size, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -147,7 +147,7 @@ public ICancellableAsyncResult BeginOpenWrite(long? size, AsyncCallback callback /// [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Needed to ensure exceptions are not thrown on threadpool threads.")] [DoesServiceRequest] - public ICancellableAsyncResult BeginOpenWrite(long? size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginOpenWrite(long? size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { this.attributes.AssertNoSnapshot(); bool createNew = size.HasValue; @@ -260,7 +260,7 @@ public ICancellableAsyncResult BeginOpenWrite(long? size, AccessCondition access /// /// An that references the pending asynchronous operation. /// A object. - public CloudBlobStream EndOpenWrite(IAsyncResult asyncResult) + public virtual CloudBlobStream EndOpenWrite(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; storageAsyncResult.End(); @@ -280,7 +280,7 @@ public CloudBlobStream EndOpenWrite(IAsyncResult asyncResult) /// To throw an exception if the blob exists instead of overwriting it, see . /// [DoesServiceRequest] - public Task OpenWriteAsync(long? size) + public virtual Task OpenWriteAsync(long? size) { return this.OpenWriteAsync(size, CancellationToken.None); } @@ -298,7 +298,7 @@ public Task OpenWriteAsync(long? size) /// To throw an exception if the blob exists instead of overwriting it, see . /// [DoesServiceRequest] - public Task OpenWriteAsync(long? size, CancellationToken cancellationToken) + public virtual Task OpenWriteAsync(long? size, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginOpenWrite, this.EndOpenWrite, size, cancellationToken); } @@ -319,7 +319,7 @@ public Task OpenWriteAsync(long? size, CancellationToken cancel /// object generated using . /// [DoesServiceRequest] - public Task OpenWriteAsync(long? size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task OpenWriteAsync(long? size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.OpenWriteAsync(size, accessCondition, options, operationContext, CancellationToken.None); } @@ -341,7 +341,7 @@ public Task OpenWriteAsync(long? size, AccessCondition accessCo /// object generated using . /// [DoesServiceRequest] - public Task OpenWriteAsync(long? size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task OpenWriteAsync(long? size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginOpenWrite, this.EndOpenWrite, size, accessCondition, options, operationContext, cancellationToken); } @@ -356,7 +356,7 @@ public Task OpenWriteAsync(long? size, AccessCondition accessCo /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadFromStream(Stream source, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromStream(Stream source, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.UploadFromStreamHelper(source, null /* length */, accessCondition, options, operationContext); } @@ -370,7 +370,7 @@ public void UploadFromStream(Stream source, AccessCondition accessCondition = nu /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadFromStream(Stream source, long length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromStream(Stream source, long length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.UploadFromStreamHelper(source, length, accessCondition, options, operationContext); } @@ -429,7 +429,7 @@ internal void UploadFromStreamHelper(Stream source, long? length, AccessConditio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, null /* length */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -445,7 +445,7 @@ public ICancellableAsyncResult BeginUploadFromStream(Stream source, AsyncCallbac /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, null /* length */, accessCondition, options, operationContext, callback, state); } @@ -459,7 +459,7 @@ public ICancellableAsyncResult BeginUploadFromStream(Stream source, AccessCondit /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, length, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -476,7 +476,7 @@ public ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, length, accessCondition, options, operationContext, callback, state); } @@ -604,7 +604,7 @@ internal ICancellableAsyncResult BeginUploadFromStreamHelper(Stream source, long /// Ends an asynchronous operation to upload a stream to a page blob. /// /// An that references the pending asynchronous operation. - public void EndUploadFromStream(IAsyncResult asyncResult) + public virtual void EndUploadFromStream(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; storageAsyncResult.End(); @@ -616,7 +616,7 @@ public void EndUploadFromStream(IAsyncResult asyncResult) /// A object providing the blob content. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source) + public virtual Task UploadFromStreamAsync(Stream source) { return this.UploadFromStreamAsync(source, CancellationToken.None); } @@ -628,7 +628,7 @@ public Task UploadFromStreamAsync(Stream source) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, cancellationToken); } @@ -642,7 +642,7 @@ public Task UploadFromStreamAsync(Stream source, CancellationToken cancellationT /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsync(source, accessCondition, options, operationContext, CancellationToken.None); } @@ -657,7 +657,7 @@ public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, accessCondition, options, operationContext, cancellationToken); } @@ -669,7 +669,7 @@ public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition /// The number of bytes to write from the source stream at its current position. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length) + public virtual Task UploadFromStreamAsync(Stream source, long length) { return this.UploadFromStreamAsync(source, length, CancellationToken.None); } @@ -682,7 +682,7 @@ public Task UploadFromStreamAsync(Stream source, long length) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, long length, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, length, cancellationToken); } @@ -697,7 +697,7 @@ public Task UploadFromStreamAsync(Stream source, long length, CancellationToken /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsync(source, length, accessCondition, options, operationContext, CancellationToken.None); } @@ -713,7 +713,7 @@ public Task UploadFromStreamAsync(Stream source, long length, AccessCondition ac /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, length, accessCondition, options, operationContext, cancellationToken); } @@ -723,16 +723,15 @@ public Task UploadFromStreamAsync(Stream source, long length, AccessCondition ac /// Uploads a file to a page blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadFromFile(string path, FileMode mode, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromFile(string path, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("path", path); - using (FileStream fileStream = new FileStream(path, mode, FileAccess.Read)) + using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { this.UploadFromStream(fileStream, accessCondition, options, operationContext); } @@ -743,21 +742,19 @@ public void UploadFromFile(string path, FileMode mode, AccessCondition accessCon /// Begins an asynchronous operation to upload a file to a page blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromFile(string path, AsyncCallback callback, object state) { - return this.BeginUploadFromFile(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); + return this.BeginUploadFromFile(path, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } /// /// Begins an asynchronous operation to upload a file to a page blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. @@ -765,11 +762,11 @@ public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, A /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromFile(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("path", path); - FileStream fileStream = new FileStream(path, mode, FileAccess.Read); + FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state) { OperationState = fileStream @@ -825,7 +822,7 @@ private void UploadFromFileCallback(IAsyncResult asyncResult) /// Ends an asynchronous operation to upload a file to a page blob. /// /// An that references the pending asynchronous operation. - public void EndUploadFromFile(IAsyncResult asyncResult) + public virtual void EndUploadFromFile(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -836,56 +833,52 @@ public void EndUploadFromFile(IAsyncResult asyncResult) /// Initiates an asynchronous operation to upload a file to a page blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode) + public virtual Task UploadFromFileAsync(string path) { - return this.UploadFromFileAsync(path, mode, CancellationToken.None); + return this.UploadFromFileAsync(path, CancellationToken.None); } /// /// Initiates an asynchronous operation to upload a file to a page blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, CancellationToken cancellationToken) + public virtual Task UploadFromFileAsync(string path, CancellationToken cancellationToken) { - return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, mode, cancellationToken); + return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, cancellationToken); } /// /// Initiates an asynchronous operation to upload a file to a page blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { - return this.UploadFromFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); + return this.UploadFromFileAsync(path, accessCondition, options, operationContext, CancellationToken.None); } /// /// Initiates an asynchronous operation to upload a file to a page blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { - return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, mode, accessCondition, options, operationContext, cancellationToken); + return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, accessCondition, options, operationContext, cancellationToken); } #endif @@ -900,7 +893,7 @@ public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition acce /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("buffer", buffer); @@ -921,7 +914,7 @@ public void UploadFromByteArray(byte[] buffer, int index, int count, AccessCondi /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AsyncCallback callback, object state) { return this.BeginUploadFromByteArray(buffer, index, count, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -939,7 +932,7 @@ public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("buffer", buffer); @@ -951,7 +944,7 @@ public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index /// Ends an asynchronous operation to upload the contents of a byte array to a page blob. If the blob already exists, it will be overwritten. /// /// An that references the pending asynchronous operation. - public void EndUploadFromByteArray(IAsyncResult asyncResult) + public virtual void EndUploadFromByteArray(IAsyncResult asyncResult) { this.EndUploadFromStream(asyncResult); } @@ -965,7 +958,7 @@ public void EndUploadFromByteArray(IAsyncResult asyncResult) /// The number of bytes to be written to the blob. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) { return this.UploadFromByteArrayAsync(buffer, index, count, CancellationToken.None); } @@ -979,7 +972,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromByteArray, this.EndUploadFromByteArray, buffer, index, count, cancellationToken); } @@ -995,7 +988,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, Cancel /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromByteArrayAsync(buffer, index, count, accessCondition, options, operationContext, CancellationToken.None); } @@ -1012,7 +1005,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, Access /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromByteArray, this.EndUploadFromByteArray, buffer, index, count, accessCondition, options, operationContext, cancellationToken); } @@ -1028,7 +1021,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, Access /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Create(long size, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void Create(long size, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); @@ -1048,7 +1041,7 @@ public void Create(long size, AccessCondition accessCondition = null, BlobReques /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(long size, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(long size, AsyncCallback callback, object state) { return this.BeginCreate(size, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1065,7 +1058,7 @@ public ICancellableAsyncResult BeginCreate(long size, AsyncCallback callback, ob /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1080,7 +1073,7 @@ public ICancellableAsyncResult BeginCreate(long size, AccessCondition accessCond /// Ends an asynchronous operation to create a page blob. /// /// An that references the pending asynchronous operation. - public void EndCreate(IAsyncResult asyncResult) + public virtual void EndCreate(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1093,7 +1086,7 @@ public void EndCreate(IAsyncResult asyncResult) /// The maximum size of the blob, in bytes. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync(long size) + public virtual Task CreateAsync(long size) { return this.CreateAsync(size, CancellationToken.None); } @@ -1106,7 +1099,7 @@ public Task CreateAsync(long size) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync(long size, CancellationToken cancellationToken) + public virtual Task CreateAsync(long size, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, size, cancellationToken); } @@ -1121,7 +1114,7 @@ public Task CreateAsync(long size, CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.CreateAsync(size, accessCondition, options, operationContext, CancellationToken.None); } @@ -1137,7 +1130,7 @@ public Task CreateAsync(long size, AccessCondition accessCondition, BlobRequestO /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, size, accessCondition, options, operationContext, cancellationToken); } @@ -1152,7 +1145,7 @@ public Task CreateAsync(long size, AccessCondition accessCondition, BlobRequestO /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Resize(long size, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void Resize(long size, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); @@ -1171,7 +1164,7 @@ public void Resize(long size, AccessCondition accessCondition = null, BlobReques /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginResize(long size, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginResize(long size, AsyncCallback callback, object state) { return this.BeginResize(size, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1187,7 +1180,7 @@ public ICancellableAsyncResult BeginResize(long size, AsyncCallback callback, ob /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginResize(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginResize(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1202,7 +1195,7 @@ public ICancellableAsyncResult BeginResize(long size, AccessCondition accessCond /// Ends an asynchronous operation to resize the page blob. /// /// An that references the pending asynchronous operation. - public void EndResize(IAsyncResult asyncResult) + public virtual void EndResize(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1214,7 +1207,7 @@ public void EndResize(IAsyncResult asyncResult) /// The size of the blob, in bytes. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ResizeAsync(long size) + public virtual Task ResizeAsync(long size) { return this.ResizeAsync(size, CancellationToken.None); } @@ -1226,7 +1219,7 @@ public Task ResizeAsync(long size) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ResizeAsync(long size, CancellationToken cancellationToken) + public virtual Task ResizeAsync(long size, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginResize, this.EndResize, size, cancellationToken); } @@ -1240,7 +1233,7 @@ public Task ResizeAsync(long size, CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ResizeAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ResizeAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.ResizeAsync(size, accessCondition, options, operationContext, CancellationToken.None); } @@ -1255,7 +1248,7 @@ public Task ResizeAsync(long size, AccessCondition accessCondition, BlobRequestO /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ResizeAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ResizeAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginResize, this.EndResize, size, accessCondition, options, operationContext, cancellationToken); } @@ -1271,7 +1264,7 @@ public Task ResizeAsync(long size, AccessCondition accessCondition, BlobRequestO /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetSequenceNumber(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void SetSequenceNumber(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); @@ -1291,7 +1284,7 @@ public void SetSequenceNumber(SequenceNumberAction sequenceNumberAction, long? s /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetSequenceNumber(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetSequenceNumber(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AsyncCallback callback, object state) { return this.BeginSetSequenceNumber(sequenceNumberAction, sequenceNumber, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1308,7 +1301,7 @@ public ICancellableAsyncResult BeginSetSequenceNumber(SequenceNumberAction seque /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetSequenceNumber(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetSequenceNumber(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1323,7 +1316,7 @@ public ICancellableAsyncResult BeginSetSequenceNumber(SequenceNumberAction seque /// Ends an asynchronous operation to set the page blob's sequence number. /// /// An that references the pending asynchronous operation. - public void EndSetSequenceNumber(IAsyncResult asyncResult) + public virtual void EndSetSequenceNumber(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1336,7 +1329,7 @@ public void EndSetSequenceNumber(IAsyncResult asyncResult) /// The sequence number. Set this parameter to null if is equal to . /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber) + public virtual Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber) { return this.SetSequenceNumberAsync(sequenceNumberAction, sequenceNumber, CancellationToken.None); } @@ -1349,7 +1342,7 @@ public Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, lo /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, CancellationToken cancellationToken) + public virtual Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetSequenceNumber, this.EndSetSequenceNumber, sequenceNumberAction, sequenceNumber, cancellationToken); } @@ -1364,7 +1357,7 @@ public Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, lo /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.SetSequenceNumberAsync(sequenceNumberAction, sequenceNumber, accessCondition, options, operationContext, CancellationToken.None); } @@ -1380,7 +1373,7 @@ public Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, lo /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetSequenceNumber, this.EndSetSequenceNumber, sequenceNumberAction, sequenceNumber, accessCondition, options, operationContext, cancellationToken); } @@ -1397,7 +1390,7 @@ public Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, lo /// An object that represents the context for the current operation. /// An enumerable collection of page ranges. [DoesServiceRequest] - public IEnumerable GetPageRanges(long? offset = null, long? length = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual IEnumerable GetPageRanges(long? offset = null, long? length = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); return Executor.ExecuteSync( @@ -1414,7 +1407,7 @@ public IEnumerable GetPageRanges(long? offset = null, long? length = /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetPageRanges(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetPageRanges(AsyncCallback callback, object state) { return this.BeginGetPageRanges(null /* offset */, null /* length */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1431,7 +1424,7 @@ public ICancellableAsyncResult BeginGetPageRanges(AsyncCallback callback, object /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetPageRanges(long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetPageRanges(long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1447,7 +1440,7 @@ public ICancellableAsyncResult BeginGetPageRanges(long? offset, long? length, Ac /// /// An that references the pending asynchronous operation. /// An enumerable collection of page ranges. - public IEnumerable EndGetPageRanges(IAsyncResult asyncResult) + public virtual IEnumerable EndGetPageRanges(IAsyncResult asyncResult) { return Executor.EndExecuteAsync>(asyncResult); } @@ -1458,7 +1451,7 @@ public IEnumerable EndGetPageRanges(IAsyncResult asyncResult) /// /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> GetPageRangesAsync() + public virtual Task> GetPageRangesAsync() { return this.GetPageRangesAsync(CancellationToken.None); } @@ -1469,7 +1462,7 @@ public Task> GetPageRangesAsync() /// A to observe while waiting for a task to complete. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> GetPageRangesAsync(CancellationToken cancellationToken) + public virtual Task> GetPageRangesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetPageRanges, this.EndGetPageRanges, cancellationToken); } @@ -1484,7 +1477,7 @@ public Task> GetPageRangesAsync(CancellationToken cancell /// An object that represents the context for the current operation. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> GetPageRangesAsync(long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task> GetPageRangesAsync(long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.GetPageRangesAsync(offset, length, accessCondition, options, operationContext, CancellationToken.None); } @@ -1500,12 +1493,139 @@ public Task> GetPageRangesAsync(long? offset, long? lengt /// A to observe while waiting for a task to complete. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> GetPageRangesAsync(long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> GetPageRangesAsync(long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetPageRanges, this.EndGetPageRanges, offset, length, accessCondition, options, operationContext, cancellationToken); } #endif +#if SYNC + /// + /// Gets the collection of page ranges that differ between a specified snapshot and this object. + /// + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. + /// The starting offset of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// The length of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// An object that represents the condition that must be met in order for the request to proceed. If null, no condition is used. + /// A object that specifies additional options for the request. If null, default options are applied to the request. + /// An object that represents the context for the current operation. + /// An enumerable collection of page ranges. + [DoesServiceRequest] + public IEnumerable GetPageRangesDiff(DateTimeOffset previousSnapshotTime, long? offset = null, long? length = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + { + BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); + return Executor.ExecuteSync( + this.GetPageRangesDiffImpl(previousSnapshotTime, offset, length, accessCondition, modifiedOptions), + modifiedOptions.RetryPolicy, + operationContext); + } +#endif + + /// + /// Begins an asynchronous operation to return the collection of page ranges that differ between a specified snapshot and this object. + /// + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. + /// An delegate that will receive notification when the asynchronous operation completes. + /// A user-defined object that will be passed to the callback delegate. + /// An that references the asynchronous operation. + [DoesServiceRequest] + public ICancellableAsyncResult BeginGetPageRangesDiff(DateTimeOffset previousSnapshotTime, AsyncCallback callback, object state) + { + return this.BeginGetPageRangesDiff(previousSnapshotTime, null /* offset */, null /* length */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); + } + + /// + /// Begins an asynchronous operation to return the collection of page ranges that differ between a specified snapshot and this object. + /// + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. + /// The starting offset of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// The length of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// An object that represents the condition that must be met in order for the request to proceed. If null, no condition is used. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// An delegate that will receive notification when the asynchronous operation completes. + /// A user-defined object that will be passed to the callback delegate. + /// An that references the asynchronous operation. + [DoesServiceRequest] + public ICancellableAsyncResult BeginGetPageRangesDiff(DateTimeOffset previousSnapshotTime, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + { + BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); + return Executor.BeginExecuteAsync( + this.GetPageRangesDiffImpl(previousSnapshotTime, offset, length, accessCondition, modifiedOptions), + modifiedOptions.RetryPolicy, + operationContext, + callback, + state); + } + + /// + /// Ends an asynchronous operation to return the collection of page ranges that differ between a specified snapshot and this object. + /// + /// An that references the pending asynchronous operation. + /// An enumerable collection of page ranges. + public IEnumerable EndGetPageRangesDiff(IAsyncResult asyncResult) + { + return Executor.EndExecuteAsync>(asyncResult); + } + +#if TASK + /// + /// Initiates an asynchronous operation to return the collection of page ranges that differ between a specified snapshot and this object. + /// + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. + /// A object that is an enumerable collection of type that represents the asynchronous operation. + [DoesServiceRequest] + public Task> GetPageRangesDiffAsync(DateTimeOffset previousSnapshotTime) + { + return this.GetPageRangesDiffAsync(previousSnapshotTime, CancellationToken.None); + } + + /// + /// Initiates an asynchronous operation to return the collection of page ranges that differ between a specified snapshot and this object. + /// + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. + /// A to observe while waiting for a task to complete. + /// A object that is an enumerable collection of type that represents the asynchronous operation. + [DoesServiceRequest] + public Task> GetPageRangesDiffAsync(DateTimeOffset previousSnapshotTime, CancellationToken cancellationToken) + { + return AsyncExtensions.TaskFromApm(this.BeginGetPageRangesDiff, this.EndGetPageRangesDiff, previousSnapshotTime, cancellationToken); + } + + /// + /// Initiates an asynchronous operation to return the collection of page ranges that differ between a specified snapshot and this object. + /// + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. + /// The starting offset of the data range, in bytes. Must be a multiple of 512. + /// The length of the data range, in bytes. Must be a multiple of 512. + /// An object that represents the condition that must be met in order for the request to proceed. If null, no condition is used. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// A object that is an enumerable collection of type that represents the asynchronous operation. + [DoesServiceRequest] + public Task> GetPageRangesDiffAsync(DateTimeOffset previousSnapshotTime, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + { + return this.GetPageRangesDiffAsync(previousSnapshotTime, offset, length, accessCondition, options, operationContext, CancellationToken.None); + } + + /// + /// Initiates an asynchronous operation to return the collection of page ranges that differ between a specified snapshot and this object. + /// + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. + /// The starting offset of the data range, in bytes. Must be a multiple of 512. + /// The length of the data range, in bytes. Must be a multiple of 512. + /// An object that represents the condition that must be met in order for the request to proceed. If null, no condition is used. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// A to observe while waiting for a task to complete. + /// A object that is an enumerable collection of type that represents the asynchronous operation. + [DoesServiceRequest] + public Task> GetPageRangesDiffAsync(DateTimeOffset previousSnapshotTime, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + { + return AsyncExtensions.TaskFromApm(this.BeginGetPageRangesDiff, this.EndGetPageRangesDiff, previousSnapshotTime, offset, length, accessCondition, options, operationContext, cancellationToken); + } +#endif + #if SYNC /// /// Creates a snapshot of the blob. @@ -1516,7 +1636,7 @@ public Task> GetPageRangesAsync(long? offset, long? lengt /// An object that represents the context for the current operation. /// A object that is a blob snapshot. [DoesServiceRequest] - public CloudPageBlob CreateSnapshot(IDictionary metadata = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual CloudPageBlob CreateSnapshot(IDictionary metadata = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); @@ -1534,7 +1654,7 @@ public CloudPageBlob CreateSnapshot(IDictionary metadata = null, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateSnapshot(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateSnapshot(AsyncCallback callback, object state) { return this.BeginCreateSnapshot(null /* metadata */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1550,7 +1670,7 @@ public ICancellableAsyncResult BeginCreateSnapshot(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateSnapshot(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateSnapshot(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); @@ -1567,7 +1687,7 @@ public ICancellableAsyncResult BeginCreateSnapshot(IDictionary m /// /// An that references the pending asynchronous operation. /// A object that is a blob snapshot. - public CloudPageBlob EndCreateSnapshot(IAsyncResult asyncResult) + public virtual CloudPageBlob EndCreateSnapshot(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -1578,7 +1698,7 @@ public CloudPageBlob EndCreateSnapshot(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateSnapshotAsync() + public virtual Task CreateSnapshotAsync() { return this.CreateSnapshotAsync(CancellationToken.None); } @@ -1589,7 +1709,7 @@ public Task CreateSnapshotAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateSnapshotAsync(CancellationToken cancellationToken) + public virtual Task CreateSnapshotAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateSnapshot, this.EndCreateSnapshot, cancellationToken); } @@ -1603,7 +1723,7 @@ public Task CreateSnapshotAsync(CancellationToken cancellationTok /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.CreateSnapshotAsync(metadata, accessCondition, options, operationContext, CancellationToken.None); } @@ -1618,7 +1738,7 @@ public Task CreateSnapshotAsync(IDictionary metad /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateSnapshot, this.EndCreateSnapshot, metadata, accessCondition, options, operationContext, cancellationToken); } @@ -1641,7 +1761,7 @@ public Task CreateSnapshotAsync(IDictionary metad /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public void WritePages(Stream pageData, long startOffset, string contentMD5 = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void WritePages(Stream pageData, long startOffset, string contentMD5 = null, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("pageData", pageData); @@ -1712,7 +1832,7 @@ public void WritePages(Stream pageData, long startOffset, string contentMD5 = nu /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public ICancellableAsyncResult BeginWritePages(Stream pageData, long startOffset, string contentMD5, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginWritePages(Stream pageData, long startOffset, string contentMD5, AsyncCallback callback, object state) { return this.BeginWritePages(pageData, startOffset, contentMD5, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1737,7 +1857,7 @@ public ICancellableAsyncResult BeginWritePages(Stream pageData, long startOffset /// [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Needed to ensure exceptions are not thrown on threadpool threads.")] [DoesServiceRequest] - public ICancellableAsyncResult BeginWritePages(Stream pageData, long startOffset, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginWritePages(Stream pageData, long startOffset, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("pageData", pageData); @@ -1846,7 +1966,7 @@ private void WritePagesHandler(Stream pageData, long startOffset, string content /// Ends an asynchronous operation to write pages to a page blob. /// /// An that references the pending asynchronous operation. - public void EndWritePages(IAsyncResult asyncResult) + public virtual void EndWritePages(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; @@ -1879,7 +1999,7 @@ public void EndWritePages(IAsyncResult asyncResult) /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5) + public virtual Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5) { return this.WritePagesAsync(pageData, startOffset, contentMD5, CancellationToken.None); } @@ -1899,7 +2019,7 @@ public Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5 /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5, CancellationToken cancellationToken) + public virtual Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginWritePages, this.EndWritePages, pageData, startOffset, contentMD5, cancellationToken); } @@ -1921,7 +2041,7 @@ public Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5 /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.WritePagesAsync(pageData, startOffset, contentMD5, accessCondition, options, operationContext, CancellationToken.None); } @@ -1944,7 +2064,7 @@ public Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5 /// to null, then the client library will calculate the MD5 value internally. /// [DoesServiceRequest] - public Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginWritePages, this.EndWritePages, pageData, startOffset, contentMD5, accessCondition, options, operationContext, cancellationToken); } @@ -1960,7 +2080,7 @@ public Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5 /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void ClearPages(long startOffset, long length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual void ClearPages(long startOffset, long length, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); Executor.ExecuteSync( @@ -1979,7 +2099,7 @@ public void ClearPages(long startOffset, long length, AccessCondition accessCond /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginClearPages(long startOffset, long length, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginClearPages(long startOffset, long length, AsyncCallback callback, object state) { return this.BeginClearPages(startOffset, length, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1996,7 +2116,7 @@ public ICancellableAsyncResult BeginClearPages(long startOffset, long length, As /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginClearPages(long startOffset, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginClearPages(long startOffset, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2011,7 +2131,7 @@ public ICancellableAsyncResult BeginClearPages(long startOffset, long length, Ac /// Ends an asynchronous operation to clear pages from a page blob. /// /// An that references the pending asynchronous operation. - public void EndClearPages(IAsyncResult asyncResult) + public virtual void EndClearPages(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -2024,7 +2144,7 @@ public void EndClearPages(IAsyncResult asyncResult) /// The length of the data range to be cleared, in bytes. The length must be a multiple of 512. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ClearPagesAsync(long startOffset, long length) + public virtual Task ClearPagesAsync(long startOffset, long length) { return this.ClearPagesAsync(startOffset, length, CancellationToken.None); } @@ -2037,7 +2157,7 @@ public Task ClearPagesAsync(long startOffset, long length) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ClearPagesAsync(long startOffset, long length, CancellationToken cancellationToken) + public virtual Task ClearPagesAsync(long startOffset, long length, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginClearPages, this.EndClearPages, startOffset, length, cancellationToken); } @@ -2052,7 +2172,7 @@ public Task ClearPagesAsync(long startOffset, long length, CancellationToken can /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ClearPagesAsync(long startOffset, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ClearPagesAsync(long startOffset, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.ClearPagesAsync(startOffset, length, accessCondition, options, operationContext, CancellationToken.None); } @@ -2068,132 +2188,12 @@ public Task ClearPagesAsync(long startOffset, long length, AccessCondition acces /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ClearPagesAsync(long startOffset, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ClearPagesAsync(long startOffset, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginClearPages, this.EndClearPages, startOffset, length, accessCondition, options, operationContext, cancellationToken); } #endif -#if SYNC - /// - /// Begins an operation to start copying another page blob's contents, properties, and metadata to this page blob. - /// - /// The of the source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. If null, default options are applied to the request. - /// An object that represents the context for the current operation. - /// The copy ID associated with the copy operation. - /// - /// This method fetches the blob's ETag, last-modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// - [Obsolete("Deprecated this method in favor of StartCopy.")] - [DoesServiceRequest] - public string StartCopyFromBlob(CloudPageBlob source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) - { - return this.StartCopy(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); - } -#endif - - /// - /// Begins an asynchronous operation to start copying another page blob's contents, properties, and metadata to this page blob. - /// - /// The that is the source blob. - /// An delegate that will receive notification when the asynchronous operation completes. - /// A user-defined object that will be passed to the callback delegate. - /// An that references the asynchronous operation. - [Obsolete("Deprecated this method in favor of BeginStartCopy.")] - [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopyFromBlob(CloudPageBlob source, AsyncCallback callback, object state) - { - return this.BeginStartCopy(CloudBlob.SourceBlobToUri(source), callback, state); - } - - /// - /// Begins an asynchronous operation to start copying another page blob's contents, properties, and metadata to this page blob. - /// - /// The that is the source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// An delegate that will receive notification when the asynchronous operation completes. - /// A user-defined object that will be passed to the callback delegate. - /// An that references the asynchronous operation. - [Obsolete("Deprecated this method in favor of BeginStartCopy.")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dest", Justification = "Reviewed")] - [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopyFromBlob(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) - { - return this.BeginStartCopy(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, callback, state); - } - -#if TASK - - /// - /// Initiates an asynchronous operation to start copying another blob's contents, properties, and metadata - /// to this page blob. - /// - /// The that is the source blob. - /// A object of type string that represents the asynchronous operation. - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(CloudPageBlob source) - { - return this.StartCopyAsync(source, CancellationToken.None); - } - - /// - /// Initiates an asynchronous operation to start copying another blob's contents, properties, and metadata - /// to this page blob. - /// - /// The that is the source blob. - /// A to observe while waiting for a task to complete. - /// A object of type string that represents the asynchronous operation. - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(CloudPageBlob source, CancellationToken cancellationToken) - { - return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, cancellationToken); - } - - /// - /// Initiates an asynchronous operation to start copying another blob's contents, properties, and metadata - /// to this page blob. - /// - /// The that is the source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// A object of type string that represents the asynchronous operation. - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); - } - - /// - /// Initiates an asynchronous operation to start copying another blob's contents, properties, and metadata - /// to this page blob. - /// - /// The that is the source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// A to observe while waiting for a task to complete. - /// A object of type string that represents the asynchronous operation. - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) - { - return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); - } -#endif - #if SYNC /// /// Begins an operation to start copying another page blob's contents, properties, and metadata to this page blob. @@ -2209,7 +2209,7 @@ public Task StartCopyFromBlobAsync(CloudPageBlob source, AccessCondition /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public string StartCopy(CloudPageBlob source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) + public virtual string StartCopy(CloudPageBlob source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { return this.StartCopy(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); } @@ -2223,7 +2223,7 @@ public string StartCopy(CloudPageBlob source, AccessCondition sourceAccessCondit /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(CloudPageBlob source, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(CloudPageBlob source, AsyncCallback callback, object state) { return this.BeginStartCopy(CloudBlob.SourceBlobToUri(source), callback, state); } @@ -2241,7 +2241,7 @@ public ICancellableAsyncResult BeginStartCopy(CloudPageBlob source, AsyncCallbac /// An that references the asynchronous operation. [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dest", Justification = "Reviewed")] [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginStartCopy(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, callback, state); } @@ -2254,7 +2254,7 @@ public ICancellableAsyncResult BeginStartCopy(CloudPageBlob source, AccessCondit /// The that is the source blob. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudPageBlob source) + public virtual Task StartCopyAsync(CloudPageBlob source) { return this.StartCopyAsync(source, CancellationToken.None); } @@ -2267,7 +2267,7 @@ public Task StartCopyAsync(CloudPageBlob source) /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudPageBlob source, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudPageBlob source, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, cancellationToken); } @@ -2283,7 +2283,7 @@ public Task StartCopyAsync(CloudPageBlob source, CancellationToken cance /// An object that represents the context for the current operation. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } @@ -2300,7 +2300,7 @@ public Task StartCopyAsync(CloudPageBlob source, AccessCondition sourceA /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); } @@ -2383,7 +2383,7 @@ private RESTCommand SetSequenceNumberImpl(SequenceNumberAction sequenc } /// - /// Gets the page ranges impl. + /// Implementation for the GetPageRanges method. /// /// The starting offset of the data range over which to list page ranges, in bytes. Must be a multiple of 512. /// The length of the data range over which to list page ranges, in bytes. Must be a multiple of 512. @@ -2398,7 +2398,6 @@ private RESTCommand> GetPageRangesImpl(long? offset, long getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; getCmd.RetrieveResponseStream = true; getCmd.BuildRequestDelegate = (uri, builder, serverTimeout, useVersionHeader, ctx) => BlobHttpWebRequestFactory.GetPageRanges(uri, serverTimeout, this.SnapshotTime, offset, length, accessCondition, useVersionHeader, ctx); - getCmd.SetHeaders = (r, ctx) => BlobHttpWebRequestFactory.AddMetadata(r, this.Metadata); getCmd.SignRequest = this.ServiceClient.AuthenticationHandler.SignRequest; getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => @@ -2412,6 +2411,36 @@ private RESTCommand> GetPageRangesImpl(long? offset, long return getCmd; } + /// + /// Implementation for the GetPageRangesDiff method. + /// + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. + /// The starting offset of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// The length of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// An object that represents the condition that must be met in order for the request to proceed. If null, no condition is used. + /// A object that specifies additional options for the request. + /// A for getting the page ranges. + private RESTCommand> GetPageRangesDiffImpl(DateTimeOffset previousSnapshotTime, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options) + { + RESTCommand> getCmd = new RESTCommand>(this.ServiceClient.Credentials, this.attributes.StorageUri); + + options.ApplyToStorageCommand(getCmd); + getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; + getCmd.RetrieveResponseStream = true; + getCmd.BuildRequestDelegate = (uri, builder, serverTimeout, useVersionHeader, ctx) => BlobHttpWebRequestFactory.GetPageRangesDiff(uri, serverTimeout, this.SnapshotTime, previousSnapshotTime, offset, length, accessCondition, useVersionHeader, ctx); + getCmd.SignRequest = this.ServiceClient.AuthenticationHandler.SignRequest; + getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); + getCmd.PostProcessResponse = (cmd, resp, ctx) => + { + CloudBlob.UpdateETagLMTLengthAndSequenceNumber(this.attributes, resp, true); + GetPageDiffRangesResponse getPageDiffRangesResponse = new GetPageDiffRangesResponse(cmd.ResponseStream); + IEnumerable pageDiffRanges = new List(getPageDiffRangesResponse.PageDiffRanges); + return pageDiffRanges; + }; + + return getCmd; + } + /// /// Implementation method for the WritePage methods. /// diff --git a/Lib/ClassLibraryCommon/Blob/ICloudBlob.cs b/Lib/ClassLibraryCommon/Blob/ICloudBlob.cs index d40f7b13e..cb98943c2 100644 --- a/Lib/ClassLibraryCommon/Blob/ICloudBlob.cs +++ b/Lib/ClassLibraryCommon/Blob/ICloudBlob.cs @@ -311,35 +311,32 @@ public partial interface ICloudBlob : IListBlobItem /// Uploads a file to the Windows Azure Blob Service. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. - void UploadFromFile(string path, FileMode mode, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null); + void UploadFromFile(string path, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null); #endif /// /// Begins an asynchronous operation to upload a file to a blob. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. - ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, AsyncCallback callback, object state); + ICancellableAsyncResult BeginUploadFromFile(string path, AsyncCallback callback, object state); /// /// Begins an asynchronous operation to upload a file to a blob. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. - ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state); + ICancellableAsyncResult BeginUploadFromFile(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state); /// /// Ends an asynchronous operation to upload a file to a blob. @@ -352,41 +349,37 @@ public partial interface ICloudBlob : IListBlobItem /// Initiates an asynchronous operation to upload a file to a blob. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A object that represents the asynchronous operation. - Task UploadFromFileAsync(string path, FileMode mode); + Task UploadFromFileAsync(string path); /// /// Initiates an asynchronous operation to upload a file to a blob. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. - Task UploadFromFileAsync(string path, FileMode mode, CancellationToken cancellationToken); + Task UploadFromFileAsync(string path, CancellationToken cancellationToken); /// /// Initiates an asynchronous operation to upload a file to a blob. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. - Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); + Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); /// /// Initiates an asynchronous operation to upload a file to a blob. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the condition that must be met in order for the request to proceed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. - Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken); + Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken); #endif #if SYNC @@ -1388,7 +1381,7 @@ public partial interface ICloudBlob : IListBlobItem /// which will be rounded down to seconds. /// A string representing the proposed lease ID for the new lease. /// A object of type string that represents the asynchronous operation. - Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId); + Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId = null); /// /// Initiates an asynchronous operation to acquire a lease on this blob. @@ -1736,96 +1729,6 @@ public partial interface ICloudBlob : IListBlobItem Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken); #endif -#if SYNC - /// - /// Begins an operation to start copying another blob's contents, properties, and metadata to this blob. - /// - /// The of the source blob. - /// An object that represents the access conditions for the source blob. - /// An object that represents the access conditions for the destination blob. - /// A object that specifies additional options for the request. If null, default options are applied to the request. - /// An object that represents the context for the current operation. - /// The copy ID associated with the copy operation. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dest", Justification = "Reviewed")] - string StartCopyFromBlob(Uri source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null); -#endif - - /// - /// Begins an asynchronous operation to start copying a blob's contents, properties, and metadata to this blob. - /// - /// The of the source blob. - /// An delegate that will receive notification when the asynchronous operation completes. - /// A user-defined object that will be passed to the callback delegate. - /// An that references the asynchronous operation. - ICancellableAsyncResult BeginStartCopyFromBlob(Uri source, AsyncCallback callback, object state); - - /// - /// Begins an asynchronous operation to start copying a blob's contents, properties, and metadata to this blob. - /// - /// The of the source blob. - /// An object that represents the access conditions for the source blob. - /// An object that represents the access conditions for the destination blob. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// An delegate that will receive notification when the asynchronous operation completes. - /// A user-defined object that will be passed to the callback delegate. - /// An that references the asynchronous operation. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dest", Justification = "Reviewed")] - ICancellableAsyncResult BeginStartCopyFromBlob(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state); - - /// - /// Ends an asynchronous operation to start copying a blob's contents, properties, and metadata to this blob. - /// - /// An that references the pending asynchronous operation. - /// The copy ID associated with the copy operation. - string EndStartCopyFromBlob(IAsyncResult asyncResult); - -#if TASK - /// - /// Initiates an asynchronous operation to start copying another blob's contents, properties, and metadata - /// to this blob. - /// - /// The of the source blob. - /// A object of type string that represents the asynchronous operation. - Task StartCopyFromBlobAsync(Uri source); - - /// - /// Initiates an asynchronous operation to start copying another blob's contents, properties, and metadata - /// to this blob. - /// - /// The of the source blob. - /// A to observe while waiting for a task to complete. - /// A object of type string that represents the asynchronous operation. - Task StartCopyFromBlobAsync(Uri source, CancellationToken cancellationToken); - - /// - /// Initiates an asynchronous operation to start copying another blob's contents, properties, and metadata - /// to this blob. - /// - /// The of the source blob. - /// An object that represents the access conditions for the source blob. - /// An object that represents the access conditions for the destination blob. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// A object of type string that represents the asynchronous operation. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dest", Justification = "Reviewed")] - Task StartCopyFromBlobAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext); - - /// - /// Initiates an asynchronous operation to start copying another blob's contents, properties, and metadata - /// to this blob. - /// - /// The of the source blob. - /// An object that represents the access conditions for the source blob. - /// An object that represents the access conditions for the destination blob. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// A to observe while waiting for a task to complete. - /// A object of type string that represents the asynchronous operation. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dest", Justification = "Reviewed")] - Task StartCopyFromBlobAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken); -#endif - #if SYNC /// /// Aborts an ongoing blob copy operation. diff --git a/Lib/ClassLibraryCommon/Blob/Protocol/BlobHttpWebRequestFactory.cs b/Lib/ClassLibraryCommon/Blob/Protocol/BlobHttpWebRequestFactory.cs index 2f4f05c73..e76cb4373 100644 --- a/Lib/ClassLibraryCommon/Blob/Protocol/BlobHttpWebRequestFactory.cs +++ b/Lib/ClassLibraryCommon/Blob/Protocol/BlobHttpWebRequestFactory.cs @@ -309,6 +309,37 @@ public static HttpWebRequest GetPageRanges(Uri uri, int? timeout, DateTimeOffset return request; } + /// + /// Constructs a web request to return the list of page ranges that differ between a specified snapshot and this object. + /// + /// A specifying the absolute URI to the blob. + /// An integer specifying the server timeout interval. + /// A specifying the snapshot timestamp, if the blob is a snapshot. + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. + /// The starting offset of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// The length of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// An object that represents the condition that must be met in order for the request to proceed. + /// A boolean value indicating whether to set the x-ms-version HTTP header. + /// An object that represents the context for the current operation. + /// A object. + public static HttpWebRequest GetPageRangesDiff(Uri uri, int? timeout, DateTimeOffset? snapshot, DateTimeOffset previousSnapshotTime, long? offset, long? count, AccessCondition accessCondition, bool useVersionHeader, OperationContext operationContext) + { + if (offset.HasValue) + { + CommonUtility.AssertNotNull("count", count); + } + + UriQueryBuilder builder = new UriQueryBuilder(); + builder.Add(Constants.QueryConstants.Component, "pagelist"); + BlobHttpWebRequestFactory.AddSnapshot(builder, snapshot); + builder.Add("prevsnapshot", Request.ConvertDateTimeToSnapshotString(previousSnapshotTime)); + + HttpWebRequest request = HttpWebRequestFactory.CreateWebRequest(WebRequestMethods.Http.Get, uri, timeout, builder, useVersionHeader, operationContext); + AddRange(request, offset, count); + request.ApplyAccessCondition(accessCondition); + return request; + } + /// /// Adds the Range Header for Blob Service Operations. /// diff --git a/Lib/ClassLibraryCommon/File/CloudFile.cs b/Lib/ClassLibraryCommon/File/CloudFile.cs index 3a44b1a1c..195a5696e 100644 --- a/Lib/ClassLibraryCommon/File/CloudFile.cs +++ b/Lib/ClassLibraryCommon/File/CloudFile.cs @@ -36,7 +36,7 @@ namespace Microsoft.WindowsAzure.Storage.File /// /// Represents a file in the Windows Azure File service. /// - public sealed partial class CloudFile : IListFileItem + public partial class CloudFile : IListFileItem { #if SYNC /// @@ -48,7 +48,7 @@ public sealed partial class CloudFile : IListFileItem /// A stream to be used for reading from the file. /// On the object returned by this method, the method must be called exactly once for every call. Failing to end a read process before beginning another read can cause unknown behavior. [DoesServiceRequest] - public Stream OpenRead(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual Stream OpenRead(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { operationContext = operationContext ?? new OperationContext(); this.FetchAttributes(accessCondition, options, operationContext); @@ -65,7 +65,7 @@ public Stream OpenRead(AccessCondition accessCondition = null, FileRequestOption /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginOpenRead(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginOpenRead(AsyncCallback callback, object state) { return this.BeginOpenRead(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -81,7 +81,7 @@ public ICancellableAsyncResult BeginOpenRead(AsyncCallback callback, object stat /// An that references the asynchronous operation. [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Reviewed.")] [DoesServiceRequest] - public ICancellableAsyncResult BeginOpenRead(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginOpenRead(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state); operationContext = operationContext ?? new OperationContext(); @@ -117,7 +117,7 @@ public ICancellableAsyncResult BeginOpenRead(AccessCondition accessCondition, Fi /// /// An that references the pending asynchronous operation. /// A stream to be used for reading from the file. - public Stream EndOpenRead(IAsyncResult asyncResult) + public virtual Stream EndOpenRead(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; storageAsyncResult.End(); @@ -130,7 +130,7 @@ public Stream EndOpenRead(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task OpenReadAsync() + public virtual Task OpenReadAsync() { return this.OpenReadAsync(CancellationToken.None); } @@ -141,7 +141,7 @@ public Task OpenReadAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task OpenReadAsync(CancellationToken cancellationToken) + public virtual Task OpenReadAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginOpenRead, this.EndOpenRead, cancellationToken); } @@ -154,7 +154,7 @@ public Task OpenReadAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task OpenReadAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task OpenReadAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.OpenReadAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -168,7 +168,7 @@ public Task OpenReadAsync(AccessCondition accessCondition, FileRequestOp /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task OpenReadAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task OpenReadAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginOpenRead, this.EndOpenRead, accessCondition, options, operationContext, cancellationToken); } @@ -184,7 +184,7 @@ public Task OpenReadAsync(AccessCondition accessCondition, FileRequestOp /// An object that represents the context for the current operation. /// A object to be used for writing to the file. [DoesServiceRequest] - public CloudFileStream OpenWrite(long? size, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual CloudFileStream OpenWrite(long? size, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient, false); operationContext = operationContext ?? new OperationContext(); @@ -222,7 +222,7 @@ public CloudFileStream OpenWrite(long? size, AccessCondition accessCondition = n /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginOpenWrite(long? size, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginOpenWrite(long? size, AsyncCallback callback, object state) { return this.BeginOpenWrite(size, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -239,7 +239,7 @@ public ICancellableAsyncResult BeginOpenWrite(long? size, AsyncCallback callback /// An that references the asynchronous operation. [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Reviewed.")] [DoesServiceRequest] - public ICancellableAsyncResult BeginOpenWrite(long? size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginOpenWrite(long? size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient, false); operationContext = operationContext ?? new OperationContext(); @@ -321,7 +321,7 @@ public ICancellableAsyncResult BeginOpenWrite(long? size, AccessCondition access /// /// An that references the pending asynchronous operation. /// A object to be used for writing to the file. - public CloudFileStream EndOpenWrite(IAsyncResult asyncResult) + public virtual CloudFileStream EndOpenWrite(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; storageAsyncResult.End(); @@ -335,7 +335,7 @@ public CloudFileStream EndOpenWrite(IAsyncResult asyncResult) /// The size of the file, in bytes. If null, the file must already exist. /// A object that represents the current operation. [DoesServiceRequest] - public Task OpenWriteAsync(long? size) + public virtual Task OpenWriteAsync(long? size) { return this.OpenWriteAsync(size, CancellationToken.None); } @@ -347,7 +347,7 @@ public Task OpenWriteAsync(long? size) /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task OpenWriteAsync(long? size, CancellationToken cancellationToken) + public virtual Task OpenWriteAsync(long? size, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginOpenWrite, this.EndOpenWrite, size, cancellationToken); } @@ -361,7 +361,7 @@ public Task OpenWriteAsync(long? size, CancellationToken cancel /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task OpenWriteAsync(long? size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task OpenWriteAsync(long? size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.OpenWriteAsync(size, accessCondition, options, operationContext, CancellationToken.None); } @@ -376,7 +376,7 @@ public Task OpenWriteAsync(long? size, AccessCondition accessCo /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task OpenWriteAsync(long? size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task OpenWriteAsync(long? size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginOpenWrite, this.EndOpenWrite, size, accessCondition, options, operationContext, cancellationToken); } @@ -391,7 +391,7 @@ public Task OpenWriteAsync(long? size, AccessCondition accessCo /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void DownloadToStream(Stream target, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void DownloadToStream(Stream target, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { this.DownloadRangeToStream(target, null /* offset */, null /* length */, accessCondition, options, operationContext); } @@ -405,7 +405,7 @@ public void DownloadToStream(Stream target, AccessCondition accessCondition = nu /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadToStream(Stream target, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadToStream(Stream target, AsyncCallback callback, object state) { return this.BeginDownloadToStream(target, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -421,7 +421,7 @@ public ICancellableAsyncResult BeginDownloadToStream(Stream target, AsyncCallbac /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadToStream(Stream target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadToStream(Stream target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginDownloadRangeToStream(target, null /* offset */, null /* length */, accessCondition, options, operationContext, callback, state); } @@ -430,7 +430,7 @@ public ICancellableAsyncResult BeginDownloadToStream(Stream target, AccessCondit /// Ends an asynchronous operation to download the contents of a file to a stream. /// /// An that references the pending asynchronous operation. - public void EndDownloadToStream(IAsyncResult asyncResult) + public virtual void EndDownloadToStream(IAsyncResult asyncResult) { this.EndDownloadRangeToStream(asyncResult); } @@ -442,7 +442,7 @@ public void EndDownloadToStream(IAsyncResult asyncResult) /// The target stream. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target) + public virtual Task DownloadToStreamAsync(Stream target) { return this.DownloadToStreamAsync(target, CancellationToken.None); } @@ -454,7 +454,7 @@ public Task DownloadToStreamAsync(Stream target) /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target, CancellationToken cancellationToken) + public virtual Task DownloadToStreamAsync(Stream target, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDownloadToStream, this.EndDownloadToStream, target, cancellationToken); } @@ -468,7 +468,7 @@ public Task DownloadToStreamAsync(Stream target, CancellationToken cancellationT /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DownloadToStreamAsync(target, accessCondition, options, operationContext, CancellationToken.None); } @@ -483,7 +483,7 @@ public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDownloadToStream, this.EndDownloadToStream, target, accessCondition, options, operationContext, cancellationToken); } @@ -499,13 +499,14 @@ public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void DownloadToFile(string path, FileMode mode, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void DownloadToFile(string path, FileMode mode, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("path", path); - + FileStream fileStream = new FileStream(path, mode, FileAccess.Write); + try { - using (FileStream fileStream = new FileStream(path, mode, FileAccess.Write)) + using (fileStream) { this.DownloadToStream(fileStream, accessCondition, options, operationContext); } @@ -539,7 +540,7 @@ public void DownloadToFile(string path, FileMode mode, AccessCondition accessCon /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadToFile(string path, FileMode mode, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadToFile(string path, FileMode mode, AsyncCallback callback, object state) { return this.BeginDownloadToFile(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -556,7 +557,7 @@ public ICancellableAsyncResult BeginDownloadToFile(string path, FileMode mode, A /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadToFile(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadToFile(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("path", path); @@ -637,7 +638,7 @@ private void DownloadToFileCallback(IAsyncResult asyncResult) /// Ends an asynchronous operation to download the contents of a file in the File service to a local file. /// /// An that references the pending asynchronous operation. - public void EndDownloadToFile(IAsyncResult asyncResult) + public virtual void EndDownloadToFile(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -651,7 +652,7 @@ public void EndDownloadToFile(IAsyncResult asyncResult) /// A enumeration value that determines how to open or create the file. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode) + public virtual Task DownloadToFileAsync(string path, FileMode mode) { return this.DownloadToFileAsync(path, mode, CancellationToken.None); } @@ -664,7 +665,7 @@ public Task DownloadToFileAsync(string path, FileMode mode) /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode, CancellationToken cancellationToken) + public virtual Task DownloadToFileAsync(string path, FileMode mode, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDownloadToFile, this.EndDownloadToFile, path, mode, cancellationToken); } @@ -679,7 +680,7 @@ public Task DownloadToFileAsync(string path, FileMode mode, CancellationToken ca /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DownloadToFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); } @@ -695,7 +696,7 @@ public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition acce /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDownloadToFile, this.EndDownloadToFile, path, mode, accessCondition, options, operationContext, cancellationToken); } @@ -712,7 +713,7 @@ public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition acce /// An object that represents the context for the current operation. /// The total number of bytes read into the buffer. [DoesServiceRequest] - public int DownloadToByteArray(byte[] target, int index, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual int DownloadToByteArray(byte[] target, int index, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { return this.DownloadRangeToByteArray(target, index, null /* fileOffset */, null /* length */, accessCondition, options, operationContext); } @@ -727,7 +728,7 @@ public int DownloadToByteArray(byte[] target, int index, AccessCondition accessC /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadToByteArray(byte[] target, int index, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadToByteArray(byte[] target, int index, AsyncCallback callback, object state) { return this.BeginDownloadToByteArray(target, index, null /* accessCondition */, null /* options */, null /*operationContext */, callback, state); } @@ -744,7 +745,7 @@ public ICancellableAsyncResult BeginDownloadToByteArray(byte[] target, int index /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadToByteArray(byte[] target, int index, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadToByteArray(byte[] target, int index, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginDownloadRangeToByteArray(target, index, null /* fileOffset */, null /* length */, accessCondition, options, operationContext, callback, state); } @@ -754,7 +755,7 @@ public ICancellableAsyncResult BeginDownloadToByteArray(byte[] target, int index /// /// An that references the pending asynchronous operation. /// The total number of bytes read into the buffer. - public int EndDownloadToByteArray(IAsyncResult asyncResult) + public virtual int EndDownloadToByteArray(IAsyncResult asyncResult) { return this.EndDownloadRangeToByteArray(asyncResult); } @@ -767,7 +768,7 @@ public int EndDownloadToByteArray(IAsyncResult asyncResult) /// The starting offset in the byte array. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadToByteArrayAsync(byte[] target, int index) + public virtual Task DownloadToByteArrayAsync(byte[] target, int index) { return this.DownloadToByteArrayAsync(target, index, CancellationToken.None); } @@ -780,7 +781,7 @@ public Task DownloadToByteArrayAsync(byte[] target, int index) /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadToByteArrayAsync(byte[] target, int index, CancellationToken cancellationToken) + public virtual Task DownloadToByteArrayAsync(byte[] target, int index, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadToByteArray, this.EndDownloadToByteArray, target, index, cancellationToken); } @@ -795,7 +796,7 @@ public Task DownloadToByteArrayAsync(byte[] target, int index, Cancellation /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DownloadToByteArrayAsync(target, index, accessCondition, options, operationContext, CancellationToken.None); } @@ -811,7 +812,7 @@ public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondit /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadToByteArray, this.EndDownloadToByteArray, target, index, accessCondition, options, operationContext, cancellationToken); } @@ -826,7 +827,8 @@ public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondit /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// The contents of the file, as a string. - public string DownloadText(Encoding encoding = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + [DoesServiceRequest] + public virtual string DownloadText(Encoding encoding = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { using (SyncMemoryStream stream = new SyncMemoryStream()) { @@ -843,7 +845,8 @@ public string DownloadText(Encoding encoding = null, AccessCondition accessCondi /// The callback delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. - public ICancellableAsyncResult BeginDownloadText(AsyncCallback callback, object state) + [DoesServiceRequest] + public virtual ICancellableAsyncResult BeginDownloadText(AsyncCallback callback, object state) { return this.BeginDownloadText(null /* encoding */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -858,7 +861,8 @@ public ICancellableAsyncResult BeginDownloadText(AsyncCallback callback, object /// The callback delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. - public ICancellableAsyncResult BeginDownloadText(Encoding encoding, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + [DoesServiceRequest] + public virtual ICancellableAsyncResult BeginDownloadText(Encoding encoding, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { SyncMemoryStream stream = new SyncMemoryStream(); StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state) { OperationState = Tuple.Create(stream, encoding) }; @@ -903,7 +907,7 @@ private void DownloadTextCallback(IAsyncResult asyncResult) /// /// An that references the pending asynchronous operation. /// The contents of the file, as a string. - public string EndDownloadText(IAsyncResult asyncResult) + public virtual string EndDownloadText(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -916,7 +920,7 @@ public string EndDownloadText(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadTextAsync() + public virtual Task DownloadTextAsync() { return this.DownloadTextAsync(CancellationToken.None); } @@ -927,7 +931,7 @@ public Task DownloadTextAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadTextAsync(CancellationToken cancellationToken) + public virtual Task DownloadTextAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadText, this.EndDownloadText, cancellationToken); } @@ -941,7 +945,7 @@ public Task DownloadTextAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DownloadTextAsync(encoding, accessCondition, options, operationContext, CancellationToken.None); } @@ -956,7 +960,7 @@ public Task DownloadTextAsync(Encoding encoding, AccessCondition accessC /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadText, this.EndDownloadText, encoding, accessCondition, options, operationContext, cancellationToken); } @@ -973,7 +977,7 @@ public Task DownloadTextAsync(Encoding encoding, AccessCondition accessC /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void DownloadRangeToStream(Stream target, long? offset, long? length, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void DownloadRangeToStream(Stream target, long? offset, long? length, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("target", target); FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); @@ -994,7 +998,7 @@ public void DownloadRangeToStream(Stream target, long? offset, long? length, Acc /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadRangeToStream(Stream target, long? offset, long? length, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadRangeToStream(Stream target, long? offset, long? length, AsyncCallback callback, object state) { return this.BeginDownloadRangeToStream(target, offset, length, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1012,7 +1016,7 @@ public ICancellableAsyncResult BeginDownloadRangeToStream(Stream target, long? o /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadRangeToStream(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadRangeToStream(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("target", target); FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); @@ -1028,7 +1032,7 @@ public ICancellableAsyncResult BeginDownloadRangeToStream(Stream target, long? o /// Ends an asynchronous operation to download the contents of a file to a stream. /// /// An that references the pending asynchronous operation. - public void EndDownloadRangeToStream(IAsyncResult asyncResult) + public virtual void EndDownloadRangeToStream(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1042,7 +1046,7 @@ public void EndDownloadRangeToStream(IAsyncResult asyncResult) /// The length of the data range, in bytes. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length) + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length) { return this.DownloadRangeToStreamAsync(target, offset, length, CancellationToken.None); } @@ -1056,7 +1060,7 @@ public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, CancellationToken cancellationToken) + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDownloadRangeToStream, this.EndDownloadRangeToStream, target, offset, length, cancellationToken); } @@ -1072,7 +1076,7 @@ public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DownloadRangeToStreamAsync(target, offset, length, accessCondition, options, operationContext, CancellationToken.None); } @@ -1089,7 +1093,7 @@ public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDownloadRangeToStream, this.EndDownloadRangeToStream, target, offset, length, accessCondition, options, operationContext, cancellationToken); } @@ -1108,7 +1112,7 @@ public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length /// An object that represents the context for the current operation. /// The total number of bytes read into the buffer. [DoesServiceRequest] - public int DownloadRangeToByteArray(byte[] target, int index, long? fileOffset, long? length, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual int DownloadRangeToByteArray(byte[] target, int index, long? fileOffset, long? length, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { using (SyncMemoryStream stream = new SyncMemoryStream(target, index)) { @@ -1129,7 +1133,7 @@ public int DownloadRangeToByteArray(byte[] target, int index, long? fileOffset, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadRangeToByteArray(byte[] target, int index, long? fileOffset, long? length, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadRangeToByteArray(byte[] target, int index, long? fileOffset, long? length, AsyncCallback callback, object state) { return this.BeginDownloadRangeToByteArray(target, index, fileOffset, length, null /* accesCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1148,7 +1152,7 @@ public ICancellableAsyncResult BeginDownloadRangeToByteArray(byte[] target, int /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDownloadRangeToByteArray(byte[] target, int index, long? fileOffset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDownloadRangeToByteArray(byte[] target, int index, long? fileOffset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { SyncMemoryStream stream = new SyncMemoryStream(target, index); StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state) { OperationState = stream }; @@ -1194,7 +1198,7 @@ private void DownloadRangeToByteArrayCallback(IAsyncResult asyncResult) /// /// An that references the pending asynchronous operation. /// The total number of bytes read into the buffer. - public int EndDownloadRangeToByteArray(IAsyncResult asyncResult) + public virtual int EndDownloadRangeToByteArray(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -1211,7 +1215,7 @@ public int EndDownloadRangeToByteArray(IAsyncResult asyncResult) /// The length of the data to download from the file, in bytes. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length) + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length) { return this.DownloadRangeToByteArrayAsync(target, index, fileOffset, length, CancellationToken.None); } @@ -1226,7 +1230,7 @@ public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? f /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length, CancellationToken cancellationToken) + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadRangeToByteArray, this.EndDownloadRangeToByteArray, target, index, fileOffset, length, cancellationToken); } @@ -1243,7 +1247,7 @@ public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? f /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DownloadRangeToByteArrayAsync(target, index, fileOffset, length, accessCondition, options, operationContext, CancellationToken.None); } @@ -1261,7 +1265,7 @@ public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? f /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDownloadRangeToByteArray, this.EndDownloadRangeToByteArray, target, index, fileOffset, length, accessCondition, options, operationContext, cancellationToken); } @@ -1276,7 +1280,7 @@ public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? f /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadFromStream(Stream source, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromStream(Stream source, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { this.UploadFromStreamHelper(source, null /* length */, accessCondition, options, operationContext); } @@ -1290,7 +1294,7 @@ public void UploadFromStream(Stream source, AccessCondition accessCondition = nu /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadFromStream(Stream source, long length, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromStream(Stream source, long length, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { this.UploadFromStreamHelper(source, length, accessCondition, options, operationContext); } @@ -1343,7 +1347,7 @@ internal void UploadFromStreamHelper(Stream source, long? length, AccessConditio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, null /* length */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1359,7 +1363,7 @@ public ICancellableAsyncResult BeginUploadFromStream(Stream source, AsyncCallbac /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, null /* length */, accessCondition, options, operationContext, callback, state); } @@ -1373,7 +1377,7 @@ public ICancellableAsyncResult BeginUploadFromStream(Stream source, AccessCondit /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, length, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1390,7 +1394,7 @@ public ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromStream(Stream source, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginUploadFromStreamHelper(source, length, accessCondition, options, operationContext, callback, state); } @@ -1512,7 +1516,7 @@ internal ICancellableAsyncResult BeginUploadFromStreamHelper(Stream source, long /// Ends an asynchronous operation to upload a stream to a file. /// /// An that references the pending asynchronous operation. - public void EndUploadFromStream(IAsyncResult asyncResult) + public virtual void EndUploadFromStream(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; storageAsyncResult.End(); @@ -1525,7 +1529,7 @@ public void EndUploadFromStream(IAsyncResult asyncResult) /// The stream providing the file content. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source) + public virtual Task UploadFromStreamAsync(Stream source) { return this.UploadFromStreamAsync(source, CancellationToken.None); } @@ -1537,7 +1541,7 @@ public Task UploadFromStreamAsync(Stream source) /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, cancellationToken); } @@ -1551,7 +1555,7 @@ public Task UploadFromStreamAsync(Stream source, CancellationToken cancellationT /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsync(source, accessCondition, options, operationContext, CancellationToken.None); } @@ -1566,7 +1570,7 @@ public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, accessCondition, options, operationContext, cancellationToken); } @@ -1578,7 +1582,7 @@ public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition /// The number of bytes to write from the source stream at its current position. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length) + public virtual Task UploadFromStreamAsync(Stream source, long length) { return this.UploadFromStreamAsync(source, length, CancellationToken.None); } @@ -1591,7 +1595,7 @@ public Task UploadFromStreamAsync(Stream source, long length) /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, long length, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, length, cancellationToken); } @@ -1606,7 +1610,7 @@ public Task UploadFromStreamAsync(Stream source, long length, CancellationToken /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsync(source, length, accessCondition, options, operationContext, CancellationToken.None); } @@ -1622,7 +1626,7 @@ public Task UploadFromStreamAsync(Stream source, long length, AccessCondition ac /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromStream, this.EndUploadFromStream, source, length, accessCondition, options, operationContext, cancellationToken); } @@ -1633,16 +1637,15 @@ public Task UploadFromStreamAsync(Stream source, long length, AccessCondition ac /// Uploads a file to the File service. If the file already exists on the service, it will be overwritten. /// /// The file providing the content. - /// A constant that determines how to open the file. /// An object that represents the access conditions for the file. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadFromFile(string path, FileMode mode, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromFile(string path, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("path", path); - using (FileStream fileStream = new FileStream(path, mode, FileAccess.Read)) + using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { this.UploadFromStream(fileStream, accessCondition, options, operationContext); } @@ -1653,21 +1656,19 @@ public void UploadFromFile(string path, FileMode mode, AccessCondition accessCon /// Begins an asynchronous operation to upload a file to the File service. If the file already exists on the service, it will be overwritten. /// /// The file providing the content. - /// A constant that determines how to open the file. /// The callback delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromFile(string path, AsyncCallback callback, object state) { - return this.BeginUploadFromFile(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); + return this.BeginUploadFromFile(path, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } /// /// Begins an asynchronous operation to upload a file to the File service. If the file already exists on the service, it will be overwritten. /// /// The file providing the content. - /// A constant that determines how to open the file. /// An object that represents the access conditions for the file. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. @@ -1675,11 +1676,11 @@ public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, A /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromFile(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromFile(string path, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("path", path); - FileStream fileStream = new FileStream(path, mode, FileAccess.Read); + FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state) { OperationState = fileStream @@ -1735,7 +1736,7 @@ private void UploadFromFileCallback(IAsyncResult asyncResult) /// Ends an asynchronous operation to upload a file to the File service. /// /// An that references the pending asynchronous operation. - public void EndUploadFromFile(IAsyncResult asyncResult) + public virtual void EndUploadFromFile(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -1746,56 +1747,52 @@ public void EndUploadFromFile(IAsyncResult asyncResult) /// Returns a task that performs an asynchronous operation to upload a local file to the File service. If the file already exists on the service, it will be overwritten. /// /// The file providing the file content. - /// A constant that determines how to open the file. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode) + public virtual Task UploadFromFileAsync(string path) { - return this.UploadFromFileAsync(path, mode, CancellationToken.None); + return this.UploadFromFileAsync(path, CancellationToken.None); } /// /// Returns a task that performs an asynchronous operation to upload a local file to the File service. If the file already exists on the service, it will be overwritten. /// /// The file providing the file content. - /// A constant that determines how to open the file. /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, CancellationToken cancellationToken) + public virtual Task UploadFromFileAsync(string path, CancellationToken cancellationToken) { - return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, mode, cancellationToken); + return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, cancellationToken); } /// /// Returns a task that performs an asynchronous operation to upload a local file to the File service. If the file already exists on the service, it will be overwritten. /// /// The file providing the file content. - /// A constant that determines how to open the file. /// An object that represents the access conditions for the file. /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { - return this.UploadFromFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); + return this.UploadFromFileAsync(path, accessCondition, options, operationContext, CancellationToken.None); } /// /// Returns a task that performs an asynchronous operation to upload a local file to the File service. If the file already exists on the service, it will be overwritten. /// /// The file providing the file content. - /// A constant that determines how to open the file. /// An object that represents the access conditions for the file. /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { - return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, mode, accessCondition, options, operationContext, cancellationToken); + return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromFile, this.EndUploadFromFile, path, accessCondition, options, operationContext, cancellationToken); } #endif @@ -1810,7 +1807,7 @@ public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition acce /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("buffer", buffer); @@ -1831,7 +1828,7 @@ public void UploadFromByteArray(byte[] buffer, int index, int count, AccessCondi /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AsyncCallback callback, object state) { return this.BeginUploadFromByteArray(buffer, index, count, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1849,7 +1846,7 @@ public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index, int count, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("buffer", buffer); @@ -1861,7 +1858,7 @@ public ICancellableAsyncResult BeginUploadFromByteArray(byte[] buffer, int index /// Ends an asynchronous operation to upload the contents of a byte array to a file. /// /// An that references the pending asynchronous operation. - public void EndUploadFromByteArray(IAsyncResult asyncResult) + public virtual void EndUploadFromByteArray(IAsyncResult asyncResult) { this.EndUploadFromStream(asyncResult); } @@ -1875,7 +1872,7 @@ public void EndUploadFromByteArray(IAsyncResult asyncResult) /// The number of bytes to be written to the file. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) { return this.UploadFromByteArrayAsync(buffer, index, count, CancellationToken.None); } @@ -1889,7 +1886,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromByteArray, this.EndUploadFromByteArray, buffer, index, count, cancellationToken); } @@ -1905,7 +1902,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, Cancel /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.UploadFromByteArrayAsync(buffer, index, count, accessCondition, options, operationContext, CancellationToken.None); } @@ -1922,7 +1919,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, Access /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadFromByteArray, this.EndUploadFromByteArray, buffer, index, count, accessCondition, options, operationContext, cancellationToken); } @@ -1938,7 +1935,7 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, Access /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UploadText(string content, Encoding encoding = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void UploadText(string content, Encoding encoding = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("content", content); @@ -1955,7 +1952,7 @@ public void UploadText(string content, Encoding encoding = null, AccessCondition /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadText(string content, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadText(string content, AsyncCallback callback, object state) { return this.BeginUploadText(content, null /* encoding */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1972,7 +1969,7 @@ public ICancellableAsyncResult BeginUploadText(string content, AsyncCallback cal /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUploadText(string content, Encoding encoding, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUploadText(string content, Encoding encoding, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("content", content); @@ -1984,7 +1981,7 @@ public ICancellableAsyncResult BeginUploadText(string content, Encoding encoding /// Ends an asynchronous operation to upload a string of text to a file. /// /// An that references the pending asynchronous operation. - public void EndUploadText(IAsyncResult asyncResult) + public virtual void EndUploadText(IAsyncResult asyncResult) { this.EndUploadFromByteArray(asyncResult); } @@ -1996,7 +1993,7 @@ public void EndUploadText(IAsyncResult asyncResult) /// The text to upload. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadTextAsync(string content) + public virtual Task UploadTextAsync(string content) { return this.UploadTextAsync(content, CancellationToken.None); } @@ -2008,7 +2005,7 @@ public Task UploadTextAsync(string content) /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadTextAsync(string content, CancellationToken cancellationToken) + public virtual Task UploadTextAsync(string content, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadText, this.EndUploadText, content, cancellationToken); } @@ -2023,7 +2020,7 @@ public Task UploadTextAsync(string content, CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.UploadTextAsync(content, encoding, accessCondition, options, operationContext, CancellationToken.None); } @@ -2039,7 +2036,7 @@ public Task UploadTextAsync(string content, Encoding encoding, AccessCondition a /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUploadText, this.EndUploadText, content, encoding, accessCondition, options, operationContext, cancellationToken); } @@ -2054,7 +2051,7 @@ public Task UploadTextAsync(string content, Encoding encoding, AccessCondition a /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Create(long size, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void Create(long size, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -2072,7 +2069,7 @@ public void Create(long size, AccessCondition accessCondition = null, FileReques /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(long size, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(long size, AsyncCallback callback, object state) { return this.BeginCreate(size, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2088,7 +2085,7 @@ public ICancellableAsyncResult BeginCreate(long size, AsyncCallback callback, ob /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2103,7 +2100,7 @@ public ICancellableAsyncResult BeginCreate(long size, AccessCondition accessCond /// Ends an asynchronous operation to create a file. /// /// An that references the pending asynchronous operation. - public void EndCreate(IAsyncResult asyncResult) + public virtual void EndCreate(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -2115,7 +2112,7 @@ public void EndCreate(IAsyncResult asyncResult) /// The maximum size of the file, in bytes. /// A object that represents the current operation. [DoesServiceRequest] - public Task CreateAsync(long size) + public virtual Task CreateAsync(long size) { return this.CreateAsync(size, CancellationToken.None); } @@ -2127,7 +2124,7 @@ public Task CreateAsync(long size) /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task CreateAsync(long size, CancellationToken cancellationToken) + public virtual Task CreateAsync(long size, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, size, cancellationToken); } @@ -2141,7 +2138,7 @@ public Task CreateAsync(long size, CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task CreateAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task CreateAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.CreateAsync(size, accessCondition, options, operationContext, CancellationToken.None); } @@ -2156,7 +2153,7 @@ public Task CreateAsync(long size, AccessCondition accessCondition, FileRequestO /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task CreateAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, size, accessCondition, options, operationContext, cancellationToken); } @@ -2170,7 +2167,7 @@ public Task CreateAsync(long size, AccessCondition accessCondition, FileRequestO /// An object that represents the context for the current operation. /// true if the file exists; false, otherwise. [DoesServiceRequest] - public bool Exists(FileRequestOptions options = null, OperationContext operationContext = null) + public virtual bool Exists(FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.ExecuteSync( @@ -2187,7 +2184,7 @@ public bool Exists(FileRequestOptions options = null, OperationContext operation /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) { return this.BeginExists(null /* options */, null /* operationContext */, callback, state); } @@ -2201,7 +2198,7 @@ public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2217,7 +2214,7 @@ public ICancellableAsyncResult BeginExists(FileRequestOptions options, Operation /// /// An that references the pending asynchronous operation. /// true if the file exists; false, otherwise. - public bool EndExists(IAsyncResult asyncResult) + public virtual bool EndExists(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -2228,7 +2225,7 @@ public bool EndExists(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task ExistsAsync() + public virtual Task ExistsAsync() { return this.ExistsAsync(CancellationToken.None); } @@ -2239,7 +2236,7 @@ public Task ExistsAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ExistsAsync(CancellationToken cancellationToken) + public virtual Task ExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, cancellationToken); } @@ -2251,7 +2248,7 @@ public Task ExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task ExistsAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task ExistsAsync(FileRequestOptions options, OperationContext operationContext) { return this.ExistsAsync(options, operationContext, CancellationToken.None); } @@ -2264,7 +2261,7 @@ public Task ExistsAsync(FileRequestOptions options, OperationContext opera /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, options, operationContext, cancellationToken); } @@ -2278,7 +2275,7 @@ public Task ExistsAsync(FileRequestOptions options, OperationContext opera /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void FetchAttributes(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void FetchAttributes(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -2295,7 +2292,7 @@ public void FetchAttributes(AccessCondition accessCondition = null, FileRequestO /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, object state) { return this.BeginFetchAttributes(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2310,7 +2307,7 @@ public ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, obje /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2325,7 +2322,7 @@ public ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondit /// Ends an asynchronous operation to populate the file's properties and metadata. /// /// An that references the pending asynchronous operation. - public void EndFetchAttributes(IAsyncResult asyncResult) + public virtual void EndFetchAttributes(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -2336,7 +2333,7 @@ public void EndFetchAttributes(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task FetchAttributesAsync() + public virtual Task FetchAttributesAsync() { return this.FetchAttributesAsync(CancellationToken.None); } @@ -2347,7 +2344,7 @@ public Task FetchAttributesAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task FetchAttributesAsync(CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginFetchAttributes, this.EndFetchAttributes, cancellationToken); } @@ -2360,7 +2357,7 @@ public Task FetchAttributesAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.FetchAttributesAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -2374,7 +2371,7 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOpt /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginFetchAttributes, this.EndFetchAttributes, accessCondition, options, operationContext, cancellationToken); } @@ -2388,7 +2385,7 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOpt /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Delete(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void Delete(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -2405,7 +2402,7 @@ public void Delete(AccessCondition accessCondition = null, FileRequestOptions op /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) { return this.BeginDelete(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2420,7 +2417,7 @@ public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2435,7 +2432,7 @@ public ICancellableAsyncResult BeginDelete(AccessCondition accessCondition, File /// Ends an asynchronous operation to delete the file. /// /// An that references the pending asynchronous operation. - public void EndDelete(IAsyncResult asyncResult) + public virtual void EndDelete(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -2446,7 +2443,7 @@ public void EndDelete(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteAsync() + public virtual Task DeleteAsync() { return this.DeleteAsync(CancellationToken.None); } @@ -2457,7 +2454,7 @@ public Task DeleteAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteAsync(CancellationToken cancellationToken) + public virtual Task DeleteAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, cancellationToken); } @@ -2470,7 +2467,7 @@ public Task DeleteAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DeleteAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -2484,7 +2481,7 @@ public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions opti /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, accessCondition, options, operationContext, cancellationToken); } @@ -2499,7 +2496,7 @@ public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions opti /// An object that represents the context for the current operation. /// true if the file did already exist and was deleted; otherwise false. [DoesServiceRequest] - public bool DeleteIfExists(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual bool DeleteIfExists(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -2544,7 +2541,7 @@ public bool DeleteIfExists(AccessCondition accessCondition = null, FileRequestOp /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) { return this.BeginDeleteIfExists(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2559,7 +2556,7 @@ public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -2661,7 +2658,7 @@ private void DeleteIfExistsHandler(AccessCondition accessCondition, FileRequestO /// /// An that references the pending asynchronous operation. /// true if the file did already exist and was deleted; otherwise, false. - public bool EndDeleteIfExists(IAsyncResult asyncResult) + public virtual bool EndDeleteIfExists(IAsyncResult asyncResult) { StorageAsyncResult res = (StorageAsyncResult)asyncResult; res.End(); @@ -2674,7 +2671,7 @@ public bool EndDeleteIfExists(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync() + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(CancellationToken.None); } @@ -2685,7 +2682,7 @@ public Task DeleteIfExistsAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, cancellationToken); } @@ -2698,7 +2695,7 @@ public Task DeleteIfExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DeleteIfExistsAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -2712,7 +2709,7 @@ public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileReque /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, accessCondition, options, operationContext, cancellationToken); } @@ -2729,7 +2726,7 @@ public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileReque /// An object that represents the context for the current operation. /// An enumerable collection of ranges. [DoesServiceRequest] - public IEnumerable ListRanges(long? offset = null, long? length = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual IEnumerable ListRanges(long? offset = null, long? length = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.ExecuteSync( @@ -2746,7 +2743,7 @@ public IEnumerable ListRanges(long? offset = null, long? length = nul /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListRanges(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListRanges(AsyncCallback callback, object state) { return this.BeginListRanges(null /* offset */, null /* length */, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2763,7 +2760,7 @@ public ICancellableAsyncResult BeginListRanges(AsyncCallback callback, object st /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListRanges(long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListRanges(long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2779,7 +2776,7 @@ public ICancellableAsyncResult BeginListRanges(long? offset, long? length, Acces /// /// An that references the pending asynchronous operation. /// An enumerable collection of ranges. - public IEnumerable EndListRanges(IAsyncResult asyncResult) + public virtual IEnumerable EndListRanges(IAsyncResult asyncResult) { return Executor.EndExecuteAsync>(asyncResult); } @@ -2790,7 +2787,7 @@ public IEnumerable EndListRanges(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task> ListRangesAsync() + public virtual Task> ListRangesAsync() { return this.ListRangesAsync(CancellationToken.None); } @@ -2801,7 +2798,7 @@ public Task> ListRangesAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task> ListRangesAsync(CancellationToken cancellationToken) + public virtual Task> ListRangesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListRanges, this.EndListRanges, cancellationToken); } @@ -2816,7 +2813,7 @@ public Task> ListRangesAsync(CancellationToken cancellati /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task> ListRangesAsync(long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task> ListRangesAsync(long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.ListRangesAsync(offset, length, accessCondition, options, operationContext, CancellationToken.None); } @@ -2832,7 +2829,7 @@ public Task> ListRangesAsync(long? offset, long? length, /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task> ListRangesAsync(long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> ListRangesAsync(long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListRanges, this.EndListRanges, offset, length, accessCondition, options, operationContext, cancellationToken); } @@ -2846,7 +2843,7 @@ public Task> ListRangesAsync(long? offset, long? length, /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetProperties(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void SetProperties(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -2863,7 +2860,7 @@ public void SetProperties(AccessCondition accessCondition = null, FileRequestOpt /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetProperties(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetProperties(AsyncCallback callback, object state) { return this.BeginSetProperties(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2878,7 +2875,7 @@ public ICancellableAsyncResult BeginSetProperties(AsyncCallback callback, object /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetProperties(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetProperties(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -2893,7 +2890,7 @@ public ICancellableAsyncResult BeginSetProperties(AccessCondition accessConditio /// Ends an asynchronous operation to update the file's properties. /// /// An that references the pending asynchronous operation. - public void EndSetProperties(IAsyncResult asyncResult) + public virtual void EndSetProperties(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -2904,7 +2901,7 @@ public void EndSetProperties(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task SetPropertiesAsync() + public virtual Task SetPropertiesAsync() { return this.SetPropertiesAsync(CancellationToken.None); } @@ -2915,7 +2912,7 @@ public Task SetPropertiesAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task SetPropertiesAsync(CancellationToken cancellationToken) + public virtual Task SetPropertiesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetProperties, this.EndSetProperties, cancellationToken); } @@ -2928,7 +2925,7 @@ public Task SetPropertiesAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.SetPropertiesAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -2942,7 +2939,7 @@ public Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptio /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetProperties, this.EndSetProperties, accessCondition, options, operationContext, cancellationToken); } @@ -2957,7 +2954,7 @@ public Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptio /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Resize(long size, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void Resize(long size, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -2975,7 +2972,7 @@ public void Resize(long size, AccessCondition accessCondition = null, FileReques /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginResize(long size, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginResize(long size, AsyncCallback callback, object state) { return this.BeginResize(size, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -2991,7 +2988,7 @@ public ICancellableAsyncResult BeginResize(long size, AsyncCallback callback, ob /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginResize(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginResize(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -3006,7 +3003,7 @@ public ICancellableAsyncResult BeginResize(long size, AccessCondition accessCond /// Ends an asynchronous operation to resize a file. /// /// An that references the pending asynchronous operation. - public void EndResize(IAsyncResult asyncResult) + public virtual void EndResize(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -3018,7 +3015,7 @@ public void EndResize(IAsyncResult asyncResult) /// The maximum size of the file, in bytes. /// A object that represents the current operation. [DoesServiceRequest] - public Task ResizeAsync(long size) + public virtual Task ResizeAsync(long size) { return this.ResizeAsync(size, CancellationToken.None); } @@ -3030,7 +3027,7 @@ public Task ResizeAsync(long size) /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ResizeAsync(long size, CancellationToken cancellationToken) + public virtual Task ResizeAsync(long size, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginResize, this.EndResize, size, cancellationToken); } @@ -3044,7 +3041,7 @@ public Task ResizeAsync(long size, CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task ResizeAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task ResizeAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.ResizeAsync(size, accessCondition, options, operationContext, CancellationToken.None); } @@ -3059,7 +3056,7 @@ public Task ResizeAsync(long size, AccessCondition accessCondition, FileRequestO /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ResizeAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ResizeAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginResize, this.EndResize, size, accessCondition, options, operationContext, cancellationToken); } @@ -3073,7 +3070,7 @@ public Task ResizeAsync(long size, AccessCondition accessCondition, FileRequestO /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetMetadata(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void SetMetadata(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -3090,7 +3087,7 @@ public void SetMetadata(AccessCondition accessCondition = null, FileRequestOptio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object state) { return this.BeginSetMetadata(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -3105,7 +3102,7 @@ public ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object s /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -3120,7 +3117,7 @@ public ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, /// Ends an asynchronous operation to update the file's metadata. /// /// An that references the pending asynchronous operation. - public void EndSetMetadata(IAsyncResult asyncResult) + public virtual void EndSetMetadata(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -3131,7 +3128,7 @@ public void EndSetMetadata(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task SetMetadataAsync() + public virtual Task SetMetadataAsync() { return this.SetMetadataAsync(CancellationToken.None); } @@ -3142,7 +3139,7 @@ public Task SetMetadataAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task SetMetadataAsync(CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetMetadata, this.EndSetMetadata, cancellationToken); } @@ -3155,7 +3152,7 @@ public Task SetMetadataAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.SetMetadataAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -3169,7 +3166,7 @@ public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetMetadata, this.EndSetMetadata, accessCondition, options, operationContext, cancellationToken); } @@ -3187,7 +3184,7 @@ public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void WriteRange(Stream rangeData, long startOffset, string contentMD5 = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void WriteRange(Stream rangeData, long startOffset, string contentMD5 = null, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("rangeData", rangeData); @@ -3253,7 +3250,7 @@ public void WriteRange(Stream rangeData, long startOffset, string contentMD5 = n /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginWriteRange(Stream rangeData, long startOffset, string contentMD5, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginWriteRange(Stream rangeData, long startOffset, string contentMD5, AsyncCallback callback, object state) { return this.BeginWriteRange(rangeData, startOffset, contentMD5, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -3272,7 +3269,7 @@ public ICancellableAsyncResult BeginWriteRange(Stream rangeData, long startOffse /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginWriteRange(Stream rangeData, long startOffset, string contentMD5, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginWriteRange(Stream rangeData, long startOffset, string contentMD5, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("rangeData", rangeData); @@ -3373,7 +3370,7 @@ private void WriteRangeHandler(Stream rangeData, long startOffset, string conten /// Ends an asynchronous operation to write a range to a file. /// /// An that references the pending asynchronous operation. - public void EndWriteRange(IAsyncResult asyncResult) + public virtual void EndWriteRange(IAsyncResult asyncResult) { StorageAsyncResult storageAsyncResult = (StorageAsyncResult)asyncResult; @@ -3401,7 +3398,7 @@ public void EndWriteRange(IAsyncResult asyncResult) /// on the file. May be null or an empty string. /// A object that represents the current operation. [DoesServiceRequest] - public Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5) + public virtual Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5) { return this.WriteRangeAsync(rangeData, startOffset, contentMD5, CancellationToken.None); } @@ -3416,7 +3413,7 @@ public Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5, CancellationToken cancellationToken) + public virtual Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginWriteRange, this.EndWriteRange, rangeData, startOffset, contentMD5, cancellationToken); } @@ -3433,7 +3430,7 @@ public Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.WriteRangeAsync(rangeData, startOffset, contentMD5, accessCondition, options, operationContext, CancellationToken.None); } @@ -3451,7 +3448,7 @@ public Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginWriteRange, this.EndWriteRange, rangeData, startOffset, contentMD5, accessCondition, options, operationContext, cancellationToken); } @@ -3467,7 +3464,7 @@ public Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void ClearRange(long startOffset, long length, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void ClearRange(long startOffset, long length, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -3486,7 +3483,7 @@ public void ClearRange(long startOffset, long length, AccessCondition accessCond /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginClearRange(long startOffset, long length, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginClearRange(long startOffset, long length, AsyncCallback callback, object state) { return this.BeginClearRange(startOffset, length, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -3503,7 +3500,7 @@ public ICancellableAsyncResult BeginClearRange(long startOffset, long length, As /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginClearRange(long startOffset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginClearRange(long startOffset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -3518,7 +3515,7 @@ public ICancellableAsyncResult BeginClearRange(long startOffset, long length, Ac /// Ends an asynchronous operation to clear ranges from a file. /// /// An that references the pending asynchronous operation. - public void EndClearRange(IAsyncResult asyncResult) + public virtual void EndClearRange(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -3531,7 +3528,7 @@ public void EndClearRange(IAsyncResult asyncResult) /// The length of the data range to be cleared, in bytes. /// A object that represents the current operation. [DoesServiceRequest] - public Task ClearRangeAsync(long startOffset, long length) + public virtual Task ClearRangeAsync(long startOffset, long length) { return this.ClearRangeAsync(startOffset, length, CancellationToken.None); } @@ -3544,7 +3541,7 @@ public Task ClearRangeAsync(long startOffset, long length) /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ClearRangeAsync(long startOffset, long length, CancellationToken cancellationToken) + public virtual Task ClearRangeAsync(long startOffset, long length, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginClearRange, this.EndClearRange, startOffset, length, cancellationToken); } @@ -3559,7 +3556,7 @@ public Task ClearRangeAsync(long startOffset, long length, CancellationToken can /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task ClearRangeAsync(long startOffset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task ClearRangeAsync(long startOffset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.ClearRangeAsync(startOffset, length, accessCondition, options, operationContext, CancellationToken.None); } @@ -3575,7 +3572,7 @@ public Task ClearRangeAsync(long startOffset, long length, AccessCondition acces /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ClearRangeAsync(long startOffset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ClearRangeAsync(long startOffset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginClearRange, this.EndClearRange, startOffset, length, accessCondition, options, operationContext, cancellationToken); } @@ -3596,7 +3593,7 @@ public Task ClearRangeAsync(long startOffset, long length, AccessCondition acces /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public string StartCopy(Uri source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual string StartCopy(Uri source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("source", source); @@ -3621,7 +3618,7 @@ public string StartCopy(Uri source, AccessCondition sourceAccessCondition = null /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public string StartCopy(CloudFile source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual string StartCopy(CloudFile source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { return this.StartCopy(CloudFile.SourceFileToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); } @@ -3640,7 +3637,7 @@ public string StartCopy(CloudFile source, AccessCondition sourceAccessCondition /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public string StartCopy(CloudBlob source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual string StartCopy(CloudBlob source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { return this.StartCopy(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); } @@ -3654,7 +3651,7 @@ public string StartCopy(CloudBlob source, AccessCondition sourceAccessCondition /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(Uri source, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(Uri source, AsyncCallback callback, object state) { return this.BeginStartCopy(source, null /* sourceAccessCondition */, null /* destAccessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -3667,7 +3664,7 @@ public ICancellableAsyncResult BeginStartCopy(Uri source, AsyncCallback callback /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(CloudFile source, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(CloudFile source, AsyncCallback callback, object state) { return this.BeginStartCopy(CloudFile.SourceFileToUri(source), callback, state); } @@ -3680,7 +3677,7 @@ public ICancellableAsyncResult BeginStartCopy(CloudFile source, AsyncCallback ca /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(CloudBlob source, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(CloudBlob source, AsyncCallback callback, object state) { return this.BeginStartCopy(CloudBlob.SourceBlobToUri(source), callback, state); } @@ -3697,7 +3694,7 @@ public ICancellableAsyncResult BeginStartCopy(CloudBlob source, AsyncCallback ca /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("source", source); @@ -3722,7 +3719,7 @@ public ICancellableAsyncResult BeginStartCopy(Uri source, AccessCondition source /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginStartCopy(CloudFile.SourceFileToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, callback, state); } @@ -3739,7 +3736,7 @@ public ICancellableAsyncResult BeginStartCopy(CloudFile source, AccessCondition /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginStartCopy(CloudBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginStartCopy(CloudBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginStartCopy(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, callback, state); } @@ -3753,7 +3750,7 @@ public ICancellableAsyncResult BeginStartCopy(CloudBlob source, AccessCondition /// This method fetches the file's ETag, last-modified time, and part of the copy state. /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// - public string EndStartCopy(IAsyncResult asyncResult) + public virtual string EndStartCopy(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -3765,7 +3762,7 @@ public string EndStartCopy(IAsyncResult asyncResult) /// The of the source blob or file. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(Uri source) + public virtual Task StartCopyAsync(Uri source) { return this.StartCopyAsync(source, CancellationToken.None); } @@ -3777,7 +3774,7 @@ public Task StartCopyAsync(Uri source) /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(Uri source, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(Uri source, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, cancellationToken); } @@ -3788,7 +3785,7 @@ public Task StartCopyAsync(Uri source, CancellationToken cancellationTok /// A object. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudFile source) + public virtual Task StartCopyAsync(CloudFile source) { return this.StartCopyAsync(source, CancellationToken.None); } @@ -3799,7 +3796,7 @@ public Task StartCopyAsync(CloudFile source) /// The that is the source blob. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudBlob source) + public virtual Task StartCopyAsync(CloudBlob source) { return this.StartCopyAsync(source, CancellationToken.None); } @@ -3811,7 +3808,7 @@ public Task StartCopyAsync(CloudBlob source) /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudFile source, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudFile source, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, cancellationToken); } @@ -3823,7 +3820,7 @@ public Task StartCopyAsync(CloudFile source, CancellationToken cancellat /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudBlob source, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudBlob source, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, cancellationToken); } @@ -3838,7 +3835,7 @@ public Task StartCopyAsync(CloudBlob source, CancellationToken cancellat /// An object that represents the context for the current operation. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } @@ -3854,7 +3851,7 @@ public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondi /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); } @@ -3869,7 +3866,7 @@ public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondi /// An object that represents the context for the current operation. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } @@ -3884,7 +3881,7 @@ public Task StartCopyAsync(CloudFile source, AccessCondition sourceAcces /// An object that represents the context for the current operation. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(CloudBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } @@ -3900,7 +3897,7 @@ public Task StartCopyAsync(CloudBlob source, AccessCondition sourceAcces /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); } @@ -3916,7 +3913,7 @@ public Task StartCopyAsync(CloudFile source, AccessCondition sourceAcces /// A to observe while waiting for a task to complete. /// A object of type string that represents the asynchronous operation. [DoesServiceRequest] - public Task StartCopyAsync(CloudBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginStartCopy, this.EndStartCopy, source, sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); } @@ -3931,7 +3928,7 @@ public Task StartCopyAsync(CloudBlob source, AccessCondition sourceAcces /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void AbortCopy(string copyId, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void AbortCopy(string copyId, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -3949,7 +3946,7 @@ public void AbortCopy(string copyId, AccessCondition accessCondition = null, Fil /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginAbortCopy(string copyId, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAbortCopy(string copyId, AsyncCallback callback, object state) { return this.BeginAbortCopy(copyId, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -3965,7 +3962,7 @@ public ICancellableAsyncResult BeginAbortCopy(string copyId, AsyncCallback callb /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginAbortCopy(string copyId, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAbortCopy(string copyId, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -3980,7 +3977,7 @@ public ICancellableAsyncResult BeginAbortCopy(string copyId, AccessCondition acc /// Ends an asynchronous operation to abort an ongoing copy operation. /// /// An that references the pending asynchronous operation. - public void EndAbortCopy(IAsyncResult asyncResult) + public virtual void EndAbortCopy(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -3992,7 +3989,7 @@ public void EndAbortCopy(IAsyncResult asyncResult) /// A string identifying the copy operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AbortCopyAsync(string copyId) + public virtual Task AbortCopyAsync(string copyId) { return this.AbortCopyAsync(copyId, CancellationToken.None); } @@ -4004,7 +4001,7 @@ public Task AbortCopyAsync(string copyId) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AbortCopyAsync(string copyId, CancellationToken cancellationToken) + public virtual Task AbortCopyAsync(string copyId, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAbortCopy, this.EndAbortCopy, copyId, cancellationToken); } @@ -4018,7 +4015,7 @@ public Task AbortCopyAsync(string copyId, CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AbortCopyAsync(string copyId, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task AbortCopyAsync(string copyId, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.AbortCopyAsync(copyId, accessCondition, options, operationContext, CancellationToken.None); } @@ -4033,7 +4030,7 @@ public Task AbortCopyAsync(string copyId, AccessCondition accessCondition, FileR /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AbortCopyAsync(string copyId, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AbortCopyAsync(string copyId, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAbortCopy, this.EndAbortCopy, copyId, accessCondition, options, operationContext, cancellationToken); } diff --git a/Lib/ClassLibraryCommon/File/CloudFileClient.cs b/Lib/ClassLibraryCommon/File/CloudFileClient.cs index 9539708ac..a8657410d 100644 --- a/Lib/ClassLibraryCommon/File/CloudFileClient.cs +++ b/Lib/ClassLibraryCommon/File/CloudFileClient.cs @@ -36,7 +36,7 @@ namespace Microsoft.WindowsAzure.Storage.File /// /// The service client encapsulates the base URI for the File service. If the service client will be used for authenticated access, /// it also encapsulates the credentials for accessing the storage account. - public sealed partial class CloudFileClient + public partial class CloudFileClient { private IAuthenticationHandler authenticationHandler; @@ -101,7 +101,7 @@ internal IAuthenticationHandler AuthenticationHandler /// An object that represents the context for the current operation. /// An enumerable collection of shares that are retrieved lazily. [DoesServiceRequest] - public IEnumerable ListShares(string prefix = null, ShareListingDetails detailsIncluded = ShareListingDetails.None, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual IEnumerable ListShares(string prefix = null, ShareListingDetails detailsIncluded = ShareListingDetails.None, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this); return CommonUtility.LazyEnumerable( @@ -115,7 +115,7 @@ public IEnumerable ListShares(string prefix = null, ShareListing /// A token returned by a previous listing operation. /// A result segment of shares. [DoesServiceRequest] - public ShareResultSegment ListSharesSegmented(FileContinuationToken currentToken) + public virtual ShareResultSegment ListSharesSegmented(FileContinuationToken currentToken) { return this.ListSharesSegmented(null, ShareListingDetails.None, null, currentToken, null, null); } @@ -127,7 +127,7 @@ public ShareResultSegment ListSharesSegmented(FileContinuationToken currentToken /// A continuation token returned by a previous listing operation. /// A result segment of shares. [DoesServiceRequest] - public ShareResultSegment ListSharesSegmented(string prefix, FileContinuationToken currentToken) + public virtual ShareResultSegment ListSharesSegmented(string prefix, FileContinuationToken currentToken) { return this.ListSharesSegmented(prefix, ShareListingDetails.None, null, currentToken, null, null); } @@ -145,7 +145,7 @@ public ShareResultSegment ListSharesSegmented(string prefix, FileContinuationTok /// An object that represents the context for the current operation. /// A result segment of shares. [DoesServiceRequest] - public ShareResultSegment ListSharesSegmented(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual ShareResultSegment ListSharesSegmented(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this); ResultSegment resultSegment = this.ListSharesSegmentedCore(prefix, detailsIncluded, maxResults, currentToken, modifiedOptions, operationContext); @@ -181,7 +181,7 @@ private ResultSegment ListSharesSegmentedCore(string prefix, Sha /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListSharesSegmented(FileContinuationToken currentToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListSharesSegmented(FileContinuationToken currentToken, AsyncCallback callback, object state) { return this.BeginListSharesSegmented(null, ShareListingDetails.None, null, currentToken, null, null, callback, state); } @@ -195,7 +195,7 @@ public ICancellableAsyncResult BeginListSharesSegmented(FileContinuationToken cu /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListSharesSegmented(string prefix, FileContinuationToken currentToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListSharesSegmented(string prefix, FileContinuationToken currentToken, AsyncCallback callback, object state) { return this.BeginListSharesSegmented(prefix, ShareListingDetails.None, null, currentToken, null, null, callback, state); } @@ -215,7 +215,7 @@ public ICancellableAsyncResult BeginListSharesSegmented(string prefix, FileConti /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListSharesSegmented(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListSharesSegmented(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this); return Executor.BeginExecuteAsync( @@ -231,7 +231,7 @@ public ICancellableAsyncResult BeginListSharesSegmented(string prefix, ShareList /// /// An that references the pending asynchronous operation. /// A result segment of shares. - public ShareResultSegment EndListSharesSegmented(IAsyncResult asyncResult) + public virtual ShareResultSegment EndListSharesSegmented(IAsyncResult asyncResult) { ResultSegment resultSegment = Executor.EndExecuteAsync>(asyncResult); return new ShareResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken); @@ -244,7 +244,7 @@ public ShareResultSegment EndListSharesSegmented(IAsyncResult asyncResult) /// A token returned by a previous listing operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task ListSharesSegmentedAsync(FileContinuationToken currentToken) + public virtual Task ListSharesSegmentedAsync(FileContinuationToken currentToken) { return this.ListSharesSegmentedAsync(currentToken, CancellationToken.None); } @@ -256,7 +256,7 @@ public Task ListSharesSegmentedAsync(FileContinuationToken c /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ListSharesSegmentedAsync(FileContinuationToken currentToken, CancellationToken cancellationToken) + public virtual Task ListSharesSegmentedAsync(FileContinuationToken currentToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListSharesSegmented, this.EndListSharesSegmented, currentToken, cancellationToken); } @@ -269,7 +269,7 @@ public Task ListSharesSegmentedAsync(FileContinuationToken c /// A continuation token returned by a previous listing operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task ListSharesSegmentedAsync(string prefix, FileContinuationToken currentToken) + public virtual Task ListSharesSegmentedAsync(string prefix, FileContinuationToken currentToken) { return this.ListSharesSegmentedAsync(prefix, currentToken, CancellationToken.None); } @@ -283,7 +283,7 @@ public Task ListSharesSegmentedAsync(string prefix, FileCont /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ListSharesSegmentedAsync(string prefix, FileContinuationToken currentToken, CancellationToken cancellationToken) + public virtual Task ListSharesSegmentedAsync(string prefix, FileContinuationToken currentToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListSharesSegmented, this.EndListSharesSegmented, prefix, currentToken, cancellationToken); } @@ -301,7 +301,7 @@ public Task ListSharesSegmentedAsync(string prefix, FileCont /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext) + public virtual Task ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext) { return this.ListSharesSegmentedAsync(prefix, detailsIncluded, maxResults, currentToken, options, operationContext, CancellationToken.None); } @@ -320,7 +320,7 @@ public Task ListSharesSegmentedAsync(string prefix, ShareLis /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListSharesSegmented, this.EndListSharesSegmented, prefix, detailsIncluded, maxResults, currentToken, options, operationContext, cancellationToken); } @@ -333,7 +333,7 @@ public Task ListSharesSegmentedAsync(string prefix, ShareLis /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceProperties(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceProperties(AsyncCallback callback, object state) { return this.BeginGetServiceProperties(null /* requestOptions */, null /* operationContext */, callback, state); } @@ -347,7 +347,7 @@ public ICancellableAsyncResult BeginGetServiceProperties(AsyncCallback callback, /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceProperties(FileRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceProperties(FileRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = FileRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -364,7 +364,7 @@ public ICancellableAsyncResult BeginGetServiceProperties(FileRequestOptions requ /// /// An that references the pending asynchronous operation. /// A object. - public FileServiceProperties EndGetServiceProperties(IAsyncResult asyncResult) + public virtual FileServiceProperties EndGetServiceProperties(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -375,7 +375,7 @@ public FileServiceProperties EndGetServiceProperties(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync() + public virtual Task GetServicePropertiesAsync() { return this.GetServicePropertiesAsync(CancellationToken.None); } @@ -386,7 +386,7 @@ public Task GetServicePropertiesAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync(CancellationToken cancellationToken) + public virtual Task GetServicePropertiesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceProperties, this.EndGetServiceProperties, cancellationToken); } @@ -398,7 +398,7 @@ public Task GetServicePropertiesAsync(CancellationToken c /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync(FileRequestOptions requestOptions, OperationContext operationContext) + public virtual Task GetServicePropertiesAsync(FileRequestOptions requestOptions, OperationContext operationContext) { return this.GetServicePropertiesAsync(requestOptions, operationContext, CancellationToken.None); } @@ -411,7 +411,7 @@ public Task GetServicePropertiesAsync(FileRequestOptions /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync(FileRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServicePropertiesAsync(FileRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceProperties, this.EndGetServiceProperties, requestOptions, operationContext, cancellationToken); } @@ -425,7 +425,7 @@ public Task GetServicePropertiesAsync(FileRequestOptions /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public FileServiceProperties GetServiceProperties(FileRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual FileServiceProperties GetServiceProperties(FileRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = FileRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -444,7 +444,7 @@ public FileServiceProperties GetServiceProperties(FileRequestOptions requestOpti /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetServiceProperties(FileServiceProperties properties, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetServiceProperties(FileServiceProperties properties, AsyncCallback callback, object state) { return this.BeginSetServiceProperties(properties, null /* requestOptions */, null /* operationContext */, callback, state); } @@ -459,7 +459,7 @@ public ICancellableAsyncResult BeginSetServiceProperties(FileServiceProperties p /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetServiceProperties(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetServiceProperties(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = FileRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -475,7 +475,7 @@ public ICancellableAsyncResult BeginSetServiceProperties(FileServiceProperties p /// Ends an asynchronous operation to set service properties for the Blob service. /// /// An that references the pending asynchronous operation. - public void EndSetServiceProperties(IAsyncResult asyncResult) + public virtual void EndSetServiceProperties(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -487,7 +487,7 @@ public void EndSetServiceProperties(IAsyncResult asyncResult) /// A object. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(FileServiceProperties properties) + public virtual Task SetServicePropertiesAsync(FileServiceProperties properties) { return this.SetServicePropertiesAsync(properties, CancellationToken.None); } @@ -499,7 +499,7 @@ public Task SetServicePropertiesAsync(FileServiceProperties properties) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(FileServiceProperties properties, CancellationToken cancellationToken) + public virtual Task SetServicePropertiesAsync(FileServiceProperties properties, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetServiceProperties, this.EndSetServiceProperties, properties, cancellationToken); } @@ -512,7 +512,7 @@ public Task SetServicePropertiesAsync(FileServiceProperties properties, Cancella /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext) + public virtual Task SetServicePropertiesAsync(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext) { return this.SetServicePropertiesAsync(properties, requestOptions, operationContext, CancellationToken.None); } @@ -526,7 +526,7 @@ public Task SetServicePropertiesAsync(FileServiceProperties properties, FileRequ /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetServicePropertiesAsync(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetServiceProperties, this.EndSetServiceProperties, properties, requestOptions, operationContext, cancellationToken); } @@ -540,7 +540,7 @@ public Task SetServicePropertiesAsync(FileServiceProperties properties, FileRequ /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetServiceProperties(FileServiceProperties properties, FileRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual void SetServiceProperties(FileServiceProperties properties, FileRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = FileRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); diff --git a/Lib/ClassLibraryCommon/File/CloudFileDirectory.cs b/Lib/ClassLibraryCommon/File/CloudFileDirectory.cs index 972bd3517..c0e28ae95 100644 --- a/Lib/ClassLibraryCommon/File/CloudFileDirectory.cs +++ b/Lib/ClassLibraryCommon/File/CloudFileDirectory.cs @@ -33,7 +33,7 @@ namespace Microsoft.WindowsAzure.Storage.File /// Represents a directory of files, designated by a delimiter character. /// /// Shares, which are encapsulated as objects, hold directories, and directories hold files. Directories can also contain sub-directories. - public sealed partial class CloudFileDirectory + public partial class CloudFileDirectory { #if SYNC /// @@ -43,7 +43,7 @@ public sealed partial class CloudFileDirectory /// An object that represents the context for the current operation. This object /// is used to track requests to the storage service, and to provide additional runtime information about the operation. [DoesServiceRequest] - public void Create(FileRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual void Create(FileRequestOptions requestOptions = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); Executor.ExecuteSync( @@ -60,7 +60,7 @@ public void Create(FileRequestOptions requestOptions = null, OperationContext op /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) { return this.BeginCreate(null /* options */, null /* operationContext */, callback, state); } @@ -74,7 +74,7 @@ public ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -89,7 +89,7 @@ public ICancellableAsyncResult BeginCreate(FileRequestOptions options, Operation /// Ends an asynchronous operation to create a directory. /// /// An that references the pending asynchronous operation. - public void EndCreate(IAsyncResult asyncResult) + public virtual void EndCreate(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -100,7 +100,7 @@ public void EndCreate(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task CreateAsync() + public virtual Task CreateAsync() { return this.CreateAsync(CancellationToken.None); } @@ -111,7 +111,7 @@ public Task CreateAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task CreateAsync(CancellationToken cancellationToken) + public virtual Task CreateAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, cancellationToken); } @@ -123,7 +123,7 @@ public Task CreateAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task CreateAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task CreateAsync(FileRequestOptions options, OperationContext operationContext) { return this.CreateAsync(options, operationContext, CancellationToken.None); } @@ -136,7 +136,7 @@ public Task CreateAsync(FileRequestOptions options, OperationContext operationCo /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task CreateAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, options, operationContext, cancellationToken); } @@ -149,8 +149,9 @@ public Task CreateAsync(FileRequestOptions options, OperationContext operationCo /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. /// true if the directory did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public bool CreateIfNotExists(FileRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual bool CreateIfNotExists(FileRequestOptions requestOptions = null, OperationContext operationContext = null) { bool exists = this.Exists(requestOptions, operationContext); if (exists) @@ -184,8 +185,9 @@ public bool CreateIfNotExists(FileRequestOptions requestOptions = null, Operatio /// The callback delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, object state) { return this.BeginCreateIfNotExists(null /* options */, null /* operationContext */, callback, state); } @@ -198,8 +200,9 @@ public ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, ob /// The callback delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateIfNotExists(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateIfNotExists(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state) @@ -290,7 +293,7 @@ private void CreateIfNotExistsHandler(FileRequestOptions options, OperationConte /// /// An that references the pending asynchronous operation. /// true if the directory did not already exist and was created; otherwise, false. - public bool EndCreateIfNotExists(IAsyncResult asyncResult) + public virtual bool EndCreateIfNotExists(IAsyncResult asyncResult) { StorageAsyncResult res = asyncResult as StorageAsyncResult; CommonUtility.AssertNotNull("AsyncResult", res); @@ -303,8 +306,9 @@ public bool EndCreateIfNotExists(IAsyncResult asyncResult) /// Returns a task that performs an asynchronous request to create the directory if it does not already exist. /// /// A object that represents the current operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync() + public virtual Task CreateIfNotExistsAsync() { return this.CreateIfNotExistsAsync(CancellationToken.None); } @@ -314,8 +318,9 @@ public Task CreateIfNotExistsAsync() /// /// A to observe while waiting for a task to complete. /// A object that represents the current operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(CancellationToken cancellationToken) + public virtual Task CreateIfNotExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateIfNotExists, this.EndCreateIfNotExists, cancellationToken); } @@ -326,8 +331,9 @@ public Task CreateIfNotExistsAsync(CancellationToken cancellationToken) /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A object that represents the current operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext) { return this.CreateIfNotExistsAsync(options, operationContext, CancellationToken.None); } @@ -339,8 +345,9 @@ public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationCo /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A object that represents the current operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateIfNotExists, this.EndCreateIfNotExists, options, operationContext, cancellationToken); } @@ -354,7 +361,7 @@ public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationCo /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Delete(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void Delete(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -371,7 +378,7 @@ public void Delete(AccessCondition accessCondition = null, FileRequestOptions op /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) { return this.BeginDelete(null /* accessCondition */, null /* options */, null /*operationContext */, callback, state); } @@ -386,7 +393,7 @@ public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -401,7 +408,7 @@ public ICancellableAsyncResult BeginDelete(AccessCondition accessCondition, File /// Ends an asynchronous operation to delete a directory. /// /// An that references the pending asynchronous operation. - public void EndDelete(IAsyncResult asyncResult) + public virtual void EndDelete(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -412,7 +419,7 @@ public void EndDelete(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteAsync() + public virtual Task DeleteAsync() { return this.DeleteAsync(CancellationToken.None); } @@ -423,7 +430,7 @@ public Task DeleteAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteAsync(CancellationToken cancellationToken) + public virtual Task DeleteAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, cancellationToken); } @@ -436,7 +443,7 @@ public Task DeleteAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DeleteAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -450,7 +457,7 @@ public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions opti /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, accessCondition, options, operationContext, cancellationToken); } @@ -465,7 +472,7 @@ public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions opti /// An object that represents the context for the current operation. /// true if the directory did already exist and was deleted; otherwise false. [DoesServiceRequest] - public bool DeleteIfExists(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual bool DeleteIfExists(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { bool exists = this.Exists(options, operationContext); if (!exists) @@ -499,7 +506,7 @@ public bool DeleteIfExists(AccessCondition accessCondition = null, FileRequestOp /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) { return this.BeginDeleteIfExists(null, null, null, callback, state); } @@ -514,7 +521,7 @@ public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); StorageAsyncResult storageAsyncResult = new StorageAsyncResult(callback, state) @@ -605,7 +612,7 @@ private void DeleteIfExistsHandler(AccessCondition accessCondition, FileRequestO /// /// An that references the pending asynchronous operation. /// true if the directory did already exist and was deleted; otherwise, false. - public bool EndDeleteIfExists(IAsyncResult asyncResult) + public virtual bool EndDeleteIfExists(IAsyncResult asyncResult) { StorageAsyncResult res = asyncResult as StorageAsyncResult; CommonUtility.AssertNotNull("AsyncResult", res); @@ -619,7 +626,7 @@ public bool EndDeleteIfExists(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync() + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(CancellationToken.None); } @@ -630,7 +637,7 @@ public Task DeleteIfExistsAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, cancellationToken); } @@ -643,7 +650,7 @@ public Task DeleteIfExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DeleteIfExistsAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -657,7 +664,7 @@ public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileReque /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, accessCondition, options, operationContext, cancellationToken); } @@ -671,7 +678,7 @@ public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileReque /// An object that represents the context for the current operation. /// true if the directory exists;false, otherwise. [DoesServiceRequest] - public bool Exists(FileRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual bool Exists(FileRequestOptions requestOptions = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); return Executor.ExecuteSync( @@ -688,7 +695,7 @@ public bool Exists(FileRequestOptions requestOptions = null, OperationContext op /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) { return this.BeginExists(null, null, callback, state); } @@ -702,7 +709,7 @@ public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -718,7 +725,7 @@ public ICancellableAsyncResult BeginExists(FileRequestOptions options, Operation /// /// An that references the pending asynchronous operation. /// true if the directory exists; false, otherwise. - public bool EndExists(IAsyncResult asyncResult) + public virtual bool EndExists(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -729,7 +736,7 @@ public bool EndExists(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task ExistsAsync() + public virtual Task ExistsAsync() { return this.ExistsAsync(CancellationToken.None); } @@ -740,7 +747,7 @@ public Task ExistsAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ExistsAsync(CancellationToken cancellationToken) + public virtual Task ExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, cancellationToken); } @@ -752,7 +759,7 @@ public Task ExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task ExistsAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task ExistsAsync(FileRequestOptions options, OperationContext operationContext) { return this.ExistsAsync(options, operationContext, CancellationToken.None); } @@ -765,7 +772,7 @@ public Task ExistsAsync(FileRequestOptions options, OperationContext opera /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, options, operationContext, cancellationToken); } @@ -779,7 +786,7 @@ public Task ExistsAsync(FileRequestOptions options, OperationContext opera /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void FetchAttributes(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void FetchAttributes(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -796,7 +803,7 @@ public void FetchAttributes(AccessCondition accessCondition = null, FileRequestO /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, object state) { return this.BeginFetchAttributes(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -811,7 +818,7 @@ public ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, obje /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -826,7 +833,7 @@ public ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondit /// Ends an asynchronous operation to populate the directory's properties and metadata. /// /// An that references the pending asynchronous operation. - public void EndFetchAttributes(IAsyncResult asyncResult) + public virtual void EndFetchAttributes(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -837,7 +844,7 @@ public void EndFetchAttributes(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task FetchAttributesAsync() + public virtual Task FetchAttributesAsync() { return this.FetchAttributesAsync(CancellationToken.None); } @@ -848,7 +855,7 @@ public Task FetchAttributesAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task FetchAttributesAsync(CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginFetchAttributes, this.EndFetchAttributes, cancellationToken); } @@ -861,7 +868,7 @@ public Task FetchAttributesAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.FetchAttributesAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -875,7 +882,7 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOpt /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginFetchAttributes, this.EndFetchAttributes, accessCondition, options, operationContext, cancellationToken); } @@ -889,7 +896,7 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOpt /// An object that represents the context for the current operation. /// An enumerable collection of objects that implement and are retrieved lazily. [DoesServiceRequest] - public IEnumerable ListFilesAndDirectories(FileRequestOptions options = null, OperationContext operationContext = null) + public virtual IEnumerable ListFilesAndDirectories(FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return CommonUtility.LazyEnumerable( @@ -904,7 +911,7 @@ public IEnumerable ListFilesAndDirectories(FileRequestOptions opt /// A continuation token returned by a previous listing operation. /// A result segment containing objects that implement . [DoesServiceRequest] - public FileResultSegment ListFilesAndDirectoriesSegmented(FileContinuationToken currentToken) + public virtual FileResultSegment ListFilesAndDirectoriesSegmented(FileContinuationToken currentToken) { return this.ListFilesAndDirectoriesSegmented(null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } @@ -920,7 +927,7 @@ public FileResultSegment ListFilesAndDirectoriesSegmented(FileContinuationToken /// An object that represents the context for the current operation. /// A result segment containing objects that implement . [DoesServiceRequest] - public FileResultSegment ListFilesAndDirectoriesSegmented(int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext) + public virtual FileResultSegment ListFilesAndDirectoriesSegmented(int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); ResultSegment resultSegment = this.ListFilesAndDirectoriesSegmentedCore(maxResults, currentToken, modifiedOptions, operationContext); @@ -955,7 +962,7 @@ private ResultSegment ListFilesAndDirectoriesSegmentedCore(int? m /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListFilesAndDirectoriesSegmented(FileContinuationToken currentToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListFilesAndDirectoriesSegmented(FileContinuationToken currentToken, AsyncCallback callback, object state) { return this.BeginListFilesAndDirectoriesSegmented(null /* maxResults */, currentToken, null /* options */, null /* operationContext */, callback, state); } @@ -973,7 +980,7 @@ public ICancellableAsyncResult BeginListFilesAndDirectoriesSegmented(FileContinu /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListFilesAndDirectoriesSegmented(int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListFilesAndDirectoriesSegmented(int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -990,7 +997,7 @@ public ICancellableAsyncResult BeginListFilesAndDirectoriesSegmented(int? maxRes /// /// An that references the pending asynchronous operation. /// A result segment containing objects that implement . - public FileResultSegment EndListFilesAndDirectoriesSegmented(IAsyncResult asyncResult) + public virtual FileResultSegment EndListFilesAndDirectoriesSegmented(IAsyncResult asyncResult) { ResultSegment resultSegment = Executor.EndExecuteAsync>(asyncResult); return new FileResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken); @@ -1004,7 +1011,7 @@ public FileResultSegment EndListFilesAndDirectoriesSegmented(IAsyncResult asyncR /// A continuation token returned by a previous listing operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task ListFilesAndDirectoriesSegmentedAsync(FileContinuationToken currentToken) + public virtual Task ListFilesAndDirectoriesSegmentedAsync(FileContinuationToken currentToken) { return this.ListFilesAndDirectoriesSegmentedAsync(currentToken, CancellationToken.None); } @@ -1017,7 +1024,7 @@ public Task ListFilesAndDirectoriesSegmentedAsync(FileContinu /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ListFilesAndDirectoriesSegmentedAsync(FileContinuationToken currentToken, CancellationToken cancellationToken) + public virtual Task ListFilesAndDirectoriesSegmentedAsync(FileContinuationToken currentToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListFilesAndDirectoriesSegmented, this.EndListFilesAndDirectoriesSegmented, currentToken, cancellationToken); } @@ -1033,7 +1040,7 @@ public Task ListFilesAndDirectoriesSegmentedAsync(FileContinu /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task ListFilesAndDirectoriesSegmentedAsync(int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext) + public virtual Task ListFilesAndDirectoriesSegmentedAsync(int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext) { return this.ListFilesAndDirectoriesSegmentedAsync(maxResults, currentToken, options, operationContext, CancellationToken.None); } @@ -1050,7 +1057,7 @@ public Task ListFilesAndDirectoriesSegmentedAsync(int? maxRes /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ListFilesAndDirectoriesSegmentedAsync(int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ListFilesAndDirectoriesSegmentedAsync(int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListFilesAndDirectoriesSegmented, this.EndListFilesAndDirectoriesSegmented, maxResults, currentToken, options, operationContext, cancellationToken); } @@ -1064,7 +1071,7 @@ public Task ListFilesAndDirectoriesSegmentedAsync(int? maxRes /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetMetadata(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void SetMetadata(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -1081,7 +1088,7 @@ public void SetMetadata(AccessCondition accessCondition = null, FileRequestOptio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object state) { return this.BeginSetMetadata(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1096,7 +1103,7 @@ public ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object s /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1111,7 +1118,7 @@ public ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, /// Ends an asynchronous operation to update the directory's metadata. /// /// An that references the pending asynchronous operation. - public void EndSetMetadata(IAsyncResult asyncResult) + public virtual void EndSetMetadata(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1122,7 +1129,7 @@ public void EndSetMetadata(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task SetMetadataAsync() + public virtual Task SetMetadataAsync() { return this.SetMetadataAsync(CancellationToken.None); } @@ -1133,7 +1140,7 @@ public Task SetMetadataAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task SetMetadataAsync(CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetMetadata, this.EndSetMetadata, cancellationToken); } @@ -1146,7 +1153,7 @@ public Task SetMetadataAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.SetMetadataAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -1160,7 +1167,7 @@ public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetMetadata, this.EndSetMetadata, accessCondition, options, operationContext, cancellationToken); } diff --git a/Lib/ClassLibraryCommon/File/CloudFileShare.cs b/Lib/ClassLibraryCommon/File/CloudFileShare.cs index 903c494fa..5f707e870 100644 --- a/Lib/ClassLibraryCommon/File/CloudFileShare.cs +++ b/Lib/ClassLibraryCommon/File/CloudFileShare.cs @@ -33,7 +33,7 @@ namespace Microsoft.WindowsAzure.Storage.File /// Represents a share in the Windows Azure File service. /// /// Shares hold directories, which are encapsulated as objects, and directories hold files. Directories can also contain sub-directories. - public sealed partial class CloudFileShare + public partial class CloudFileShare { #if SYNC /// @@ -43,7 +43,7 @@ public sealed partial class CloudFileShare /// An object that represents the context for the current operation. This object /// is used to track requests to the storage service, and to provide additional runtime information about the operation. [DoesServiceRequest] - public void Create(FileRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual void Create(FileRequestOptions requestOptions = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); Executor.ExecuteSync( @@ -60,7 +60,7 @@ public void Create(FileRequestOptions requestOptions = null, OperationContext op /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) { return this.BeginCreate(null /* options */, null /* operationContext */, callback, state); } @@ -74,7 +74,7 @@ public ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -89,7 +89,7 @@ public ICancellableAsyncResult BeginCreate(FileRequestOptions options, Operation /// Ends an asynchronous operation to create a share. /// /// An that references the pending asynchronous operation. - public void EndCreate(IAsyncResult asyncResult) + public virtual void EndCreate(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -100,7 +100,7 @@ public void EndCreate(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task CreateAsync() + public virtual Task CreateAsync() { return this.CreateAsync(CancellationToken.None); } @@ -111,7 +111,7 @@ public Task CreateAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task CreateAsync(CancellationToken cancellationToken) + public virtual Task CreateAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, cancellationToken); } @@ -123,7 +123,7 @@ public Task CreateAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task CreateAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task CreateAsync(FileRequestOptions options, OperationContext operationContext) { return this.CreateAsync(options, operationContext, CancellationToken.None); } @@ -136,7 +136,7 @@ public Task CreateAsync(FileRequestOptions options, OperationContext operationCo /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task CreateAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, options, operationContext, cancellationToken); } @@ -149,8 +149,9 @@ public Task CreateAsync(FileRequestOptions options, OperationContext operationCo /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. /// true if the share did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public bool CreateIfNotExists(FileRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual bool CreateIfNotExists(FileRequestOptions requestOptions = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -194,8 +195,9 @@ public bool CreateIfNotExists(FileRequestOptions requestOptions = null, Operatio /// The callback delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, object state) { return this.BeginCreateIfNotExists(null /* options */, null /* operationContext */, callback, state); } @@ -208,8 +210,9 @@ public ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, ob /// The callback delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateIfNotExists(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateIfNotExists(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -309,7 +312,7 @@ private void CreateIfNotExistsHandler(FileRequestOptions options, OperationConte /// /// An that references the pending asynchronous operation. /// true if the share did not already exist and was created; otherwise, false. - public bool EndCreateIfNotExists(IAsyncResult asyncResult) + public virtual bool EndCreateIfNotExists(IAsyncResult asyncResult) { StorageAsyncResult res = asyncResult as StorageAsyncResult; CommonUtility.AssertNotNull("AsyncResult", res); @@ -322,8 +325,9 @@ public bool EndCreateIfNotExists(IAsyncResult asyncResult) /// Returns a task that performs an asynchronous request to create the share if it does not already exist. /// /// A object that represents the current operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync() + public virtual Task CreateIfNotExistsAsync() { return this.CreateIfNotExistsAsync(CancellationToken.None); } @@ -333,8 +337,9 @@ public Task CreateIfNotExistsAsync() /// /// A to observe while waiting for a task to complete. /// A object that represents the current operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(CancellationToken cancellationToken) + public virtual Task CreateIfNotExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateIfNotExists, this.EndCreateIfNotExists, cancellationToken); } @@ -345,8 +350,9 @@ public Task CreateIfNotExistsAsync(CancellationToken cancellationToken) /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A object that represents the current operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext) { return this.CreateIfNotExistsAsync(options, operationContext, CancellationToken.None); } @@ -358,8 +364,9 @@ public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationCo /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A object that represents the current operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateIfNotExists, this.EndCreateIfNotExists, options, operationContext, cancellationToken); } @@ -373,7 +380,7 @@ public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationCo /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Delete(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void Delete(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -390,7 +397,7 @@ public void Delete(AccessCondition accessCondition = null, FileRequestOptions op /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) { return this.BeginDelete(null /* accessCondition */, null /* options */, null /*operationContext */, callback, state); } @@ -405,7 +412,7 @@ public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -420,7 +427,7 @@ public ICancellableAsyncResult BeginDelete(AccessCondition accessCondition, File /// Ends an asynchronous operation to delete a share. /// /// An that references the pending asynchronous operation. - public void EndDelete(IAsyncResult asyncResult) + public virtual void EndDelete(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -431,7 +438,7 @@ public void EndDelete(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteAsync() + public virtual Task DeleteAsync() { return this.DeleteAsync(CancellationToken.None); } @@ -442,7 +449,7 @@ public Task DeleteAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteAsync(CancellationToken cancellationToken) + public virtual Task DeleteAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, cancellationToken); } @@ -455,7 +462,7 @@ public Task DeleteAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DeleteAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -469,7 +476,7 @@ public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions opti /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, accessCondition, options, operationContext, cancellationToken); } @@ -484,7 +491,7 @@ public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions opti /// An object that represents the context for the current operation. /// true if the share did not already exist and was created; otherwise false. [DoesServiceRequest] - public bool DeleteIfExists(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual bool DeleteIfExists(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -529,7 +536,7 @@ public bool DeleteIfExists(AccessCondition accessCondition = null, FileRequestOp /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) { return this.BeginDeleteIfExists(null, null, null, callback, state); } @@ -544,7 +551,7 @@ public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -646,7 +653,7 @@ private void DeleteIfExistsHandler(AccessCondition accessCondition, FileRequestO /// /// An that references the pending asynchronous operation. /// true if the share did not already exist and was created; otherwise, false. - public bool EndDeleteIfExists(IAsyncResult asyncResult) + public virtual bool EndDeleteIfExists(IAsyncResult asyncResult) { StorageAsyncResult res = asyncResult as StorageAsyncResult; CommonUtility.AssertNotNull("AsyncResult", res); @@ -660,7 +667,7 @@ public bool EndDeleteIfExists(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync() + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(CancellationToken.None); } @@ -671,7 +678,7 @@ public Task DeleteIfExistsAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, cancellationToken); } @@ -684,7 +691,7 @@ public Task DeleteIfExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DeleteIfExistsAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -698,7 +705,7 @@ public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileReque /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, accessCondition, options, operationContext, cancellationToken); } @@ -712,7 +719,7 @@ public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileReque /// An object that represents the context for the current operation. /// true if the share exists. [DoesServiceRequest] - public bool Exists(FileRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual bool Exists(FileRequestOptions requestOptions = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); return Executor.ExecuteSync( @@ -729,7 +736,7 @@ public bool Exists(FileRequestOptions requestOptions = null, OperationContext op /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) { return this.BeginExists(null, null, callback, state); } @@ -743,7 +750,7 @@ public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -759,7 +766,7 @@ public ICancellableAsyncResult BeginExists(FileRequestOptions options, Operation /// /// An that references the pending asynchronous operation. /// true if the share exists. - public bool EndExists(IAsyncResult asyncResult) + public virtual bool EndExists(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -770,7 +777,7 @@ public bool EndExists(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task ExistsAsync() + public virtual Task ExistsAsync() { return this.ExistsAsync(CancellationToken.None); } @@ -781,7 +788,7 @@ public Task ExistsAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ExistsAsync(CancellationToken cancellationToken) + public virtual Task ExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, cancellationToken); } @@ -793,7 +800,7 @@ public Task ExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task ExistsAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task ExistsAsync(FileRequestOptions options, OperationContext operationContext) { return this.ExistsAsync(options, operationContext, CancellationToken.None); } @@ -806,7 +813,7 @@ public Task ExistsAsync(FileRequestOptions options, OperationContext opera /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task ExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, options, operationContext, cancellationToken); } @@ -820,7 +827,7 @@ public Task ExistsAsync(FileRequestOptions options, OperationContext opera /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void FetchAttributes(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void FetchAttributes(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -837,7 +844,7 @@ public void FetchAttributes(AccessCondition accessCondition = null, FileRequestO /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, object state) { return this.BeginFetchAttributes(null, null, null, callback, state); } @@ -852,7 +859,7 @@ public ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, obje /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -867,7 +874,7 @@ public ICancellableAsyncResult BeginFetchAttributes(AccessCondition accessCondit /// Ends an asynchronous operation to retrieve the share's attributes. /// /// An that references the pending asynchronous operation. - public void EndFetchAttributes(IAsyncResult asyncResult) + public virtual void EndFetchAttributes(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -878,7 +885,7 @@ public void EndFetchAttributes(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task FetchAttributesAsync() + public virtual Task FetchAttributesAsync() { return this.FetchAttributesAsync(CancellationToken.None); } @@ -889,7 +896,7 @@ public Task FetchAttributesAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task FetchAttributesAsync(CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginFetchAttributes, this.EndFetchAttributes, cancellationToken); } @@ -902,7 +909,7 @@ public Task FetchAttributesAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.FetchAttributesAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -916,7 +923,7 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOpt /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginFetchAttributes, this.EndFetchAttributes, accessCondition, options, operationContext, cancellationToken); } @@ -931,7 +938,7 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOpt /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public FileSharePermissions GetPermissions(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual FileSharePermissions GetPermissions(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.ExecuteSync( @@ -948,7 +955,7 @@ public FileSharePermissions GetPermissions(AccessCondition accessCondition = nul /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetPermissions(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetPermissions(AsyncCallback callback, object state) { return this.BeginGetPermissions(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -963,7 +970,7 @@ public ICancellableAsyncResult BeginGetPermissions(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetPermissions(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetPermissions(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -979,7 +986,7 @@ public ICancellableAsyncResult BeginGetPermissions(AccessCondition accessConditi /// /// An that references the pending asynchronous operation. /// A object. - public FileSharePermissions EndGetPermissions(IAsyncResult asyncResult) + public virtual FileSharePermissions EndGetPermissions(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -990,7 +997,7 @@ public FileSharePermissions EndGetPermissions(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync() + public virtual Task GetPermissionsAsync() { return this.GetPermissionsAsync(CancellationToken.None); } @@ -1001,7 +1008,7 @@ public Task GetPermissionsAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync(CancellationToken cancellationToken) + public virtual Task GetPermissionsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetPermissions, this.EndGetPermissions, cancellationToken); } @@ -1014,7 +1021,7 @@ public Task GetPermissionsAsync(CancellationToken cancella /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task GetPermissionsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.GetPermissionsAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -1028,7 +1035,7 @@ public Task GetPermissionsAsync(AccessCondition accessCond /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetPermissionsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetPermissions, this.EndGetPermissions, accessCondition, options, operationContext, cancellationToken); } @@ -1042,7 +1049,7 @@ public Task GetPermissionsAsync(AccessCondition accessCond /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public ShareStats GetStats(FileRequestOptions options = null, OperationContext operationContext = null) + public virtual ShareStats GetStats(FileRequestOptions options = null, OperationContext operationContext = null) { options = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1060,7 +1067,7 @@ public ShareStats GetStats(FileRequestOptions options = null, OperationContext o /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetStats(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetStats(AsyncCallback callback, object state) { return this.BeginGetStats(null /* options */, null /* operationContext */, callback, state); } @@ -1074,7 +1081,7 @@ public ICancellableAsyncResult BeginGetStats(AsyncCallback callback, object stat /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetStats(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetStats(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { options = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1091,7 +1098,7 @@ public ICancellableAsyncResult BeginGetStats(FileRequestOptions options, Operati /// /// An that references the pending asynchronous operation. /// A object. - public ShareStats EndGetStats(IAsyncResult asyncResult) + public virtual ShareStats EndGetStats(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -1102,7 +1109,7 @@ public ShareStats EndGetStats(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetStatsAsync() + public virtual Task GetStatsAsync() { return this.GetStatsAsync(CancellationToken.None); } @@ -1113,7 +1120,7 @@ public Task GetStatsAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetStatsAsync(CancellationToken cancellationToken) + public virtual Task GetStatsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetStats, this.EndGetStats, cancellationToken); } @@ -1125,7 +1132,7 @@ public Task GetStatsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetStatsAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task GetStatsAsync(FileRequestOptions options, OperationContext operationContext) { return this.GetStatsAsync(options, operationContext, CancellationToken.None); } @@ -1138,7 +1145,7 @@ public Task GetStatsAsync(FileRequestOptions options, OperationConte /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetStatsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetStatsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetStats, this.EndGetStats, options, operationContext, cancellationToken); } @@ -1152,7 +1159,7 @@ public Task GetStatsAsync(FileRequestOptions options, OperationConte /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetMetadata(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void SetMetadata(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -1169,7 +1176,7 @@ public void SetMetadata(AccessCondition accessCondition = null, FileRequestOptio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object state) { return this.BeginSetMetadata(null, null, null, callback, state); } @@ -1184,7 +1191,7 @@ public ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object s /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1199,7 +1206,7 @@ public ICancellableAsyncResult BeginSetMetadata(AccessCondition accessCondition, /// Ends an asynchronous request operation to set user-defined metadata on the share. /// /// An that references the pending asynchronous operation. - public void EndSetMetadata(IAsyncResult asyncResult) + public virtual void EndSetMetadata(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1210,7 +1217,7 @@ public void EndSetMetadata(IAsyncResult asyncResult) /// /// A object that represents the current operation. [DoesServiceRequest] - public Task SetMetadataAsync() + public virtual Task SetMetadataAsync() { return this.SetMetadataAsync(CancellationToken.None); } @@ -1221,7 +1228,7 @@ public Task SetMetadataAsync() /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task SetMetadataAsync(CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetMetadata, this.EndSetMetadata, cancellationToken); } @@ -1234,7 +1241,7 @@ public Task SetMetadataAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the current operation. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.SetMetadataAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -1248,7 +1255,7 @@ public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions /// A to observe while waiting for a task to complete. /// A object that represents the current operation. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetMetadata, this.EndSetMetadata, accessCondition, options, operationContext, cancellationToken); } @@ -1263,7 +1270,7 @@ public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetPermissions(FileSharePermissions permissions, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void SetPermissions(FileSharePermissions permissions, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -1281,7 +1288,7 @@ public void SetPermissions(FileSharePermissions permissions, AccessCondition acc /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetPermissions(FileSharePermissions permissions, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetPermissions(FileSharePermissions permissions, AsyncCallback callback, object state) { return this.BeginSetPermissions(permissions, null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1297,7 +1304,7 @@ public ICancellableAsyncResult BeginSetPermissions(FileSharePermissions permissi /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetPermissions(FileSharePermissions permissions, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetPermissions(FileSharePermissions permissions, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1312,7 +1319,7 @@ public ICancellableAsyncResult BeginSetPermissions(FileSharePermissions permissi /// Returns the result of an asynchronous request to set permissions for the share. /// /// An that references the pending asynchronous operation. - public void EndSetPermissions(IAsyncResult asyncResult) + public virtual void EndSetPermissions(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1324,7 +1331,7 @@ public void EndSetPermissions(IAsyncResult asyncResult) /// The permissions to apply to the share. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(FileSharePermissions permissions) + public virtual Task SetPermissionsAsync(FileSharePermissions permissions) { return this.SetPermissionsAsync(permissions, CancellationToken.None); } @@ -1336,7 +1343,7 @@ public Task SetPermissionsAsync(FileSharePermissions permissions) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(FileSharePermissions permissions, CancellationToken cancellationToken) + public virtual Task SetPermissionsAsync(FileSharePermissions permissions, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetPermissions, this.EndSetPermissions, permissions, cancellationToken); } @@ -1350,7 +1357,7 @@ public Task SetPermissionsAsync(FileSharePermissions permissions, CancellationTo /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(FileSharePermissions permissions, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task SetPermissionsAsync(FileSharePermissions permissions, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.SetPermissionsAsync(permissions, accessCondition, options, operationContext, CancellationToken.None); } @@ -1365,7 +1372,7 @@ public Task SetPermissionsAsync(FileSharePermissions permissions, AccessConditio /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(FileSharePermissions permissions, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetPermissionsAsync(FileSharePermissions permissions, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetPermissions, this.EndSetPermissions, permissions, accessCondition, options, operationContext, cancellationToken); } @@ -1379,7 +1386,7 @@ public Task SetPermissionsAsync(FileSharePermissions permissions, AccessConditio /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetProperties(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) + public virtual void SetProperties(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); Executor.ExecuteSync( @@ -1396,7 +1403,7 @@ public void SetProperties(AccessCondition accessCondition = null, FileRequestOpt /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetProperties(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetProperties(AsyncCallback callback, object state) { return this.BeginSetProperties(null /* accessCondition */, null /* options */, null /* operationContext */, callback, state); } @@ -1411,7 +1418,7 @@ public ICancellableAsyncResult BeginSetProperties(AsyncCallback callback, object /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetProperties(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetProperties(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Executor.BeginExecuteAsync( @@ -1426,7 +1433,7 @@ public ICancellableAsyncResult BeginSetProperties(AccessCondition accessConditio /// Ends an asynchronous operation to update the share's properties. /// /// An that references the pending asynchronous operation. - public void EndSetProperties(IAsyncResult asyncResult) + public virtual void EndSetProperties(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1437,7 +1444,7 @@ public void EndSetProperties(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPropertiesAsync() + public virtual Task SetPropertiesAsync() { return this.SetPropertiesAsync(CancellationToken.None); } @@ -1448,7 +1455,7 @@ public Task SetPropertiesAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPropertiesAsync(CancellationToken cancellationToken) + public virtual Task SetPropertiesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetProperties, this.EndSetProperties, cancellationToken); } @@ -1461,7 +1468,7 @@ public Task SetPropertiesAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.SetPropertiesAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -1475,7 +1482,7 @@ public Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptio /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetProperties, this.EndSetProperties, accessCondition, options, operationContext, cancellationToken); } diff --git a/Lib/ClassLibraryCommon/Queue/CloudQueue.cs b/Lib/ClassLibraryCommon/Queue/CloudQueue.cs index d0f289513..3a538dcb9 100644 --- a/Lib/ClassLibraryCommon/Queue/CloudQueue.cs +++ b/Lib/ClassLibraryCommon/Queue/CloudQueue.cs @@ -35,7 +35,7 @@ namespace Microsoft.WindowsAzure.Storage.Queue /// /// This class represents a queue in the Windows Azure Queue service. /// - public sealed partial class CloudQueue + public partial class CloudQueue { #if SYNC /// @@ -44,7 +44,7 @@ public sealed partial class CloudQueue /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Create(QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual void Create(QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -63,7 +63,7 @@ public void Create(QueueRequestOptions options = null, OperationContext operatio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) { return this.BeginCreate(null /* options */, null /* operationContext */, callback, state); } @@ -77,7 +77,7 @@ public ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -94,7 +94,7 @@ public ICancellableAsyncResult BeginCreate(QueueRequestOptions options, Operatio /// Ends an asynchronous operation to create a queue. /// /// An that references the pending asynchronous operation. - public void EndCreate(IAsyncResult asyncResult) + public virtual void EndCreate(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -105,7 +105,7 @@ public void EndCreate(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync() + public virtual Task CreateAsync() { return this.CreateAsync(CancellationToken.None); } @@ -116,7 +116,7 @@ public Task CreateAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync(CancellationToken cancellationToken) + public virtual Task CreateAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, cancellationToken); } @@ -128,7 +128,7 @@ public Task CreateAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task CreateAsync(QueueRequestOptions options, OperationContext operationContext) { return this.CreateAsync(options, operationContext, CancellationToken.None); } @@ -141,7 +141,7 @@ public Task CreateAsync(QueueRequestOptions options, OperationContext operationC /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, options, operationContext, cancellationToken); } @@ -154,8 +154,9 @@ public Task CreateAsync(QueueRequestOptions options, OperationContext operationC /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. /// true if the queue did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public bool CreateIfNotExists(QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual bool CreateIfNotExists(QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -204,8 +205,9 @@ public bool CreateIfNotExists(QueueRequestOptions options = null, OperationConte /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, object state) { return this.BeginCreateIfNotExists(null /* options */, null /*operationContext */, callback, state); } @@ -218,8 +220,9 @@ public ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, ob /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateIfNotExists(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateIfNotExists(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -316,7 +319,7 @@ private void CreateIfNotExistsHandler(IAsyncResult asyncResult) /// /// An that references the pending asynchronous operation. /// true if the queue did not already exist and was created; otherwise, false. - public bool EndCreateIfNotExists(IAsyncResult asyncResult) + public virtual bool EndCreateIfNotExists(IAsyncResult asyncResult) { StorageAsyncResult res = asyncResult as StorageAsyncResult; CommonUtility.AssertNotNull("AsyncResult", res); @@ -329,8 +332,9 @@ public bool EndCreateIfNotExists(IAsyncResult asyncResult) /// Initiates an asynchronous operation to create the queue if it does not already exist. /// /// A object of type bool that represents the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync() + public virtual Task CreateIfNotExistsAsync() { return this.CreateIfNotExistsAsync(CancellationToken.None); } @@ -340,8 +344,9 @@ public Task CreateIfNotExistsAsync() /// /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(CancellationToken cancellationToken) + public virtual Task CreateIfNotExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateIfNotExists, this.EndCreateIfNotExists, cancellationToken); } @@ -352,8 +357,9 @@ public Task CreateIfNotExistsAsync(CancellationToken cancellationToken) /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A object of type bool that represents the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task CreateIfNotExistsAsync(QueueRequestOptions options, OperationContext operationContext) { return this.CreateIfNotExistsAsync(options, operationContext, CancellationToken.None); } @@ -365,8 +371,9 @@ public Task CreateIfNotExistsAsync(QueueRequestOptions options, OperationC /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateIfNotExistsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateIfNotExists, this.EndCreateIfNotExists, options, operationContext, cancellationToken); } @@ -380,7 +387,7 @@ public Task CreateIfNotExistsAsync(QueueRequestOptions options, OperationC /// An object that represents the context for the current operation. /// true if the queue did not already exist and was created; otherwise false. [DoesServiceRequest] - public bool DeleteIfExists(QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual bool DeleteIfExists(QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -425,7 +432,7 @@ public bool DeleteIfExists(QueueRequestOptions options = null, OperationContext /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) { return this.BeginDeleteIfExists(null /* options */, null /* operationContext */, callback, state); } @@ -439,7 +446,7 @@ public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -535,7 +542,7 @@ private void DeleteIfExistsHandler(IAsyncResult asyncResult) /// /// An that references the pending asynchronous operation. /// true if the queue did not already exist and was created; otherwise, false. - public bool EndDeleteIfExists(IAsyncResult asyncResult) + public virtual bool EndDeleteIfExists(IAsyncResult asyncResult) { StorageAsyncResult res = asyncResult as StorageAsyncResult; CommonUtility.AssertNotNull("AsyncResult", res); @@ -549,7 +556,7 @@ public bool EndDeleteIfExists(IAsyncResult asyncResult) /// /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync() + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(CancellationToken.None); } @@ -560,7 +567,7 @@ public Task DeleteIfExistsAsync() /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, cancellationToken); } @@ -572,7 +579,7 @@ public Task DeleteIfExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task DeleteIfExistsAsync(QueueRequestOptions options, OperationContext operationContext) { return this.DeleteIfExistsAsync(options, operationContext, CancellationToken.None); } @@ -585,7 +592,7 @@ public Task DeleteIfExistsAsync(QueueRequestOptions options, OperationCont /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, options, operationContext, cancellationToken); } @@ -598,7 +605,7 @@ public Task DeleteIfExistsAsync(QueueRequestOptions options, OperationCont /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Delete(QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual void Delete(QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -617,7 +624,7 @@ public void Delete(QueueRequestOptions options = null, OperationContext operatio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) { return this.BeginDelete(null /* options */, null /* operationContext */, callback, state); } @@ -631,7 +638,7 @@ public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -648,7 +655,7 @@ public ICancellableAsyncResult BeginDelete(QueueRequestOptions options, Operatio /// Ends an asynchronous operation to delete a queue. /// /// An that references the pending asynchronous operation. - public void EndDelete(IAsyncResult asyncResult) + public virtual void EndDelete(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -659,7 +666,7 @@ public void EndDelete(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync() + public virtual Task DeleteAsync() { return this.DeleteAsync(CancellationToken.None); } @@ -670,7 +677,7 @@ public Task DeleteAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync(CancellationToken cancellationToken) + public virtual Task DeleteAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, cancellationToken); } @@ -682,7 +689,7 @@ public Task DeleteAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task DeleteAsync(QueueRequestOptions options, OperationContext operationContext) { return this.DeleteAsync(options, operationContext, CancellationToken.None); } @@ -695,7 +702,7 @@ public Task DeleteAsync(QueueRequestOptions options, OperationContext operationC /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, options, operationContext, cancellationToken); } @@ -709,7 +716,7 @@ public Task DeleteAsync(QueueRequestOptions options, OperationContext operationC /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetPermissions(QueuePermissions permissions, QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual void SetPermissions(QueuePermissions permissions, QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -729,7 +736,7 @@ public void SetPermissions(QueuePermissions permissions, QueueRequestOptions opt /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetPermissions(QueuePermissions permissions, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetPermissions(QueuePermissions permissions, AsyncCallback callback, object state) { return this.BeginSetPermissions(permissions, null /* options */, null /* operationContext */, callback, state); } @@ -744,7 +751,7 @@ public ICancellableAsyncResult BeginSetPermissions(QueuePermissions permissions, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetPermissions(QueuePermissions permissions, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetPermissions(QueuePermissions permissions, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -761,7 +768,7 @@ public ICancellableAsyncResult BeginSetPermissions(QueuePermissions permissions, /// Returns the result of an asynchronous operation to set permissions for the queue. /// /// An that references the pending asynchronous operation. - public void EndSetPermissions(IAsyncResult asyncResult) + public virtual void EndSetPermissions(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -773,7 +780,7 @@ public void EndSetPermissions(IAsyncResult asyncResult) /// A object. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(QueuePermissions permissions) + public virtual Task SetPermissionsAsync(QueuePermissions permissions) { return this.SetPermissionsAsync(permissions, CancellationToken.None); } @@ -785,7 +792,7 @@ public Task SetPermissionsAsync(QueuePermissions permissions) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(QueuePermissions permissions, CancellationToken cancellationToken) + public virtual Task SetPermissionsAsync(QueuePermissions permissions, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetPermissions, this.EndSetPermissions, permissions, cancellationToken); } @@ -798,7 +805,7 @@ public Task SetPermissionsAsync(QueuePermissions permissions, CancellationToken /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(QueuePermissions permissions, QueueRequestOptions options, OperationContext operationContext) + public virtual Task SetPermissionsAsync(QueuePermissions permissions, QueueRequestOptions options, OperationContext operationContext) { return this.SetPermissionsAsync(permissions, options, operationContext, CancellationToken.None); } @@ -812,7 +819,7 @@ public Task SetPermissionsAsync(QueuePermissions permissions, QueueRequestOption /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(QueuePermissions permissions, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetPermissionsAsync(QueuePermissions permissions, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetPermissions, this.EndSetPermissions, permissions, options, operationContext, cancellationToken); } @@ -826,7 +833,7 @@ public Task SetPermissionsAsync(QueuePermissions permissions, QueueRequestOption /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public QueuePermissions GetPermissions(QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual QueuePermissions GetPermissions(QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -845,7 +852,7 @@ public QueuePermissions GetPermissions(QueueRequestOptions options = null, Opera /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetPermissions(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetPermissions(AsyncCallback callback, object state) { return this.BeginGetPermissions(null /* options */, null /* operationContext */, callback, state); } @@ -859,7 +866,7 @@ public ICancellableAsyncResult BeginGetPermissions(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetPermissions(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetPermissions(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -877,7 +884,7 @@ public ICancellableAsyncResult BeginGetPermissions(QueueRequestOptions options, /// /// An that references the pending asynchronous operation. /// A object. - public QueuePermissions EndGetPermissions(IAsyncResult asyncResult) + public virtual QueuePermissions EndGetPermissions(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -888,7 +895,7 @@ public QueuePermissions EndGetPermissions(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync() + public virtual Task GetPermissionsAsync() { return this.GetPermissionsAsync(CancellationToken.None); } @@ -899,7 +906,7 @@ public Task GetPermissionsAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync(CancellationToken cancellationToken) + public virtual Task GetPermissionsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetPermissions, this.EndGetPermissions, cancellationToken); } @@ -911,7 +918,7 @@ public Task GetPermissionsAsync(CancellationToken cancellation /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task GetPermissionsAsync(QueueRequestOptions options, OperationContext operationContext) { return this.GetPermissionsAsync(options, operationContext, CancellationToken.None); } @@ -924,7 +931,7 @@ public Task GetPermissionsAsync(QueueRequestOptions options, O /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetPermissionsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetPermissions, this.EndGetPermissions, options, operationContext, cancellationToken); } @@ -938,7 +945,7 @@ public Task GetPermissionsAsync(QueueRequestOptions options, O /// An object that represents the context for the current operation. /// true if the queue exists. [DoesServiceRequest] - public bool Exists(QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual bool Exists(QueueRequestOptions options = null, OperationContext operationContext = null) { return this.Exists(false, options, operationContext); } @@ -969,7 +976,7 @@ private bool Exists(bool primaryOnly, QueueRequestOptions options, OperationCont /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) { return this.BeginExists(null /* options */, null /* operationContext */, callback, state); } @@ -983,7 +990,7 @@ public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginExists(false, options, operationContext, callback, state); } @@ -1015,7 +1022,7 @@ private ICancellableAsyncResult BeginExists(bool primaryOnly, QueueRequestOption /// /// An that references the pending asynchronous operation. /// true if the queue exists. - public bool EndExists(IAsyncResult asyncResult) + public virtual bool EndExists(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -1026,7 +1033,7 @@ public bool EndExists(IAsyncResult asyncResult) /// /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync() + public virtual Task ExistsAsync() { return this.ExistsAsync(CancellationToken.None); } @@ -1037,7 +1044,7 @@ public Task ExistsAsync() /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync(CancellationToken cancellationToken) + public virtual Task ExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, cancellationToken); } @@ -1049,7 +1056,7 @@ public Task ExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task ExistsAsync(QueueRequestOptions options, OperationContext operationContext) { return this.ExistsAsync(options, operationContext, CancellationToken.None); } @@ -1062,7 +1069,7 @@ public Task ExistsAsync(QueueRequestOptions options, OperationContext oper /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExistsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, options, operationContext, cancellationToken); } @@ -1075,7 +1082,7 @@ public Task ExistsAsync(QueueRequestOptions options, OperationContext oper /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetMetadata(QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual void SetMetadata(QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1094,7 +1101,7 @@ public void SetMetadata(QueueRequestOptions options = null, OperationContext ope /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object state) { return this.BeginSetMetadata(null /* options */, null /* operationContext */, callback, state); } @@ -1108,7 +1115,7 @@ public ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object s /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetMetadata(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetMetadata(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1125,7 +1132,7 @@ public ICancellableAsyncResult BeginSetMetadata(QueueRequestOptions options, Ope /// Ends an asynchronous operation to set user-defined metadata on the queue. /// /// An that references the pending asynchronous operation. - public void EndSetMetadata(IAsyncResult asyncResult) + public virtual void EndSetMetadata(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1136,7 +1143,7 @@ public void EndSetMetadata(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetMetadataAsync() + public virtual Task SetMetadataAsync() { return this.SetMetadataAsync(CancellationToken.None); } @@ -1147,7 +1154,7 @@ public Task SetMetadataAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetMetadataAsync(CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetMetadata, this.EndSetMetadata, cancellationToken); } @@ -1159,7 +1166,7 @@ public Task SetMetadataAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetMetadataAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task SetMetadataAsync(QueueRequestOptions options, OperationContext operationContext) { return this.SetMetadataAsync(options, operationContext, CancellationToken.None); } @@ -1172,7 +1179,7 @@ public Task SetMetadataAsync(QueueRequestOptions options, OperationContext opera /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetMetadataAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetMetadata, this.EndSetMetadata, options, operationContext, cancellationToken); } @@ -1185,7 +1192,7 @@ public Task SetMetadataAsync(QueueRequestOptions options, OperationContext opera /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void FetchAttributes(QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual void FetchAttributes(QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1204,7 +1211,7 @@ public void FetchAttributes(QueueRequestOptions options = null, OperationContext /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, object state) { return this.BeginFetchAttributes(null /* options */, null /* operationContext */, callback, state); } @@ -1218,7 +1225,7 @@ public ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, obje /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginFetchAttributes(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginFetchAttributes(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1235,7 +1242,7 @@ public ICancellableAsyncResult BeginFetchAttributes(QueueRequestOptions options, /// Ends an asynchronous operation to fetch a queue's attributes. /// /// An that references the pending asynchronous operation. - public void EndFetchAttributes(IAsyncResult asyncResult) + public virtual void EndFetchAttributes(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1246,7 +1253,7 @@ public void EndFetchAttributes(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task FetchAttributesAsync() + public virtual Task FetchAttributesAsync() { return this.FetchAttributesAsync(CancellationToken.None); } @@ -1257,7 +1264,7 @@ public Task FetchAttributesAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task FetchAttributesAsync(CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginFetchAttributes, this.EndFetchAttributes, cancellationToken); } @@ -1269,7 +1276,7 @@ public Task FetchAttributesAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task FetchAttributesAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task FetchAttributesAsync(QueueRequestOptions options, OperationContext operationContext) { return this.FetchAttributesAsync(options, operationContext, CancellationToken.None); } @@ -1282,7 +1289,7 @@ public Task FetchAttributesAsync(QueueRequestOptions options, OperationContext o /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task FetchAttributesAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginFetchAttributes, this.EndFetchAttributes, options, operationContext, cancellationToken); } @@ -1299,7 +1306,7 @@ public Task FetchAttributesAsync(QueueRequestOptions options, OperationContext o /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void AddMessage(CloudQueueMessage message, TimeSpan? timeToLive = null, TimeSpan? initialVisibilityDelay = null, QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual void AddMessage(CloudQueueMessage message, TimeSpan? timeToLive = null, TimeSpan? initialVisibilityDelay = null, QueueRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("message", message); @@ -1321,7 +1328,7 @@ public void AddMessage(CloudQueueMessage message, TimeSpan? timeToLive = null, T /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginAddMessage(CloudQueueMessage message, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAddMessage(CloudQueueMessage message, AsyncCallback callback, object state) { return this.BeginAddMessage(message, null /* timeToLive */, null /* initialVisibilityDelay */, null /* options */, null /*operationContext */, callback, state); } @@ -1339,7 +1346,7 @@ public ICancellableAsyncResult BeginAddMessage(CloudQueueMessage message, AsyncC /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginAddMessage(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginAddMessage(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("message", message); @@ -1358,7 +1365,7 @@ public ICancellableAsyncResult BeginAddMessage(CloudQueueMessage message, TimeSp /// Ends an asynchronous operation to add a message to the queue. /// /// An that references the pending asynchronous operation. - public void EndAddMessage(IAsyncResult asyncResult) + public virtual void EndAddMessage(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1370,7 +1377,7 @@ public void EndAddMessage(IAsyncResult asyncResult) /// A object. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AddMessageAsync(CloudQueueMessage message) + public virtual Task AddMessageAsync(CloudQueueMessage message) { return this.AddMessageAsync(message, CancellationToken.None); } @@ -1382,7 +1389,7 @@ public Task AddMessageAsync(CloudQueueMessage message) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AddMessageAsync(CloudQueueMessage message, CancellationToken cancellationToken) + public virtual Task AddMessageAsync(CloudQueueMessage message, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAddMessage, this.EndAddMessage, message, cancellationToken); } @@ -1398,7 +1405,7 @@ public Task AddMessageAsync(CloudQueueMessage message, CancellationToken cancell /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay, QueueRequestOptions options, OperationContext operationContext) + public virtual Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay, QueueRequestOptions options, OperationContext operationContext) { return this.AddMessageAsync(message, timeToLive, initialVisibilityDelay, options, operationContext, CancellationToken.None); } @@ -1415,7 +1422,7 @@ public Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, Tim /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginAddMessage, this.EndAddMessage, message, timeToLive, initialVisibilityDelay, options, operationContext, cancellationToken); } @@ -1431,7 +1438,7 @@ public Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, Tim /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void UpdateMessage(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual void UpdateMessage(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1453,7 +1460,7 @@ public void UpdateMessage(CloudQueueMessage message, TimeSpan visibilityTimeout, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUpdateMessage(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUpdateMessage(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, AsyncCallback callback, object state) { return this.BeginUpdateMessage(message, visibilityTimeout, updateFields, null /* options */, null /* operationContext */, callback, state); } @@ -1470,7 +1477,7 @@ public ICancellableAsyncResult BeginUpdateMessage(CloudQueueMessage message, Tim /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginUpdateMessage(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginUpdateMessage(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("message", message); @@ -1489,7 +1496,7 @@ public ICancellableAsyncResult BeginUpdateMessage(CloudQueueMessage message, Tim /// Ends an asynchronous operation to add a message to the queue. /// /// An that references the pending asynchronous operation. - public void EndUpdateMessage(IAsyncResult asyncResult) + public virtual void EndUpdateMessage(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1503,7 +1510,7 @@ public void EndUpdateMessage(IAsyncResult asyncResult) /// A set of values that specify which parts of the message are to be updated. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields) + public virtual Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields) { return this.UpdateMessageAsync(message, visibilityTimeout, updateFields, CancellationToken.None); } @@ -1517,7 +1524,7 @@ public Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTim /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, CancellationToken cancellationToken) + public virtual Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUpdateMessage, this.EndUpdateMessage, message, visibilityTimeout, updateFields, cancellationToken); } @@ -1532,7 +1539,7 @@ public Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTim /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, QueueRequestOptions options, OperationContext operationContext) + public virtual Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, QueueRequestOptions options, OperationContext operationContext) { return this.UpdateMessageAsync(message, visibilityTimeout, updateFields, options, operationContext, CancellationToken.None); } @@ -1548,7 +1555,7 @@ public Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTim /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginUpdateMessage, this.EndUpdateMessage, message, visibilityTimeout, updateFields, options, operationContext, cancellationToken); } @@ -1562,7 +1569,7 @@ public Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTim /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void DeleteMessage(CloudQueueMessage message, QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual void DeleteMessage(CloudQueueMessage message, QueueRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("message", message); @@ -1577,7 +1584,7 @@ public void DeleteMessage(CloudQueueMessage message, QueueRequestOptions options /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void DeleteMessage(string messageId, string popReceipt, QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual void DeleteMessage(string messageId, string popReceipt, QueueRequestOptions options = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("messageId", messageId); CommonUtility.AssertNotNull("popReceipt", popReceipt); @@ -1600,7 +1607,7 @@ public void DeleteMessage(string messageId, string popReceipt, QueueRequestOptio /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteMessage(CloudQueueMessage message, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteMessage(CloudQueueMessage message, AsyncCallback callback, object state) { return this.BeginDeleteMessage(message, null /* options */, null /* operationContext */, callback, state); } @@ -1615,7 +1622,7 @@ public ICancellableAsyncResult BeginDeleteMessage(CloudQueueMessage message, Asy /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteMessage(CloudQueueMessage message, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteMessage(CloudQueueMessage message, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("message", message); @@ -1631,7 +1638,7 @@ public ICancellableAsyncResult BeginDeleteMessage(CloudQueueMessage message, Que /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteMessage(string messageId, string popReceipt, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteMessage(string messageId, string popReceipt, AsyncCallback callback, object state) { return this.BeginDeleteMessage(messageId, popReceipt, null /* options */, null /* operationContext */, callback, state); } @@ -1647,7 +1654,7 @@ public ICancellableAsyncResult BeginDeleteMessage(string messageId, string popRe /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteMessage(string messageId, string popReceipt, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteMessage(string messageId, string popReceipt, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("messageId", messageId); CommonUtility.AssertNotNull("popReceipt", popReceipt); @@ -1667,7 +1674,7 @@ public ICancellableAsyncResult BeginDeleteMessage(string messageId, string popRe /// Ends an asynchronous operation to delete a message. /// /// An that references the pending asynchronous operation. - public void EndDeleteMessage(IAsyncResult asyncResult) + public virtual void EndDeleteMessage(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1679,7 +1686,7 @@ public void EndDeleteMessage(IAsyncResult asyncResult) /// A object. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteMessageAsync(CloudQueueMessage message) + public virtual Task DeleteMessageAsync(CloudQueueMessage message) { return this.DeleteMessageAsync(message, null /* options */, null /* operationContext */, CancellationToken.None); } @@ -1691,7 +1698,7 @@ public Task DeleteMessageAsync(CloudQueueMessage message) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteMessageAsync(CloudQueueMessage message, CancellationToken cancellationToken) + public virtual Task DeleteMessageAsync(CloudQueueMessage message, CancellationToken cancellationToken) { return this.DeleteMessageAsync(message, null /* options */, null /* operationContext */, cancellationToken); } @@ -1704,7 +1711,7 @@ public Task DeleteMessageAsync(CloudQueueMessage message, CancellationToken canc /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteMessageAsync(CloudQueueMessage message, QueueRequestOptions options, OperationContext operationContext) + public virtual Task DeleteMessageAsync(CloudQueueMessage message, QueueRequestOptions options, OperationContext operationContext) { return this.DeleteMessageAsync(message, options, operationContext, CancellationToken.None); } @@ -1718,7 +1725,7 @@ public Task DeleteMessageAsync(CloudQueueMessage message, QueueRequestOptions op /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteMessageAsync(CloudQueueMessage message, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteMessageAsync(CloudQueueMessage message, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDeleteMessage, this.EndDeleteMessage, message, options, operationContext, cancellationToken); } @@ -1730,7 +1737,7 @@ public Task DeleteMessageAsync(CloudQueueMessage message, QueueRequestOptions op /// A string specifying the pop receipt value. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteMessageAsync(string messageId, string popReceipt) + public virtual Task DeleteMessageAsync(string messageId, string popReceipt) { return this.DeleteMessageAsync(messageId, popReceipt, null /* options */, null /* operationContext */, CancellationToken.None); } @@ -1743,7 +1750,7 @@ public Task DeleteMessageAsync(string messageId, string popReceipt) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteMessageAsync(string messageId, string popReceipt, CancellationToken cancellationToken) + public virtual Task DeleteMessageAsync(string messageId, string popReceipt, CancellationToken cancellationToken) { return this.DeleteMessageAsync(messageId, popReceipt, null /* options */, null /* operationContext */, cancellationToken); } @@ -1757,7 +1764,7 @@ public Task DeleteMessageAsync(string messageId, string popReceipt, Cancellation /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteMessageAsync(string messageId, string popReceipt, QueueRequestOptions options, OperationContext operationContext) + public virtual Task DeleteMessageAsync(string messageId, string popReceipt, QueueRequestOptions options, OperationContext operationContext) { return this.DeleteMessageAsync(messageId, popReceipt, options, operationContext, CancellationToken.None); } @@ -1772,7 +1779,7 @@ public Task DeleteMessageAsync(string messageId, string popReceipt, QueueRequest /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteMessageAsync(string messageId, string popReceipt, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteMessageAsync(string messageId, string popReceipt, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDeleteMessage, this.EndDeleteMessage, messageId, popReceipt, options, operationContext, cancellationToken); } @@ -1790,7 +1797,7 @@ public Task DeleteMessageAsync(string messageId, string popReceipt, QueueRequest /// An object that represents the context for the current operation. /// An enumerable collection of messages. [DoesServiceRequest] - public IEnumerable GetMessages(int messageCount, TimeSpan? visibilityTimeout = null, QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual IEnumerable GetMessages(int messageCount, TimeSpan? visibilityTimeout = null, QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1810,7 +1817,7 @@ public IEnumerable GetMessages(int messageCount, TimeSpan? vi /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetMessages(int messageCount, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetMessages(int messageCount, AsyncCallback callback, object state) { return this.BeginGetMessages(messageCount, null /* visibilityTimeout */, null /* options */, null /* operationContext */, callback, state); } @@ -1828,7 +1835,7 @@ public ICancellableAsyncResult BeginGetMessages(int messageCount, AsyncCallback /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetMessages(int messageCount, TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetMessages(int messageCount, TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1846,7 +1853,7 @@ public ICancellableAsyncResult BeginGetMessages(int messageCount, TimeSpan? visi /// /// An that references the pending asynchronous operation. /// An enumerable collection of messages. - public IEnumerable EndGetMessages(IAsyncResult asyncResult) + public virtual IEnumerable EndGetMessages(IAsyncResult asyncResult) { return Executor.EndExecuteAsync>(asyncResult); } @@ -1858,7 +1865,7 @@ public IEnumerable EndGetMessages(IAsyncResult asyncResult) /// The number of messages to retrieve. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> GetMessagesAsync(int messageCount) + public virtual Task> GetMessagesAsync(int messageCount) { return this.GetMessagesAsync(messageCount, CancellationToken.None); } @@ -1870,7 +1877,7 @@ public Task> GetMessagesAsync(int messageCount) /// A to observe while waiting for a task to complete. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> GetMessagesAsync(int messageCount, CancellationToken cancellationToken) + public virtual Task> GetMessagesAsync(int messageCount, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetMessages, this.EndGetMessages, messageCount, cancellationToken); } @@ -1886,7 +1893,7 @@ public Task> GetMessagesAsync(int messageCount, C /// An object that represents the context for the current operation. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> GetMessagesAsync(int messageCount, TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext) + public virtual Task> GetMessagesAsync(int messageCount, TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext) { return this.GetMessagesAsync(messageCount, visibilityTimeout, options, operationContext, CancellationToken.None); } @@ -1903,7 +1910,7 @@ public Task> GetMessagesAsync(int messageCount, T /// A to observe while waiting for a task to complete. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> GetMessagesAsync(int messageCount, TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> GetMessagesAsync(int messageCount, TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetMessages, this.EndGetMessages, messageCount, visibilityTimeout, options, operationContext, cancellationToken); } @@ -1918,7 +1925,7 @@ public Task> GetMessagesAsync(int messageCount, T /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public CloudQueueMessage GetMessage(TimeSpan? visibilityTimeout = null, QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual CloudQueueMessage GetMessage(TimeSpan? visibilityTimeout = null, QueueRequestOptions options = null, OperationContext operationContext = null) { return this.GetMessages(1, visibilityTimeout, options, operationContext).FirstOrDefault(); } @@ -1931,7 +1938,7 @@ public CloudQueueMessage GetMessage(TimeSpan? visibilityTimeout = null, QueueReq /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetMessage(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetMessage(AsyncCallback callback, object state) { return this.BeginGetMessage(null /* visibilityTimeout */, null /* options */, null /* operationContext */, callback, state); } @@ -1947,7 +1954,7 @@ public ICancellableAsyncResult BeginGetMessage(AsyncCallback callback, object st /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetMessage(TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetMessage(TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginGetMessages(1, visibilityTimeout, options, operationContext, callback, state); } @@ -1957,7 +1964,7 @@ public ICancellableAsyncResult BeginGetMessage(TimeSpan? visibilityTimeout, Queu /// /// An that references the pending asynchronous operation. /// A object. - public CloudQueueMessage EndGetMessage(IAsyncResult asyncResult) + public virtual CloudQueueMessage EndGetMessage(IAsyncResult asyncResult) { IEnumerable resultList = Executor.EndExecuteAsync>(asyncResult); @@ -1970,7 +1977,7 @@ public CloudQueueMessage EndGetMessage(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetMessageAsync() + public virtual Task GetMessageAsync() { return this.GetMessageAsync(CancellationToken.None); } @@ -1981,7 +1988,7 @@ public Task GetMessageAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetMessageAsync(CancellationToken cancellationToken) + public virtual Task GetMessageAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetMessage, this.EndGetMessage, cancellationToken); } @@ -1995,7 +2002,7 @@ public Task GetMessageAsync(CancellationToken cancellationTok /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetMessageAsync(TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext) + public virtual Task GetMessageAsync(TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext) { return this.GetMessageAsync(visibilityTimeout, options, operationContext, CancellationToken.None); } @@ -2010,7 +2017,7 @@ public Task GetMessageAsync(TimeSpan? visibilityTimeout, Queu /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetMessageAsync(TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetMessageAsync(TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetMessage, this.EndGetMessage, visibilityTimeout, options, operationContext, cancellationToken); } @@ -2025,7 +2032,7 @@ public Task GetMessageAsync(TimeSpan? visibilityTimeout, Queu /// An object that represents the context for the current operation. /// An enumerable collection of objects. [DoesServiceRequest] - public IEnumerable PeekMessages(int messageCount, QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual IEnumerable PeekMessages(int messageCount, QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -2045,7 +2052,7 @@ public IEnumerable PeekMessages(int messageCount, QueueReques /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginPeekMessages(int messageCount, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginPeekMessages(int messageCount, AsyncCallback callback, object state) { return this.BeginPeekMessages(messageCount, null /* options */, null /* operationContext */, callback, state); } @@ -2060,7 +2067,7 @@ public ICancellableAsyncResult BeginPeekMessages(int messageCount, AsyncCallback /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginPeekMessages(int messageCount, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginPeekMessages(int messageCount, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -2078,7 +2085,7 @@ public ICancellableAsyncResult BeginPeekMessages(int messageCount, QueueRequestO /// /// An that references the pending asynchronous operation. /// An enumerable collection of objects. - public IEnumerable EndPeekMessages(IAsyncResult asyncResult) + public virtual IEnumerable EndPeekMessages(IAsyncResult asyncResult) { return Executor.EndExecuteAsync>(asyncResult); } @@ -2090,7 +2097,7 @@ public IEnumerable EndPeekMessages(IAsyncResult asyncResult) /// The number of messages to peek. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> PeekMessagesAsync(int messageCount) + public virtual Task> PeekMessagesAsync(int messageCount) { return this.PeekMessagesAsync(messageCount, CancellationToken.None); } @@ -2102,7 +2109,7 @@ public Task> PeekMessagesAsync(int messageCount) /// A to observe while waiting for a task to complete. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> PeekMessagesAsync(int messageCount, CancellationToken cancellationToken) + public virtual Task> PeekMessagesAsync(int messageCount, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginPeekMessages, this.EndPeekMessages, messageCount, cancellationToken); } @@ -2115,7 +2122,7 @@ public Task> PeekMessagesAsync(int messageCount, /// An object that represents the context for the current operation. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> PeekMessagesAsync(int messageCount, QueueRequestOptions options, OperationContext operationContext) + public virtual Task> PeekMessagesAsync(int messageCount, QueueRequestOptions options, OperationContext operationContext) { return this.PeekMessagesAsync(messageCount, options, operationContext, CancellationToken.None); } @@ -2129,7 +2136,7 @@ public Task> PeekMessagesAsync(int messageCount, /// A to observe while waiting for a task to complete. /// A object that is an enumerable collection of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> PeekMessagesAsync(int messageCount, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> PeekMessagesAsync(int messageCount, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginPeekMessages, this.EndPeekMessages, messageCount, options, operationContext, cancellationToken); } @@ -2143,7 +2150,7 @@ public Task> PeekMessagesAsync(int messageCount, /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public CloudQueueMessage PeekMessage(QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual CloudQueueMessage PeekMessage(QueueRequestOptions options = null, OperationContext operationContext = null) { return this.PeekMessages(1, options, operationContext).FirstOrDefault(); } @@ -2156,7 +2163,7 @@ public CloudQueueMessage PeekMessage(QueueRequestOptions options = null, Operati /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginPeekMessage(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginPeekMessage(AsyncCallback callback, object state) { return this.BeginPeekMessage(null /* options */, null /* operationContext */, callback, state); } @@ -2170,7 +2177,7 @@ public ICancellableAsyncResult BeginPeekMessage(AsyncCallback callback, object s /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginPeekMessage(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginPeekMessage(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginPeekMessages(1, options, operationContext, callback, state); } @@ -2180,7 +2187,7 @@ public ICancellableAsyncResult BeginPeekMessage(QueueRequestOptions options, Ope /// /// An that references the pending asynchronous operation. /// A object. - public CloudQueueMessage EndPeekMessage(IAsyncResult asyncResult) + public virtual CloudQueueMessage EndPeekMessage(IAsyncResult asyncResult) { IEnumerable resultList = Executor.EndExecuteAsync>(asyncResult); @@ -2193,7 +2200,7 @@ public CloudQueueMessage EndPeekMessage(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task PeekMessageAsync() + public virtual Task PeekMessageAsync() { return this.PeekMessageAsync(CancellationToken.None); } @@ -2204,7 +2211,7 @@ public Task PeekMessageAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task PeekMessageAsync(CancellationToken cancellationToken) + public virtual Task PeekMessageAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginPeekMessage, this.EndPeekMessage, cancellationToken); } @@ -2216,7 +2223,7 @@ public Task PeekMessageAsync(CancellationToken cancellationTo /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task PeekMessageAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task PeekMessageAsync(QueueRequestOptions options, OperationContext operationContext) { return this.PeekMessageAsync(options, operationContext, CancellationToken.None); } @@ -2229,7 +2236,7 @@ public Task PeekMessageAsync(QueueRequestOptions options, Ope /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task PeekMessageAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task PeekMessageAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginPeekMessage, this.EndPeekMessage, options, operationContext, cancellationToken); } @@ -2242,7 +2249,7 @@ public Task PeekMessageAsync(QueueRequestOptions options, Ope /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Clear(QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual void Clear(QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -2261,7 +2268,7 @@ public void Clear(QueueRequestOptions options = null, OperationContext operation /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginClear(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginClear(AsyncCallback callback, object state) { return this.BeginClear(null /* options */, null /* operationContext */, callback, state); } @@ -2275,7 +2282,7 @@ public ICancellableAsyncResult BeginClear(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginClear(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginClear(QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -2292,7 +2299,7 @@ public ICancellableAsyncResult BeginClear(QueueRequestOptions options, Operation /// Ends an asynchronous operation to clear all messages from the queue. /// /// An that references the pending asynchronous operation. - public void EndClear(IAsyncResult asyncResult) + public virtual void EndClear(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -2303,7 +2310,7 @@ public void EndClear(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ClearAsync() + public virtual Task ClearAsync() { return this.ClearAsync(CancellationToken.None); } @@ -2314,7 +2321,7 @@ public Task ClearAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ClearAsync(CancellationToken cancellationToken) + public virtual Task ClearAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginClear, this.EndClear, cancellationToken); } @@ -2326,7 +2333,7 @@ public Task ClearAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ClearAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task ClearAsync(QueueRequestOptions options, OperationContext operationContext) { return this.ClearAsync(options, operationContext, CancellationToken.None); } @@ -2339,23 +2346,12 @@ public Task ClearAsync(QueueRequestOptions options, OperationContext operationCo /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task ClearAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ClearAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginClear, this.EndClear, options, operationContext, cancellationToken); } #endif - /// - /// Ends an asynchronous operation to clear all messages from the queue. - /// - /// An that references the pending asynchronous operation. - [Obsolete("This class is improperly named; use class EndClear instead.")] - [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Reviewed.")] - public void EndBeginClear(IAsyncResult asyncResult) - { - Executor.EndExecuteAsync(asyncResult); - } - /// /// Implementation for the ClearMessages method. /// diff --git a/Lib/ClassLibraryCommon/Queue/CloudQueueClient.cs b/Lib/ClassLibraryCommon/Queue/CloudQueueClient.cs index eb962f107..12830fce7 100644 --- a/Lib/ClassLibraryCommon/Queue/CloudQueueClient.cs +++ b/Lib/ClassLibraryCommon/Queue/CloudQueueClient.cs @@ -35,7 +35,7 @@ namespace Microsoft.WindowsAzure.Storage.Queue /// Provides a client-side logical representation of the Windows Azure Queue service. This client is used to configure and execute requests against the Queue service. /// /// The service client encapsulates the endpoint or endpoints for the Queue service. If the service client will be used for authenticated access, it also encapsulates the credentials for accessing the storage account. - public sealed partial class CloudQueueClient + public partial class CloudQueueClient { private IAuthenticationHandler authenticationHandler; @@ -102,7 +102,7 @@ internal IAuthenticationHandler AuthenticationHandler /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. /// An enumerable collection of objects of type that are retrieved lazily. - public IEnumerable ListQueues(string prefix = null, QueueListingDetails queueListingDetails = QueueListingDetails.None, QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual IEnumerable ListQueues(string prefix = null, QueueListingDetails queueListingDetails = QueueListingDetails.None, QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this); operationContext = operationContext ?? new OperationContext(); @@ -117,7 +117,7 @@ public IEnumerable ListQueues(string prefix = null, QueueListingDeta /// /// A continuation token returned by a previous listing operation. /// A object. - public QueueResultSegment ListQueuesSegmented(QueueContinuationToken currentToken) + public virtual QueueResultSegment ListQueuesSegmented(QueueContinuationToken currentToken) { return this.ListQueuesSegmented(null, QueueListingDetails.None, null, currentToken, null, null); } @@ -128,7 +128,7 @@ public QueueResultSegment ListQueuesSegmented(QueueContinuationToken currentToke /// A string containing the queue name prefix. /// A continuation token returned by a previous listing operation. /// A object. - public QueueResultSegment ListQueuesSegmented(string prefix, QueueContinuationToken currentToken) + public virtual QueueResultSegment ListQueuesSegmented(string prefix, QueueContinuationToken currentToken) { return this.ListQueuesSegmented(prefix, QueueListingDetails.None, null, currentToken, null, null); } @@ -144,7 +144,7 @@ public QueueResultSegment ListQueuesSegmented(string prefix, QueueContinuationTo /// A object that specifies additional options for the request. If null, default options are applied to the request. /// An object that represents the context for the current operation. /// A object. - public QueueResultSegment ListQueuesSegmented(string prefix, QueueListingDetails queueListingDetails, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options = null, OperationContext operationContext = null) + public virtual QueueResultSegment ListQueuesSegmented(string prefix, QueueListingDetails queueListingDetails, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this); operationContext = operationContext ?? new OperationContext(); @@ -180,7 +180,7 @@ private ResultSegment ListQueuesSegmentedCore(string prefix, QueueLi /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. - public ICancellableAsyncResult BeginListQueuesSegmented(QueueContinuationToken currentToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListQueuesSegmented(QueueContinuationToken currentToken, AsyncCallback callback, object state) { return this.BeginListQueuesSegmented(null, QueueListingDetails.None, null, currentToken, null, null, callback, state); } @@ -193,7 +193,7 @@ public ICancellableAsyncResult BeginListQueuesSegmented(QueueContinuationToken c /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. - public ICancellableAsyncResult BeginListQueuesSegmented(string prefix, QueueContinuationToken currentToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListQueuesSegmented(string prefix, QueueContinuationToken currentToken, AsyncCallback callback, object state) { return this.BeginListQueuesSegmented(prefix, QueueListingDetails.None, null, currentToken, null, null, callback, state); } @@ -211,7 +211,7 @@ public ICancellableAsyncResult BeginListQueuesSegmented(string prefix, QueueCont /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. - public ICancellableAsyncResult BeginListQueuesSegmented(string prefix, QueueListingDetails queueListingDetails, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListQueuesSegmented(string prefix, QueueListingDetails queueListingDetails, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this); @@ -230,7 +230,7 @@ public ICancellableAsyncResult BeginListQueuesSegmented(string prefix, QueueList /// /// An that references the pending asynchronous operation. /// A object. - public QueueResultSegment EndListQueuesSegmented(IAsyncResult asyncResult) + public virtual QueueResultSegment EndListQueuesSegmented(IAsyncResult asyncResult) { ResultSegment resultSegment = Executor.EndExecuteAsync>(asyncResult); return new QueueResultSegment(resultSegment.Results, (QueueContinuationToken)resultSegment.ContinuationToken); @@ -243,7 +243,7 @@ public QueueResultSegment EndListQueuesSegmented(IAsyncResult asyncResult) /// A returned by a previous listing operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListQueuesSegmentedAsync(QueueContinuationToken currentToken) + public virtual Task ListQueuesSegmentedAsync(QueueContinuationToken currentToken) { return this.ListQueuesSegmentedAsync(currentToken, CancellationToken.None); } @@ -255,7 +255,7 @@ public Task ListQueuesSegmentedAsync(QueueContinuationToken /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListQueuesSegmentedAsync(QueueContinuationToken currentToken, CancellationToken cancellationToken) + public virtual Task ListQueuesSegmentedAsync(QueueContinuationToken currentToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListQueuesSegmented, this.EndListQueuesSegmented, currentToken, cancellationToken); } @@ -267,7 +267,7 @@ public Task ListQueuesSegmentedAsync(QueueContinuationToken /// A returned by a previous listing operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken) + public virtual Task ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken) { return this.ListQueuesSegmentedAsync(prefix, currentToken, CancellationToken.None); } @@ -280,7 +280,7 @@ public Task ListQueuesSegmentedAsync(string prefix, QueueCon /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken, CancellationToken cancellationToken) + public virtual Task ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListQueuesSegmented, this.EndListQueuesSegmented, prefix, currentToken, cancellationToken); } @@ -297,7 +297,7 @@ public Task ListQueuesSegmentedAsync(string prefix, QueueCon /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListQueuesSegmentedAsync(string prefix, QueueListingDetails queueListingDetails, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext) + public virtual Task ListQueuesSegmentedAsync(string prefix, QueueListingDetails queueListingDetails, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext) { return this.ListQueuesSegmentedAsync(prefix, queueListingDetails, maxResults, currentToken, options, operationContext, CancellationToken.None); } @@ -315,7 +315,7 @@ public Task ListQueuesSegmentedAsync(string prefix, QueueLis /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListQueuesSegmentedAsync(string prefix, QueueListingDetails queueListingDetails, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ListQueuesSegmentedAsync(string prefix, QueueListingDetails queueListingDetails, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListQueuesSegmented, this.EndListQueuesSegmented, prefix, queueListingDetails, maxResults, currentToken, options, operationContext, cancellationToken); } @@ -380,7 +380,7 @@ private RESTCommand> ListQueuesImpl(string prefix, int /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceProperties(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceProperties(AsyncCallback callback, object state) { return this.BeginGetServiceProperties(null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -394,7 +394,7 @@ public ICancellableAsyncResult BeginGetServiceProperties(AsyncCallback callback, /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceProperties(QueueRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceProperties(QueueRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = QueueRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -411,7 +411,7 @@ public ICancellableAsyncResult BeginGetServiceProperties(QueueRequestOptions req /// /// The result returned from a prior call to . /// A object. - public ServiceProperties EndGetServiceProperties(IAsyncResult asyncResult) + public virtual ServiceProperties EndGetServiceProperties(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -422,7 +422,7 @@ public ServiceProperties EndGetServiceProperties(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync() + public virtual Task GetServicePropertiesAsync() { return this.GetServicePropertiesAsync(CancellationToken.None); } @@ -433,7 +433,7 @@ public Task GetServicePropertiesAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync(CancellationToken cancellationToken) + public virtual Task GetServicePropertiesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceProperties, this.EndGetServiceProperties, cancellationToken); } @@ -445,7 +445,7 @@ public Task GetServicePropertiesAsync(CancellationToken cance /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync(QueueRequestOptions requestOptions, OperationContext operationContext) + public virtual Task GetServicePropertiesAsync(QueueRequestOptions requestOptions, OperationContext operationContext) { return this.GetServicePropertiesAsync(requestOptions, operationContext, CancellationToken.None); } @@ -458,7 +458,7 @@ public Task GetServicePropertiesAsync(QueueRequestOptions req /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync(QueueRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServicePropertiesAsync(QueueRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceProperties, this.EndGetServiceProperties, requestOptions, operationContext, cancellationToken); } @@ -472,7 +472,7 @@ public Task GetServicePropertiesAsync(QueueRequestOptions req /// An object that represents the context for the current operation. /// A containing the Queue service properties. [DoesServiceRequest] - public ServiceProperties GetServiceProperties(QueueRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual ServiceProperties GetServiceProperties(QueueRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = QueueRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -491,7 +491,7 @@ public ServiceProperties GetServiceProperties(QueueRequestOptions requestOptions /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties properties, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties properties, AsyncCallback callback, object state) { return this.BeginSetServiceProperties(properties, null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -506,7 +506,7 @@ public ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties prope /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties properties, QueueRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties properties, QueueRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = QueueRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -522,7 +522,7 @@ public ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties prope /// Ends an asynchronous operation to set service properties for the Queue service. /// /// The returned from a prior call to . - public void EndSetServiceProperties(IAsyncResult asyncResult) + public virtual void EndSetServiceProperties(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -534,7 +534,7 @@ public void EndSetServiceProperties(IAsyncResult asyncResult) /// A object. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties) { return this.SetServicePropertiesAsync(properties, CancellationToken.None); } @@ -546,7 +546,7 @@ public Task SetServicePropertiesAsync(ServiceProperties properties) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties, CancellationToken cancellationToken) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetServiceProperties, this.EndSetServiceProperties, properties, cancellationToken); } @@ -559,7 +559,7 @@ public Task SetServicePropertiesAsync(ServiceProperties properties, Cancellation /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties, QueueRequestOptions options, OperationContext operationContext) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, QueueRequestOptions options, OperationContext operationContext) { return this.SetServicePropertiesAsync(properties, options, operationContext, CancellationToken.None); } @@ -573,7 +573,7 @@ public Task SetServicePropertiesAsync(ServiceProperties properties, QueueRequest /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetServiceProperties, this.EndSetServiceProperties, properties, options, operationContext, cancellationToken); } @@ -587,7 +587,7 @@ public Task SetServicePropertiesAsync(ServiceProperties properties, QueueRequest /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetServiceProperties(ServiceProperties properties, QueueRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual void SetServiceProperties(ServiceProperties properties, QueueRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = QueueRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -602,7 +602,7 @@ public void SetServiceProperties(ServiceProperties properties, QueueRequestOptio /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceStats(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceStats(AsyncCallback callback, object state) { return this.BeginGetServiceStats(null /* requestOptions */, null /* operationContext */, callback, state); } @@ -616,7 +616,7 @@ public ICancellableAsyncResult BeginGetServiceStats(AsyncCallback callback, obje /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceStats(QueueRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceStats(QueueRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = QueueRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -633,7 +633,7 @@ public ICancellableAsyncResult BeginGetServiceStats(QueueRequestOptions requestO /// /// An that references the pending asynchronous operation. /// A object. - public ServiceStats EndGetServiceStats(IAsyncResult asyncResult) + public virtual ServiceStats EndGetServiceStats(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -644,7 +644,7 @@ public ServiceStats EndGetServiceStats(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServiceStatsAsync() + public virtual Task GetServiceStatsAsync() { return this.GetServiceStatsAsync(CancellationToken.None); } @@ -655,7 +655,7 @@ public Task GetServiceStatsAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServiceStatsAsync(CancellationToken cancellationToken) + public virtual Task GetServiceStatsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceStats, this.EndGetServiceStats, cancellationToken); } @@ -667,7 +667,7 @@ public Task GetServiceStatsAsync(CancellationToken cancellationTok /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServiceStatsAsync(QueueRequestOptions requestOptions, OperationContext operationContext) + public virtual Task GetServiceStatsAsync(QueueRequestOptions requestOptions, OperationContext operationContext) { return this.GetServiceStatsAsync(requestOptions, operationContext, CancellationToken.None); } @@ -680,7 +680,7 @@ public Task GetServiceStatsAsync(QueueRequestOptions requestOption /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServiceStatsAsync(QueueRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServiceStatsAsync(QueueRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceStats, this.EndGetServiceStats, requestOptions, operationContext, cancellationToken); } @@ -694,7 +694,7 @@ public Task GetServiceStatsAsync(QueueRequestOptions requestOption /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public ServiceStats GetServiceStats(QueueRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual ServiceStats GetServiceStats(QueueRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = QueueRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); diff --git a/Lib/ClassLibraryCommon/Table/CloudTable.cs b/Lib/ClassLibraryCommon/Table/CloudTable.cs index 7e0f8e318..39a70c9a0 100644 --- a/Lib/ClassLibraryCommon/Table/CloudTable.cs +++ b/Lib/ClassLibraryCommon/Table/CloudTable.cs @@ -34,7 +34,7 @@ namespace Microsoft.WindowsAzure.Storage.Table /// /// Represents a Windows Azure table. /// - public sealed partial class CloudTable + public partial class CloudTable { #region TableOperation Execute Methods #if SYNC @@ -46,7 +46,7 @@ public sealed partial class CloudTable /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public TableResult Execute(TableOperation operation, TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual TableResult Execute(TableOperation operation, TableRequestOptions requestOptions = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("operation", operation); @@ -62,7 +62,7 @@ public TableResult Execute(TableOperation operation, TableRequestOptions request /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecute(TableOperation operation, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExecute(TableOperation operation, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("batch", operation); return this.BeginExecute(operation, null /* RequestOptions */, null /* OperationContext */, callback, state); @@ -78,7 +78,7 @@ public ICancellableAsyncResult BeginExecute(TableOperation operation, AsyncCallb /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecute(TableOperation operation, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExecute(TableOperation operation, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("operation", operation); @@ -90,7 +90,7 @@ public ICancellableAsyncResult BeginExecute(TableOperation operation, TableReque /// /// An that references the pending asynchronous operation. /// A containing the result executing the operation on the table. - public TableResult EndExecute(IAsyncResult asyncResult) + public virtual TableResult EndExecute(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -102,7 +102,7 @@ public TableResult EndExecute(IAsyncResult asyncResult) /// A object that represents the operation to perform. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ExecuteAsync(TableOperation operation) + public virtual Task ExecuteAsync(TableOperation operation) { return this.ExecuteAsync(operation, CancellationToken.None); } @@ -114,7 +114,7 @@ public Task ExecuteAsync(TableOperation operation) /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ExecuteAsync(TableOperation operation, CancellationToken cancellationToken) + public virtual Task ExecuteAsync(TableOperation operation, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExecute, this.EndExecute, operation, cancellationToken); } @@ -127,7 +127,7 @@ public Task ExecuteAsync(TableOperation operation, CancellationToke /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ExecuteAsync(TableOperation operation, TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task ExecuteAsync(TableOperation operation, TableRequestOptions requestOptions, OperationContext operationContext) { return this.ExecuteAsync(operation, requestOptions, operationContext, CancellationToken.None); } @@ -141,7 +141,7 @@ public Task ExecuteAsync(TableOperation operation, TableRequestOpti /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ExecuteAsync(TableOperation operation, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExecuteAsync(TableOperation operation, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExecute, this.EndExecute, operation, requestOptions, operationContext, cancellationToken); } @@ -159,7 +159,7 @@ public Task ExecuteAsync(TableOperation operation, TableRequestOpti /// An object that represents the context for the current operation. /// An enumerable collection of objects that contains the results, in order, of each operation in the on the table. [DoesServiceRequest] - public IList ExecuteBatch(TableBatchOperation batch, TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual IList ExecuteBatch(TableBatchOperation batch, TableRequestOptions requestOptions = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("batch", batch); return batch.Execute(this.ServiceClient, this, requestOptions, operationContext); @@ -174,7 +174,7 @@ public IList ExecuteBatch(TableBatchOperation batch, TableRequestOp /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecuteBatch(TableBatchOperation batch, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExecuteBatch(TableBatchOperation batch, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("batch", batch); return this.BeginExecuteBatch(batch, null /* RequestOptions */, null /* OperationContext */, callback, state); @@ -190,7 +190,7 @@ public ICancellableAsyncResult BeginExecuteBatch(TableBatchOperation batch, Asyn /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecuteBatch(TableBatchOperation batch, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExecuteBatch(TableBatchOperation batch, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("batch", batch); @@ -202,7 +202,7 @@ public ICancellableAsyncResult BeginExecuteBatch(TableBatchOperation batch, Tabl /// /// An that references the pending asynchronous operation. /// A enumerable collection of type that contains the results, in order, of each operation in the on the table. - public IList EndExecuteBatch(IAsyncResult asyncResult) + public virtual IList EndExecuteBatch(IAsyncResult asyncResult) { return Executor.EndExecuteAsync>(asyncResult); } @@ -214,7 +214,7 @@ public IList EndExecuteBatch(IAsyncResult asyncResult) /// The object representing the operations to execute on the table. /// A object that is list of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteBatchAsync(TableBatchOperation batch) + public virtual Task> ExecuteBatchAsync(TableBatchOperation batch) { return this.ExecuteBatchAsync(batch, CancellationToken.None); } @@ -226,7 +226,7 @@ public Task> ExecuteBatchAsync(TableBatchOperation batch) /// A to observe while waiting for a task to complete. /// A object that is list of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteBatchAsync(TableBatchOperation batch, CancellationToken cancellationToken) + public virtual Task> ExecuteBatchAsync(TableBatchOperation batch, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExecuteBatch, this.EndExecuteBatch, batch, cancellationToken); } @@ -239,7 +239,7 @@ public Task> ExecuteBatchAsync(TableBatchOperation batch, Can /// An object that represents the context for the current operation. /// A object that is list of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteBatchAsync(TableBatchOperation batch, TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task> ExecuteBatchAsync(TableBatchOperation batch, TableRequestOptions requestOptions, OperationContext operationContext) { return this.ExecuteBatchAsync(batch, requestOptions, operationContext, CancellationToken.None); } @@ -253,7 +253,7 @@ public Task> ExecuteBatchAsync(TableBatchOperation batch, Tab /// A to observe while waiting for a task to complete. /// A object that is list of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteBatchAsync(TableBatchOperation batch, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> ExecuteBatchAsync(TableBatchOperation batch, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExecuteBatch, this.EndExecuteBatch, batch, requestOptions, operationContext, cancellationToken); } @@ -272,7 +272,7 @@ public Task> ExecuteBatchAsync(TableBatchOperation batch, Tab /// An object that represents the context for the current operation. /// An enumerable collection of objects, representing table entities returned by the query. [DoesServiceRequest] - public IEnumerable ExecuteQuery(TableQuery query, TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual IEnumerable ExecuteQuery(TableQuery query, TableRequestOptions requestOptions = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("query", query); return query.Execute(this.ServiceClient, this, requestOptions, operationContext); @@ -287,7 +287,7 @@ public IEnumerable ExecuteQuery(TableQuery query, TableReque /// An object that represents the context for the current operation. /// A object of type containing the results of executing the query. [DoesServiceRequest] - public TableQuerySegment ExecuteQuerySegmented(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual TableQuerySegment ExecuteQuerySegmented(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("query", query); return query.ExecuteQuerySegmented(token, this.ServiceClient, this, requestOptions, operationContext); @@ -303,7 +303,7 @@ public TableQuerySegment ExecuteQuerySegmented(TableQuery qu /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, TableContinuationToken token, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, TableContinuationToken token, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("query", query); return this.BeginExecuteQuerySegmented(query, token, null /* RequestOptions */, null /* OperationContext */, callback, state); @@ -320,7 +320,7 @@ public ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, Tabl /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("query", query); return query.BeginExecuteQuerySegmented(token, this.ServiceClient, this, requestOptions, operationContext, callback, state); @@ -331,7 +331,7 @@ public ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, Tabl /// /// An that references the pending asynchronous operation. /// A object of type containing the results of executing the query. - public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult asyncResult) + public virtual TableQuerySegment EndExecuteQuerySegmented(IAsyncResult asyncResult) { return Executor.EndExecuteAsync>(asyncResult); } @@ -344,7 +344,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResu /// A object representing a continuation token from the server when the operation returns a partial result. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token) + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token) { return this.ExecuteQuerySegmentedAsync(query, token, CancellationToken.None); } @@ -357,7 +357,7 @@ public Task> ExecuteQuerySegmentedAsync(Ta /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, CancellationToken cancellationToken) + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExecuteQuerySegmented, this.EndExecuteQuerySegmented, query, token, cancellationToken); } @@ -371,7 +371,7 @@ public Task> ExecuteQuerySegmentedAsync(Ta /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) { return this.ExecuteQuerySegmentedAsync(query, token, requestOptions, operationContext, CancellationToken.None); } @@ -386,7 +386,7 @@ public Task> ExecuteQuerySegmentedAsync(Ta /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExecuteQuerySegmented, this.EndExecuteQuerySegmented, query, token, requestOptions, operationContext, cancellationToken); } @@ -403,7 +403,7 @@ public Task> ExecuteQuerySegmentedAsync(Ta /// An object that represents the context for the current operation. /// An enumerable collection, containing the projection into type TResult, of the results of executing the query. [DoesServiceRequest] - public IEnumerable ExecuteQuery(TableQuery query, EntityResolver resolver, TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual IEnumerable ExecuteQuery(TableQuery query, EntityResolver resolver, TableRequestOptions requestOptions = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("query", query); CommonUtility.AssertNotNull("resolver", resolver); @@ -420,7 +420,7 @@ public IEnumerable ExecuteQuery(TableQuery query, EntityResolv /// An object that represents the context for the current operation. /// A object containing the results of executing the query. [DoesServiceRequest] - public TableQuerySegment ExecuteQuerySegmented(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual TableQuerySegment ExecuteQuerySegmented(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions = null, OperationContext operationContext = null) { CommonUtility.AssertNotNull("query", query); return query.ExecuteQuerySegmented(token, this.ServiceClient, this, resolver, requestOptions, operationContext); @@ -437,7 +437,7 @@ public TableQuerySegment ExecuteQuerySegmented(TableQuery quer /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, EntityResolver resolver, TableContinuationToken token, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, EntityResolver resolver, TableContinuationToken token, AsyncCallback callback, object state) { return this.BeginExecuteQuerySegmented(query, resolver, token, null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -455,7 +455,7 @@ public ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery qu /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { CommonUtility.AssertNotNull("query", query); CommonUtility.AssertNotNull("resolver", resolver); @@ -472,7 +472,7 @@ public ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery qu /// A object representing a continuation token from the server when the operation returns a partial result. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token) + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token) { return this.ExecuteQuerySegmentedAsync(query, resolver, token, CancellationToken.None); } @@ -487,7 +487,7 @@ public Task> ExecuteQuerySegmentedAsync(Tabl /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, CancellationToken cancellationToken) + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExecuteQuerySegmented, this.EndExecuteQuerySegmented, query, resolver, token, cancellationToken); } @@ -503,7 +503,7 @@ public Task> ExecuteQuerySegmentedAsync(Tabl /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) { return this.ExecuteQuerySegmentedAsync(query, resolver, token, requestOptions, operationContext, CancellationToken.None); } @@ -520,7 +520,7 @@ public Task> ExecuteQuerySegmentedAsync(Tabl /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExecuteQuerySegmented, this.EndExecuteQuerySegmented, query, resolver, token, requestOptions, operationContext, cancellationToken); } @@ -541,7 +541,7 @@ public Task> ExecuteQuerySegmentedAsync(Tabl /// including , , and . To use these methods, include a using /// statement that references the namespace. /// - public TableQuery CreateQuery() where TElement : ITableEntity, new() + public virtual TableQuery CreateQuery() where TElement : ITableEntity, new() { return new TableQuery(this); } @@ -556,7 +556,7 @@ public Task> ExecuteQuerySegmentedAsync(Tabl /// An object that represents the context for the current operation. /// An enumerable collection, specialized for type TElement, of the results of executing the query. [DoesServiceRequest] - public IEnumerable ExecuteQuery(TableQuery query, TableRequestOptions requestOptions = null, OperationContext operationContext = null) where TElement : ITableEntity, new() + public virtual IEnumerable ExecuteQuery(TableQuery query, TableRequestOptions requestOptions = null, OperationContext operationContext = null) where TElement : ITableEntity, new() { CommonUtility.AssertNotNull("query", query); if (query.Provider != null) @@ -579,7 +579,7 @@ public Task> ExecuteQuerySegmentedAsync(Tabl /// An object that represents the context for the current operation. /// A , specialized for type TElement, containing the results of executing the query. [DoesServiceRequest] - public TableQuerySegment ExecuteQuerySegmented(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions = null, OperationContext operationContext = null) where TElement : ITableEntity, new() + public virtual TableQuerySegment ExecuteQuerySegmented(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions = null, OperationContext operationContext = null) where TElement : ITableEntity, new() { CommonUtility.AssertNotNull("query", query); if (query.Provider != null) @@ -603,7 +603,7 @@ public Task> ExecuteQuerySegmentedAsync(Tabl /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, TableContinuationToken token, AsyncCallback callback, object state) where TElement : ITableEntity, new() + public virtual ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, TableContinuationToken token, AsyncCallback callback, object state) where TElement : ITableEntity, new() { CommonUtility.AssertNotNull("query", query); return this.BeginExecuteQuerySegmented(query, token, null /* RequestOptions */, null /* OperationContext */, callback, state); @@ -621,7 +621,7 @@ public Task> ExecuteQuerySegmentedAsync(Tabl /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) where TElement : ITableEntity, new() + public virtual ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) where TElement : ITableEntity, new() { CommonUtility.AssertNotNull("query", query); if (query.Provider != null) @@ -640,7 +640,7 @@ public Task> ExecuteQuerySegmentedAsync(Tabl /// The type of the results to be returned. Can be the entity type specified in the Begin or the result type of the resolver /// An that references the pending asynchronous operation. /// A containing the results of executing the query. - public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult asyncResult) + public virtual TableQuerySegment EndExecuteQuerySegmented(IAsyncResult asyncResult) { return Executor.EndExecuteAsync>(asyncResult); } @@ -654,7 +654,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// A object representing a continuation token from the server when the operation returns a partial result. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token) where TElement : ITableEntity, new() + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token) where TElement : ITableEntity, new() { return this.ExecuteQuerySegmentedAsync(query, token, CancellationToken.None); } @@ -668,7 +668,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, CancellationToken cancellationToken) where TElement : ITableEntity, new() + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, CancellationToken cancellationToken) where TElement : ITableEntity, new() { return AsyncExtensions.TaskFromApm(this.BeginExecuteQuerySegmented, this.EndExecuteQuerySegmented, query, token, cancellationToken); } @@ -683,7 +683,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) where TElement : ITableEntity, new() + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) where TElement : ITableEntity, new() { return this.ExecuteQuerySegmentedAsync(query, token, requestOptions, operationContext, CancellationToken.None); } @@ -699,7 +699,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) where TElement : ITableEntity, new() + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) where TElement : ITableEntity, new() { return AsyncExtensions.TaskFromApm(this.BeginExecuteQuerySegmented, this.EndExecuteQuerySegmented, query, token, requestOptions, operationContext, cancellationToken); } @@ -720,7 +720,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// An object that represents the context for the current operation. /// An enumerable collection, containing the projection into type TResult, of the results of executing the query. [DoesServiceRequest] - public IEnumerable ExecuteQuery(TableQuery query, EntityResolver resolver, TableRequestOptions requestOptions = null, OperationContext operationContext = null) where TElement : ITableEntity, new() + public virtual IEnumerable ExecuteQuery(TableQuery query, EntityResolver resolver, TableRequestOptions requestOptions = null, OperationContext operationContext = null) where TElement : ITableEntity, new() { CommonUtility.AssertNotNull("query", query); CommonUtility.AssertNotNull("resolver", resolver); @@ -746,7 +746,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// An object that represents the context for the current operation. /// A containing the projection into type TResult of the results of executing the query. [DoesServiceRequest] - public TableQuerySegment ExecuteQuerySegmented(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions = null, OperationContext operationContext = null) where TElement : ITableEntity, new() + public virtual TableQuerySegment ExecuteQuerySegmented(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions = null, OperationContext operationContext = null) where TElement : ITableEntity, new() { CommonUtility.AssertNotNull("query", query); CommonUtility.AssertNotNull("resolver", resolver); @@ -773,7 +773,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, EntityResolver resolver, TableContinuationToken token, AsyncCallback callback, object state) where TElement : ITableEntity, new() + public virtual ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, EntityResolver resolver, TableContinuationToken token, AsyncCallback callback, object state) where TElement : ITableEntity, new() { return this.BeginExecuteQuerySegmented(query, resolver, token, null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -792,7 +792,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) where TElement : ITableEntity, new() + public virtual ICancellableAsyncResult BeginExecuteQuerySegmented(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) where TElement : ITableEntity, new() { CommonUtility.AssertNotNull("query", query); CommonUtility.AssertNotNull("resolver", resolver); @@ -814,7 +814,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// An that references the pending asynchronous operation. /// A containing the projection into type TResult of the results of executing the query. [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Reveiewed.")] - public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult asyncResult) where TElement : ITableEntity, new() + public virtual TableQuerySegment EndExecuteQuerySegmented(IAsyncResult asyncResult) where TElement : ITableEntity, new() { return Executor.EndExecuteAsync>(asyncResult); } @@ -830,7 +830,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// A object representing a continuation token from the server when the operation returns a partial result. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token) where TElement : ITableEntity, new() + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token) where TElement : ITableEntity, new() { return this.ExecuteQuerySegmentedAsync(query, resolver, token, CancellationToken.None); } @@ -846,7 +846,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, CancellationToken cancellationToken) where TElement : ITableEntity, new() + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, CancellationToken cancellationToken) where TElement : ITableEntity, new() { return AsyncExtensions.TaskFromApm(this.BeginExecuteQuerySegmented, this.EndExecuteQuerySegmented, query, resolver, token, cancellationToken); } @@ -863,7 +863,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) where TElement : ITableEntity, new() + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) where TElement : ITableEntity, new() { return this.ExecuteQuerySegmentedAsync(query, resolver, token, requestOptions, operationContext, CancellationToken.None); } @@ -881,7 +881,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) where TElement : ITableEntity, new() + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) where TElement : ITableEntity, new() { return AsyncExtensions.TaskFromApm(this.BeginExecuteQuerySegmented, this.EndExecuteQuerySegmented, query, resolver, token, requestOptions, operationContext, cancellationToken); } @@ -899,7 +899,7 @@ public TableQuerySegment EndExecuteQuerySegmented(IAsyncResult /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Create(TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual void Create(TableRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = TableRequestOptions.ApplyDefaultsAndClearEncryption(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -920,7 +920,7 @@ public void Create(TableRequestOptions requestOptions = null, OperationContext o /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) { return this.BeginCreate(null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -934,7 +934,7 @@ public ICancellableAsyncResult BeginCreate(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreate(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreate(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = TableRequestOptions.ApplyDefaultsAndClearEncryption(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -952,7 +952,7 @@ public ICancellableAsyncResult BeginCreate(TableRequestOptions requestOptions, O /// Ends an asynchronous operation to create a table. /// /// An that references the pending asynchronous operation. - public void EndCreate(IAsyncResult asyncResult) + public virtual void EndCreate(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -963,7 +963,7 @@ public void EndCreate(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync() + public virtual Task CreateAsync() { return this.CreateAsync(CancellationToken.None); } @@ -974,7 +974,7 @@ public Task CreateAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync(CancellationToken cancellationToken) + public virtual Task CreateAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, cancellationToken); } @@ -986,7 +986,7 @@ public Task CreateAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync(TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task CreateAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.CreateAsync(requestOptions, operationContext, CancellationToken.None); } @@ -999,7 +999,7 @@ public Task CreateAsync(TableRequestOptions requestOptions, OperationContext ope /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task CreateAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginCreate, this.EndCreate, requestOptions, operationContext, cancellationToken); } @@ -1015,8 +1015,9 @@ public Task CreateAsync(TableRequestOptions requestOptions, OperationContext ope /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// true if table was created; otherwise, false. + /// This API performs an existence check and therefore requires list permissions. [DoesServiceRequest] - public bool CreateIfNotExists(TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual bool CreateIfNotExists(TableRequestOptions requestOptions = null, OperationContext operationContext = null) { TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1061,8 +1062,9 @@ public bool CreateIfNotExists(TableRequestOptions requestOptions = null, Operati /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. + /// This API performs an existence check and therefore requires list permissions. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, object state) { return this.BeginCreateIfNotExists(null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -1075,8 +1077,9 @@ public ICancellableAsyncResult BeginCreateIfNotExists(AsyncCallback callback, ob /// An delegate that will receive notification when the asynchronous operation completes. /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. + /// This API performs an existence check and therefore requires list permissions. [DoesServiceRequest] - public ICancellableAsyncResult BeginCreateIfNotExists(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginCreateIfNotExists(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1173,7 +1176,7 @@ private void CreateIfNotExistHandler(IAsyncResult asyncResult) /// /// An that references the pending asynchronous operation. /// true if table was created; otherwise, false. - public bool EndCreateIfNotExists(IAsyncResult asyncResult) + public virtual bool EndCreateIfNotExists(IAsyncResult asyncResult) { StorageAsyncResult res = asyncResult as StorageAsyncResult; CommonUtility.AssertNotNull("AsyncResult", res); @@ -1186,8 +1189,9 @@ public bool EndCreateIfNotExists(IAsyncResult asyncResult) /// Initiates an asynchronous operation to create a table if it does not already exist. /// /// A object of type bool that represents the asynchronous operation. + /// This API performs an existence check and therefore requires list permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync() + public virtual Task CreateIfNotExistsAsync() { return this.CreateIfNotExistsAsync(CancellationToken.None); } @@ -1197,8 +1201,9 @@ public Task CreateIfNotExistsAsync() /// /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. + /// This API performs an existence check and therefore requires list permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(CancellationToken cancellationToken) + public virtual Task CreateIfNotExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateIfNotExists, this.EndCreateIfNotExists, cancellationToken); } @@ -1209,8 +1214,9 @@ public Task CreateIfNotExistsAsync(CancellationToken cancellationToken) /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A object of type bool that represents the asynchronous operation. + /// This API performs an existence check and therefore requires list permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task CreateIfNotExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.CreateIfNotExistsAsync(requestOptions, operationContext, CancellationToken.None); } @@ -1222,8 +1228,9 @@ public Task CreateIfNotExistsAsync(TableRequestOptions requestOptions, Ope /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. + /// This API performs an existence check and therefore requires list permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateIfNotExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginCreateIfNotExists, this.EndCreateIfNotExists, requestOptions, operationContext, cancellationToken); } @@ -1239,7 +1246,7 @@ public Task CreateIfNotExistsAsync(TableRequestOptions requestOptions, Ope /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void Delete(TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual void Delete(TableRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1260,7 +1267,7 @@ public void Delete(TableRequestOptions requestOptions = null, OperationContext o /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) { return this.BeginDelete(null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -1274,7 +1281,7 @@ public ICancellableAsyncResult BeginDelete(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDelete(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDelete(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1292,7 +1299,7 @@ public ICancellableAsyncResult BeginDelete(TableRequestOptions requestOptions, O /// Ends an asynchronous operation to delete a table. /// /// An that references the pending asynchronous operation. - public void EndDelete(IAsyncResult asyncResult) + public virtual void EndDelete(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1303,7 +1310,7 @@ public void EndDelete(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync() + public virtual Task DeleteAsync() { return this.DeleteAsync(CancellationToken.None); } @@ -1314,7 +1321,7 @@ public Task DeleteAsync() /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync(CancellationToken cancellationToken) + public virtual Task DeleteAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, cancellationToken); } @@ -1326,7 +1333,7 @@ public Task DeleteAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync(TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task DeleteAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.DeleteAsync(requestOptions, operationContext, CancellationToken.None); } @@ -1339,7 +1346,7 @@ public Task DeleteAsync(TableRequestOptions requestOptions, OperationContext ope /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginDelete, this.EndDelete, requestOptions, operationContext, cancellationToken); } @@ -1356,7 +1363,7 @@ public Task DeleteAsync(TableRequestOptions requestOptions, OperationContext ope /// An object that represents the context for the current operation. /// true if the table was deleted; otherwise, false. [DoesServiceRequest] - public bool DeleteIfExists(TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual bool DeleteIfExists(TableRequestOptions requestOptions = null, OperationContext operationContext = null) { TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1402,7 +1409,7 @@ public bool DeleteIfExists(TableRequestOptions requestOptions = null, OperationC /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, object state) { return this.BeginDeleteIfExists(null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -1416,7 +1423,7 @@ public ICancellableAsyncResult BeginDeleteIfExists(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginDeleteIfExists(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginDeleteIfExists(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1512,7 +1519,7 @@ private void DeleteIfExistsHandler(IAsyncResult asyncResult) /// /// An that references the pending asynchronous operation. /// true if the table was deleted; otherwise, false. - public bool EndDeleteIfExists(IAsyncResult asyncResult) + public virtual bool EndDeleteIfExists(IAsyncResult asyncResult) { StorageAsyncResult res = asyncResult as StorageAsyncResult; CommonUtility.AssertNotNull("AsyncResult", res); @@ -1526,7 +1533,7 @@ public bool EndDeleteIfExists(IAsyncResult asyncResult) /// /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync() + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(CancellationToken.None); } @@ -1537,7 +1544,7 @@ public Task DeleteIfExistsAsync() /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, cancellationToken); } @@ -1549,7 +1556,7 @@ public Task DeleteIfExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task DeleteIfExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.DeleteIfExistsAsync(requestOptions, operationContext, CancellationToken.None); } @@ -1562,7 +1569,7 @@ public Task DeleteIfExistsAsync(TableRequestOptions requestOptions, Operat /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task DeleteIfExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, requestOptions, operationContext, cancellationToken); } @@ -1578,7 +1585,7 @@ public Task DeleteIfExistsAsync(TableRequestOptions requestOptions, Operat /// An object that represents the context for the current operation. /// true if table exists; otherwise, false. [DoesServiceRequest] - public bool Exists(TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual bool Exists(TableRequestOptions requestOptions = null, OperationContext operationContext = null) { return this.Exists(false, requestOptions, operationContext); } @@ -1616,7 +1623,7 @@ private bool Exists(bool primaryOnly, TableRequestOptions requestOptions, Operat /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) { return this.BeginExists(null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -1630,7 +1637,7 @@ public ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExists(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExists(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { return this.BeginExists(false, requestOptions, operationContext, callback, state); } @@ -1664,7 +1671,7 @@ private ICancellableAsyncResult BeginExists(bool primaryOnly, TableRequestOption /// /// An that references the pending asynchronous operation. /// true if table exists; otherwise, false. - public bool EndExists(IAsyncResult asyncResult) + public virtual bool EndExists(IAsyncResult asyncResult) { TableResult res = Executor.EndExecuteAsync(asyncResult); @@ -1678,7 +1685,7 @@ public bool EndExists(IAsyncResult asyncResult) /// /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync() + public virtual Task ExistsAsync() { return this.ExistsAsync(CancellationToken.None); } @@ -1689,7 +1696,7 @@ public Task ExistsAsync() /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync(CancellationToken cancellationToken) + public virtual Task ExistsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, cancellationToken); } @@ -1701,7 +1708,7 @@ public Task ExistsAsync(CancellationToken cancellationToken) /// An object that represents the context for the current operation. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task ExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.ExistsAsync(requestOptions, operationContext, CancellationToken.None); } @@ -1714,7 +1721,7 @@ public Task ExistsAsync(TableRequestOptions requestOptions, OperationConte /// A to observe while waiting for a task to complete. /// A object of type bool that represents the asynchronous operation. [DoesServiceRequest] - public Task ExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExists, this.EndExists, requestOptions, operationContext, cancellationToken); } @@ -1731,7 +1738,7 @@ public Task ExistsAsync(TableRequestOptions requestOptions, OperationConte /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public TablePermissions GetPermissions(TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual TablePermissions GetPermissions(TableRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1747,7 +1754,7 @@ public TablePermissions GetPermissions(TableRequestOptions requestOptions = null /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetPermissions(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetPermissions(AsyncCallback callback, object state) { return this.BeginGetPermissions(null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -1761,7 +1768,7 @@ public ICancellableAsyncResult BeginGetPermissions(AsyncCallback callback, objec /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetPermissions(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetPermissions(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1778,7 +1785,7 @@ public ICancellableAsyncResult BeginGetPermissions(TableRequestOptions requestOp /// /// An that references the pending asynchronous operation. /// A object. - public TablePermissions EndGetPermissions(IAsyncResult asyncResult) + public virtual TablePermissions EndGetPermissions(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -1789,7 +1796,7 @@ public TablePermissions EndGetPermissions(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync() + public virtual Task GetPermissionsAsync() { return this.GetPermissionsAsync(CancellationToken.None); } @@ -1800,7 +1807,7 @@ public Task GetPermissionsAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync(CancellationToken cancellationToken) + public virtual Task GetPermissionsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetPermissions, this.EndGetPermissions, cancellationToken); } @@ -1812,7 +1819,7 @@ public Task GetPermissionsAsync(CancellationToken cancellation /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync(TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task GetPermissionsAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.GetPermissionsAsync(requestOptions, operationContext, CancellationToken.None); } @@ -1825,7 +1832,7 @@ public Task GetPermissionsAsync(TableRequestOptions requestOpt /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetPermissionsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetPermissionsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetPermissions, this.EndGetPermissions, requestOptions, operationContext, cancellationToken); } @@ -1865,7 +1872,7 @@ private TablePermissions ParseGetAcl(RESTCommand cmd, HttpWebR /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetPermissions(TablePermissions permissions, TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual void SetPermissions(TablePermissions permissions, TableRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1881,7 +1888,7 @@ public void SetPermissions(TablePermissions permissions, TableRequestOptions req /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetPermissions(TablePermissions permissions, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetPermissions(TablePermissions permissions, AsyncCallback callback, object state) { return this.BeginSetPermissions(permissions, null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -1896,7 +1903,7 @@ public ICancellableAsyncResult BeginSetPermissions(TablePermissions permissions, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetPermissions(TablePermissions permissions, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetPermissions(TablePermissions permissions, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1912,7 +1919,7 @@ public ICancellableAsyncResult BeginSetPermissions(TablePermissions permissions, /// Returns the asynchronous result of the request to get the permissions settings for the table. /// /// An that references the pending asynchronous operation. - public void EndSetPermissions(IAsyncResult asyncResult) + public virtual void EndSetPermissions(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -1924,7 +1931,7 @@ public void EndSetPermissions(IAsyncResult asyncResult) /// A object that represents the permissions to set. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(TablePermissions permissions) + public virtual Task SetPermissionsAsync(TablePermissions permissions) { return this.SetPermissionsAsync(permissions, CancellationToken.None); } @@ -1936,7 +1943,7 @@ public Task SetPermissionsAsync(TablePermissions permissions) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(TablePermissions permissions, CancellationToken cancellationToken) + public virtual Task SetPermissionsAsync(TablePermissions permissions, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetPermissions, this.EndSetPermissions, permissions, cancellationToken); } @@ -1949,7 +1956,7 @@ public Task SetPermissionsAsync(TablePermissions permissions, CancellationToken /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(TablePermissions permissions, TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task SetPermissionsAsync(TablePermissions permissions, TableRequestOptions requestOptions, OperationContext operationContext) { return this.SetPermissionsAsync(permissions, requestOptions, operationContext, CancellationToken.None); } @@ -1963,7 +1970,7 @@ public Task SetPermissionsAsync(TablePermissions permissions, TableRequestOption /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetPermissionsAsync(TablePermissions permissions, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetPermissionsAsync(TablePermissions permissions, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetPermissions, this.EndSetPermissions, permissions, requestOptions, operationContext, cancellationToken); } diff --git a/Lib/ClassLibraryCommon/Table/CloudTableClient.cs b/Lib/ClassLibraryCommon/Table/CloudTableClient.cs index 25cf42604..02adbf5f6 100644 --- a/Lib/ClassLibraryCommon/Table/CloudTableClient.cs +++ b/Lib/ClassLibraryCommon/Table/CloudTableClient.cs @@ -40,7 +40,7 @@ namespace Microsoft.WindowsAzure.Storage.Table /// Provides a client-side logical representation of the Windows Azure Table Service. This client is used to configure and execute requests against the Table Service. /// /// The service client encapsulates the endpoint or endpoints for the Table service. If the service client will be used for authenticated access, it also encapsulates the credentials for accessing the storage account. - public sealed partial class CloudTableClient + public partial class CloudTableClient { private IAuthenticationHandler authenticationHandler; @@ -110,7 +110,7 @@ internal IAuthenticationHandler AuthenticationHandler /// An object that represents the context for the current operation. /// An enumerable collection of objects that are retrieved lazily. [DoesServiceRequest] - public IEnumerable ListTables(string prefix = null, TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual IEnumerable ListTables(string prefix = null, TableRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = TableRequestOptions.ApplyDefaultsAndClearEncryption(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -126,7 +126,7 @@ public IEnumerable ListTables(string prefix = null, TableRequestOpti /// A returned by a previous listing operation. /// A object. [DoesServiceRequest] - public TableResultSegment ListTablesSegmented(TableContinuationToken currentToken) + public virtual TableResultSegment ListTablesSegmented(TableContinuationToken currentToken) { return this.ListTablesSegmented(null, currentToken); } @@ -138,7 +138,7 @@ public TableResultSegment ListTablesSegmented(TableContinuationToken currentToke /// A returned by a previous listing operation. /// A object. [DoesServiceRequest] - public TableResultSegment ListTablesSegmented(string prefix, TableContinuationToken currentToken) + public virtual TableResultSegment ListTablesSegmented(string prefix, TableContinuationToken currentToken) { return this.ListTablesSegmented(prefix, null, currentToken); } @@ -154,7 +154,7 @@ public TableResultSegment ListTablesSegmented(string prefix, TableContinuationTo /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public TableResultSegment ListTablesSegmented(string prefix, int? maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual TableResultSegment ListTablesSegmented(string prefix, int? maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = TableRequestOptions.ApplyDefaultsAndClearEncryption(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -179,7 +179,7 @@ public TableResultSegment ListTablesSegmented(string prefix, int? maxResults, Ta /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListTablesSegmented(TableContinuationToken currentToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListTablesSegmented(TableContinuationToken currentToken, AsyncCallback callback, object state) { return this.BeginListTablesSegmented(null, currentToken, callback, state); } @@ -193,7 +193,7 @@ public ICancellableAsyncResult BeginListTablesSegmented(TableContinuationToken c /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListTablesSegmented(string prefix, TableContinuationToken currentToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListTablesSegmented(string prefix, TableContinuationToken currentToken, AsyncCallback callback, object state) { return this.BeginListTablesSegmented(prefix, null, currentToken, null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -211,7 +211,7 @@ public ICancellableAsyncResult BeginListTablesSegmented(string prefix, TableCont /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginListTablesSegmented(string prefix, int? maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginListTablesSegmented(string prefix, int? maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = TableRequestOptions.ApplyDefaultsAndClearEncryption(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -232,7 +232,7 @@ public ICancellableAsyncResult BeginListTablesSegmented(string prefix, int? maxR /// /// An that references the pending asynchronous operation. /// A object. - public TableResultSegment EndListTablesSegmented(IAsyncResult asyncResult) + public virtual TableResultSegment EndListTablesSegmented(IAsyncResult asyncResult) { TableQuerySegment res = Executor.EndExecuteAsync>(asyncResult); @@ -251,7 +251,7 @@ public TableResultSegment EndListTablesSegmented(IAsyncResult asyncResult) /// A returned by a previous listing operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListTablesSegmentedAsync(TableContinuationToken currentToken) + public virtual Task ListTablesSegmentedAsync(TableContinuationToken currentToken) { return this.ListTablesSegmentedAsync(currentToken, CancellationToken.None); } @@ -263,7 +263,7 @@ public Task ListTablesSegmentedAsync(TableContinuationToken /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListTablesSegmentedAsync(TableContinuationToken currentToken, CancellationToken cancellationToken) + public virtual Task ListTablesSegmentedAsync(TableContinuationToken currentToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListTablesSegmented, this.EndListTablesSegmented, currentToken, cancellationToken); } @@ -275,7 +275,7 @@ public Task ListTablesSegmentedAsync(TableContinuationToken /// A returned by a previous listing operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListTablesSegmentedAsync(string prefix, TableContinuationToken currentToken) + public virtual Task ListTablesSegmentedAsync(string prefix, TableContinuationToken currentToken) { return this.ListTablesSegmentedAsync(prefix, currentToken, CancellationToken.None); } @@ -288,7 +288,7 @@ public Task ListTablesSegmentedAsync(string prefix, TableCon /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListTablesSegmentedAsync(string prefix, TableContinuationToken currentToken, CancellationToken cancellationToken) + public virtual Task ListTablesSegmentedAsync(string prefix, TableContinuationToken currentToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListTablesSegmented, this.EndListTablesSegmented, prefix, currentToken, cancellationToken); } @@ -304,7 +304,7 @@ public Task ListTablesSegmentedAsync(string prefix, TableCon /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListTablesSegmentedAsync(string prefix, int? maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task ListTablesSegmentedAsync(string prefix, int? maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext) { return this.ListTablesSegmentedAsync(prefix, maxResults, currentToken, requestOptions, operationContext, CancellationToken.None); } @@ -321,7 +321,7 @@ public Task ListTablesSegmentedAsync(string prefix, int? max /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task ListTablesSegmentedAsync(string prefix, int? maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ListTablesSegmentedAsync(string prefix, int? maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListTablesSegmented, this.EndListTablesSegmented, prefix, maxResults, currentToken, requestOptions, operationContext, cancellationToken); } @@ -360,7 +360,7 @@ private static TableQuery GenerateListTablesQuery(string pre /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public ServiceProperties GetServiceProperties(TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual ServiceProperties GetServiceProperties(TableRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -375,7 +375,7 @@ public ServiceProperties GetServiceProperties(TableRequestOptions requestOptions /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceProperties(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceProperties(AsyncCallback callback, object state) { return this.BeginGetServiceProperties(null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -389,7 +389,7 @@ public ICancellableAsyncResult BeginGetServiceProperties(AsyncCallback callback, /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceProperties(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceProperties(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -401,7 +401,7 @@ public ICancellableAsyncResult BeginGetServiceProperties(TableRequestOptions req /// /// The result returned from a prior call to . /// A object. - public ServiceProperties EndGetServiceProperties(IAsyncResult asyncResult) + public virtual ServiceProperties EndGetServiceProperties(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -412,7 +412,7 @@ public ServiceProperties EndGetServiceProperties(IAsyncResult asyncResult) /// /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync() + public virtual Task GetServicePropertiesAsync() { return this.GetServicePropertiesAsync(CancellationToken.None); } @@ -423,7 +423,7 @@ public Task GetServicePropertiesAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync(CancellationToken cancellationToken) + public virtual Task GetServicePropertiesAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceProperties, this.EndGetServiceProperties, cancellationToken); } @@ -435,7 +435,7 @@ public Task GetServicePropertiesAsync(CancellationToken cance /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync(TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task GetServicePropertiesAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.GetServicePropertiesAsync(requestOptions, operationContext, CancellationToken.None); } @@ -448,7 +448,7 @@ public Task GetServicePropertiesAsync(TableRequestOptions req /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServicePropertiesAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServicePropertiesAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceProperties, this.EndGetServiceProperties, requestOptions, operationContext, cancellationToken); } @@ -462,7 +462,7 @@ public Task GetServicePropertiesAsync(TableRequestOptions req /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public void SetServiceProperties(ServiceProperties properties, TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual void SetServiceProperties(ServiceProperties properties, TableRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -478,7 +478,7 @@ public void SetServiceProperties(ServiceProperties properties, TableRequestOptio /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties properties, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties properties, AsyncCallback callback, object state) { return this.BeginSetServiceProperties(properties, null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -493,7 +493,7 @@ public ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties prope /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties properties, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties properties, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -504,7 +504,7 @@ public ICancellableAsyncResult BeginSetServiceProperties(ServiceProperties prope /// Ends an asynchronous operation to set the service properties of the Table service. /// /// The result returned from a prior call to - public void EndSetServiceProperties(IAsyncResult asyncResult) + public virtual void EndSetServiceProperties(IAsyncResult asyncResult) { Executor.EndExecuteAsync(asyncResult); } @@ -516,7 +516,7 @@ public void EndSetServiceProperties(IAsyncResult asyncResult) /// A object. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties) { return this.SetServicePropertiesAsync(properties, CancellationToken.None); } @@ -528,7 +528,7 @@ public Task SetServicePropertiesAsync(ServiceProperties properties) /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties, CancellationToken cancellationToken) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetServiceProperties, this.EndSetServiceProperties, properties, cancellationToken); } @@ -541,7 +541,7 @@ public Task SetServicePropertiesAsync(ServiceProperties properties, Cancellation /// An object that represents the context for the current operation. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties, TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, TableRequestOptions requestOptions, OperationContext operationContext) { return this.SetServicePropertiesAsync(properties, requestOptions, operationContext, CancellationToken.None); } @@ -555,7 +555,7 @@ public Task SetServicePropertiesAsync(ServiceProperties properties, TableRequest /// A to observe while waiting for a task to complete. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromVoidApm(this.BeginSetServiceProperties, this.EndSetServiceProperties, properties, requestOptions, operationContext, cancellationToken); } @@ -568,7 +568,7 @@ public Task SetServicePropertiesAsync(ServiceProperties properties, TableRequest /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceStats(AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceStats(AsyncCallback callback, object state) { return this.BeginGetServiceStats(null /* requestOptions */, null /* operationContext */, callback, state); } @@ -582,7 +582,7 @@ public ICancellableAsyncResult BeginGetServiceStats(AsyncCallback callback, obje /// A user-defined object to be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginGetServiceStats(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginGetServiceStats(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -599,7 +599,7 @@ public ICancellableAsyncResult BeginGetServiceStats(TableRequestOptions requestO /// /// An that references the pending asynchronous operation. /// A object. - public ServiceStats EndGetServiceStats(IAsyncResult asyncResult) + public virtual ServiceStats EndGetServiceStats(IAsyncResult asyncResult) { return Executor.EndExecuteAsync(asyncResult); } @@ -610,7 +610,7 @@ public ServiceStats EndGetServiceStats(IAsyncResult asyncResult) /// /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServiceStatsAsync() + public virtual Task GetServiceStatsAsync() { return this.GetServiceStatsAsync(CancellationToken.None); } @@ -621,7 +621,7 @@ public Task GetServiceStatsAsync() /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServiceStatsAsync(CancellationToken cancellationToken) + public virtual Task GetServiceStatsAsync(CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceStats, this.EndGetServiceStats, cancellationToken); } @@ -633,7 +633,7 @@ public Task GetServiceStatsAsync(CancellationToken cancellationTok /// An object that represents the context for the current operation. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServiceStatsAsync(TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task GetServiceStatsAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.GetServiceStatsAsync(requestOptions, operationContext, CancellationToken.None); } @@ -646,7 +646,7 @@ public Task GetServiceStatsAsync(TableRequestOptions requestOption /// A to observe while waiting for a task to complete. /// A object of type that represents the asynchronous operation. [DoesServiceRequest] - public Task GetServiceStatsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServiceStatsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginGetServiceStats, this.EndGetServiceStats, requestOptions, operationContext, cancellationToken); } @@ -660,7 +660,7 @@ public Task GetServiceStatsAsync(TableRequestOptions requestOption /// An object that represents the context for the current operation. /// A object. [DoesServiceRequest] - public ServiceStats GetServiceStats(TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual ServiceStats GetServiceStats(TableRequestOptions requestOptions = null, OperationContext operationContext = null) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); diff --git a/Lib/ClassLibraryCommon/Table/Protocol/TableOperationHttpRequestFactory.cs b/Lib/ClassLibraryCommon/Table/Protocol/TableOperationHttpRequestFactory.cs index 05b17024c..2031973f2 100644 --- a/Lib/ClassLibraryCommon/Table/Protocol/TableOperationHttpRequestFactory.cs +++ b/Lib/ClassLibraryCommon/Table/Protocol/TableOperationHttpRequestFactory.cs @@ -61,7 +61,7 @@ internal static Tuple BuildRequestForTableOperation(Uri if (operation.HttpMethod != "HEAD" && operation.HttpMethod != "GET") { - SetContentTypeForHttpWebRequest(msg, payloadFormat); + msg.ContentType = Constants.JsonContentTypeHeaderValue; } if (operation.OperationType == TableOperationType.InsertOrMerge || operation.OperationType == TableOperationType.Merge) @@ -105,7 +105,7 @@ internal static Tuple BuildRequestForTableOperation(Uri HttpWebRequestAdapterMessage adapterMsg = new HttpWebRequestAdapterMessage(msg, bufferManager); if (operation.HttpMethod != "HEAD" && operation.HttpMethod != "GET") { - SetContentTypeForAdapterMessage(adapterMsg, payloadFormat); + adapterMsg.SetHeader(Constants.HeaderConstants.PayloadContentTypeHeader, Constants.JsonContentTypeHeaderValue); } ODataMessageWriter odataWriter = new ODataMessageWriter(adapterMsg, writerSettings, new TableStorageModel(accountName)); @@ -253,14 +253,9 @@ internal static IEnumerable GetPropertiesWithKeys(ITableEntity en #endregion #region Set Headers - #pragma warning disable 0618 private static void SetAcceptHeaderForHttpWebRequest(HttpWebRequest msg, TablePayloadFormat payloadFormat) { - if (payloadFormat == TablePayloadFormat.AtomPub) - { - msg.Accept = Constants.AtomAcceptHeaderValue; - } - else if (payloadFormat == TablePayloadFormat.JsonFullMetadata) + if (payloadFormat == TablePayloadFormat.JsonFullMetadata) { msg.Accept = Constants.JsonFullMetadataAcceptHeaderValue; } @@ -274,38 +269,9 @@ private static void SetAcceptHeaderForHttpWebRequest(HttpWebRequest msg, TablePa } } - private static void SetContentTypeForHttpWebRequest(HttpWebRequest msg, TablePayloadFormat payloadFormat) - { - if (payloadFormat == TablePayloadFormat.AtomPub) - { - msg.ContentType = Constants.AtomContentTypeHeaderValue; - } - else - { - msg.ContentType = Constants.JsonContentTypeHeaderValue; - } - } - - private static void SetContentTypeForAdapterMessage(HttpWebRequestAdapterMessage adapterMsg, TablePayloadFormat payloadFormat) - { - if (payloadFormat == TablePayloadFormat.AtomPub) - { - adapterMsg.SetHeader(Constants.HeaderConstants.PayloadContentTypeHeader, Constants.AtomContentTypeHeaderValue); - } - else - { - adapterMsg.SetHeader(Constants.HeaderConstants.PayloadContentTypeHeader, Constants.JsonContentTypeHeaderValue); - } - } - private static void SetAcceptAndContentTypeForODataBatchMessage(ODataBatchOperationRequestMessage mimePartMsg, TablePayloadFormat payloadFormat) { - if (payloadFormat == TablePayloadFormat.AtomPub) - { - mimePartMsg.SetHeader(Constants.HeaderConstants.PayloadAcceptHeader, Constants.AtomAcceptHeaderValue); - mimePartMsg.SetHeader(Constants.HeaderConstants.PayloadContentTypeHeader, Constants.AtomContentTypeHeaderValue); - } - else if (payloadFormat == TablePayloadFormat.JsonFullMetadata) + if (payloadFormat == TablePayloadFormat.JsonFullMetadata) { mimePartMsg.SetHeader(Constants.HeaderConstants.PayloadAcceptHeader, Constants.JsonFullMetadataAcceptHeaderValue); mimePartMsg.SetHeader(Constants.HeaderConstants.PayloadContentTypeHeader, Constants.JsonContentTypeHeaderValue); @@ -321,7 +287,6 @@ private static void SetAcceptAndContentTypeForODataBatchMessage(ODataBatchOperat mimePartMsg.SetHeader(Constants.HeaderConstants.PayloadContentTypeHeader, Constants.JsonContentTypeHeaderValue); } } - #pragma warning restore 0618 #endregion } } diff --git a/Lib/ClassLibraryCommon/Table/Protocol/TableOperationHttpResponseParsers.cs b/Lib/ClassLibraryCommon/Table/Protocol/TableOperationHttpResponseParsers.cs index 2278d5f46..aa5adbbe0 100644 --- a/Lib/ClassLibraryCommon/Table/Protocol/TableOperationHttpResponseParsers.cs +++ b/Lib/ClassLibraryCommon/Table/Protocol/TableOperationHttpResponseParsers.cs @@ -205,6 +205,15 @@ internal static IList TableBatchOperationPostProcess(IList TableBatchOperationPostProcess(IList { #region Factories - /// - /// Inserts a into the batch that retrieves an entity based on its row key and partition key. The entity will be deserialized into the specified class type which extends . - /// - /// The class of type for the entity to retrieve. - /// A string containing the partition key of the entity to retrieve. - /// A string containing the row key of the entity to retrieve. - [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Reviewed.")] - public void Retrieve(string partitionKey, string rowKey) where TElement : ITableEntity - { - Retrieve(partitionKey, rowKey, selectedColumns: null); - } - /// /// Inserts a into the batch that retrieves an entity based on its row key and partition key. The entity will be deserialized into the specified class type which extends . /// @@ -64,18 +52,6 @@ public void Retrieve(string partitionKey, string rowKey, List this.Add(new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowKey, SelectColumns = selectedColumns, RetrieveResolver = (pk, rk, ts, prop, etag) => EntityUtilities.ResolveEntityByType(pk, rk, ts, prop, etag) }); } - /// - /// Adds a table operation to retrieve an entity of the specified class type with the specified partition key and row key to the batch operation. - /// - /// The return type which the specified will resolve the given entity to. - /// A string containing the partition key of the entity to retrieve. - /// A string containing the row key of the entity to retrieve. - /// The implementation to project the entity to retrieve as a particular type in the result. - public void Retrieve(string partitionKey, string rowKey, EntityResolver resolver) - { - Retrieve(partitionKey, rowKey, resolver, selectedColumns: null); - } - /// /// Adds a table operation to retrieve an entity of the specified class type with the specified partition key and row key to the batch operation. /// @@ -109,6 +85,11 @@ internal IList Execute(CloudTableClient client, CloudTable table, T throw new InvalidOperationException(SR.EmptyBatchOperation); } + if (this.operations.Count > 100) + { + throw new InvalidOperationException(SR.BatchExceededMaximumNumberOfOperations); + } + return Executor.ExecuteSync(BatchImpl(this, client, table, modifiedOptions), modifiedOptions.RetryPolicy, operationContext); } #endif @@ -126,6 +107,11 @@ internal ICancellableAsyncResult BeginExecute(CloudTableClient client, CloudTabl throw new InvalidOperationException(SR.EmptyBatchOperation); } + if (this.operations.Count > 100) + { + throw new InvalidOperationException(SR.BatchExceededMaximumNumberOfOperations); + } + return Executor.BeginExecuteAsync( BatchImpl(this, client, table, modifiedOptions), modifiedOptions.RetryPolicy, diff --git a/Lib/ClassLibraryCommon/Table/TableOperation.cs b/Lib/ClassLibraryCommon/Table/TableOperation.cs index 5db324b60..9b4988176 100644 --- a/Lib/ClassLibraryCommon/Table/TableOperation.cs +++ b/Lib/ClassLibraryCommon/Table/TableOperation.cs @@ -29,7 +29,7 @@ namespace Microsoft.WindowsAzure.Storage.Table /// /// Represents a single table operation. /// - public sealed partial class TableOperation + public partial class TableOperation { #if SYNC internal TableResult Execute(CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext) @@ -211,7 +211,7 @@ private static RESTCommand RetrieveImpl(TableOperation operation, C operation.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionPropertyDetails); } - retrieveCmd.Builder = operation.GenerateQueryBuilder(); + retrieveCmd.Builder = operation.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); } retrieveCmd.CommandLocationMode = operation.isPrimaryOnlyRetrieve ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary; diff --git a/Lib/ClassLibraryCommon/Table/TableQuery.cs b/Lib/ClassLibraryCommon/Table/TableQuery.cs index ceccc9987..90d0db086 100644 --- a/Lib/ClassLibraryCommon/Table/TableQuery.cs +++ b/Lib/ClassLibraryCommon/Table/TableQuery.cs @@ -93,7 +93,7 @@ internal TableQuery(Expression queryExpression, TableQueryProvider queryProvider /// An object that represents the context for the current operation. /// An enumerable collection, specialized for type TElement, of the results of executing the query. [DoesServiceRequest] - public IEnumerable Execute(TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual IEnumerable Execute(TableRequestOptions requestOptions = null, OperationContext operationContext = null) { if (this.queryProvider == null) { @@ -123,7 +123,7 @@ public IEnumerable Execute(TableRequestOptions requestOptions = null, /// A user-defined object that will be passed to the callback delegate. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecuteSegmented(TableContinuationToken currentToken, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExecuteSegmented(TableContinuationToken currentToken, AsyncCallback callback, object state) { return this.BeginExecuteSegmented(currentToken, null /* RequestOptions */, null /* OperationContext */, callback, state); } @@ -138,7 +138,7 @@ public ICancellableAsyncResult BeginExecuteSegmented(TableContinuationToken curr /// A object that specifies additional options for the request. /// An that references the asynchronous operation. [DoesServiceRequest] - public ICancellableAsyncResult BeginExecuteSegmented(TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) + public virtual ICancellableAsyncResult BeginExecuteSegmented(TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state) { if (this.queryProvider == null) { @@ -180,7 +180,7 @@ public ICancellableAsyncResult BeginExecuteSegmented(TableContinuationToken curr /// /// The reference to the pending asynchronous request to finish. /// A object of type . - public TableQuerySegment EndExecuteSegmented(IAsyncResult asyncResult) + public virtual TableQuerySegment EndExecuteSegmented(IAsyncResult asyncResult) { return Executor.EndExecuteAsync>(asyncResult); } @@ -192,7 +192,7 @@ public TableQuerySegment EndExecuteSegmented(IAsyncResult asyncResult) /// A continuation token returned by a previous listing operation, can be null. /// A of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteSegmentedAsync(TableContinuationToken currentToken) + public virtual Task> ExecuteSegmentedAsync(TableContinuationToken currentToken) { return this.ExecuteSegmentedAsync(currentToken, CancellationToken.None); } @@ -203,7 +203,7 @@ public Task> ExecuteSegmentedAsync(TableContinuation /// A continuation token returned by a previous listing operation, can be null./// A to observe while waiting for a task to complete. /// A of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteSegmentedAsync(TableContinuationToken currentToken, CancellationToken cancellationToken) + public virtual Task> ExecuteSegmentedAsync(TableContinuationToken currentToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExecuteSegmented, this.EndExecuteSegmented, currentToken, cancellationToken); } @@ -216,7 +216,7 @@ public Task> ExecuteSegmentedAsync(TableContinuation /// A object that specifies additional options for the request. /// A of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteSegmentedAsync(TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task> ExecuteSegmentedAsync(TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext) { return this.ExecuteSegmentedAsync(currentToken, requestOptions, operationContext, CancellationToken.None); } @@ -230,7 +230,7 @@ public Task> ExecuteSegmentedAsync(TableContinuation /// A to observe while waiting for a task to complete. /// A of type that represents the asynchronous operation. [DoesServiceRequest] - public Task> ExecuteSegmentedAsync(TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> ExecuteSegmentedAsync(TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginExecuteSegmented, this.EndExecuteSegmented, currentToken, requestOptions, operationContext, cancellationToken); } @@ -245,7 +245,7 @@ public Task> ExecuteSegmentedAsync(TableContinuation /// An object that represents the context for the current operation. /// A , specialized for type TElement, containing the results of executing the query. [DoesServiceRequest] - public TableQuerySegment ExecuteSegmented(TableContinuationToken continuationToken, TableRequestOptions requestOptions = null, OperationContext operationContext = null) + public virtual TableQuerySegment ExecuteSegmented(TableContinuationToken continuationToken, TableRequestOptions requestOptions = null, OperationContext operationContext = null) { if (this.queryProvider == null) { @@ -275,7 +275,7 @@ public TableQuerySegment ExecuteSegmented(TableContinuationToken conti /// Returns an enumerator that iterates through the . /// /// An for the . - public IEnumerator GetEnumerator() + public virtual IEnumerator GetEnumerator() { if (this.Expression == null) { @@ -544,7 +544,7 @@ private static RESTCommand> QueryImpl> QueryImpl(Tabl query.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionPropertyDetails); } - UriQueryBuilder builder = query.GenerateQueryBuilder(); + UriQueryBuilder builder = query.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); if (token != null) { @@ -198,7 +198,7 @@ private static RESTCommand> QueryImpl(Tabl private static RESTCommand> QueryImpl(TableQuery query, TableContinuationToken token, CloudTableClient client, CloudTable table, EntityResolver resolver, TableRequestOptions requestOptions) { - UriQueryBuilder builder = query.GenerateQueryBuilder(); + UriQueryBuilder builder = query.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); if (token != null) { diff --git a/Lib/Common/Auth/StorageCredentials.cs b/Lib/Common/Auth/StorageCredentials.cs index 1a4d6dd37..86c16209d 100644 --- a/Lib/Common/Auth/StorageCredentials.cs +++ b/Lib/Common/Auth/StorageCredentials.cs @@ -21,7 +21,6 @@ namespace Microsoft.WindowsAzure.Storage.Auth using Microsoft.WindowsAzure.Storage.Core.Util; using Microsoft.WindowsAzure.Storage.Shared.Protocol; using System; - using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -34,12 +33,7 @@ namespace Microsoft.WindowsAzure.Storage.Auth /// public sealed class StorageCredentials { - private UriQueryBuilder queryBuilder; - - /// - /// A value indicating whether or not this StorageCredentials object is meant for HTTPS access only. - /// - private bool isHttpsOnly; + private SasQueryBuilder queryBuilder; /// /// Gets the associated shared access signature token for the credentials. @@ -89,7 +83,7 @@ public bool IsSAS { get { - return (this.SASToken != null); + return this.SASToken != null; } } @@ -293,14 +287,6 @@ public byte[] ExportKey() public Uri TransformUri(Uri resourceUri) { CommonUtility.AssertNotNull("resourceUri", resourceUri); -#if WINDOWS_RT || PORTABLE || ASPNET_K - if (this.isHttpsOnly && (string.CompareOrdinal(resourceUri.Scheme, "https") != 0)) -#else - if (this.isHttpsOnly && (string.CompareOrdinal(resourceUri.Scheme, Uri.UriSchemeHttps) != 0)) -#endif - { - throw new ArgumentException(SR.CannotTransformNonHttpsUriWithHttpsOnlyCredentials); - } if (this.IsSAS) { @@ -332,8 +318,13 @@ public StorageUri TransformUri(StorageUri resourceUri) /// The account access key. public string ExportBase64EncodedKey() { - StorageAccountKey localKey = this.Key; - return (localKey.KeyValue == null) ? null : Convert.ToBase64String(localKey.KeyValue); + StorageAccountKey thisAccountKey = this.Key; + return GetBase64EncodedKey(thisAccountKey); + } + + private static string GetBase64EncodedKey(StorageAccountKey accountKey) + { + return (accountKey.KeyValue == null) ? null : Convert.ToBase64String(accountKey.KeyValue); } internal string ToString(bool exportSecrets) @@ -370,30 +361,23 @@ public bool Equals(StorageCredentials other) } else { + StorageAccountKey thisAccountKey = this.Key; + StorageAccountKey otherAccountKey = other.Key; + return string.Equals(this.SASToken, other.SASToken) && string.Equals(this.AccountName, other.AccountName) && - string.Equals(this.KeyName, other.KeyName) && - string.Equals(this.ExportBase64EncodedKey(), other.ExportBase64EncodedKey()); + string.Equals(thisAccountKey.KeyName, otherAccountKey.KeyName) && + string.Equals(GetBase64EncodedKey(thisAccountKey), GetBase64EncodedKey(otherAccountKey)); } } private void UpdateQueryBuilder() { - this.queryBuilder = new UriQueryBuilder(); - this.isHttpsOnly = false; - IDictionary parameters = HttpWebUtility.ParseQueryString(this.SASToken); - foreach (KeyValuePair parameter in parameters) - { - if (string.CompareOrdinal(parameter.Key, Constants.QueryConstants.SignedProtocols) == 0 && string.CompareOrdinal(parameter.Value, "https") == 0) - { - this.isHttpsOnly = true; - } + SasQueryBuilder newQueryBuilder = new SasQueryBuilder(this.SASToken); - this.queryBuilder.Add(parameter.Key, parameter.Value); - } + newQueryBuilder.Add(Constants.QueryConstants.ApiVersion, Constants.HeaderConstants.TargetStorageVersion); - this.queryBuilder.Add(Constants.QueryConstants.ApiVersion, Constants.HeaderConstants.TargetStorageVersion); - + this.queryBuilder = newQueryBuilder; } } } diff --git a/Lib/Common/Blob/BlobRequestOptions.cs b/Lib/Common/Blob/BlobRequestOptions.cs index 34a83048a..97572a633 100644 --- a/Lib/Common/Blob/BlobRequestOptions.cs +++ b/Lib/Common/Blob/BlobRequestOptions.cs @@ -48,6 +48,35 @@ public sealed class BlobRequestOptions : IRequestOptions /// private TimeSpan? maximumExecutionTime; + /// + /// Defines the absolute default option values, should neither the user nor client specify anything. + /// + internal static BlobRequestOptions BaseDefaultRequestOptions = new BlobRequestOptions() + { + RetryPolicy = new NoRetry(), + AbsorbConditionalErrorsOnRetry = false, + +#if !(WINDOWS_RT || ASPNET_K || PORTABLE) + EncryptionPolicy = null, + RequireEncryption = null, +#endif + LocationMode = RetryPolicies.LocationMode.PrimaryOnly, + ServerTimeout = null, + MaximumExecutionTime = null, + ParallelOperationThreadCount = 1, + SingleBlobUploadThresholdInBytes = Constants.MaxSingleUploadBlobSize / 2, + +#if (WINDOWS_PHONE && WINDOWS_DESKTOP) || PORTABLE + DisableContentMD5Validation = true, + StoreBlobContentMD5 = false, + UseTransactionalMD5 = false, +#else + DisableContentMD5Validation = false, + //// StoreBlobContentMD5 = (blobType == BlobType.BlockBlob), // must be computed in ApplyDefaults + UseTransactionalMD5 = false, +#endif + }; + /// /// Initializes a new instance of the class. /// @@ -86,25 +115,52 @@ internal static BlobRequestOptions ApplyDefaults(BlobRequestOptions options, Blo { BlobRequestOptions modifiedOptions = new BlobRequestOptions(options); - modifiedOptions.RetryPolicy = modifiedOptions.RetryPolicy ?? serviceClient.DefaultRequestOptions.RetryPolicy; - modifiedOptions.AbsorbConditionalErrorsOnRetry = modifiedOptions.AbsorbConditionalErrorsOnRetry - ?? serviceClient.DefaultRequestOptions.AbsorbConditionalErrorsOnRetry - ?? false; + modifiedOptions.RetryPolicy = + modifiedOptions.RetryPolicy + ?? serviceClient.DefaultRequestOptions.RetryPolicy + ?? BaseDefaultRequestOptions.RetryPolicy; + + modifiedOptions.AbsorbConditionalErrorsOnRetry = + modifiedOptions.AbsorbConditionalErrorsOnRetry + ?? serviceClient.DefaultRequestOptions.AbsorbConditionalErrorsOnRetry + ?? BaseDefaultRequestOptions.AbsorbConditionalErrorsOnRetry; + #if !(WINDOWS_RT || ASPNET_K || PORTABLE) - modifiedOptions.EncryptionPolicy = modifiedOptions.EncryptionPolicy ?? serviceClient.DefaultRequestOptions.EncryptionPolicy; - modifiedOptions.RequireEncryption = modifiedOptions.RequireEncryption ?? serviceClient.DefaultRequestOptions.RequireEncryption; + modifiedOptions.EncryptionPolicy = + modifiedOptions.EncryptionPolicy + ?? serviceClient.DefaultRequestOptions.EncryptionPolicy + ?? BaseDefaultRequestOptions.EncryptionPolicy; + + modifiedOptions.RequireEncryption = + modifiedOptions.RequireEncryption + ?? serviceClient.DefaultRequestOptions.RequireEncryption + ?? BaseDefaultRequestOptions.RequireEncryption; #endif - modifiedOptions.LocationMode = (modifiedOptions.LocationMode - ?? serviceClient.DefaultRequestOptions.LocationMode) - ?? RetryPolicies.LocationMode.PrimaryOnly; - modifiedOptions.ServerTimeout = modifiedOptions.ServerTimeout ?? serviceClient.DefaultRequestOptions.ServerTimeout; - modifiedOptions.MaximumExecutionTime = modifiedOptions.MaximumExecutionTime ?? serviceClient.DefaultRequestOptions.MaximumExecutionTime; - modifiedOptions.ParallelOperationThreadCount = (modifiedOptions.ParallelOperationThreadCount - ?? serviceClient.DefaultRequestOptions.ParallelOperationThreadCount) - ?? 1; - modifiedOptions.SingleBlobUploadThresholdInBytes = (modifiedOptions.SingleBlobUploadThresholdInBytes - ?? serviceClient.DefaultRequestOptions.SingleBlobUploadThresholdInBytes) - ?? Constants.MaxSingleUploadBlobSize / 2; + + modifiedOptions.LocationMode = + modifiedOptions.LocationMode + ?? serviceClient.DefaultRequestOptions.LocationMode + ?? BaseDefaultRequestOptions.LocationMode; + + modifiedOptions.ServerTimeout = + modifiedOptions.ServerTimeout + ?? serviceClient.DefaultRequestOptions.ServerTimeout + ?? BaseDefaultRequestOptions.ServerTimeout; + + modifiedOptions.MaximumExecutionTime = + modifiedOptions.MaximumExecutionTime + ?? serviceClient.DefaultRequestOptions.MaximumExecutionTime + ?? BaseDefaultRequestOptions.MaximumExecutionTime; + + modifiedOptions.ParallelOperationThreadCount = + modifiedOptions.ParallelOperationThreadCount + ?? serviceClient.DefaultRequestOptions.ParallelOperationThreadCount + ?? BaseDefaultRequestOptions.ParallelOperationThreadCount; + + modifiedOptions.SingleBlobUploadThresholdInBytes = + modifiedOptions.SingleBlobUploadThresholdInBytes + ?? serviceClient.DefaultRequestOptions.SingleBlobUploadThresholdInBytes + ?? BaseDefaultRequestOptions.SingleBlobUploadThresholdInBytes; if (applyExpiry && !modifiedOptions.OperationExpiryTime.HasValue && modifiedOptions.MaximumExecutionTime.HasValue) { @@ -112,19 +168,24 @@ internal static BlobRequestOptions ApplyDefaults(BlobRequestOptions options, Blo } #if (WINDOWS_PHONE && WINDOWS_DESKTOP) || PORTABLE - modifiedOptions.DisableContentMD5Validation = true; - modifiedOptions.StoreBlobContentMD5 = false; - modifiedOptions.UseTransactionalMD5 = false; + modifiedOptions.DisableContentMD5Validation = BaseDefaultRequestOptions.DisableContentMD5Validation; + modifiedOptions.StoreBlobContentMD5 = BaseDefaultRequestOptions.StoreBlobContentMD5; + modifiedOptions.UseTransactionalMD5 = BaseDefaultRequestOptions.UseTransactionalMD5; #else - modifiedOptions.DisableContentMD5Validation = (modifiedOptions.DisableContentMD5Validation - ?? serviceClient.DefaultRequestOptions.DisableContentMD5Validation) - ?? false; - modifiedOptions.StoreBlobContentMD5 = (modifiedOptions.StoreBlobContentMD5 - ?? serviceClient.DefaultRequestOptions.StoreBlobContentMD5) - ?? blobType == BlobType.BlockBlob; - modifiedOptions.UseTransactionalMD5 = (modifiedOptions.UseTransactionalMD5 - ?? serviceClient.DefaultRequestOptions.UseTransactionalMD5) - ?? false; + modifiedOptions.DisableContentMD5Validation = + modifiedOptions.DisableContentMD5Validation + ?? serviceClient.DefaultRequestOptions.DisableContentMD5Validation + ?? BaseDefaultRequestOptions.DisableContentMD5Validation; + + modifiedOptions.StoreBlobContentMD5 = + modifiedOptions.StoreBlobContentMD5 + ?? serviceClient.DefaultRequestOptions.StoreBlobContentMD5 + ?? (blobType == BlobType.BlockBlob); // must be computed + + modifiedOptions.UseTransactionalMD5 = + modifiedOptions.UseTransactionalMD5 + ?? serviceClient.DefaultRequestOptions.UseTransactionalMD5 + ?? BaseDefaultRequestOptions.UseTransactionalMD5; #endif return modifiedOptions; diff --git a/Lib/Common/Blob/BlobWriteStreamBase.cs b/Lib/Common/Blob/BlobWriteStreamBase.cs index d0eb57232..eb9a78f2a 100644 --- a/Lib/Common/Blob/BlobWriteStreamBase.cs +++ b/Lib/Common/Blob/BlobWriteStreamBase.cs @@ -29,11 +29,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed.")] internal abstract class BlobWriteStreamBase : -#if WINDOWS_RT - Stream -#else CloudBlobStream -#endif { protected CloudBlockBlob blockBlob; protected CloudPageBlob pageBlob; diff --git a/Lib/Common/Blob/CloudAppendBlob.Common.cs b/Lib/Common/Blob/CloudAppendBlob.Common.cs index 308f6106f..1a2565838 100644 --- a/Lib/Common/Blob/CloudAppendBlob.Common.cs +++ b/Lib/Common/Blob/CloudAppendBlob.Common.cs @@ -25,7 +25,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// Represents an append blob, a type of blob where blocks of data are always committed to the end of the blob. /// - public sealed partial class CloudAppendBlob : CloudBlob, ICloudBlob + public partial class CloudAppendBlob : CloudBlob, ICloudBlob { /// /// Default is 4 MB. @@ -68,19 +68,8 @@ public CloudAppendBlob(Uri blobAbsoluteUri, DateTimeOffset? snapshotTime, Storag /// A containing the absolute URI to the blob at both the primary and secondary locations. /// A specifying the snapshot timestamp, if the blob is a snapshot. /// A object. -#if WINDOWS_RT - /// A object. - public static new CloudAppendBlob Create(StorageUri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials) - { - return new CloudAppendBlob(blobAbsoluteUri, snapshotTime, credentials); - } - - internal CloudAppendBlob(StorageUri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials) - : base(blobAbsoluteUri, snapshotTime, credentials) -#else public CloudAppendBlob(StorageUri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials) : base(blobAbsoluteUri, snapshotTime, credentials) -#endif { this.Properties.BlobType = BlobType.AppendBlob; } diff --git a/Lib/Common/Blob/CloudBlob.Common.cs b/Lib/Common/Blob/CloudBlob.Common.cs index d8d04300e..ab18607cf 100644 --- a/Lib/Common/Blob/CloudBlob.Common.cs +++ b/Lib/Common/Blob/CloudBlob.Common.cs @@ -72,17 +72,8 @@ public CloudBlob(Uri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCrede /// A containing the absolute URI to the blob at both the primary and secondary locations. /// A specifying the snapshot timestamp, if the blob is a snapshot. /// A object. -#if WINDOWS_RT /// A object. - public static CloudBlob Create(StorageUri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials) - { - return new CloudBlob(blobAbsoluteUri, snapshotTime, credentials); - } - - internal CloudBlob(StorageUri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials) -#else public CloudBlob(StorageUri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials) -#endif { CommonUtility.AssertNotNull("blobAbsoluteUri", blobAbsoluteUri); CommonUtility.AssertNotNull("blobAbsoluteUri", blobAbsoluteUri.PrimaryUri); diff --git a/Lib/Common/Blob/CloudBlobClient.Common.cs b/Lib/Common/Blob/CloudBlobClient.Common.cs index 81e02858e..24f669638 100644 --- a/Lib/Common/Blob/CloudBlobClient.Common.cs +++ b/Lib/Common/Blob/CloudBlobClient.Common.cs @@ -31,7 +31,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// The service client encapsulates the endpoint or endpoints for the Blob service. If the service client will be used for authenticated access, it also encapsulates /// the credentials for accessing the storage account. - public sealed partial class CloudBlobClient + public partial class CloudBlobClient { /// /// Stores the default delimiter. @@ -67,25 +67,18 @@ public CloudBlobClient(Uri baseUri, StorageCredentials credentials) /// /// A object containing the Blob service endpoint to use to create the client. /// A object. -#if WINDOWS_RT - /// A object. - public static CloudBlobClient Create(StorageUri storageUri, StorageCredentials credentials) - { - return new CloudBlobClient(storageUri, credentials); - } - - internal CloudBlobClient(StorageUri storageUri, StorageCredentials credentials) -#else public CloudBlobClient(StorageUri storageUri, StorageCredentials credentials) -#endif { this.StorageUri = storageUri; this.Credentials = credentials ?? new StorageCredentials(); - this.DefaultRequestOptions = new BlobRequestOptions(); - this.DefaultRequestOptions.RetryPolicy = new ExponentialRetry(); - this.DefaultRequestOptions.LocationMode = RetryPolicies.LocationMode.PrimaryOnly; - this.DefaultRequestOptions.SingleBlobUploadThresholdInBytes = Constants.MaxSingleUploadBlobSize / 2; - this.DefaultRequestOptions.ParallelOperationThreadCount = 1; + this.DefaultRequestOptions = + new BlobRequestOptions() + { + RetryPolicy = new ExponentialRetry(), + LocationMode = BlobRequestOptions.BaseDefaultRequestOptions.LocationMode, + SingleBlobUploadThresholdInBytes = BlobRequestOptions.BaseDefaultRequestOptions.SingleBlobUploadThresholdInBytes, + ParallelOperationThreadCount = BlobRequestOptions.BaseDefaultRequestOptions.ParallelOperationThreadCount + }; this.DefaultDelimiter = NavigationHelper.Slash; this.AuthenticationScheme = AuthenticationScheme.SharedKey; this.UsePathStyleUris = CommonUtility.UsePathStyleAddressing(this.BaseUri); @@ -146,60 +139,6 @@ public IRetryPolicy RetryPolicy } } - /// - /// Gets or sets the default location mode for requests made via the Blob service client. - /// - /// A enumeration value. - [Obsolete("Use DefaultRequestOptions.LocationMode.")] - public LocationMode? LocationMode - { - get - { - return this.DefaultRequestOptions.LocationMode; - } - - set - { - this.DefaultRequestOptions.LocationMode = value; - } - } - - /// - /// Gets or sets the default server timeout for requests made via the Blob service client. - /// - /// A containing the server timeout interval. - [Obsolete("Use DefaultRequestOptions.ServerTimeout.")] - public TimeSpan? ServerTimeout - { - get - { - return this.DefaultRequestOptions.ServerTimeout; - } - - set - { - this.DefaultRequestOptions.ServerTimeout = value; - } - } - - /// - /// Gets or sets the maximum execution time across all potential retries. - /// - /// A containing the maximum execution time across all potential retries. - [Obsolete("Use DefaultRequestOptions.MaximumExecutionTime.")] - public TimeSpan? MaximumExecutionTime - { - get - { - return this.DefaultRequestOptions.MaximumExecutionTime; - } - - set - { - this.DefaultRequestOptions.MaximumExecutionTime = value; - } - } - /// /// Gets or sets the default delimiter that may be used to create a virtual directory structure of blobs. /// @@ -224,44 +163,6 @@ public string DefaultDelimiter } } - /// - /// Gets or sets the maximum size of a blob in bytes that may be uploaded as a single blob. - /// - /// A long containing the maximum size of a blob, in bytes, that may be uploaded as a single blob, - /// ranging from between 1 and 64 MB inclusive. - [Obsolete("Use DefaultRequestOptions.SingleBlobUploadThresholdInBytes.")] - public long? SingleBlobUploadThresholdInBytes - { - get - { - return this.DefaultRequestOptions.SingleBlobUploadThresholdInBytes; - } - - set - { - this.DefaultRequestOptions.SingleBlobUploadThresholdInBytes = value; - } - } - - /// - /// Gets or sets the number of blocks that may be simultaneously uploaded when uploading a blob that is greater than - /// the value specified by the property in size. - /// - /// An integer indicating the number of parallel operations that may proceed. - [Obsolete("Use DefaultRequestOptions.ParallelOperationThreadCount.")] - public int? ParallelOperationThreadCount - { - get - { - return this.DefaultRequestOptions.ParallelOperationThreadCount; - } - - set - { - this.DefaultRequestOptions.ParallelOperationThreadCount = value; - } - } - /// /// Gets a value indicating whether the service client is used with Path style or Host style. /// @@ -291,7 +192,7 @@ public CloudBlobContainer GetContainerReference(string containerName) return new CloudBlobContainer(containerName, this); } - private ICanonicalizer GetCanonicalizer() + internal ICanonicalizer GetCanonicalizer() { if (this.AuthenticationScheme == AuthenticationScheme.SharedKeyLite) { diff --git a/Lib/Common/Blob/CloudBlobContainer.Common.cs b/Lib/Common/Blob/CloudBlobContainer.Common.cs index 6d1b5c044..039700eeb 100644 --- a/Lib/Common/Blob/CloudBlobContainer.Common.cs +++ b/Lib/Common/Blob/CloudBlobContainer.Common.cs @@ -29,7 +29,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// Represents a container in the Windows Azure Blob service. /// - public sealed partial class CloudBlobContainer + public partial class CloudBlobContainer { /// /// Initializes a new instance of the class. @@ -55,17 +55,7 @@ public CloudBlobContainer(Uri containerAddress, StorageCredentials credentials) /// /// A object specifying the absolute URI to the container. /// A object. -#if WINDOWS_RT - /// A object. - public static CloudBlobContainer Create(StorageUri containerAddress, StorageCredentials credentials) - { - return new CloudBlobContainer(containerAddress, credentials); - } - - internal CloudBlobContainer(StorageUri containerAddress, StorageCredentials credentials) -#else public CloudBlobContainer(StorageUri containerAddress, StorageCredentials credentials) -#endif { CommonUtility.AssertNotNull("containerAddress", containerAddress); CommonUtility.AssertNotNull("containerAddress", containerAddress.PrimaryUri); diff --git a/Lib/Common/Blob/CloudBlobDirectory.Common.cs b/Lib/Common/Blob/CloudBlobDirectory.Common.cs index 3216adcac..c269ca3a9 100644 --- a/Lib/Common/Blob/CloudBlobDirectory.Common.cs +++ b/Lib/Common/Blob/CloudBlobDirectory.Common.cs @@ -23,7 +23,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// Represents a virtual directory of blobs on the client which emulates a hierarchical data store by using delimiter characters. /// - public sealed partial class CloudBlobDirectory : IListBlobItem + public partial class CloudBlobDirectory : IListBlobItem { /// /// Stores the parent directory. @@ -218,16 +218,5 @@ public CloudBlobDirectory GetDirectoryReference(string itemName) StorageUri subdirectoryUri = NavigationHelper.AppendPathToUri(this.StorageUri, itemName, this.ServiceClient.DefaultDelimiter); return new CloudBlobDirectory(subdirectoryUri, this.Prefix + itemName, this.Container); } - - /// - /// Returns a virtual subdirectory within this virtual directory. - /// - /// The name of the virtual subdirectory. - /// A object representing the virtual subdirectory. - [Obsolete("GetSubdirectoryReference has been renamed to GetDirectoryReference.")] - public CloudBlobDirectory GetSubdirectoryReference(string itemName) - { - return this.GetDirectoryReference(itemName); - } } } \ No newline at end of file diff --git a/Lib/Common/Blob/CloudBlockBlob.Common.cs b/Lib/Common/Blob/CloudBlockBlob.Common.cs index ce4321374..7ede755db 100644 --- a/Lib/Common/Blob/CloudBlockBlob.Common.cs +++ b/Lib/Common/Blob/CloudBlockBlob.Common.cs @@ -30,7 +30,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// Represents a blob that is uploaded as a set of blocks. /// - public sealed partial class CloudBlockBlob : CloudBlob, ICloudBlob + public partial class CloudBlockBlob : CloudBlob, ICloudBlob { /// /// Default is 4 MB. @@ -73,19 +73,8 @@ public CloudBlockBlob(Uri blobAbsoluteUri, DateTimeOffset? snapshotTime, Storage /// A containing the absolute URI to the blob at both the primary and secondary locations. /// A specifying the snapshot timestamp, if the blob is a snapshot. /// A object. -#if WINDOWS_RT - /// A object. - public static new CloudBlockBlob Create(StorageUri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials) - { - return new CloudBlockBlob(blobAbsoluteUri, snapshotTime, credentials); - } - - internal CloudBlockBlob(StorageUri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials) - : base(blobAbsoluteUri, snapshotTime, credentials) -#else public CloudBlockBlob(StorageUri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials) : base(blobAbsoluteUri, snapshotTime, credentials) -#endif { this.Properties.BlobType = BlobType.BlockBlob; } diff --git a/Lib/Common/Blob/CloudPageBlob.Common.cs b/Lib/Common/Blob/CloudPageBlob.Common.cs index 02b57c5b1..53712d98b 100644 --- a/Lib/Common/Blob/CloudPageBlob.Common.cs +++ b/Lib/Common/Blob/CloudPageBlob.Common.cs @@ -30,7 +30,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// Represents a Windows Azure page blob. /// - public sealed partial class CloudPageBlob : CloudBlob, ICloudBlob + public partial class CloudPageBlob : CloudBlob, ICloudBlob { /// /// Default is 4 MB. @@ -73,19 +73,8 @@ public CloudPageBlob(Uri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageC /// The absolute URI to the blob. The service assumes this is the URI for the blob in the primary location. /// A specifying the snapshot timestamp, if the blob is a snapshot. /// A object. -#if WINDOWS_RT - /// A object. - public static new CloudPageBlob Create(StorageUri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials) - { - return new CloudPageBlob(blobAbsoluteUri, snapshotTime, credentials); - } - - internal CloudPageBlob(StorageUri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials) - : base(blobAbsoluteUri, snapshotTime, credentials) -#else public CloudPageBlob(StorageUri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials) : base(blobAbsoluteUri, snapshotTime, credentials) -#endif { this.Properties.BlobType = BlobType.PageBlob; } diff --git a/Lib/Common/Blob/PageDiffRange.cs b/Lib/Common/Blob/PageDiffRange.cs new file mode 100644 index 000000000..9717afdd7 --- /dev/null +++ b/Lib/Common/Blob/PageDiffRange.cs @@ -0,0 +1,47 @@ +//----------------------------------------------------------------------- +// +// Copyright 2013 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//----------------------------------------------------------------------- + +namespace Microsoft.WindowsAzure.Storage.Blob +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + + /// + /// Represents a range of pages in a page blob. + /// + public sealed class PageDiffRange : PageRange + { + /// + /// Initializes a new instance of the class. + /// + /// The starting offset. + /// The ending offset. + /// True if the page range is a cleared range, false otherwise. + public PageDiffRange(long start, long end, bool isCleared): + base(start, end) + { + this.IsClearedPageRange = isCleared; + } + + /// + /// True if the page range is a cleared range, false otherwise. + /// + public bool IsClearedPageRange { get; internal set; } + } +} diff --git a/Lib/Common/Blob/PageRange.cs b/Lib/Common/Blob/PageRange.cs index e1fa32d31..136fd09f0 100644 --- a/Lib/Common/Blob/PageRange.cs +++ b/Lib/Common/Blob/PageRange.cs @@ -22,7 +22,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// Represents a range of pages in a page blob. /// - public sealed class PageRange + public class PageRange { /// /// Initializes a new instance of the class. diff --git a/Lib/Common/Blob/Protocol/GetPageDiffRangesResponse.cs b/Lib/Common/Blob/Protocol/GetPageDiffRangesResponse.cs new file mode 100644 index 000000000..75d3edd87 --- /dev/null +++ b/Lib/Common/Blob/Protocol/GetPageDiffRangesResponse.cs @@ -0,0 +1,128 @@ +//----------------------------------------------------------------------- +// +// Copyright 2013 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//----------------------------------------------------------------------- + +namespace Microsoft.WindowsAzure.Storage.Blob.Protocol +{ + using Microsoft.WindowsAzure.Storage.Shared.Protocol; + using System.Collections.Generic; + using System.IO; + + /// + /// Provides methods for parsing the response from an operation to get a range of differing pages for a page blob. + /// +#if WINDOWS_DESKTOP || ASPNET_K || PORTABLE + public +#else + internal +#endif + sealed class GetPageDiffRangesResponse : ResponseParsingBase + { + /// + /// Initializes a new instance of the class. + /// + /// The stream of page ranges to be parsed. + public GetPageDiffRangesResponse(Stream stream) + : base(stream) + { + } + + /// + /// Gets an enumerable collection of objects from the response. + /// + /// An enumerable collection of objects. + public IEnumerable PageDiffRanges + { + get + { + return this.ObjectsToParse; + } + } + + /// + /// Reads a page range. + /// + /// Page range entry + private PageDiffRange ParsePageDiffRange(bool isCleared) + { + long start = 0L; + long end = 0L; + + this.reader.ReadStartElement(); + while (this.reader.IsStartElement()) + { + if (this.reader.IsEmptyElement) + { + this.reader.Skip(); + } + else + { + switch (this.reader.Name) + { + case Constants.StartElement: + start = reader.ReadElementContentAsLong(); + break; + + case Constants.EndElement: + end = reader.ReadElementContentAsLong(); + break; + + default: + reader.Skip(); + break; + } + } + } + + this.reader.ReadEndElement(); + + return new PageDiffRange(start, end, isCleared); + } + + /// + /// Parses the XML response for an operation to get a range of pages for a page blob. + /// + /// An enumerable collection of objects. + protected override IEnumerable ParseXml() + { + if (this.reader.ReadToFollowing(Constants.PageListElement)) + { + if (this.reader.IsEmptyElement) + { + this.reader.Skip(); + } + else + { + this.reader.ReadStartElement(); + while (this.reader.IsStartElement()) + { + if (this.reader.IsStartElement(Constants.ClearRangeElement)) + { + yield return this.ParsePageDiffRange(true /* isClear */); + } + else if (this.reader.IsStartElement(Constants.PageRangeElement)) + { + yield return this.ParsePageDiffRange(false /* isClear */); + } + } + + this.allObjectsParsed = true; + this.reader.ReadEndElement(); + } + } + } + } +} diff --git a/Lib/Common/CloudStorageAccount.cs b/Lib/Common/CloudStorageAccount.cs index d3b8d993c..c010f8546 100644 --- a/Lib/Common/CloudStorageAccount.cs +++ b/Lib/Common/CloudStorageAccount.cs @@ -638,8 +638,10 @@ public string GetSharedAccessSignature(SharedAccessAccountPolicy policy) throw new InvalidOperationException(errorMessage); } - string signature = SharedAccessSignatureHelper.GetHash(policy, this.Credentials.AccountName, Constants.HeaderConstants.TargetStorageVersion, this.Credentials.Key.KeyValue); - UriQueryBuilder builder = SharedAccessSignatureHelper.GetSignature(policy, signature, this.Credentials.Key.KeyName, Constants.HeaderConstants.TargetStorageVersion); + StorageAccountKey accountKey = this.Credentials.Key; + + string signature = SharedAccessSignatureHelper.GetHash(policy, this.Credentials.AccountName, Constants.HeaderConstants.TargetStorageVersion, accountKey.KeyValue); + UriQueryBuilder builder = SharedAccessSignatureHelper.GetSignature(policy, signature, accountKey.KeyName, Constants.HeaderConstants.TargetStorageVersion); return builder.ToString(); } #endif diff --git a/Lib/Common/Core/Auth/SharedAccessSignatureHelper.cs b/Lib/Common/Core/Auth/SharedAccessSignatureHelper.cs index ab04b8652..6a354429b 100644 --- a/Lib/Common/Core/Auth/SharedAccessSignatureHelper.cs +++ b/Lib/Common/Core/Auth/SharedAccessSignatureHelper.cs @@ -342,6 +342,11 @@ internal static string GetProtocolString(SharedAccessProtocol? protocols) return null; } + if ((protocols.Value != SharedAccessProtocol.HttpsOnly) && (protocols.Value != SharedAccessProtocol.HttpsOrHttp)) + { + throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, SR.InvalidProtocolsInSAS, protocols.Value)); + } + return protocols.Value == SharedAccessProtocol.HttpsOnly ? "https" : "https,http"; } #endif diff --git a/Lib/Common/Core/Executor/ExecutionState.cs b/Lib/Common/Core/Executor/ExecutionState.cs index 4b919c5ee..b1c0b03be 100644 --- a/Lib/Common/Core/Executor/ExecutionState.cs +++ b/Lib/Common/Core/Executor/ExecutionState.cs @@ -260,9 +260,7 @@ private void CheckDisposeAction() } #if WINDOWS_RT || ASPNET_K || PORTABLE - internal HttpClient Client { get; set; } - - internal HttpRequestMessage Req { get; set; } + internal StorageRequestMessage Req { get; set; } private HttpResponseMessage resp = null; diff --git a/Lib/Common/Core/Executor/RESTCommand.cs b/Lib/Common/Core/Executor/RESTCommand.cs index 195486d79..b1d3742be 100644 --- a/Lib/Common/Core/Executor/RESTCommand.cs +++ b/Lib/Common/Core/Executor/RESTCommand.cs @@ -97,11 +97,9 @@ public Stream ResponseStream public Stream StreamToDispose { get; set; } #if WINDOWS_RT || ASPNET_K || PORTABLE - public Func, HttpMessageHandler, bool, OperationContext, HttpClient> BuildClient; - public Func, OperationContext, HttpContent> BuildContent; - public Func, Uri, UriQueryBuilder, HttpContent, int?, OperationContext, HttpRequestMessage> BuildRequest; + public Func, Uri, UriQueryBuilder, HttpContent, int?, OperationContext, StorageRequestMessage> BuildRequest; // Pre-Stream Retrival func (i.e. if 409 no stream is retrieved), in some cases this method will return directly public Func, HttpResponseMessage, Exception, OperationContext, T> PreProcessResponse; diff --git a/Lib/Common/Core/Executor/StorageCommandBase.cs b/Lib/Common/Core/Executor/StorageCommandBase.cs index f2ab400b7..0ee90aa12 100644 --- a/Lib/Common/Core/Executor/StorageCommandBase.cs +++ b/Lib/Common/Core/Executor/StorageCommandBase.cs @@ -65,10 +65,6 @@ internal IList RequestResults get { return this.requestResults; } } -#if WINDOWS_RT || ASPNET_K || PORTABLE - public HttpClientHandler Handler = null; -#endif - // Delegate that will be executed in the event of an Exception after signing. public Action, Exception, OperationContext> RecoveryAction = null; diff --git a/Lib/Common/Core/SR.cs b/Lib/Common/Core/SR.cs index ef5617512..1639e7409 100644 --- a/Lib/Common/Core/SR.cs +++ b/Lib/Common/Core/SR.cs @@ -30,6 +30,8 @@ internal class SR public const string ArgumentTooSmallError = "The argument '{0}' is smaller than minimum of '{1}'"; public const string AttemptedEdmTypeForTheProperty = "Attempting to deserialize '{0}' as type '{1}'"; public const string BatchWithRetreiveContainsOtherOperations = "A batch transaction with a retrieve operation cannot contain any other operations."; + public const string BatchExceededMaximumNumberOfOperations = "The maximum number of operations allowed in one batch has been exceeded."; + public const string BatchOperationRequiresPartitionKeyRowKey = "A batch non-retrieve operation requires a non-null partition key and row key."; public const string BatchErrorInOperation = "Element {0} in the batch returned an unexpected response code."; public const string BinaryMessageShouldUseBase64Encoding = "EncodeMessage should be true for binary message."; public const string Blob = "blob"; @@ -104,6 +106,7 @@ internal class SR public const string InvalidMetricsLevel = "Invalid metrics level specified."; public const string InvalidBlockSize = "Append block data should not exceed the maximum blob size condition value."; public const string InvalidPageSize = "Page data must be a multiple of 512 bytes."; + public const string InvalidProtocolsInSAS = "Invalid value {0} for the SharedAccessProtocol parameter when creating a SharedAccessSignature. Use 'null' if you do not wish to include a SharedAccessProtocol."; public const string InvalidResourceName = "Invalid {0} name. Check MSDN for more information about valid {0} naming."; public const string InvalidResourceNameLength = "Invalid {0} name length. The {0} name must be between {1} and {2} characters long."; public const string InvalidResourceReservedName = "Invalid {0} name. This {0} name is reserved."; @@ -168,6 +171,7 @@ internal class SR public const string ResourceNameEmpty = "Invalid {0} name. The {0} name may not be null, empty, or whitespace only."; public const string RetrieveWithContinuationToken = "Retrieved '{0}' results with continuation token '{1}'."; public const string SecondaryOnlyCommand = "This operation can only be executed against the secondary storage location."; + public const string SetServicePropertiesRequiresNonNullSettings = "At least one service property needs to be non-null for SetServiceProperties API."; public const string Share = "share"; public const string StartTimeExceedsEndTime = "StartTime invalid. The start time '{0}' occurs after the end time '{1}'."; public const string StorageUriMissingLocation = "The Uri for the target storage location is not specified. Please consider changing the request's location mode."; diff --git a/Lib/Common/Core/SasQueryBuilder.cs b/Lib/Common/Core/SasQueryBuilder.cs new file mode 100644 index 000000000..6901d5af1 --- /dev/null +++ b/Lib/Common/Core/SasQueryBuilder.cs @@ -0,0 +1,89 @@ +//----------------------------------------------------------------------- +// +// Copyright 2013 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//----------------------------------------------------------------------- + +namespace Microsoft.WindowsAzure.Storage.Core +{ + using Microsoft.WindowsAzure.Storage.Core.Util; + using Microsoft.WindowsAzure.Storage.Shared.Protocol; + using System; + + /// + /// A convenience class for constructing SAS-specific URI query strings. + /// +#if WINDOWS_RT + internal +#else + public +#endif + class SasQueryBuilder : UriQueryBuilder + { + /// + /// Public SasQueryBuilder constructor. + /// + /// The ASA token used to authenticate request. + public SasQueryBuilder(string sasToken) + { + this.AddRange(HttpWebUtility.ParseQueryString(sasToken)); + } + + /// + /// Returns True if any of the parameters specifies https:. + /// + public bool RequireHttps { get; private set; } + + /// + /// Add the query string value with URI escaping. + /// + /// The query string name. + /// The query string value. + public override void Add(string name, string value) + { + if (value != null) + { + value = Uri.EscapeDataString(value); + } + + if (string.CompareOrdinal(name, Constants.QueryConstants.SignedProtocols) == 0 && string.CompareOrdinal(value, "https") == 0) + { + this.RequireHttps = true; + } + + this.Parameters.Add(name, value); + } + + /// + /// Adds a query parameter to a URI. + /// + /// A object containing the original URI, including any existing query parameters. + /// A object with the new query parameter appended. + public override Uri AddToUri(Uri uri) + { + CommonUtility.AssertNotNull("uri", uri); + +#if WINDOWS_RT || PORTABLE || ASPNET_K + if (this.RequireHttps && (string.CompareOrdinal(uri.Scheme, "https") != 0)) +#else + if (this.RequireHttps && (string.CompareOrdinal(uri.Scheme, Uri.UriSchemeHttps) != 0)) +#endif + { + throw new ArgumentException(SR.CannotTransformNonHttpsUriWithHttpsOnlyCredentials); + } + + return this.AddToUriCore(uri); + } + } +} diff --git a/Lib/Common/Core/UriQueryBuilder.cs b/Lib/Common/Core/UriQueryBuilder.cs index 11b228fff..cbf014a5e 100644 --- a/Lib/Common/Core/UriQueryBuilder.cs +++ b/Lib/Common/Core/UriQueryBuilder.cs @@ -31,7 +31,7 @@ namespace Microsoft.WindowsAzure.Storage.Core #else public #endif - class UriQueryBuilder + class UriQueryBuilder { /// /// Initializes a new instance of the class. @@ -47,15 +47,15 @@ public UriQueryBuilder() /// The whose elements are copied to the new . public UriQueryBuilder(UriQueryBuilder builder) { - this.parameters = builder != null ? - new Dictionary(builder.parameters) : + this.Parameters = builder != null ? + new Dictionary(builder.Parameters) : new Dictionary(); } - + /// /// Stores the query parameters. /// - private Dictionary parameters; + protected IDictionary Parameters { get; private set; } /// /// Gets the query string value associated with the given name. @@ -66,7 +66,7 @@ public string this[string name] get { string value; - if (this.parameters.TryGetValue(name, out value)) + if (this.Parameters.TryGetValue(name, out value)) { return value; } @@ -82,14 +82,28 @@ public string this[string name] /// /// The query string name. /// The query string value. - public void Add(string name, string value) + public virtual void Add(string name, string value) { if (value != null) { value = Uri.EscapeDataString(value); } - this.parameters.Add(name, value); + this.Parameters.Add(name, value); + } + + /// + /// Add multiple query string values with URI escaping. + /// + /// The set of query string name/value pairs + public void AddRange(IEnumerable> parameters) + { + CommonUtility.AssertNotNull("parameters", parameters); + + foreach (KeyValuePair parameter in parameters) + { + this.Add(parameter.Key, parameter.Value); + } } /// @@ -103,7 +117,7 @@ public override string ToString() StringBuilder sb = new StringBuilder(); bool first = true; - foreach (KeyValuePair pair in this.parameters) + foreach (KeyValuePair pair in this.Parameters) { if (first) { @@ -145,7 +159,17 @@ public StorageUri AddToUri(StorageUri storageUri) /// /// A object containing the original URI, including any existing query parameters. /// A object with the new query parameter appended. - public Uri AddToUri(Uri uri) + public virtual Uri AddToUri(Uri uri) + { + return this.AddToUriCore(uri); + } + + /// + /// Adds a query parameter to a URI. + /// + /// A object containing the original URI, including any existing query parameters. + /// A object with the new query parameter appended. + protected Uri AddToUriCore(Uri uri) { if (uri == null) { diff --git a/Lib/Common/Core/Util/StreamExtensions.cs b/Lib/Common/Core/Util/StreamExtensions.cs index c417f8aa1..8d4d03b2e 100644 --- a/Lib/Common/Core/Util/StreamExtensions.cs +++ b/Lib/Common/Core/Util/StreamExtensions.cs @@ -269,65 +269,75 @@ internal static async Task WriteToAsync(this Stream stream, Stream toStream, streamCopyState.Md5HashRef = new MD5Wrapper(); } - if (executionState.OperationExpiryTime.HasValue) - { - // Setup token for timeout - CancellationTokenSource cts = new CancellationTokenSource(executionState.RemainingTimeout); - CancellationToken tokenWithTimeout = cts.Token; - - // Hookup user's token - token.Register(() => cts.Cancel()); - - // Switch tokens - token = tokenWithTimeout; - } + CancellationTokenSource cts = null; - byte[] buffer = new byte[GetBufferSize(stream)]; - long? bytesRemaining = copyLength; - int readCount; - do + try { - // Determine how many bytes to read this time so that no more than count bytes are read - int bytesToRead = bytesRemaining.HasValue && bytesRemaining < buffer.Length ? (int)bytesRemaining : buffer.Length; - - if (bytesToRead == 0) + if (executionState.OperationExpiryTime.HasValue) { - break; - } - - readCount = await stream.ReadAsync(buffer, 0, bytesToRead, token); + // Setup token for timeout + cts = CancellationTokenSource.CreateLinkedTokenSource(token); + cts.CancelAfter(executionState.RemainingTimeout); - if (bytesRemaining.HasValue) - { - bytesRemaining -= readCount; + // Switch tokens + token = cts.Token; } - if (readCount > 0) + byte[] buffer = new byte[GetBufferSize(stream)]; + long? bytesRemaining = copyLength; + int readCount; + do { - await toStream.WriteAsync(buffer, 0, readCount, token); + // Determine how many bytes to read this time so that no more than count bytes are read + int bytesToRead = bytesRemaining.HasValue && bytesRemaining < buffer.Length ? (int)bytesRemaining : buffer.Length; - // Update the StreamDescriptor after the bytes are successfully committed to the output stream - if (streamCopyState != null) + if (bytesToRead == 0) { - streamCopyState.Length += readCount; + break; + } - if (maxLength.HasValue && streamCopyState.Length > maxLength.Value) - { - throw new InvalidOperationException(SR.StreamLengthError); - } + readCount = await stream.ReadAsync(buffer, 0, bytesToRead, token); + + if (bytesRemaining.HasValue) + { + bytesRemaining -= readCount; + } + + if (readCount > 0) + { + await toStream.WriteAsync(buffer, 0, readCount, token); - if (streamCopyState.Md5HashRef != null) + // Update the StreamDescriptor after the bytes are successfully committed to the output stream + if (streamCopyState != null) { - streamCopyState.Md5HashRef.UpdateHash(buffer, 0, readCount); + streamCopyState.Length += readCount; + + if (maxLength.HasValue && streamCopyState.Length > maxLength.Value) + { + throw new InvalidOperationException(SR.StreamLengthError); + } + + if (streamCopyState.Md5HashRef != null) + { + streamCopyState.Md5HashRef.UpdateHash(buffer, 0, readCount); + } } } } - } - while (readCount > 0); + while (readCount > 0); - if (bytesRemaining.HasValue && bytesRemaining != 0) + if (bytesRemaining.HasValue && bytesRemaining != 0) + { + throw new ArgumentOutOfRangeException("copyLength", SR.StreamLengthShortError); + } + } + finally { - throw new ArgumentOutOfRangeException("copyLength", SR.StreamLengthShortError); + if (cts != null) + { + cts.Dispose(); + cts = null; + } } // Streams opened with AsStreamForWrite extension need to be flushed diff --git a/Lib/Common/File/CloudFile.Common.cs b/Lib/Common/File/CloudFile.Common.cs index 9ad8a4ea1..a1c4130d0 100644 --- a/Lib/Common/File/CloudFile.Common.cs +++ b/Lib/Common/File/CloudFile.Common.cs @@ -31,7 +31,7 @@ namespace Microsoft.WindowsAzure.Storage.File /// /// Represents a Windows Azure File. /// - public sealed partial class CloudFile : IListFileItem + public partial class CloudFile : IListFileItem { /// /// Default is 4 MB. @@ -67,17 +67,7 @@ public CloudFile(Uri fileAbsoluteUri, StorageCredentials credentials) /// /// The absolute URI to the file. /// A object. -#if WINDOWS_RT - /// A object. - public static CloudFile Create(StorageUri fileAbsoluteUri, StorageCredentials credentials) - { - return new CloudFile(fileAbsoluteUri, credentials); - } - - internal CloudFile(StorageUri fileAbsoluteUri, StorageCredentials credentials) -#else public CloudFile(StorageUri fileAbsoluteUri, StorageCredentials credentials) -#endif { this.attributes = new CloudFileAttributes(); this.ParseQueryAndVerify(fileAbsoluteUri, credentials); diff --git a/Lib/Common/File/CloudFileClient.Common.cs b/Lib/Common/File/CloudFileClient.Common.cs index 2e870df6b..f70583ee3 100644 --- a/Lib/Common/File/CloudFileClient.Common.cs +++ b/Lib/Common/File/CloudFileClient.Common.cs @@ -28,7 +28,7 @@ namespace Microsoft.WindowsAzure.Storage.File /// /// The service client encapsulates the base URI for the File service. If the service client will be used for authenticated access, it also encapsulates /// the credentials for accessing the storage account. - public sealed partial class CloudFileClient + public partial class CloudFileClient { private AuthenticationScheme authenticationScheme; @@ -49,24 +49,17 @@ public CloudFileClient(Uri baseUri, StorageCredentials credentials) /// /// The File service endpoint to use to create the client. /// A object. -#if WINDOWS_RT - /// A object. - public static CloudFileClient Create(StorageUri storageUri, StorageCredentials credentials) - { - return new CloudFileClient(storageUri, credentials); - } - - internal CloudFileClient(StorageUri storageUri, StorageCredentials credentials) -#else public CloudFileClient(StorageUri storageUri, StorageCredentials credentials) -#endif { this.StorageUri = storageUri; this.Credentials = credentials ?? new StorageCredentials(); - this.DefaultRequestOptions = new FileRequestOptions(); - this.DefaultRequestOptions.RetryPolicy = new ExponentialRetry(); - this.DefaultRequestOptions.LocationMode = RetryPolicies.LocationMode.PrimaryOnly; - this.DefaultRequestOptions.ParallelOperationThreadCount = 1; + this.DefaultRequestOptions = + new FileRequestOptions() + { + RetryPolicy = new ExponentialRetry(), + LocationMode = FileRequestOptions.BaseDefaultRequestOptions.LocationMode, + ParallelOperationThreadCount = FileRequestOptions.BaseDefaultRequestOptions.ParallelOperationThreadCount + }; this.AuthenticationScheme = AuthenticationScheme.SharedKey; this.UsePathStyleUris = CommonUtility.UsePathStyleAddressing(this.BaseUri); } @@ -124,7 +117,7 @@ public CloudFileShare GetShareReference(string shareName) return new CloudFileShare(shareName, this); } - private ICanonicalizer GetCanonicalizer() + internal ICanonicalizer GetCanonicalizer() { if (this.AuthenticationScheme == AuthenticationScheme.SharedKeyLite) { diff --git a/Lib/Common/File/CloudFileDirectory.Common.cs b/Lib/Common/File/CloudFileDirectory.Common.cs index 1fe66b17e..69b1a2f7e 100644 --- a/Lib/Common/File/CloudFileDirectory.Common.cs +++ b/Lib/Common/File/CloudFileDirectory.Common.cs @@ -30,7 +30,7 @@ namespace Microsoft.WindowsAzure.Storage.File /// Represents a directory of files, designated by a delimiter character. /// /// Shares, which are encapsulated as objects, hold directories, and directories hold files. Directories can also contain sub-directories. - public sealed partial class CloudFileDirectory : IListFileItem + public partial class CloudFileDirectory : IListFileItem { /// /// Stores the that contains this directory. @@ -66,17 +66,7 @@ public CloudFileDirectory(Uri directoryAbsoluteUri, StorageCredentials credentia /// /// A object containing the absolute URI to the directory. /// A object. -#if WINDOWS_RT - /// A object. - public static CloudFileDirectory Create(StorageUri directoryAbsoluteUri, StorageCredentials credentials) - { - return new CloudFileDirectory(directoryAbsoluteUri, credentials); - } - - internal CloudFileDirectory(StorageUri directoryAbsoluteUri, StorageCredentials credentials) -#else public CloudFileDirectory(StorageUri directoryAbsoluteUri, StorageCredentials credentials) -#endif { this.Metadata = new Dictionary(); this.Properties = new FileDirectoryProperties(); diff --git a/Lib/Common/File/CloudFileShare.Common.cs b/Lib/Common/File/CloudFileShare.Common.cs index f8930638e..771128d6d 100644 --- a/Lib/Common/File/CloudFileShare.Common.cs +++ b/Lib/Common/File/CloudFileShare.Common.cs @@ -30,7 +30,7 @@ namespace Microsoft.WindowsAzure.Storage.File /// /// Represents a share in the Windows Azure File service. /// - public sealed partial class CloudFileShare + public partial class CloudFileShare { /// /// Initializes a new instance of the class. @@ -56,17 +56,7 @@ public CloudFileShare(Uri shareAddress, StorageCredentials credentials) /// /// The absolute URI to the share. /// A object. -#if WINDOWS_RT - /// A object. - public static CloudFileShare Create(StorageUri shareAddress, StorageCredentials credentials) - { - return new CloudFileShare(shareAddress, credentials); - } - - internal CloudFileShare(StorageUri shareAddress, StorageCredentials credentials) -#else public CloudFileShare(StorageUri shareAddress, StorageCredentials credentials) -#endif { CommonUtility.AssertNotNull("shareAddress", shareAddress); CommonUtility.AssertNotNull("shareAddress", shareAddress.PrimaryUri); diff --git a/Lib/Common/File/FileRequestOptions.cs b/Lib/Common/File/FileRequestOptions.cs index 06dd2a7fc..d1b5b5dfa 100644 --- a/Lib/Common/File/FileRequestOptions.cs +++ b/Lib/Common/File/FileRequestOptions.cs @@ -39,7 +39,34 @@ public sealed class FileRequestOptions : IRequestOptions /// Stores the maximum execution time. /// private TimeSpan? maximumExecutionTime; - + + /// + /// Defines the absolute default option values, should neither the user nor client specify anything. + /// + internal static FileRequestOptions BaseDefaultRequestOptions = new FileRequestOptions() + { + RetryPolicy = new NoRetry(), + LocationMode = RetryPolicies.LocationMode.PrimaryOnly, + +#if !(WINDOWS_RT || ASPNET_K || PORTABLE) + RequireEncryption = null, +#endif + + ServerTimeout = null, + MaximumExecutionTime = null, + ParallelOperationThreadCount = 1, + +#if WINDOWS_PHONE && WINDOWS_DESKTOP + DisableContentMD5Validation = true, + StoreFileContentMD5 = false, + UseTransactionalMD5 = false, +#else + DisableContentMD5Validation = false, + StoreFileContentMD5 = false, + UseTransactionalMD5 = false, +#endif + }; + /// /// Initializes a new instance of the class. /// @@ -76,19 +103,37 @@ internal static FileRequestOptions ApplyDefaults(FileRequestOptions options, Clo { FileRequestOptions modifiedOptions = new FileRequestOptions(options); - modifiedOptions.RetryPolicy = modifiedOptions.RetryPolicy ?? serviceClient.DefaultRequestOptions.RetryPolicy; - modifiedOptions.LocationMode = (modifiedOptions.LocationMode - ?? serviceClient.DefaultRequestOptions.LocationMode) - ?? RetryPolicies.LocationMode.PrimaryOnly; + modifiedOptions.RetryPolicy = + modifiedOptions.RetryPolicy + ?? serviceClient.DefaultRequestOptions.RetryPolicy + ?? BaseDefaultRequestOptions.RetryPolicy; + + modifiedOptions.LocationMode = + modifiedOptions.LocationMode + ?? serviceClient.DefaultRequestOptions.LocationMode + ?? BaseDefaultRequestOptions.LocationMode; + #if !(WINDOWS_RT || ASPNET_K || PORTABLE) - modifiedOptions.RequireEncryption = modifiedOptions.RequireEncryption ?? serviceClient.DefaultRequestOptions.RequireEncryption; + modifiedOptions.RequireEncryption = + modifiedOptions.RequireEncryption + ?? serviceClient.DefaultRequestOptions.RequireEncryption + ?? BaseDefaultRequestOptions.RequireEncryption; #endif - modifiedOptions.ServerTimeout = modifiedOptions.ServerTimeout ?? serviceClient.DefaultRequestOptions.ServerTimeout; - modifiedOptions.MaximumExecutionTime = modifiedOptions.MaximumExecutionTime ?? serviceClient.DefaultRequestOptions.MaximumExecutionTime; - modifiedOptions.ParallelOperationThreadCount = (modifiedOptions.ParallelOperationThreadCount - ?? serviceClient.DefaultRequestOptions.ParallelOperationThreadCount) - ?? 1; + modifiedOptions.ServerTimeout = + modifiedOptions.ServerTimeout + ?? serviceClient.DefaultRequestOptions.ServerTimeout + ?? BaseDefaultRequestOptions.ServerTimeout; + + modifiedOptions.MaximumExecutionTime = + modifiedOptions.MaximumExecutionTime + ?? serviceClient.DefaultRequestOptions.MaximumExecutionTime + ?? BaseDefaultRequestOptions.MaximumExecutionTime; + + modifiedOptions.ParallelOperationThreadCount = + modifiedOptions.ParallelOperationThreadCount + ?? serviceClient.DefaultRequestOptions.ParallelOperationThreadCount + ?? BaseDefaultRequestOptions.ParallelOperationThreadCount; if (applyExpiry && !modifiedOptions.OperationExpiryTime.HasValue && modifiedOptions.MaximumExecutionTime.HasValue) { @@ -96,19 +141,24 @@ internal static FileRequestOptions ApplyDefaults(FileRequestOptions options, Clo } #if WINDOWS_PHONE && WINDOWS_DESKTOP - modifiedOptions.DisableContentMD5Validation = true; - modifiedOptions.StoreFileContentMD5 = false; - modifiedOptions.UseTransactionalMD5 = false; + modifiedOptions.DisableContentMD5Validation = BaseDefaultRequestOptions.DisableContentMD5Validation; + modifiedOptions.StoreFileContentMD5 = BaseDefaultRequestOptions.StoreFileContentMD5; + modifiedOptions.UseTransactionalMD5 = BaseDefaultRequestOptions.UseTransactionalMD5; #else - modifiedOptions.DisableContentMD5Validation = (modifiedOptions.DisableContentMD5Validation - ?? serviceClient.DefaultRequestOptions.DisableContentMD5Validation) - ?? false; - modifiedOptions.StoreFileContentMD5 = (modifiedOptions.StoreFileContentMD5 - ?? serviceClient.DefaultRequestOptions.StoreFileContentMD5) - ?? false; - modifiedOptions.UseTransactionalMD5 = (modifiedOptions.UseTransactionalMD5 - ?? serviceClient.DefaultRequestOptions.UseTransactionalMD5) - ?? false; + modifiedOptions.DisableContentMD5Validation = + modifiedOptions.DisableContentMD5Validation + ?? serviceClient.DefaultRequestOptions.DisableContentMD5Validation + ?? BaseDefaultRequestOptions.DisableContentMD5Validation; + + modifiedOptions.StoreFileContentMD5 = + modifiedOptions.StoreFileContentMD5 + ?? serviceClient.DefaultRequestOptions.StoreFileContentMD5 + ?? BaseDefaultRequestOptions.StoreFileContentMD5; + + modifiedOptions.UseTransactionalMD5 = + modifiedOptions.UseTransactionalMD5 + ?? serviceClient.DefaultRequestOptions.UseTransactionalMD5 + ?? BaseDefaultRequestOptions.UseTransactionalMD5; #endif return modifiedOptions; diff --git a/Lib/Common/File/FileWriteStreamBase.cs b/Lib/Common/File/FileWriteStreamBase.cs index 61e299b82..e0d24b7e7 100644 --- a/Lib/Common/File/FileWriteStreamBase.cs +++ b/Lib/Common/File/FileWriteStreamBase.cs @@ -25,11 +25,7 @@ namespace Microsoft.WindowsAzure.Storage.File [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed.")] internal abstract class FileWriteStreamBase : -#if WINDOWS_RT - Stream -#else CloudFileStream -#endif { protected CloudFile file; protected long fileSize; diff --git a/Lib/Common/File/Protocol/FileServiceProperties.cs b/Lib/Common/File/Protocol/FileServiceProperties.cs index 584194f6b..d1051774f 100644 --- a/Lib/Common/File/Protocol/FileServiceProperties.cs +++ b/Lib/Common/File/Protocol/FileServiceProperties.cs @@ -42,7 +42,14 @@ public sealed class FileServiceProperties public FileServiceProperties() { this.serviceProperties = new ServiceProperties(); - this.serviceProperties.Logging = null; + } + + /// + /// Initializes a new instance of the class. + /// + public FileServiceProperties(MetricsProperties hourMetrics = null, MetricsProperties minuteMetrics = null, CorsProperties cors = null) + { + this.serviceProperties = new ServiceProperties(null, hourMetrics, minuteMetrics, cors); } /// diff --git a/Lib/Common/Queue/CloudQueue.Common.cs b/Lib/Common/Queue/CloudQueue.Common.cs index e4e0eedc7..e1f16605e 100644 --- a/Lib/Common/Queue/CloudQueue.Common.cs +++ b/Lib/Common/Queue/CloudQueue.Common.cs @@ -32,7 +32,7 @@ namespace Microsoft.WindowsAzure.Storage.Queue /// This class represents a queue in the Windows Azure Queue service. /// [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix", Justification = "Reviewed.")] - public sealed partial class CloudQueue + public partial class CloudQueue { /// /// Initializes a new instance of the class. @@ -58,17 +58,8 @@ public CloudQueue(Uri queueAddress, StorageCredentials credentials) /// /// A containing the absolute URI to the queue at both the primary and secondary locations. /// A object. -#if WINDOWS_RT /// A object. - public static CloudQueue Create(StorageUri queueAddress, StorageCredentials credentials) - { - return new CloudQueue(queueAddress, credentials); - } - - internal CloudQueue(StorageUri queueAddress, StorageCredentials credentials) -#else public CloudQueue(StorageUri queueAddress, StorageCredentials credentials) -#endif { this.ParseQueryAndVerify(queueAddress, credentials); this.Metadata = new Dictionary(); diff --git a/Lib/Common/Queue/CloudQueueClient.Common.cs b/Lib/Common/Queue/CloudQueueClient.Common.cs index bceb08893..465673934 100644 --- a/Lib/Common/Queue/CloudQueueClient.Common.cs +++ b/Lib/Common/Queue/CloudQueueClient.Common.cs @@ -27,7 +27,7 @@ namespace Microsoft.WindowsAzure.Storage.Queue /// Provides a client-side logical representation of the Windows Azure Queue service. This client is used to configure and execute requests against the Queue service. /// /// The service client encapsulates the endpoint or endpoints for the Queue service. If the service client will be used for authenticated access, it also encapsulates the credentials for accessing the storage account. - public sealed partial class CloudQueueClient + public partial class CloudQueueClient { private AuthenticationScheme authenticationScheme; @@ -48,23 +48,15 @@ public CloudQueueClient(Uri baseUri, StorageCredentials credentials) /// /// A object containing the Queue service endpoint to use to create the client. /// A object. -#if WINDOWS_RT - /// A object. - public static CloudQueueClient Create(StorageUri storageUri, StorageCredentials credentials) - { - return new CloudQueueClient(storageUri, credentials); - } - - internal CloudQueueClient(StorageUri storageUri, StorageCredentials credentials) -#else public CloudQueueClient(StorageUri storageUri, StorageCredentials credentials) -#endif { this.StorageUri = storageUri; this.Credentials = credentials ?? new StorageCredentials(); - this.DefaultRequestOptions = new QueueRequestOptions(); - this.DefaultRequestOptions.RetryPolicy = new ExponentialRetry(); - this.DefaultRequestOptions.LocationMode = RetryPolicies.LocationMode.PrimaryOnly; + this.DefaultRequestOptions = + new QueueRequestOptions(QueueRequestOptions.BaseDefaultRequestOptions) + { + RetryPolicy = new ExponentialRetry() + }; this.AuthenticationScheme = AuthenticationScheme.SharedKey; this.UsePathStyleUris = CommonUtility.UsePathStyleAddressing(this.BaseUri); } @@ -106,78 +98,6 @@ public Uri BaseUri /// A object. public QueueRequestOptions DefaultRequestOptions { get; set; } - /// - /// Gets or sets the default retry policy for requests made via the Queue service client. - /// - /// An object of type . - [Obsolete("Use DefaultRequestOptions.RetryPolicy.")] - public IRetryPolicy RetryPolicy - { - get - { - return this.DefaultRequestOptions.RetryPolicy; - } - - set - { - this.DefaultRequestOptions.RetryPolicy = value; - } - } - - /// - /// Gets or sets the default location mode for requests made via the Queue service client. - /// - /// A enumeration value. - [Obsolete("Use DefaultRequestOptions.LocationMode.")] - public LocationMode? LocationMode - { - get - { - return this.DefaultRequestOptions.LocationMode; - } - - set - { - this.DefaultRequestOptions.LocationMode = value; - } - } - - /// - /// Gets or sets the default server timeout for requests made via the Queue service client. - /// - /// A containing the server timeout interval. - [Obsolete("Use DefaultRequestOptions.ServerTimeout.")] - public TimeSpan? ServerTimeout - { - get - { - return this.DefaultRequestOptions.ServerTimeout; - } - - set - { - this.DefaultRequestOptions.ServerTimeout = value; - } - } - - /// - /// Gets or sets the maximum execution time across all potential retries. - /// - /// A containing the maximum execution time across all potential retries. - [Obsolete("Use DefaultRequestOptions.MaximumExecutionTime.")] - public TimeSpan? MaximumExecutionTime - { - get - { - return this.DefaultRequestOptions.MaximumExecutionTime; - } - - set - { - this.DefaultRequestOptions.MaximumExecutionTime = value; - } - } - /// /// Gets a value indicating whether the service client is used with Path style or Host style. /// @@ -195,7 +115,7 @@ public CloudQueue GetQueueReference(string queueName) return new CloudQueue(queueName, this); } - private ICanonicalizer GetCanonicalizer() + internal ICanonicalizer GetCanonicalizer() { if (this.AuthenticationScheme == AuthenticationScheme.SharedKeyLite) { diff --git a/Lib/Common/Queue/QueueRequestOptions.cs b/Lib/Common/Queue/QueueRequestOptions.cs index d07cc8813..b8c591bcb 100644 --- a/Lib/Common/Queue/QueueRequestOptions.cs +++ b/Lib/Common/Queue/QueueRequestOptions.cs @@ -34,6 +34,21 @@ public sealed class QueueRequestOptions : IRequestOptions /// private TimeSpan? maximumExecutionTime; + /// + /// Defines the absolute default option values, should neither the user nor client specify anything. + /// + internal static QueueRequestOptions BaseDefaultRequestOptions = new QueueRequestOptions() + { + RetryPolicy = new NoRetry(), +#if !(WINDOWS_RT || ASPNET_K || PORTABLE) + EncryptionPolicy = null, + RequireEncryption = null, +#endif + LocationMode = RetryPolicies.LocationMode.PrimaryOnly, + ServerTimeout = null, + MaximumExecutionTime = null + }; + /// /// Initializes a new instance of the class. /// @@ -65,17 +80,38 @@ internal QueueRequestOptions(QueueRequestOptions other) internal static QueueRequestOptions ApplyDefaults(QueueRequestOptions options, CloudQueueClient serviceClient) { QueueRequestOptions modifiedOptions = new QueueRequestOptions(options); - - modifiedOptions.RetryPolicy = modifiedOptions.RetryPolicy ?? serviceClient.DefaultRequestOptions.RetryPolicy; + + modifiedOptions.RetryPolicy = + modifiedOptions.RetryPolicy + ?? serviceClient.DefaultRequestOptions.RetryPolicy + ?? BaseDefaultRequestOptions.RetryPolicy; + #if !(WINDOWS_RT || ASPNET_K || PORTABLE) - modifiedOptions.EncryptionPolicy = modifiedOptions.EncryptionPolicy ?? serviceClient.DefaultRequestOptions.EncryptionPolicy; - modifiedOptions.RequireEncryption = modifiedOptions.RequireEncryption ?? serviceClient.DefaultRequestOptions.RequireEncryption; + modifiedOptions.EncryptionPolicy = + modifiedOptions.EncryptionPolicy + ?? serviceClient.DefaultRequestOptions.EncryptionPolicy + ?? BaseDefaultRequestOptions.EncryptionPolicy; + + modifiedOptions.RequireEncryption = + modifiedOptions.RequireEncryption + ?? serviceClient.DefaultRequestOptions.RequireEncryption + ?? BaseDefaultRequestOptions.RequireEncryption; #endif - modifiedOptions.LocationMode = (modifiedOptions.LocationMode - ?? serviceClient.DefaultRequestOptions.LocationMode) - ?? RetryPolicies.LocationMode.PrimaryOnly; - modifiedOptions.ServerTimeout = modifiedOptions.ServerTimeout ?? serviceClient.DefaultRequestOptions.ServerTimeout; - modifiedOptions.MaximumExecutionTime = modifiedOptions.MaximumExecutionTime ?? serviceClient.DefaultRequestOptions.MaximumExecutionTime; + + modifiedOptions.LocationMode = + modifiedOptions.LocationMode + ?? serviceClient.DefaultRequestOptions.LocationMode + ?? BaseDefaultRequestOptions.LocationMode; + + modifiedOptions.ServerTimeout = + modifiedOptions.ServerTimeout + ?? serviceClient.DefaultRequestOptions.ServerTimeout + ?? BaseDefaultRequestOptions.ServerTimeout; + + modifiedOptions.MaximumExecutionTime = + modifiedOptions.MaximumExecutionTime + ?? serviceClient.DefaultRequestOptions.MaximumExecutionTime + ?? BaseDefaultRequestOptions.MaximumExecutionTime; if (!modifiedOptions.OperationExpiryTime.HasValue && modifiedOptions.MaximumExecutionTime.HasValue) { diff --git a/Lib/Common/Shared/Protocol/Constants.cs b/Lib/Common/Shared/Protocol/Constants.cs index 449ac6314..0bb57118f 100644 --- a/Lib/Common/Shared/Protocol/Constants.cs +++ b/Lib/Common/Shared/Protocol/Constants.cs @@ -81,12 +81,6 @@ static class Constants /// public static readonly TimeSpan DefaultClientSideTimeout = TimeSpan.FromMinutes(5); - /// - /// Default server side timeout for all service clients. - /// - [Obsolete("Server-side timeout is not required by default.")] - public static readonly TimeSpan DefaultServerSideTimeout = TimeSpan.FromSeconds(90); - /// /// Maximum Retry Policy back-off /// @@ -208,6 +202,11 @@ static class Constants /// public const string PageRangeElement = "PageRange"; + /// + /// XML element for clear ranges. + /// + public const string ClearRangeElement = "ClearRange"; + /// /// XML element for page list elements. /// @@ -698,11 +697,6 @@ static class Constants /// internal const string XMLAcceptHeaderValue = "application/xml"; - /// - /// Header value to set Accept to AtomPub. - /// - internal const string AtomAcceptHeaderValue = "application/atom+xml,application/atomsvc+xml,application/xml"; - /// /// Header value to set Accept to JsonLight. /// @@ -722,10 +716,6 @@ static class Constants /// Header value argument to set JSON no metadata. /// internal const string NoMetadata = "odata=nometadata"; - /// - /// Header value to set Content-Type to AtomPub. - /// - internal const string AtomContentTypeHeaderValue = "application/atom+xml"; /// /// Header value to set Content-Type to JSON. @@ -753,7 +743,7 @@ static HeaderConstants() #elif WINDOWS_RT UserAgentComment = "(Windows Runtime)"; #elif ASPNET_K - UserAgentComment = "(ASP.NET Core 5.0)"; + UserAgentComment = "(.NET Core 5.0)"; #elif PORTABLE UserAgentComment = "(Portable Class Library)"; #else @@ -776,15 +766,15 @@ static HeaderConstants() /// /// Specifies the value to use for UserAgent header. /// - public const string UserAgentProductName = "WA-Storage"; + public const string UserAgentProductName = "Azure-Storage"; /// /// Specifies the value to use for UserAgent header. /// #if ASPNET_K || PORTABLE - public const string UserAgentProductVersion = "6.2.2-preview"; + public const string UserAgentProductVersion = "7.0.1-preview"; #else - public const string UserAgentProductVersion = "6.2.2"; + public const string UserAgentProductVersion = "7.0.0"; #endif /// @@ -1066,7 +1056,7 @@ static HeaderConstants() /// Current storage version header value. /// Every time this version changes, assembly version needs to be updated as well. /// - public const string TargetStorageVersion = "2015-04-05"; + public const string TargetStorageVersion = "2015-07-08"; /// /// Specifies the file type. diff --git a/Lib/Common/Shared/Protocol/LoggingProperties.cs b/Lib/Common/Shared/Protocol/LoggingProperties.cs index 28de76df6..8949bb532 100644 --- a/Lib/Common/Shared/Protocol/LoggingProperties.cs +++ b/Lib/Common/Shared/Protocol/LoggingProperties.cs @@ -22,6 +22,22 @@ namespace Microsoft.WindowsAzure.Storage.Shared.Protocol /// public sealed class LoggingProperties { + /// + /// Initializes a new instance of the LoggingProperties class. + /// + public LoggingProperties() + : this(Constants.AnalyticsConstants.LoggingVersionV1) + { + } + + /// + /// Initializes a new instance of the LoggingProperties class. + /// + public LoggingProperties(string version) + { + this.Version = version; + } + /// /// Gets or sets the version of the analytics service. /// diff --git a/Lib/Common/Shared/Protocol/MetricsProperties.cs b/Lib/Common/Shared/Protocol/MetricsProperties.cs index d801f442b..2ffc8596c 100644 --- a/Lib/Common/Shared/Protocol/MetricsProperties.cs +++ b/Lib/Common/Shared/Protocol/MetricsProperties.cs @@ -22,6 +22,22 @@ namespace Microsoft.WindowsAzure.Storage.Shared.Protocol /// public sealed class MetricsProperties { + /// + /// Initializes a new instance of the MetricsProperties class. + /// + public MetricsProperties() + : this(Constants.AnalyticsConstants.MetricsVersionV1) + { + } + + /// + /// Initializes a new instance of the MetricsProperties class. + /// + public MetricsProperties(string version) + { + this.Version = version; + } + /// /// Gets or sets the version of the analytics service. /// diff --git a/Lib/Common/Shared/Protocol/ServiceProperties.cs b/Lib/Common/Shared/Protocol/ServiceProperties.cs index 7f6e3ca8f..c54b5a331 100644 --- a/Lib/Common/Shared/Protocol/ServiceProperties.cs +++ b/Lib/Common/Shared/Protocol/ServiceProperties.cs @@ -138,38 +138,27 @@ public sealed class ServiceProperties /// public ServiceProperties() { - this.Logging = new LoggingProperties(); - this.HourMetrics = new MetricsProperties(); - this.MinuteMetrics = new MetricsProperties(); - this.Cors = new CorsProperties(); } /// - /// Gets or sets the logging properties. + /// Initializes a new instance of the ServiceProperties class. /// - /// The logging properties. - public LoggingProperties Logging + public ServiceProperties(LoggingProperties logging = null, MetricsProperties hourMetrics = null, MetricsProperties minuteMetrics = null, CorsProperties cors = null) { - get; - set; + this.Logging = logging; + this.HourMetrics = hourMetrics; + this.MinuteMetrics = minuteMetrics; + this.Cors = cors; } /// - /// Gets or sets the hour metrics properties. + /// Gets or sets the logging properties. /// - /// The metrics properties. - [Obsolete("Metrics has been renamed to HourMetrics.")] - public MetricsProperties Metrics + /// The logging properties. + public LoggingProperties Logging { - get - { - return this.HourMetrics; - } - - set - { - this.HourMetrics = value; - } + get; + set; } /// @@ -241,8 +230,14 @@ internal static ServiceProperties FromServiceXml(XDocument servicePropertiesDocu /// Converts these properties into XML for communicating with the service. /// /// An XML document containing the service properties. + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "SetServiceProperties", Justification = "API name is properly spelled")] internal XDocument ToServiceXml() { + if (this.Logging == null && this.HourMetrics == null && this.MinuteMetrics == null && this.Cors == null && this.DefaultServiceVersion == null) + { + throw new InvalidOperationException(SR.SetServicePropertiesRequiresNonNullSettings); + } + XElement storageServiceElement = new XElement(StorageServicePropertiesName); if (this.Logging != null) @@ -394,7 +389,7 @@ private static LoggingProperties ReadLoggingPropertiesFromXml(XElement element) { if (element == null) { - return new LoggingProperties(); + return null; } LoggingOperations state = LoggingOperations.None; @@ -431,7 +426,7 @@ internal static MetricsProperties ReadMetricsPropertiesFromXml(XElement element) { if (element == null) { - return new MetricsProperties(); + return null; } MetricsLevel state = MetricsLevel.None; @@ -461,14 +456,13 @@ internal static MetricsProperties ReadMetricsPropertiesFromXml(XElement element) /// A CorsProperties object containing the properties in the element. internal static CorsProperties ReadCorsPropertiesFromXml(XElement element) { - CorsProperties ret = new CorsProperties(); - - // Check that CORS properties exist if (element == null) { - return ret; + return null; } + CorsProperties ret = new CorsProperties(); + IEnumerable corsRules = element.Descendants(CorsRuleName); ret.CorsRules = diff --git a/Lib/Common/StorageException.cs b/Lib/Common/StorageException.cs index 1f25ada33..381ad4356 100644 --- a/Lib/Common/StorageException.cs +++ b/Lib/Common/StorageException.cs @@ -38,17 +38,13 @@ namespace Microsoft.WindowsAzure.Storage #endif /// - /// Represents an exception thrown by the Windows Azure storage service. + /// Represents an exception thrown by the Azure Storage service. /// #if WINDOWS_DESKTOP && !WINDOWS_PHONE [Serializable] #endif -#if WINDOWS_RT - internal class StorageException : COMException -#else public class StorageException : Exception -#endif { /// /// Gets the object for this object. @@ -56,6 +52,9 @@ public class StorageException : Exception /// The object for this object. public RequestResult RequestInformation { get; private set; } + /// + /// Indicates if exception is retryable. + /// internal bool IsRetryable { get; set; } /// @@ -88,8 +87,8 @@ public StorageException(string message, Exception innerException) : /// /// Initializes a new instance of the class with serialized data. /// - /// The that contains contextual information about the source or destination. /// The object that holds serialized object data for the exception being thrown. + /// The that contains contextual information about the source or destination. /// This constructor is called during de-serialization to reconstitute the exception object transmitted over a stream. protected StorageException(SerializationInfo info, StreamingContext context) : base(info, context) @@ -104,8 +103,8 @@ protected StorageException(SerializationInfo info, StreamingContext context) : /// /// Populates a object with the data needed to serialize the target object. /// - /// The destination context for this serialization. /// The object to populate with data. + /// The destination context for this serialization. public override void GetObjectData(SerializationInfo info, StreamingContext context) { if (info != null) diff --git a/Lib/Common/StorageExtendedErrorInformation.cs b/Lib/Common/StorageExtendedErrorInformation.cs index 1c7320953..aa6a9847d 100644 --- a/Lib/Common/StorageExtendedErrorInformation.cs +++ b/Lib/Common/StorageExtendedErrorInformation.cs @@ -81,12 +81,7 @@ public static StorageExtendedErrorInformation ReadFromStream(IInputStream inputS /// /// The input stream. /// The error details. -#if WINDOWS_RT - internal -#else - public -#endif - static StorageExtendedErrorInformation ReadFromStream(Stream inputStream) + public static StorageExtendedErrorInformation ReadFromStream(Stream inputStream) { CommonUtility.AssertNotNull("inputStream", inputStream); diff --git a/Lib/Common/Table/CloudTable.Common.cs b/Lib/Common/Table/CloudTable.Common.cs index d13fd81ea..1d69cc753 100644 --- a/Lib/Common/Table/CloudTable.Common.cs +++ b/Lib/Common/Table/CloudTable.Common.cs @@ -30,7 +30,7 @@ namespace Microsoft.WindowsAzure.Storage.Table /// /// Represents a Windows Azure table. /// - public sealed partial class CloudTable + public partial class CloudTable { /// /// Initializes a new instance of the class. @@ -56,17 +56,7 @@ public CloudTable(Uri tableAbsoluteUri, StorageCredentials credentials) /// /// A containing the absolute URI to the table at both the primary and secondary locations. /// A object. -#if WINDOWS_RT - /// A object. - public static CloudTable Create(StorageUri tableAddress, StorageCredentials credentials) - { - return new CloudTable(tableAddress, credentials); - } - - internal CloudTable(StorageUri tableAddress, StorageCredentials credentials) -#else public CloudTable(StorageUri tableAddress, StorageCredentials credentials) -#endif { this.ParseQueryAndVerify(tableAddress, credentials); } diff --git a/Lib/Common/Table/CloudTableClient.Common.cs b/Lib/Common/Table/CloudTableClient.Common.cs index 9b7018047..9eee87030 100644 --- a/Lib/Common/Table/CloudTableClient.Common.cs +++ b/Lib/Common/Table/CloudTableClient.Common.cs @@ -18,7 +18,6 @@ namespace Microsoft.WindowsAzure.Storage.Table { using Microsoft.WindowsAzure.Storage.Auth; - using Microsoft.WindowsAzure.Storage.Core; using Microsoft.WindowsAzure.Storage.Core.Auth; using Microsoft.WindowsAzure.Storage.Core.Util; using Microsoft.WindowsAzure.Storage.RetryPolicies; @@ -29,7 +28,7 @@ namespace Microsoft.WindowsAzure.Storage.Table /// /// The CloudTableClient object encapsulates the base URI for the Table service. If the service client will be used for authenticated access, /// it also encapsulates the credentials for accessing the storage account. - public sealed partial class CloudTableClient + public partial class CloudTableClient { private AuthenticationScheme authenticationScheme; @@ -52,24 +51,15 @@ public CloudTableClient(Uri baseUri, StorageCredentials credentials) /// /// A object containing the Table service endpoint to use to create the client. /// A object. -#if WINDOWS_RT - /// A object. - public static CloudTableClient Create(StorageUri storageUri, StorageCredentials credentials) - { - return new CloudTableClient(storageUri, credentials); - } - - internal CloudTableClient(StorageUri storageUri, StorageCredentials credentials) -#else public CloudTableClient(StorageUri storageUri, StorageCredentials credentials) -#endif { this.StorageUri = storageUri; this.Credentials = credentials ?? new StorageCredentials(); - this.DefaultRequestOptions = new TableRequestOptions(); - this.DefaultRequestOptions.RetryPolicy = new ExponentialRetry(); - this.DefaultRequestOptions.LocationMode = RetryPolicies.LocationMode.PrimaryOnly; - this.DefaultRequestOptions.PayloadFormat = TablePayloadFormat.Json; + this.DefaultRequestOptions = + new TableRequestOptions(TableRequestOptions.BaseDefaultRequestOptions) + { + RetryPolicy = new ExponentialRetry() + }; this.AuthenticationScheme = AuthenticationScheme.SharedKey; this.UsePathStyleUris = CommonUtility.UsePathStyleAddressing(this.BaseUri); @@ -116,97 +106,6 @@ public Uri BaseUri /// A object. public TableRequestOptions DefaultRequestOptions { get; set; } - /// - /// Gets or sets the default retry policy for requests made via the Table service client. - /// - /// An object of type . - [Obsolete("Use DefaultRequestOptions.RetryPolicy.")] - public IRetryPolicy RetryPolicy - { - get - { - return this.DefaultRequestOptions.RetryPolicy; - } - - set - { - this.DefaultRequestOptions.RetryPolicy = value; - } - } - - /// - /// Gets or sets the default location mode for requests made via the Table service client. - /// - /// A enumeration value. - [Obsolete("Use DefaultRequestOptions.LocationMode.")] - public LocationMode? LocationMode - { - get - { - return this.DefaultRequestOptions.LocationMode; - } - - set - { - this.DefaultRequestOptions.LocationMode = value; - } - } - - /// - /// Gets or sets the default server timeout for requests made via the Table service client. - /// - /// A containing the server timeout interval. - [Obsolete("Use DefaultRequestOptions.ServerTimeout.")] - public TimeSpan? ServerTimeout - { - get - { - return this.DefaultRequestOptions.ServerTimeout; - } - - set - { - this.DefaultRequestOptions.ServerTimeout = value; - } - } - - /// - /// Gets or sets the maximum execution time across all potential retries. - /// - /// A containing the maximum execution time across all potential retries. - [Obsolete("Use DefaultRequestOptions.MaximumExecutionTime.")] - public TimeSpan? MaximumExecutionTime - { - get - { - return this.DefaultRequestOptions.MaximumExecutionTime; - } - - set - { - this.DefaultRequestOptions.MaximumExecutionTime = value; - } - } - - /// - /// Gets and sets the table payload format for requests against any table accessed with this object. - /// - /// A enumeration value. - /// By default, this property is set to . - [Obsolete("Use DefaultRequestOptions.PayloadFormat.")] - public TablePayloadFormat? PayloadFormat - { - get - { - return this.DefaultRequestOptions.PayloadFormat; - } - - set - { - this.DefaultRequestOptions.PayloadFormat = value; - } - } - /// /// Gets a value indicating whether the service client is used with Path style or Host style. /// @@ -241,7 +140,7 @@ public CloudTable GetTableReference(string tableName) return new CloudTable(tableName, this); } - private ICanonicalizer GetCanonicalizer() + internal ICanonicalizer GetCanonicalizer() { if (this.AuthenticationScheme == AuthenticationScheme.SharedKeyLite) { diff --git a/Lib/Common/Table/DynamicTableEntity.cs b/Lib/Common/Table/DynamicTableEntity.cs index e6f2dd9e8..6532ec443 100644 --- a/Lib/Common/Table/DynamicTableEntity.cs +++ b/Lib/Common/Table/DynamicTableEntity.cs @@ -67,8 +67,6 @@ public DynamicTableEntity(string partitionKey, string rowKey, string etag, IDict /// An object containing the entity's properties, indexed by property name. internal DynamicTableEntity(string partitionKey, string rowKey, DateTimeOffset timestamp, string etag, IDictionary properties) { - CommonUtility.AssertNotNull("partitionKey", partitionKey); - CommonUtility.AssertNotNull("rowKey", rowKey); CommonUtility.AssertNotNull("properties", properties); // Store the information about this entity. Make a copy of diff --git a/Lib/Common/Table/TableBatchOperation.Common.cs b/Lib/Common/Table/TableBatchOperation.Common.cs index 82aa9c1ad..ef1f94c3c 100644 --- a/Lib/Common/Table/TableBatchOperation.Common.cs +++ b/Lib/Common/Table/TableBatchOperation.Common.cs @@ -29,7 +29,7 @@ namespace Microsoft.WindowsAzure.Storage.Table /// Entity Group Transaction.A batch operation may contain up to 100 individual /// table operations, with the requirement that each operation entity must have same partition key. A batch with a retrieve operation cannot contain any other operations. /// Note that the total payload of a batch operation is limited to 4MB. - public sealed partial class TableBatchOperation : IList + public partial class TableBatchOperation : IList { private bool hasQuery = false; private string batchPartitionKey = null; @@ -189,6 +189,7 @@ public void Insert(int index, TableOperation item) CommonUtility.AssertNotNull("item", item); this.CheckSingleQueryPerBatch(item); this.LockToPartitionKey(item.OperationType == TableOperationType.Retrieve ? item.RetrievePartitionKey : item.Entity.PartitionKey); + CheckPartitionKeyRowKeyPresent(item); this.operations.Insert(index, item); } @@ -235,6 +236,7 @@ public void Add(TableOperation item) CommonUtility.AssertNotNull("item", item); this.CheckSingleQueryPerBatch(item); this.LockToPartitionKey(item.OperationType == TableOperationType.Retrieve ? item.RetrievePartitionKey : item.Entity.PartitionKey); + CheckPartitionKeyRowKeyPresent(item); this.operations.Add(item); } @@ -364,6 +366,19 @@ private void LockToPartitionKey(string partitionKey) } } + private static void CheckPartitionKeyRowKeyPresent(TableOperation item) + { + if (item.OperationType == TableOperationType.Retrieve) + { + return; + } + + if (item.Entity.PartitionKey == null || item.Entity.RowKey == null) + { + throw new ArgumentNullException("item", SR.BatchOperationRequiresPartitionKeyRowKey); + } + } + #endregion } } diff --git a/Lib/Common/Table/TableOperation.Common.cs b/Lib/Common/Table/TableOperation.Common.cs index 95e7f792e..850a37d8c 100644 --- a/Lib/Common/Table/TableOperation.Common.cs +++ b/Lib/Common/Table/TableOperation.Common.cs @@ -29,7 +29,7 @@ namespace Microsoft.WindowsAzure.Storage.Table /// /// Represents a single table operation. /// - public sealed partial class TableOperation + public partial class TableOperation { /// /// Creates a new instance of the class given the @@ -240,24 +240,6 @@ public static TableOperation Replace(ITableEntity entity) return new TableOperation(entity, TableOperationType.Replace); } - /// - /// Creates a new table operation that retrieves the contents of - /// the given entity in a table. - /// - /// The class of type for the entity to retrieve. - /// A string containing the partition key of the entity to retrieve. - /// A string containing the row key of the entity to retrieve. - /// The object. - [SuppressMessage("Microsoft.Design", - "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Reviewed")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "rowkey", - Justification = "Reviewed : rowkey is acceptable.")] - public static TableOperation Retrieve(string partitionKey, string rowkey) - where TElement : ITableEntity - { - return Retrieve(partitionKey, rowkey, selectColumns: null); - } - /// /// Creates a new table operation that retrieves the contents of /// the given entity in a table. @@ -294,21 +276,6 @@ public static TableOperation Retrieve(string partitionKey, string rowk }; } - /// - /// Creates a new table operation that retrieves the contents of - /// the given entity in a table. - /// - /// The return type which the specified will resolve the given entity to. - /// A string containing the partition key of the entity to retrieve. - /// A string containing the row key of the entity to retrieve. - /// The implementation to project the entity to retrieve as a particular type in the result. - /// The object. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "rowkey", Justification = "Reviewed : rowkey is acceptable.")] - public static TableOperation Retrieve(string partitionKey, string rowkey, EntityResolver resolver) - { - return Retrieve(partitionKey, rowkey, resolver, selectedColumns: null); - } - /// /// Creates a new table operation that retrieves the contents of /// the given entity in a table. @@ -329,19 +296,6 @@ public static TableOperation Retrieve(string partitionKey, string rowke return new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowkey, RetrieveResolver = (pk, rk, ts, prop, etag) => resolver(pk, rk, ts, prop, etag), SelectColumns = selectedColumns }; } - /// - /// Creates a new table operation that retrieves the contents of - /// the given entity in a table. - /// - /// A string containing the partition key of the entity to be retrieved. - /// A string containing the row key of the entity to be retrieved. - /// The object. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "rowkey", Justification = "Reviewed : rowkey is allowed.")] - public static TableOperation Retrieve(string partitionKey, string rowkey) - { - return Retrieve(partitionKey, rowkey, selectedColumns: null); - } - /// /// Creates a new table operation that retrieves the contents of /// the given entity in a table. @@ -414,7 +368,7 @@ internal Uri GenerateRequestURI(Uri uri, string tableName) } } - internal UriQueryBuilder GenerateQueryBuilder() + internal UriQueryBuilder GenerateQueryBuilder(bool? projectSystemProperties) { UriQueryBuilder builder = new UriQueryBuilder(); @@ -448,22 +402,25 @@ internal UriQueryBuilder GenerateQueryBuilder() } } - if (!foundPk) + if (projectSystemProperties.Value) { - colBuilder.Append(","); - colBuilder.Append(TableConstants.PartitionKey); - } + if (!foundPk) + { + colBuilder.Append(","); + colBuilder.Append(TableConstants.PartitionKey); + } - if (!foundRk) - { - colBuilder.Append(","); - colBuilder.Append(TableConstants.RowKey); - } + if (!foundRk) + { + colBuilder.Append(","); + colBuilder.Append(TableConstants.RowKey); + } - if (!foundTs) - { - colBuilder.Append(","); - colBuilder.Append(TableConstants.Timestamp); + if (!foundTs) + { + colBuilder.Append(","); + colBuilder.Append(TableConstants.Timestamp); + } } builder.Add(TableConstants.Select, colBuilder.ToString()); diff --git a/Lib/Common/Table/TablePayloadFormat.cs b/Lib/Common/Table/TablePayloadFormat.cs index 2d281a518..687951845 100644 --- a/Lib/Common/Table/TablePayloadFormat.cs +++ b/Lib/Common/Table/TablePayloadFormat.cs @@ -24,12 +24,6 @@ namespace Microsoft.WindowsAzure.Storage.Table /// public enum TablePayloadFormat { - /// - /// Use AtomPub. - /// - [Obsolete("Please use a JSON payload format for table operations.")] - AtomPub, - /// /// Use JSON with full metadata. /// diff --git a/Lib/Common/Table/TableQuery.Common.cs b/Lib/Common/Table/TableQuery.Common.cs index f2b15e7aa..58e03cd11 100644 --- a/Lib/Common/Table/TableQuery.Common.cs +++ b/Lib/Common/Table/TableQuery.Common.cs @@ -35,7 +35,7 @@ namespace Microsoft.WindowsAzure.Storage.Table /// /// The class aggregates and encodes the query parameters to pass with the request when the query is executed. /// To execute the query, call the executeQuery or executeQuerySegmented method of the class. - public sealed partial class TableQuery + public partial class TableQuery { #region Filter Generation @@ -293,7 +293,7 @@ public TableQuery Where(string filter) #region Impl - internal UriQueryBuilder GenerateQueryBuilder() + internal UriQueryBuilder GenerateQueryBuilder(bool? projectSystemProperties) { UriQueryBuilder builder = new UriQueryBuilder(); @@ -339,22 +339,25 @@ internal UriQueryBuilder GenerateQueryBuilder() } } - if (!foundPk) + if (projectSystemProperties.Value) { - colBuilder.Append(","); - colBuilder.Append(TableConstants.PartitionKey); - } + if (!foundPk) + { + colBuilder.Append(","); + colBuilder.Append(TableConstants.PartitionKey); + } - if (!foundRk) - { - colBuilder.Append(","); - colBuilder.Append(TableConstants.RowKey); - } + if (!foundRk) + { + colBuilder.Append(","); + colBuilder.Append(TableConstants.RowKey); + } - if (!foundTs) - { - colBuilder.Append(","); - colBuilder.Append(TableConstants.Timestamp); + if (!foundTs) + { + colBuilder.Append(","); + colBuilder.Append(TableConstants.Timestamp); + } } builder.Add(TableConstants.Select, colBuilder.ToString()); diff --git a/Lib/Common/Table/TableQueryGeneric.Common.cs b/Lib/Common/Table/TableQueryGeneric.Common.cs index bfdd6f67c..4bb3c84e2 100644 --- a/Lib/Common/Table/TableQueryGeneric.Common.cs +++ b/Lib/Common/Table/TableQueryGeneric.Common.cs @@ -28,7 +28,7 @@ namespace Microsoft.WindowsAzure.Storage.Table /// /// Represents a query against a Windows Azure table. /// - public sealed partial class TableQuery + public partial class TableQuery { #region Properties @@ -129,7 +129,7 @@ public TableQuery Where(string filter) #region Impl - internal UriQueryBuilder GenerateQueryBuilder() + internal UriQueryBuilder GenerateQueryBuilder(bool? projectSystemProperties) { UriQueryBuilder builder = new UriQueryBuilder(); @@ -175,22 +175,25 @@ internal UriQueryBuilder GenerateQueryBuilder() } } - if (!foundPk) + if (projectSystemProperties.Value) { - colBuilder.Append(","); - colBuilder.Append(TableConstants.PartitionKey); - } + if (!foundPk) + { + colBuilder.Append(","); + colBuilder.Append(TableConstants.PartitionKey); + } - if (!foundRk) - { - colBuilder.Append(","); - colBuilder.Append(TableConstants.RowKey); - } + if (!foundRk) + { + colBuilder.Append(","); + colBuilder.Append(TableConstants.RowKey); + } - if (!foundTs) - { - colBuilder.Append(","); - colBuilder.Append(TableConstants.Timestamp); + if (!foundTs) + { + colBuilder.Append(","); + colBuilder.Append(TableConstants.Timestamp); + } } builder.Add(TableConstants.Select, colBuilder.ToString()); diff --git a/Lib/Common/Table/TableRequestOptions.cs b/Lib/Common/Table/TableRequestOptions.cs index 771d401f0..589cc5708 100644 --- a/Lib/Common/Table/TableRequestOptions.cs +++ b/Lib/Common/Table/TableRequestOptions.cs @@ -36,6 +36,26 @@ public sealed class TableRequestOptions : IRequestOptions /// private TimeSpan? maximumExecutionTime; + /// + /// Defines the absolute default option values, should neither the user nor client specify anything. + /// + internal static TableRequestOptions BaseDefaultRequestOptions = new TableRequestOptions() + { + RetryPolicy = new NoRetry(), + LocationMode = RetryPolicies.LocationMode.PrimaryOnly, + ServerTimeout = null, + MaximumExecutionTime = null, + PayloadFormat = TablePayloadFormat.Json, + PropertyResolver = null, + ProjectSystemProperties = true, + +#if !(WINDOWS_RT || ASPNET_K || PORTABLE) + EncryptionPolicy = null, + RequireEncryption = null, + EncryptionResolver = null +#endif + }; + /// /// Initializes a new instance of the class. /// @@ -58,6 +78,7 @@ public TableRequestOptions(TableRequestOptions other) this.OperationExpiryTime = other.OperationExpiryTime; this.PayloadFormat = other.PayloadFormat; this.PropertyResolver = other.PropertyResolver; + this.ProjectSystemProperties = other.ProjectSystemProperties; #if !(WINDOWS_RT || ASPNET_K || PORTABLE) this.EncryptionPolicy = other.EncryptionPolicy; this.RequireEncryption = other.RequireEncryption; @@ -70,27 +91,61 @@ internal static TableRequestOptions ApplyDefaults(TableRequestOptions requestOpt { TableRequestOptions modifiedOptions = new TableRequestOptions(requestOptions); - modifiedOptions.RetryPolicy = modifiedOptions.RetryPolicy ?? serviceClient.DefaultRequestOptions.RetryPolicy; - modifiedOptions.LocationMode = (modifiedOptions.LocationMode - ?? serviceClient.DefaultRequestOptions.LocationMode) - ?? RetryPolicies.LocationMode.PrimaryOnly; - modifiedOptions.ServerTimeout = modifiedOptions.ServerTimeout ?? serviceClient.DefaultRequestOptions.ServerTimeout; - modifiedOptions.MaximumExecutionTime = modifiedOptions.MaximumExecutionTime ?? serviceClient.DefaultRequestOptions.MaximumExecutionTime; - modifiedOptions.PayloadFormat = ( + modifiedOptions.RetryPolicy = + modifiedOptions.RetryPolicy + ?? serviceClient.DefaultRequestOptions.RetryPolicy + ?? BaseDefaultRequestOptions.RetryPolicy; + + modifiedOptions.LocationMode = + modifiedOptions.LocationMode + ?? serviceClient.DefaultRequestOptions.LocationMode + ?? BaseDefaultRequestOptions.LocationMode; + + modifiedOptions.ServerTimeout = + modifiedOptions.ServerTimeout + ?? serviceClient.DefaultRequestOptions.ServerTimeout + ?? BaseDefaultRequestOptions.ServerTimeout; + + modifiedOptions.MaximumExecutionTime = + modifiedOptions.MaximumExecutionTime + ?? serviceClient.DefaultRequestOptions.MaximumExecutionTime + ?? BaseDefaultRequestOptions.MaximumExecutionTime; + + modifiedOptions.PayloadFormat = modifiedOptions.PayloadFormat - ?? serviceClient.DefaultRequestOptions.PayloadFormat) - ?? TablePayloadFormat.Json; + ?? serviceClient.DefaultRequestOptions.PayloadFormat + ?? BaseDefaultRequestOptions.PayloadFormat; if (!modifiedOptions.OperationExpiryTime.HasValue && modifiedOptions.MaximumExecutionTime.HasValue) { modifiedOptions.OperationExpiryTime = DateTime.Now + modifiedOptions.MaximumExecutionTime.Value; } - modifiedOptions.PropertyResolver = modifiedOptions.PropertyResolver ?? serviceClient.DefaultRequestOptions.PropertyResolver; + modifiedOptions.PropertyResolver = + modifiedOptions.PropertyResolver + ?? serviceClient.DefaultRequestOptions.PropertyResolver + ?? BaseDefaultRequestOptions.PropertyResolver; + + modifiedOptions.ProjectSystemProperties = + modifiedOptions.ProjectSystemProperties + ?? serviceClient.DefaultRequestOptions.ProjectSystemProperties + ?? BaseDefaultRequestOptions.ProjectSystemProperties; + #if !(WINDOWS_RT || ASPNET_K || PORTABLE) - modifiedOptions.EncryptionPolicy = modifiedOptions.EncryptionPolicy ?? serviceClient.DefaultRequestOptions.EncryptionPolicy; - modifiedOptions.RequireEncryption = modifiedOptions.RequireEncryption ?? serviceClient.DefaultRequestOptions.RequireEncryption; - modifiedOptions.EncryptionResolver = modifiedOptions.EncryptionResolver ?? serviceClient.DefaultRequestOptions.EncryptionResolver; + modifiedOptions.EncryptionPolicy = + modifiedOptions.EncryptionPolicy + ?? serviceClient.DefaultRequestOptions.EncryptionPolicy + ?? BaseDefaultRequestOptions.EncryptionPolicy; + + modifiedOptions.RequireEncryption = + modifiedOptions.RequireEncryption + ?? serviceClient.DefaultRequestOptions.RequireEncryption + ?? BaseDefaultRequestOptions.RequireEncryption; + + modifiedOptions.EncryptionResolver = + modifiedOptions.EncryptionResolver + ?? serviceClient.DefaultRequestOptions.EncryptionResolver + ?? BaseDefaultRequestOptions.EncryptionResolver; #endif return modifiedOptions; @@ -179,6 +234,11 @@ internal void AssertPolicyIfRequired() /// An object of type . public IRetryPolicy RetryPolicy { get; set; } + /// + /// Gets or sets the option to include system properties such as Partition Key and Row Key in queries. + /// + public bool? ProjectSystemProperties { get; set; } + #if !(WINDOWS_RT || ASPNET_K || PORTABLE) /// /// Gets or sets the encryption policy for the request. @@ -247,29 +307,17 @@ public TablePayloadFormat? PayloadFormat } } - private Func propertyResolver = null; - /// /// Gets or sets the delegate that is used to get the for an entity property given the partition key, row key, and the property name. /// - public Func PropertyResolver - { - get { return this.propertyResolver; } - set { this.propertyResolver = value; } - } + public Func PropertyResolver { get; set; } #if !(WINDOWS_RT || ASPNET_K || PORTABLE) - private Func encryptionResolver = null; - /// /// Gets or sets the delegate to get the value indicating whether or not a property should be encrypted, given the partition key, row key, /// and property name. /// - public Func EncryptionResolver - { - get { return this.encryptionResolver; } - set { this.encryptionResolver = value; } - } + public Func EncryptionResolver { get; set; } #endif } } diff --git a/Lib/Portable/Microsoft.WindowsAzure.Storage.csproj b/Lib/Portable/Microsoft.WindowsAzure.Storage.csproj index 914742d6e..15eaca6b9 100644 --- a/Lib/Portable/Microsoft.WindowsAzure.Storage.csproj +++ b/Lib/Portable/Microsoft.WindowsAzure.Storage.csproj @@ -154,6 +154,9 @@ Blob\ListBlockItem.cs + + Blob\PageDiffRange.cs + Blob\PageRange.cs @@ -181,6 +184,9 @@ Blob\Protocol\GetBlockListResponse.cs + + Blob\Protocol\GetPageDiffRangesResponse.cs + Blob\Protocol\GetPageRangesResponse.cs @@ -256,6 +262,9 @@ Core\NullType.cs + + Core\SasQueryBuilder.cs + Core\SR.cs @@ -613,8 +622,8 @@ Table\TableServiceTable.cs - - Auth\Protocol\NoOpAuthenticationHttpHandler.cs + + Auth\Protocol\StorageAuthenticationHttpHandler.cs Blob\BlobReadStream.cs @@ -697,8 +706,8 @@ Core\Util\HttpResponseMessageUtils.cs - - Core\Util\WindowsAzureErrorCode.cs + + Core\StorageRequestMessage.cs ExceptionInfo.cs @@ -775,9 +784,6 @@ Table\TableQuerySegmentNonGeneric.cs - - WrappedStorageException.cs - diff --git a/Lib/Portable/Properties/AssemblyInfo.cs b/Lib/Portable/Properties/AssemblyInfo.cs index 7ac3626e4..442534c24 100644 --- a/Lib/Portable/Properties/AssemblyInfo.cs +++ b/Lib/Portable/Properties/AssemblyInfo.cs @@ -26,6 +26,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("6.2.2.0")] -[assembly: AssemblyFileVersion("6.2.2.0")] -[assembly: AssemblyInformationalVersion("6.2.2.0-preview")] +[assembly: AssemblyVersion("7.0.0.0")] +[assembly: AssemblyFileVersion("7.0.0.0")] +[assembly: AssemblyInformationalVersion("7.0.1.0-preview")] diff --git a/Lib/WindowsDesktop/GlobalSuppressions.cs b/Lib/WindowsDesktop/GlobalSuppressions.cs index be0239812..00d6d589a 100644 --- a/Lib/WindowsDesktop/GlobalSuppressions.cs +++ b/Lib/WindowsDesktop/GlobalSuppressions.cs @@ -214,6 +214,7 @@ [assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.ICloudBlob.#UploadFromFile(System.String,System.IO.FileMode,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext)", Justification = "Backward compatibility")] [assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.ICloudBlob.#UploadFromByteArray(System.Byte[],System.Int32,System.Int32,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext)", Justification = "Backward compatibility")] [assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.ICloudBlob.#DownloadRangeToByteArray(System.Byte[],System.Int32,System.Nullable`1,System.Nullable`1,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext)", Justification = "Backward compatibility")] +[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.ICloudBlob.#AcquireLeaseAsync(System.Nullable`1,System.String)", Justification = "Backward compatibility")] [assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Table.TableQuery`1.#ExecuteSegmented(Microsoft.WindowsAzure.Storage.Table.TableContinuationToken,Microsoft.WindowsAzure.Storage.Table.TableRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext)", Justification = "Backward compatibility")] [assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Table.TableQuery`1.#Execute(Microsoft.WindowsAzure.Storage.Table.TableRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext)", Justification = "Backward compatibility")] [assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob.#SetSequenceNumber(Microsoft.WindowsAzure.Storage.Blob.SequenceNumberAction,System.Nullable`1,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext)", Justification = "Backward compatibility")] @@ -338,6 +339,17 @@ [assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Table.TableOperation.#Retrieve`1(System.String,System.String,Microsoft.WindowsAzure.Storage.Table.EntityResolver`1,System.Collections.Generic.List`1)", Justification = "Backward compatibility")] [assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Table.TableOperation.#Retrieve(System.String,System.String,System.Collections.Generic.List`1)", Justification = "Backward compatibility")] [assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Table.TableBatchOperation.#Retrieve`1(System.String,System.String,Microsoft.WindowsAzure.Storage.Table.EntityResolver`1,System.Collections.Generic.List`1)", Justification = "Backward compatibility")] +[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.ICloudBlob.#UploadFromFile(System.String,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext)", Justification = "Backward compatibility")] +[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob.#UploadFromFile(System.String,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext)", Justification = "Backward compatibility")] +[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.#UploadFromFile(System.String,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext)", Justification = "Backward compatibility")] +[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.#AcquireLeaseAsync(System.Nullable`1,System.String)", Justification = "Backward compatibility")] +[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudBlob.#AcquireLeaseAsync(System.Nullable`1,System.String)", Justification = "Backward compatibility")] +[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob.#AppendFromFile(System.String,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext)", Justification = "Backward compatibility")] +[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob.#UploadFromFile(System.String,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext)", Justification = "Backward compatibility")] +[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.File.CloudFile.#UploadFromFile(System.String,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.File.FileRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext)", Justification = "Backward compatibility")] +[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.File.Protocol.FileServiceProperties.#.ctor(Microsoft.WindowsAzure.Storage.Shared.Protocol.MetricsProperties,Microsoft.WindowsAzure.Storage.Shared.Protocol.MetricsProperties,Microsoft.WindowsAzure.Storage.Shared.Protocol.CorsProperties)", Justification = "Backward compatibility")] +[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Shared.Protocol.ServiceProperties.#.ctor(Microsoft.WindowsAzure.Storage.Shared.Protocol.LoggingProperties,Microsoft.WindowsAzure.Storage.Shared.Protocol.MetricsProperties,Microsoft.WindowsAzure.Storage.Shared.Protocol.MetricsProperties,Microsoft.WindowsAzure.Storage.Shared.Protocol.CorsProperties)", Justification = "Backward compatibility")] +[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob.#GetPageRangesDiff(System.DateTimeOffset,System.Nullable`1,System.Nullable`1,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext)")] // CA1031 [assembly: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.#BeginOpenWrite(Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext,System.AsyncCallback,System.Object)", Justification = "Needed to ensure exceptions are not thrown on threadpool thread.")] @@ -479,6 +491,7 @@ [assembly: SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Table.Protocol.TableOperationHttpResponseParsers.#TableBatchOperationPostProcess(System.Collections.Generic.IList`1,Microsoft.WindowsAzure.Storage.Table.TableBatchOperation,Microsoft.WindowsAzure.Storage.Core.Executor.RESTCommand`1>,System.Net.HttpWebResponse,Microsoft.WindowsAzure.Storage.OperationContext,Microsoft.WindowsAzure.Storage.Table.TableRequestOptions,System.String)", Justification = "Reviewed")] [assembly: SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.#BeginUploadFromStreamHelper(System.IO.Stream,System.Nullable`1,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext,System.AsyncCallback,System.Object)", Justification = "Reviewed")] [assembly: SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudBlob.#GetBlobImpl(Microsoft.WindowsAzure.Storage.Blob.BlobAttributes,System.IO.Stream,System.Nullable`1,System.Nullable`1,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions)", Justification = "Reviewed")] +[assembly: SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions.#ApplyDefaults(Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.Blob.BlobType,Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient,System.Boolean)", Justification = "Reviewed")] // CA1505 [assembly: SuppressMessage("Microsoft.Maintainability", "CA1505:AvoidUnmaintainableCode", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Table.Queryable.ReflectionUtil.#.cctor()", Justification = "Reviewed")] @@ -717,6 +730,11 @@ [assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Core.LengthLimitingStream.#BeginWrite(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object)", Justification = "Reviewed.")] [assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Table.Protocol.TableOperationHttpWebRequestFactory.#BuildRequestForTableBatchOperation(System.Uri,Microsoft.WindowsAzure.Storage.Core.UriQueryBuilder,Microsoft.WindowsAzure.Storage.IBufferManager,System.Nullable`1,System.String,Microsoft.WindowsAzure.Storage.Table.TableBatchOperation,System.Boolean,Microsoft.WindowsAzure.Storage.OperationContext,Microsoft.WindowsAzure.Storage.Table.TableRequestOptions,System.String)", Justification = "Reviewed.")] [assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Table.Protocol.TableOperationHttpWebRequestFactory.#BuildRequestForTableOperation(System.Uri,Microsoft.WindowsAzure.Storage.Core.UriQueryBuilder,Microsoft.WindowsAzure.Storage.IBufferManager,System.Nullable`1,Microsoft.WindowsAzure.Storage.Table.TableOperation,System.Boolean,Microsoft.WindowsAzure.Storage.OperationContext,Microsoft.WindowsAzure.Storage.Table.TableRequestOptions,System.String)", Justification = "Reviewed.")] +[assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob.#BeginAppendFromFile(System.String,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext,System.AsyncCallback,System.Object)", Justification = "Reviewed.")] +[assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob.#BeginUploadFromFile(System.String,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext,System.AsyncCallback,System.Object)", Justification = "Reviewed.")] +[assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob.#BeginUploadFromFile(System.String,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext,System.AsyncCallback,System.Object)", Justification = "Reviewed.")] +[assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.File.CloudFile.#BeginUploadFromFile(System.String,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.File.FileRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext,System.AsyncCallback,System.Object)", Justification = "Reviewed.")] +[assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.#BeginUploadFromFile(System.String,Microsoft.WindowsAzure.Storage.AccessCondition,Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions,Microsoft.WindowsAzure.Storage.OperationContext,System.AsyncCallback,System.Object)", Justification = "Reviewed.")] // CA2204 [assembly: SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "deleteSnapshotsOption", Scope = "member", Target = "Microsoft.WindowsAzure.Storage.Blob.Protocol.BlobHttpWebRequestFactory.#Delete(System.Uri,System.Nullable`1,System.Nullable`1,Microsoft.WindowsAzure.Storage.Blob.DeleteSnapshotsOption,Microsoft.WindowsAzure.Storage.AccessCondition,System.Boolean,Microsoft.WindowsAzure.Storage.OperationContext)", Justification = "Reviewed.")] diff --git a/Lib/WindowsDesktop/Microsoft.WindowsAzure.Storage.csproj b/Lib/WindowsDesktop/Microsoft.WindowsAzure.Storage.csproj index 960c100a5..d2ffc292a 100644 --- a/Lib/WindowsDesktop/Microsoft.WindowsAzure.Storage.csproj +++ b/Lib/WindowsDesktop/Microsoft.WindowsAzure.Storage.csproj @@ -56,7 +56,7 @@ False ..\..\packages\Microsoft.Data.Services.Client.5.6.4\lib\net40\Microsoft.Data.Services.Client.dll - + False ..\..\packages\Newtonsoft.Json.6.0.8\lib\net40\Newtonsoft.Json.dll diff --git a/Lib/WindowsDesktop/Properties/AssemblyInfo.cs b/Lib/WindowsDesktop/Properties/AssemblyInfo.cs index 1e5485265..46ffe5873 100644 --- a/Lib/WindowsDesktop/Properties/AssemblyInfo.cs +++ b/Lib/WindowsDesktop/Properties/AssemblyInfo.cs @@ -34,8 +34,8 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("6.2.2.0")] -[assembly: AssemblyFileVersion("6.2.2.0")] +[assembly: AssemblyVersion("7.0.0.0")] +[assembly: AssemblyFileVersion("7.0.0.0")] #if SIGN [assembly: InternalsVisibleTo( diff --git a/Lib/WindowsDesktop/WindowsAzure.Storage.nuspec b/Lib/WindowsDesktop/WindowsAzure.Storage.nuspec index 2786bb493..8383b6ee4 100644 --- a/Lib/WindowsDesktop/WindowsAzure.Storage.nuspec +++ b/Lib/WindowsDesktop/WindowsAzure.Storage.nuspec @@ -2,7 +2,7 @@ WindowsAzure.Storage - 6.2.1 + 7.0.0 Windows Azure Storage Microsoft Microsoft diff --git a/Lib/WindowsPhone/Properties/AssemblyInfo.cs b/Lib/WindowsPhone/Properties/AssemblyInfo.cs index 4893cae19..148338949 100644 --- a/Lib/WindowsPhone/Properties/AssemblyInfo.cs +++ b/Lib/WindowsPhone/Properties/AssemblyInfo.cs @@ -32,8 +32,8 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("6.2.2.0")] -[assembly: AssemblyFileVersion("6.2.2.0")] +[assembly: AssemblyVersion("7.0.0.0")] +[assembly: AssemblyFileVersion("7.0.0.0")] [assembly: NeutralResourcesLanguageAttribute("en-US")] #if SIGN diff --git a/Lib/WindowsPhoneRT/Properties/AssemblyInfo.cs b/Lib/WindowsPhoneRT/Properties/AssemblyInfo.cs index b4a0af1ac..86e1ad223 100644 --- a/Lib/WindowsPhoneRT/Properties/AssemblyInfo.cs +++ b/Lib/WindowsPhoneRT/Properties/AssemblyInfo.cs @@ -24,8 +24,8 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("6.2.2.0")] -[assembly: AssemblyFileVersion("6.2.2.0")] +[assembly: AssemblyVersion("7.0.0.0")] +[assembly: AssemblyFileVersion("7.0.0.0")] [assembly: NeutralResourcesLanguageAttribute("en-US")] [assembly: ComVisible(false)] diff --git a/Lib/WindowsRuntime/Auth/Protocol/StorageAuthenticationHttpHandler.SharedKey.cs b/Lib/WindowsRuntime/Auth/Protocol/StorageAuthenticationHttpHandler.SharedKey.cs new file mode 100644 index 000000000..1196a0434 --- /dev/null +++ b/Lib/WindowsRuntime/Auth/Protocol/StorageAuthenticationHttpHandler.SharedKey.cs @@ -0,0 +1,66 @@ +// ----------------------------------------------------------------------------------------- +// +// Copyright 2013 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------------------- + +namespace Microsoft.WindowsAzure.Storage.Auth.Protocol +{ + using Microsoft.WindowsAzure.Storage.Core; + using Microsoft.WindowsAzure.Storage.Core.Auth; + using Microsoft.WindowsAzure.Storage.Core.Util; + using Microsoft.WindowsAzure.Storage.Shared.Protocol; + using System; + using System.Globalization; + using System.Net.Http; + using System.Net.Http.Headers; + using System.Threading; + using System.Threading.Tasks; + + partial class StorageAuthenticationHttpHandler + { + private Task GetSharedKeyAuthenticationTask(StorageRequestMessage request, CancellationToken cancellationToken) + { + StorageRequestMessage storageRequest = request as StorageRequestMessage; + + ICanonicalizer canonicalizer = storageRequest.Canonicalizer; + StorageCredentials credentials = storageRequest.Credentials; + string accountName = storageRequest.AccountName; + + if (!request.Headers.Contains(Constants.HeaderConstants.Date)) + { + string dateString = HttpWebUtility.ConvertDateTimeToHttpString(DateTimeOffset.UtcNow); + request.Headers.Add(Constants.HeaderConstants.Date, dateString); + } + + if (credentials.IsSharedKey) + { + StorageAccountKey accountKey = credentials.Key; + if (!string.IsNullOrEmpty(accountKey.KeyName)) + { + request.Headers.Add(Constants.HeaderConstants.KeyNameHeader, accountKey.KeyName); + } + + string message = canonicalizer.CanonicalizeHttpRequest(request, accountName); + string signature = CryptoUtility.ComputeHmac256(accountKey.KeyValue, message); + + request.Headers.Authorization = new AuthenticationHeaderValue( + canonicalizer.AuthorizationScheme, + string.Format(CultureInfo.InvariantCulture, "{0}:{1}", credentials.AccountName, signature)); + } + + return base.SendAsync(request, cancellationToken); + } + } +} diff --git a/Lib/WindowsRuntime/Auth/Protocol/StorageAuthenticationHttpHandler.cs b/Lib/WindowsRuntime/Auth/Protocol/StorageAuthenticationHttpHandler.cs new file mode 100644 index 000000000..49b86bc45 --- /dev/null +++ b/Lib/WindowsRuntime/Auth/Protocol/StorageAuthenticationHttpHandler.cs @@ -0,0 +1,79 @@ +// ----------------------------------------------------------------------------------------- +// +// Copyright 2013 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------------------- + +namespace Microsoft.WindowsAzure.Storage.Auth.Protocol +{ + using Microsoft.WindowsAzure.Storage.Core; + using Microsoft.WindowsAzure.Storage.Core.Auth; + using Microsoft.WindowsAzure.Storage.Core.Util; + using Microsoft.WindowsAzure.Storage.Shared.Protocol; + using System; + using System.Globalization; + using System.Net.Http; + using System.Net.Http.Headers; + using System.Threading; + using System.Threading.Tasks; + + internal sealed partial class StorageAuthenticationHttpHandler : HttpClientHandler + { + private static Lazy instance = new Lazy(() => new StorageAuthenticationHttpHandler()); + + public static StorageAuthenticationHttpHandler Instance + { + get + { + return instance.Value; + } + } + + private Task GetNoOpAuthenticationTask(StorageRequestMessage request, CancellationToken cancellationToken) + { + return base.SendAsync(request, cancellationToken); + } + + protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + StorageRequestMessage storageRequest = request as StorageRequestMessage; + + Func> taskFactory = this.SelectAuthenticationTaskFactory(storageRequest); + + Task task = taskFactory(storageRequest, cancellationToken); + + return task; + } + + private Func> SelectAuthenticationTaskFactory(StorageRequestMessage request) + { + Func> authenticationHandler; + + if (request.Credentials.IsSharedKey) + { +#if PORTABLE + throw new NotSupportedException(SR.PortableDoesNotSupportSharedKey); +#else + authenticationHandler = this.GetSharedKeyAuthenticationTask; +#endif + } + else + { + authenticationHandler = this.GetNoOpAuthenticationTask; + } + + return authenticationHandler; + } + } +} \ No newline at end of file diff --git a/Lib/WindowsRuntime/Blob/BlobReadStream.cs b/Lib/WindowsRuntime/Blob/BlobReadStream.cs index 88cfeadb3..3f4f82ade 100644 --- a/Lib/WindowsRuntime/Blob/BlobReadStream.cs +++ b/Lib/WindowsRuntime/Blob/BlobReadStream.cs @@ -134,7 +134,7 @@ private async Task DispatchReadAsync(byte[] buffer, int offset, int count) { this.internalBuffer.SetLength(0); await this.blob.DownloadRangeToStreamAsync( - this.internalBuffer.AsOutputStream(), + this.internalBuffer, this.currentOffset, this.GetReadSize(), this.accessCondition, diff --git a/Lib/WindowsRuntime/Blob/BlobWriteStream.cs b/Lib/WindowsRuntime/Blob/BlobWriteStream.cs index f43dfec07..5dc970d58 100644 --- a/Lib/WindowsRuntime/Blob/BlobWriteStream.cs +++ b/Lib/WindowsRuntime/Blob/BlobWriteStream.cs @@ -223,11 +223,7 @@ protected override void Dispose(bool disposing) /// Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying blob, and commits the blob. /// /// A task that represents the asynchronous commit operation. -#if ASPNET_K || PORTABLE public override async Task CommitAsync() -#else - public async Task CommitAsync() -#endif { await this.FlushAsync(); this.committed = true; @@ -329,7 +325,7 @@ private async Task WriteBlockAsync(Stream blockData, string blockId, string bloc { this.noPendingWritesEvent.Increment(); await this.parallelOperationSemaphore.WaitAsync(); - Task putBlockTask = this.blockBlob.PutBlockAsync(blockId, blockData.AsInputStream(), blockMD5, this.accessCondition, this.options, this.operationContext).AsTask().ContinueWith(task => + Task putBlockTask = this.blockBlob.PutBlockAsync(blockId, blockData, blockMD5, this.accessCondition, this.options, this.operationContext).ContinueWith(task => { if (task.Exception != null) { @@ -352,7 +348,7 @@ private async Task WritePagesAsync(Stream pageData, long offset, string contentM { this.noPendingWritesEvent.Increment(); await this.parallelOperationSemaphore.WaitAsync(); - Task writePagesTask = this.pageBlob.WritePagesAsync(pageData.AsInputStream(), offset, contentMD5, this.accessCondition, this.options, this.operationContext).AsTask().ContinueWith(task => + Task writePagesTask = this.pageBlob.WritePagesAsync(pageData, offset, contentMD5, this.accessCondition, this.options, this.operationContext).ContinueWith(task => { if (task.Exception != null) { @@ -381,7 +377,7 @@ private async Task WriteAppendBlockAsync(Stream blockData, long offset, string b this.accessCondition.IfAppendPositionEqual = offset; int previousResultsCount = this.operationContext.RequestResults.Count; - Task writeBlockTask = this.appendBlob.AppendBlockAsync(blockData.AsInputStream(), blockMD5, this.accessCondition, this.options, this.operationContext).AsTask().ContinueWith(task => + Task writeBlockTask = this.appendBlob.AppendBlockAsync(blockData, blockMD5, this.accessCondition, this.options, this.operationContext).ContinueWith(task => { if (task.Exception != null) { diff --git a/Lib/WindowsRuntime/Blob/BlobWriteStreamHelper.cs b/Lib/WindowsRuntime/Blob/BlobWriteStreamHelper.cs index 778b2b79b..34fac73cd 100644 --- a/Lib/WindowsRuntime/Blob/BlobWriteStreamHelper.cs +++ b/Lib/WindowsRuntime/Blob/BlobWriteStreamHelper.cs @@ -28,7 +28,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// This class implements IRandomAccessStream and acts like a proxy between /// the caller and the actual Stream implementation. /// - internal class BlobWriteStreamHelper : ICloudBlobStream + internal class BlobWriteStreamHelper { private BlobWriteStream originalStream; private IOutputStream originalStreamAsOutputStream; diff --git a/Lib/WindowsRuntime/Blob/CloudAppendBlob.cs b/Lib/WindowsRuntime/Blob/CloudAppendBlob.cs index b6fe39263..fd8e7ee3f 100644 --- a/Lib/WindowsRuntime/Blob/CloudAppendBlob.cs +++ b/Lib/WindowsRuntime/Blob/CloudAppendBlob.cs @@ -28,11 +28,10 @@ namespace Microsoft.WindowsAzure.Storage.Blob using System.Net; using System.Net.Http; using System.Text; - -#if ASPNET_K || PORTABLE using System.Threading; using System.Threading.Tasks; -#else + +#if WINDOWS_RT using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Storage.Streams; @@ -42,7 +41,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// Represents an append blob, a type of blob where blocks of data are always committed to the end of the blob. /// - public sealed partial class CloudAppendBlob : CloudBlob, ICloudBlob + public partial class CloudAppendBlob : CloudBlob, ICloudBlob { /// /// Opens a stream for writing to the blob. @@ -50,11 +49,7 @@ public sealed partial class CloudAppendBlob : CloudBlob, ICloudBlob /// Use true to create a new append blob or overwrite an existing one, false to append to an existing blob. /// A stream to be used for writing to the blob. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task OpenWriteAsync(bool createNew) -#else - public IAsyncOperation OpenWriteAsync(bool createNew) -#endif + public virtual Task OpenWriteAsync(bool createNew) { return this.OpenWriteAsync(createNew, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -70,8 +65,7 @@ public IAsyncOperation OpenWriteAsync(bool createNew) /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// A stream to be used for writing to the blob. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task OpenWriteAsync(bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task OpenWriteAsync(bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.OpenWriteAsync(createNew, accessCondition, options, operationContext, CancellationToken.None); } @@ -86,10 +80,7 @@ public Task OpenWriteAsync(bool createNew, AccessCondition acce /// A to observe while waiting for a task to complete. /// A stream to be used for writing to the blob. [DoesServiceRequest] - public Task OpenWriteAsync(bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation OpenWriteAsync(bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task OpenWriteAsync(bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.AppendBlob, this.ServiceClient, false); @@ -98,29 +89,17 @@ public IAsyncOperation OpenWriteAsync(bool createNew, AccessCo throw new ArgumentException(SR.MD5NotPossible); } -#if ASPNET_K || PORTABLE return Task.Run(async () => -#else - return AsyncInfo.Run(async (token) => -#endif { if (createNew) { -#if ASPNET_K || PORTABLE await this.CreateOrReplaceAsync(accessCondition, options, operationContext, cancellationToken); -#else - await this.CreateOrReplaceAsync(accessCondition, options, operationContext).AsTask(token); -#endif } else { // Although we don't need any properties from the service, we should make this call in order to honor the user specified conditional headers // while opening an existing stream and to get the append position for an existing blob if user didn't specify one. -#if ASPNET_K || PORTABLE await this.FetchAttributesAsync(accessCondition, options, operationContext, cancellationToken); -#else - await this.FetchAttributesAsync(accessCondition, options, operationContext).AsTask(token); -#endif } if (accessCondition != null) @@ -128,41 +107,22 @@ public IAsyncOperation OpenWriteAsync(bool createNew, AccessCo accessCondition = new AccessCondition() { LeaseId = accessCondition.LeaseId, IfAppendPositionEqual = accessCondition.IfAppendPositionEqual, IfMaxSizeLessThanOrEqual = accessCondition.IfMaxSizeLessThanOrEqual }; } -#if ASPNET_K || PORTABLE CloudBlobStream stream = new BlobWriteStream(this, accessCondition, modifiedOptions, operationContext); -#else - ICloudBlobStream stream = new BlobWriteStreamHelper(this, accessCondition, modifiedOptions, operationContext); -#endif return stream; -#if ASPNET_K || PORTABLE }, cancellationToken); -#else - }); -#endif } /// /// Uploads a stream to an append blob. If the blob already exists, it will be overwritten. Recommended only for single-writer scenarios. /// /// The stream providing the blob content. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source) -#else - /// An that represents an asynchronous action. - /// - /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. - /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// To append data to an append blob that already exists, see . - /// - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source) -#endif + public virtual Task UploadFromStreamAsync(Stream source) { return this.UploadFromStreamAsyncHelper(source, null /* length */, true /* createNew */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -172,7 +132,6 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source) /// /// The stream providing the blob content. /// The number of bytes to write from the source stream at its current position. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. @@ -180,17 +139,7 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source) /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length) -#else - /// An that represents an asynchronous action. - /// - /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. - /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// To append data to an append blob that already exists, see . - /// - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source, long length) -#endif + public virtual Task UploadFromStreamAsync(Stream source, long length) { return this.UploadFromStreamAsyncHelper(source, length, true /* createNew */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -202,7 +151,6 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, long length) /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. @@ -210,17 +158,7 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, long length) /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - /// An that represents an asynchronous action. - /// - /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. - /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// To append data to an append blob that already exists, see . - /// - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsyncHelper(source, null /* length */, true /* createNew */, accessCondition, options, operationContext); } @@ -233,7 +171,6 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, AccessCondition a /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. @@ -241,22 +178,11 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, AccessCondition a /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - /// An that represents an asynchronous action. - /// - /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. - /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// To append data to an append blob that already exists, see . - /// - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsyncHelper(source, length, true /* createNew */, accessCondition, options, operationContext); } -#if ASPNET_K || PORTABLE /// /// Uploads a stream to an append blob. If the blob already exists, it will be overwritten. Recommended only for single-writer scenarios. /// @@ -272,7 +198,7 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, long length, Acce /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.UploadFromStreamAsyncHelper(source, null /* length */, true /* createNew */, accessCondition, options, operationContext, cancellationToken); } @@ -293,32 +219,22 @@ public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.UploadFromStreamAsyncHelper(source, length, true /* createNew */, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Appends a stream to an append blob. Recommended only for single-writer scenarios. /// /// The stream providing the blob content. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source) -#else - /// An that represents an asynchronous action. - /// - /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// - [DoesServiceRequest] - public IAsyncAction AppendFromStreamAsync(IInputStream source) -#endif + public virtual Task AppendFromStreamAsync(Stream source) { return this.UploadFromStreamAsyncHelper(source, null /* length */, false /* createNew */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -328,18 +244,12 @@ public IAsyncAction AppendFromStreamAsync(IInputStream source) /// /// The stream providing the blob content. /// The number of bytes to write from the source stream at its current position. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source, long length) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction AppendFromStreamAsync(IInputStream source, long length) -#endif + public virtual Task AppendFromStreamAsync(Stream source, long length) { return this.UploadFromStreamAsyncHelper(source, length, false /* createNew */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -351,23 +261,13 @@ public IAsyncAction AppendFromStreamAsync(IInputStream source, long length) /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - /// An that represents an asynchronous action. - /// - /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. - /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// - [DoesServiceRequest] - public IAsyncAction AppendFromStreamAsync(IInputStream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task AppendFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsyncHelper(source, null /* length */, false /* createNew */, accessCondition, options, operationContext); } @@ -380,28 +280,17 @@ public IAsyncAction AppendFromStreamAsync(IInputStream source, AccessCondition a /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - /// An that represents an asynchronous action. - /// - /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. - /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// - [DoesServiceRequest] - public IAsyncAction AppendFromStreamAsync(IInputStream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task AppendFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsyncHelper(source, length, false /* createNew */, accessCondition, options, operationContext); } -#if ASPNET_K || PORTABLE /// /// Appends a stream to an append blob. Recommended only for single-writer scenarios. /// @@ -416,7 +305,7 @@ public IAsyncAction AppendFromStreamAsync(IInputStream source, long length, Acce /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AppendFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.UploadFromStreamAsyncHelper(source, null /* length */, false /* createNew */, accessCondition, options, operationContext, cancellationToken); } @@ -436,11 +325,10 @@ public Task AppendFromStreamAsync(Stream source, AccessCondition accessCondition /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AppendFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.UploadFromStreamAsyncHelper(source, length, false /* createNew */, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Uploads a stream to an append blob. Recommended only for single-writer scenarios. @@ -451,7 +339,6 @@ public Task AppendFromStreamAsync(Stream source, long length, AccessCondition ac /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] internal Task UploadFromStreamAsyncHelper(Stream source, long? length, bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) @@ -472,20 +359,14 @@ internal Task UploadFromStreamAsyncHelper(Stream source, long? length, bool crea /// A that represents an asynchronous action. [DoesServiceRequest] internal Task UploadFromStreamAsyncHelper(Stream source, long? length, bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - internal IAsyncAction UploadFromStreamAsyncHelper(IInputStream source, long? length, bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif { CommonUtility.AssertNotNull("source", source); - Stream sourceAsStream = source.AsStreamForRead(); if (length.HasValue) { CommonUtility.AssertInBounds("length", length.Value, 1); - if (sourceAsStream.CanSeek && length > sourceAsStream.Length - sourceAsStream.Position) + if (source.CanSeek && length > source.Length - source.Position) { throw new ArgumentOutOfRangeException("length", SR.StreamLengthShortError); } @@ -496,29 +377,16 @@ internal IAsyncAction UploadFromStreamAsyncHelper(IInputStream source, long? len operationContext = operationContext ?? new OperationContext(); ExecutionState tempExecutionState = CommonUtility.CreateTemporaryExecutionState(modifiedOptions); -#if ASPNET_K || PORTABLE return Task.Run(async () => { using (CloudBlobStream blobStream = await this.OpenWriteAsync(createNew, accessCondition, options, operationContext, cancellationToken)) { // We should always call AsStreamForWrite with bufferSize=0 to prevent buffering. Our // stream copier only writes 64K buffers at a time anyway, so no buffering is needed. - await sourceAsStream.WriteToAsync(blobStream, length, null /* maxLength */, false, tempExecutionState, null /* streamCopyState */, cancellationToken); + await source.WriteToAsync(blobStream, length, null /* maxLength */, false, tempExecutionState, null /* streamCopyState */, cancellationToken); await blobStream.CommitAsync(); } }, cancellationToken); -#else - return AsyncInfo.Run(async (token) => - { - using (ICloudBlobStream blobStream = await this.OpenWriteAsync(createNew, accessCondition, options, operationContext).AsTask(token)) - { - // We should always call AsStreamForWrite with bufferSize=0 to prevent buffering. Our - // stream copier only writes 64K buffers at a time anyway, so no buffering is needed. - await sourceAsStream.WriteToAsync(blobStream.AsStreamForWrite(0), length, null /* maxLength */, false, tempExecutionState, null /* streamCopyState */, token); - await blobStream.CommitAsync().AsTask(token); - } - }); -#endif } #if !PORTABLE @@ -527,26 +395,25 @@ internal IAsyncAction UploadFromStreamAsyncHelper(IInputStream source, long? len /// #if ASPNET_K /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. - /// To append data to an append blob that already exists, see . + /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode) + public virtual Task UploadFromFileAsync(string path) { - return this.UploadFromFileAsync(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */); + return this.UploadFromFileAsync(path, null /* accessCondition */, null /* options */, null /* operationContext */); } #else /// The file providing the blob content. - /// An that represents an asynchronous action. + /// An that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public IAsyncAction UploadFromFileAsync(StorageFile source) + public virtual Task UploadFromFileAsync(StorageFile source) { return this.UploadFromFileAsync(source, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -555,51 +422,46 @@ public IAsyncAction UploadFromFileAsync(StorageFile source) /// /// Uploads a file to an append blob. If the blob already exists, it will be overwritten. /// +#if ASPNET_K /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// To append data to an append blob that already exists, see . + /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { - return this.UploadFromFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); + return this.UploadFromFileAsync(path, accessCondition, options, operationContext, CancellationToken.None); } #else - /// An that represents an asynchronous action. + /// The file providing the blob content. + /// An object that represents the access conditions for the blob. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// An that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public IAsyncAction UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { - CommonUtility.AssertNotNull("source", source); - - return AsyncInfo.Run(async (token) => - { - using (IRandomAccessStreamWithContentType stream = await source.OpenReadAsync().AsTask(token)) - { - await this.UploadFromStreamAsync(stream, accessCondition, options, operationContext).AsTask(token); - } - }); + return this.UploadFromFileAsync(source, accessCondition, options, operationContext, CancellationToken.None); } #endif -#if ASPNET_K + /// /// Uploads a file to an append blob. If the blob already exists, it will be overwritten. /// +#if ASPNET_K /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. @@ -608,21 +470,47 @@ public IAsyncAction UploadFromFileAsync(StorageFile source, AccessCondition acce /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// To append data to an append blob that already exists, see . + /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("path", path); return Task.Run(async () => { - using (Stream stream = new FileStream(path, mode, FileAccess.Read)) + using (Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { await this.UploadFromStreamAsync(stream, accessCondition, options, operationContext, cancellationToken); } }, cancellationToken); } +#else + /// The file providing the blob content. + /// A enumeration value that specifies how to open the file. + /// An object that represents the access conditions for the blob. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// A to observe while waiting for a task to complete. + /// A that represents an asynchronous action. + /// + /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. + /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. + /// To append data to an append blob that already exists, see . + /// + [DoesServiceRequest] + public virtual Task UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + { + CommonUtility.AssertNotNull("source", source); + + return Task.Run(async () => + { + using (IRandomAccessStreamWithContentType stream = await source.OpenReadAsync().AsTask(cancellationToken)) + { + await this.UploadFromStreamAsync(stream.AsStream(), accessCondition, options, operationContext, cancellationToken); + } + }); + } #endif /// @@ -630,18 +518,17 @@ public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition acce /// #if ASPNET_K /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task AppendFromFileAsync(string path, FileMode mode) + public virtual Task AppendFromFileAsync(string path) { - return this.AppendFromFileAsync(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */); + return this.AppendFromFileAsync(path, null /* accessCondition */, null /* options */, null /* operationContext */); } #else /// The file providing the blob content. - /// An that represents an asynchronous action. + /// An that represents an asynchronous action. [DoesServiceRequest] - public IAsyncAction AppendFromFileAsync(StorageFile source) + public virtual Task AppendFromFileAsync(StorageFile source) { return this.AppendFromFileAsync(source, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -650,47 +537,42 @@ public IAsyncAction AppendFromFileAsync(StorageFile source) /// /// Appends a file to an append blob. Recommended only for single-writer scenarios. /// +#if ASPNET_K /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K /// A that represents an asynchronous action. /// /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AppendFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { - return this.AppendFromFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); + return this.AppendFromFileAsync(path, accessCondition, options, operationContext, CancellationToken.None); } #else - /// An that represents an asynchronous action. + /// The file providing the blob content. + /// An object that represents the access conditions for the blob. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// An that represents an asynchronous action. /// /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public IAsyncAction AppendFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AppendFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { - CommonUtility.AssertNotNull("source", source); - - return AsyncInfo.Run(async (token) => - { - using (IRandomAccessStreamWithContentType stream = await source.OpenReadAsync().AsTask(token)) - { - await this.AppendFromStreamAsync(stream, accessCondition, options, operationContext).AsTask(token); - } - }); + return this.AppendFromFileAsync(source, accessCondition, options, operationContext, CancellationToken.None); } + #endif -#if ASPNET_K /// /// Appends a file to an append blob. Recommended only for single-writer scenarios. /// +#if ASPNET_K /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. @@ -700,18 +582,42 @@ public IAsyncAction AppendFromFileAsync(StorageFile source, AccessCondition acce /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AppendFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("path", path); return Task.Run(async () => { - using (Stream stream = new FileStream(path, mode, FileAccess.Read)) + using (Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { await this.AppendFromStreamAsync(stream, accessCondition, options, operationContext, cancellationToken); } }, cancellationToken); } +#else + /// The file providing the blob content. + /// An object that represents the access conditions for the blob. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// A to observe while waiting for a task to complete. + /// A that represents an asynchronous action. + /// + /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. + /// + [DoesServiceRequest] + public virtual Task AppendFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + { + + CommonUtility.AssertNotNull("source", source); + + return Task.Run(async () => + { + using (IRandomAccessStreamWithContentType stream = await source.OpenReadAsync().AsTask(cancellationToken)) + { + await this.AppendFromStreamAsync(stream.AsStream(), accessCondition, options, operationContext, cancellationToken); + } + }); + } #endif #endif @@ -721,23 +627,13 @@ public Task AppendFromFileAsync(string path, FileMode mode, AccessCondition acce /// An array of bytes. /// The zero-based byte offset in buffer at which to begin uploading bytes to the blob. /// The number of bytes to be written to the blob. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) -#else - /// An that represents an asynchronous action. - /// - /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. - /// To append data to an append blob that already exists, see . - /// - [DoesServiceRequest] - public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int index, int count) -#endif + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) { return this.UploadFromByteArrayAsync(buffer, index, count, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -751,7 +647,6 @@ public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. @@ -759,28 +654,11 @@ public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromByteArrayAsync(buffer, index, count, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - /// - /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. - /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// To append data to an append blob that already exists, see . - /// - [DoesServiceRequest] - public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - CommonUtility.AssertNotNull("buffer", buffer); - - SyncMemoryStream stream = new SyncMemoryStream(buffer, index, count); - return this.UploadFromStreamAsync(stream.AsInputStream(), accessCondition, options, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Uploads the contents of a byte array to an append blob. If the blob already exists, it will be overwritten. /// @@ -798,14 +676,13 @@ public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("buffer", buffer); SyncMemoryStream stream = new SyncMemoryStream(buffer, index, count); return this.UploadFromStreamAsync(stream, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Appends the contents of a byte array to an append blob. Recommended only for single-writer scenarios. @@ -813,15 +690,9 @@ public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, Access /// An array of bytes. /// The zero-based byte offset in buffer at which to begin uploading bytes to the blob. /// The number of bytes to be written to the blob. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task AppendFromByteArrayAsync(byte[] buffer, int index, int count) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction AppendFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int index, int count) -#endif + public virtual Task AppendFromByteArrayAsync(byte[] buffer, int index, int count) { return this.AppendFromByteArrayAsync(buffer, index, count, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -835,32 +706,16 @@ public IAsyncAction AppendFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AppendFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.AppendFromByteArrayAsync(buffer, index, count, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - /// - /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// - [DoesServiceRequest] - public IAsyncAction AppendFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - CommonUtility.AssertNotNull("buffer", buffer); - SyncMemoryStream stream = new SyncMemoryStream(buffer, index, count); - return this.AppendFromStreamAsync(stream.AsInputStream(), accessCondition, options, operationContext); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Appends the contents of a byte array to an append blob. Recommended only for single-writer scenarios. /// @@ -876,36 +731,25 @@ public IAsyncAction AppendFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AppendFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("buffer", buffer); SyncMemoryStream stream = new SyncMemoryStream(buffer, index, count); return this.AppendFromStreamAsync(stream, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Uploads a string of text to an append blob. If the blob already exists, it will be overwritten. /// /// The text to upload, encoded as a UTF-8 string. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadTextAsync(string content) -#else - /// An that represents an asynchronous action. - /// - /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. - /// To append data to an append blob that already exists, see . - /// - [DoesServiceRequest] - public IAsyncAction UploadTextAsync(string content) -#endif + public virtual Task UploadTextAsync(string content) { return this.UploadTextAsync(content, null /* encoding */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -918,7 +762,6 @@ public IAsyncAction UploadTextAsync(string content) /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. @@ -926,28 +769,11 @@ public IAsyncAction UploadTextAsync(string content) /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadTextAsync(content, encoding, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - /// - /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. - /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// To append data to an append blob that already exists, see . - /// - [DoesServiceRequest] - public IAsyncAction UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - CommonUtility.AssertNotNull("content", content); - byte[] contentAsBytes = (encoding ?? Encoding.UTF8).GetBytes(content); - return this.UploadFromByteArrayAsync(contentAsBytes, 0, contentAsBytes.Length, accessCondition, options, operationContext); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Uploads a string of text to an append blob. If the blob already exists, it will be overwritten. /// @@ -964,14 +790,13 @@ public IAsyncAction UploadTextAsync(string content, Encoding encoding, AccessCon /// To append data to an append blob that already exists, see . /// [DoesServiceRequest] - public Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("content", content); byte[] contentAsBytes = (encoding ?? Encoding.UTF8).GetBytes(content); return this.UploadFromByteArrayAsync(contentAsBytes, 0, contentAsBytes.Length, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Appends a string of text to an append blob. @@ -980,15 +805,9 @@ public Task UploadTextAsync(string content, Encoding encoding, AccessCondition a /// /// Use this method only in single-writer scenarios. Internally, this method uses the append-offset conditional header to avoid duplicate blocks, which may cause problems in multiple-writer scenarios. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task AppendTextAsync(string content) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction AppendTextAsync(string content) -#endif + public virtual Task AppendTextAsync(string content) { return this.AppendTextAsync(content, null /* encoding */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1001,32 +820,16 @@ public IAsyncAction AppendTextAsync(string content) /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. /// /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AppendTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.AppendTextAsync(content, encoding, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - /// - /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. - /// - [DoesServiceRequest] - public IAsyncAction AppendTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - CommonUtility.AssertNotNull("content", content); - - byte[] contentAsBytes = (encoding ?? Encoding.UTF8).GetBytes(content); - return this.AppendFromByteArrayAsync(contentAsBytes, 0, contentAsBytes.Length, accessCondition, options, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Appends a string of text to an append blob. /// @@ -1042,29 +845,21 @@ public IAsyncAction AppendTextAsync(string content, Encoding encoding, AccessCon /// If you have a single-writer scenario, see to determine whether setting this flag to true is acceptable for your scenario. /// [DoesServiceRequest] - public Task AppendTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AppendTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("content", content); byte[] contentAsBytes = (encoding ?? Encoding.UTF8).GetBytes(content); return this.AppendFromByteArrayAsync(contentAsBytes, 0, contentAsBytes.Length, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Creates an empty append blob. If the blob already exists, this operation will overwrite it. To throw an exception instead of overwriting the blob, /// use . /// - /// An that represents an asynchronous action. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task CreateOrReplaceAsync() -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction CreateOrReplaceAsync() -#endif + public virtual Task CreateOrReplaceAsync() { return this.CreateOrReplaceAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1076,28 +871,13 @@ public IAsyncAction CreateOrReplaceAsync() /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task CreateOrReplaceAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateOrReplaceAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.CreateOrReplaceAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction CreateOrReplaceAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.AppendBlob, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.CreateImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Creates an empty append blob. If the blob already exists, this operation will overwrite it. To throw an exception instead of overwriting the blob, /// pass in an object generated using . @@ -1108,7 +888,7 @@ public IAsyncAction CreateOrReplaceAsync(AccessCondition accessCondition, BlobRe /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task CreateOrReplaceAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateOrReplaceAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.AppendBlob, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1117,21 +897,14 @@ public Task CreateOrReplaceAsync(AccessCondition accessCondition, BlobRequestOpt operationContext, cancellationToken), cancellationToken); } -#endif /// /// Commits a new block of data to the end of the blob. /// /// A stream that provides the data for the block. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task AppendBlockAsync(Stream blockData) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncOperation AppendBlockAsync(IInputStream blockData) -#endif + public virtual Task AppendBlockAsync(Stream blockData) { return this.AppendBlockAsync(blockData, null /* contentMD5 */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1142,15 +915,9 @@ public IAsyncOperation AppendBlockAsync(IInputStream blockData) /// A stream that provides the data for the block. /// An optional hash value that will be used to set the property /// on the blob. May be null or an empty string. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task AppendBlockAsync(Stream blockData, string contentMD5) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncOperation AppendBlockAsync(IInputStream blockData, string contentMD5) -#endif + public virtual Task AppendBlockAsync(Stream blockData, string contentMD5) { return this.AppendBlockAsync(blockData, contentMD5, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1164,9 +931,8 @@ public IAsyncOperation AppendBlockAsync(IInputStream blockData, string con /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. - public Task AppendBlockAsync(Stream blockData, string contentMD5, AccessCondition accesscondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AppendBlockAsync(Stream blockData, string contentMD5, AccessCondition accesscondition, BlobRequestOptions options, OperationContext operationContext) { return this.AppendBlockAsync(blockData, contentMD5, accesscondition, options, operationContext, CancellationToken.None); } @@ -1183,25 +949,16 @@ public Task AppendBlockAsync(Stream blockData, string contentMD5, AccessCo /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task AppendBlockAsync(Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncOperation AppendBlockAsync(IInputStream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task AppendBlockAsync(Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.AppendBlob, this.ServiceClient); bool requiresContentMD5 = string.IsNullOrEmpty(contentMD5) && modifiedOptions.UseTransactionalMD5.Value; operationContext = operationContext ?? new OperationContext(); ExecutionState tempExecutionState = CommonUtility.CreateTemporaryExecutionState(modifiedOptions); -#if ASPNET_K || PORTABLE return Task.Run(async () => -#else - return AsyncInfo.Run(async (cancellationToken) => -#endif { - Stream blockDataAsStream = blockData.AsStreamForRead(); + Stream blockDataAsStream = blockData; Stream seekableStream = blockDataAsStream; bool seekableStreamCreated = false; @@ -1245,22 +1002,15 @@ public IAsyncOperation AppendBlockAsync(IInputStream blockData, string con seekableStream.Dispose(); } } -#if ASPNET_K || PORTABLE }, cancellationToken); -#else - }); -#endif } /// /// Downloads the blob's contents as a string. /// /// The contents of the blob, as a string. -#if ASPNET_K || PORTABLE - public Task DownloadTextAsync() -#else - public IAsyncOperation DownloadTextAsync() -#endif + [DoesServiceRequest] + public virtual Task DownloadTextAsync() { return this.DownloadTextAsync(null /* encoding */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1273,27 +1023,12 @@ public IAsyncOperation DownloadTextAsync() /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// The contents of the blob, as a string. -#if ASPNET_K || PORTABLE - public Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadTextAsync(encoding, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return AsyncInfo.Run(async (token) => - { - using (SyncMemoryStream stream = new SyncMemoryStream()) - { - await this.DownloadToStreamAsync(stream.AsOutputStream(), accessCondition, options, operationContext).AsTask(token); - byte[] streamAsBytes = stream.ToArray(); - return (encoding ?? Encoding.UTF8).GetString(streamAsBytes, 0, streamAsBytes.Length); - } - }); - } -#endif -#if ASPNET_K || PORTABLE /// /// Downloads the blob's contents as a string. /// @@ -1303,7 +1038,8 @@ public IAsyncOperation DownloadTextAsync(Encoding encoding, AccessCondit /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// The contents of the blob, as a string. - public Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + [DoesServiceRequest] + public virtual Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return Task.Run(async () => { @@ -1315,7 +1051,6 @@ public Task DownloadTextAsync(Encoding encoding, AccessCondition accessC } }, cancellationToken); } -#endif /// /// Begins an operation to start copying an existing block blob's contents, properties, and metadata to a new blob. @@ -1327,11 +1062,7 @@ public Task DownloadTextAsync(Encoding encoding, AccessCondition accessC /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task StartCopyAsync(CloudAppendBlob source) -#else - public IAsyncOperation StartCopyAsync(CloudAppendBlob source) -#endif + public virtual Task StartCopyAsync(CloudAppendBlob source) { return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source)); } @@ -1350,19 +1081,11 @@ public IAsyncOperation StartCopyAsync(CloudAppendBlob source) /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task StartCopyAsync(CloudAppendBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(CloudAppendBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation StartCopyAsync(CloudAppendBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Begins an operation to start copying another append blob's contents, properties, and metadata to a new blob. /// @@ -1378,22 +1101,17 @@ public IAsyncOperation StartCopyAsync(CloudAppendBlob source, AccessCond /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public Task StartCopyAsync(CloudAppendBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudAppendBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); } -#endif /// /// Creates a snapshot of the blob. /// /// A blob snapshot. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task CreateSnapshotAsync() -#else - public IAsyncOperation CreateSnapshotAsync() -#endif + public virtual Task CreateSnapshotAsync() { return this.CreateSnapshotAsync(null /* metadata */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1407,25 +1125,11 @@ public IAsyncOperation CreateSnapshotAsync() /// An object that represents the context for the current operation. /// A blob snapshot. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return CreateSnapshotAsync(metadata, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - this.attributes.AssertNoSnapshot(); - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.AppendBlob, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.CreateSnapshotImpl(metadata, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Creates a snapshot of the blob. /// @@ -1436,7 +1140,7 @@ public IAsyncOperation CreateSnapshotAsync(IDictionaryA to observe while waiting for a task to complete. /// A blob snapshot. [DoesServiceRequest] - public Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.AppendBlob, this.ServiceClient); @@ -1446,7 +1150,6 @@ public Task CreateSnapshotAsync(IDictionary met operationContext, cancellationToken), cancellationToken); } -#endif /// /// Implements the Create method. @@ -1459,11 +1162,9 @@ private RESTCommand CreateImpl(AccessCondition accessCondition, BlobRe RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = BlobHttpRequestMessageFactory.Put(uri, serverTimeout, this.Properties, BlobType.AppendBlob, 0, accessCondition, cnt, ctx); + StorageRequestMessage msg = BlobHttpRequestMessageFactory.Put(uri, serverTimeout, this.Properties, BlobType.AppendBlob, 0, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); BlobHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -1494,10 +1195,8 @@ internal RESTCommand AppendBlockImpl(Stream source, string contentMD5, Acc RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(source, offset, length, contentMD5, cmd, ctx); - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.AppendBlock(uri, serverTimeout, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.AppendBlock(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { long appendOffset = -1; @@ -1527,11 +1226,9 @@ internal RESTCommand CreateSnapshotImpl(IDictionary putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = BlobHttpRequestMessageFactory.Snapshot(uri, serverTimeout, accessCondition, cnt, ctx); + StorageRequestMessage msg = BlobHttpRequestMessageFactory.Snapshot(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); if (metadata != null) { BlobHttpRequestMessageFactory.AddMetadata(msg, metadata); diff --git a/Lib/WindowsRuntime/Blob/CloudBlob.cs b/Lib/WindowsRuntime/Blob/CloudBlob.cs index 941ee92ed..67764ba26 100644 --- a/Lib/WindowsRuntime/Blob/CloudBlob.cs +++ b/Lib/WindowsRuntime/Blob/CloudBlob.cs @@ -27,6 +27,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob using System.Net; using System.Net.Http; using System.Threading.Tasks; + #if ASPNET_K || PORTABLE using System.Threading; #else @@ -35,6 +36,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob using Windows.Foundation.Metadata; using Windows.Storage; using Windows.Storage.Streams; + using System.Threading; #endif /// @@ -47,11 +49,7 @@ public partial class CloudBlob : IListBlobItem /// /// A stream to be used for reading from the blob. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task OpenReadAsync() -#else - public IAsyncOperation OpenReadAsync() -#endif + public virtual Task OpenReadAsync() { return this.OpenReadAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -64,25 +62,11 @@ public IAsyncOperation OpenReadAsync() /// An object that represents the context for the current operation. /// A stream to be used for reading from the blob. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task OpenReadAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task OpenReadAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.OpenReadAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation OpenReadAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return AsyncInfo.Run(async (token) => - { - await this.FetchAttributesAsync(accessCondition, options, operationContext).AsTask(token); - AccessCondition streamAccessCondition = AccessCondition.CloneConditionWithETag(accessCondition, this.Properties.ETag); - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, this.BlobType, this.ServiceClient, false); - return new BlobReadStreamHelper(this, streamAccessCondition, modifiedOptions, operationContext); - }); - } -#endif -#if ASPNET_K || PORTABLE /// /// Opens a stream for reading from the blob. /// @@ -92,7 +76,7 @@ public IAsyncOperation OpenReadAsync(AccessC /// A to observe while waiting for a task to complete. /// A stream to be used for reading from the blob. [DoesServiceRequest] - public Task OpenReadAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task OpenReadAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return Task.Run(async () => { @@ -102,21 +86,14 @@ public Task OpenReadAsync(AccessCondition accessCondition, BlobRequestOp return new BlobReadStream(this, streamAccessCondition, modifiedOptions, operationContext); }, cancellationToken); } -#endif /// /// Downloads the contents of a blob to a stream. /// /// The target stream. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DownloadToStreamAsync(IOutputStream target) -#endif + public virtual Task DownloadToStreamAsync(Stream target) { return this.DownloadToStreamAsync(target, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -128,20 +105,13 @@ public IAsyncAction DownloadToStreamAsync(IOutputStream target) /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DownloadToStreamAsync(IOutputStream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadRangeToStreamAsync(target, null /* offset */, null /* length */, accessCondition, options, operationContext); } -#if ASPNET_K || PORTABLE /// /// Downloads the contents of a blob to a stream. /// @@ -152,11 +122,10 @@ public IAsyncAction DownloadToStreamAsync(IOutputStream target, AccessCondition /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.DownloadRangeToStreamAsync(target, null /* offset */, null /* length */, accessCondition, options, operationContext, cancellationToken); } -#endif #if !PORTABLE /// @@ -167,15 +136,15 @@ public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition /// A enumeration value that specifies how to open the file. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode) + public virtual Task DownloadToFileAsync(string path, FileMode mode) { return this.DownloadToFileAsync(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */); } #else /// The target file. - /// An that represents an asynchronous action. + /// An that represents an asynchronous action. [DoesServiceRequest] - public IAsyncAction DownloadToFileAsync(StorageFile target) + public virtual Task DownloadToFileAsync(StorageFile target) { return this.DownloadToFileAsync(target, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -192,7 +161,7 @@ public IAsyncAction DownloadToFileAsync(StorageFile target) /// An object that represents the context for the current operation. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadToFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); } @@ -201,17 +170,30 @@ public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition acce /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. - /// An that represents an asynchronous action. + /// An that represents an asynchronous action. [DoesServiceRequest] - public IAsyncAction DownloadToFileAsync(StorageFile target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DownloadToFileAsync(StorageFile target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { - CommonUtility.AssertNotNull("target", target); + return DownloadToFileAsync(target, accessCondition, options, operationContext); + } - return AsyncInfo.Run(async (token) => + /// + /// Downloads the contents of a blob to a file. + /// + /// The target file. + /// An object that represents the access conditions for the blob. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// A to observe while waiting for a task to complete. + /// An that represents an asynchronous action. + [DoesServiceRequest] + public virtual Task DownloadToFileAsync(StorageFile target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + { + return Task.Run(async () => { - using (StorageStreamTransaction transaction = await target.OpenTransactedWriteAsync().AsTask(token)) + using (StorageStreamTransaction transaction = await target.OpenTransactedWriteAsync().AsTask(cancellationToken)) { - await this.DownloadToStreamAsync(transaction.Stream, accessCondition, options, operationContext).AsTask(token); + await this.DownloadToStreamAsync(transaction.Stream.AsStream(), accessCondition, options, operationContext, cancellationToken); await transaction.CommitAsync(); } }); @@ -228,22 +210,45 @@ public IAsyncAction DownloadToFileAsync(StorageFile target, AccessCondition acce /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. - /// An that represents an asynchronous action. + /// An that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("path", path); return Task.Run(async () => { - using (FileStream stream = new FileStream(path, mode, FileAccess.Write)) + FileStream stream = new FileStream(path, mode, FileAccess.Write); + + try { - await this.DownloadToStreamAsync(stream, accessCondition, options, operationContext, cancellationToken); + using (stream) + { + await this.DownloadToStreamAsync(stream, accessCondition, options, operationContext, cancellationToken); + } } + catch (Exception) + { + if (mode == FileMode.Create || mode == FileMode.CreateNew) + { + try + { + File.Delete(path); + } + catch (Exception) + { + // Best effort to clean up in the event that download was unsuccessful. + // Do not throw as we want to throw original exception. + } + } + + throw; + } + }, cancellationToken); } #endif -#endif +#endif /// /// Downloads the contents of a blob to a byte array. @@ -252,11 +257,7 @@ public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition acce /// The starting offset in the byte array. /// The total number of bytes read into the buffer. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task DownloadToByteArrayAsync(byte[] target, int index) -#else - public IAsyncOperation DownloadToByteArrayAsync([WriteOnlyArray] byte[] target, int index) -#endif + public virtual Task DownloadToByteArrayAsync(byte[] target, int index) { return this.DownloadToByteArrayAsync(target, index, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -271,16 +272,11 @@ public IAsyncOperation DownloadToByteArrayAsync([WriteOnlyArray] byte[] tar /// An object that represents the context for the current operation. /// The total number of bytes read into the buffer. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - public IAsyncOperation DownloadToByteArrayAsync([WriteOnlyArray] byte[] target, int index, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadRangeToByteArrayAsync(target, index, null /* blobOffset */, null /* length */, accessCondition, options, operationContext); } -#if ASPNET_K || PORTABLE /// /// Downloads the contents of a blob to a byte array. /// @@ -292,11 +288,10 @@ public IAsyncOperation DownloadToByteArrayAsync([WriteOnlyArray] byte[] tar /// A to observe while waiting for a task to complete. /// The total number of bytes read into the buffer. [DoesServiceRequest] - public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.DownloadRangeToByteArrayAsync(target, index, null /* blobOffset */, null /* length */, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Downloads a range of bytes from a blob to a stream. @@ -304,15 +299,9 @@ public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondit /// The target stream. /// The offset at which to begin downloading the blob, in bytes. /// The length of the data to download from the blob, in bytes. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DownloadRangeToStreamAsync(IOutputStream target, long? offset, long? length) -#endif + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length) { return this.DownloadRangeToStreamAsync(target, offset, length, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -326,33 +315,13 @@ public IAsyncAction DownloadRangeToStreamAsync(IOutputStream target, long? offse /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadRangeToStreamAsync(target, offset, length, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DownloadRangeToStreamAsync(IOutputStream target, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - CommonUtility.AssertNotNull("target", target); - - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - - // We should always call AsStreamForWrite with bufferSize=0 to prevent buffering. Our - // stream copier only writes 64K buffers at a time anyway, so no buffering is needed. - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.GetBlobImpl(this.attributes, target.AsStreamForWrite(0), offset, length, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Downloads a range of bytes from a blob to a stream. /// @@ -365,7 +334,7 @@ public IAsyncAction DownloadRangeToStreamAsync(IOutputStream target, long? offse /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("target", target); @@ -379,7 +348,6 @@ public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length operationContext, cancellationToken), cancellationToken); } -#endif /// /// Downloads a range of bytes from a blob to a byte array. @@ -390,11 +358,7 @@ public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length /// The length of the data range, in bytes. /// The total number of bytes read into the buffer. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length) -#else - public IAsyncOperation DownloadRangeToByteArrayAsync([WriteOnlyArray] byte[] target, int index, long? blobOffset, long? length) -#endif + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length) { return this.DownloadRangeToByteArrayAsync(target, index, blobOffset, length, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -411,26 +375,11 @@ public IAsyncOperation DownloadRangeToByteArrayAsync([WriteOnlyArray] byte[ /// An object that represents the context for the current operation. /// The total number of bytes read into the buffer. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadRangeToByteArrayAsync(target, index, blobOffset, length, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation DownloadRangeToByteArrayAsync([WriteOnlyArray] byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return AsyncInfo.Run(async (token) => - { - using (SyncMemoryStream stream = new SyncMemoryStream(target, index)) - { - await this.DownloadRangeToStreamAsync(stream.AsOutputStream(), blobOffset, length, accessCondition, options, operationContext).AsTask(token); - return (int)stream.Position; - } - }); - } -#endif -#if ASPNET_K || PORTABLE /// /// Downloads a range of bytes from a blob to a byte array. /// @@ -444,7 +393,7 @@ public IAsyncOperation DownloadRangeToByteArrayAsync([WriteOnlyArray] byte[ /// A to observe while waiting for a task to complete. /// The total number of bytes read into the buffer. [DoesServiceRequest] - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return Task.Run(async () => { @@ -455,17 +404,13 @@ public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? b } }, cancellationToken); } -#endif + /// /// Checks existence of the blob. /// /// true if the blob exists. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ExistsAsync() -#else - public IAsyncOperation ExistsAsync() -#endif + public virtual Task ExistsAsync() { return this.ExistsAsync(null /* options */, null /* operationContext */); } @@ -477,19 +422,11 @@ public IAsyncOperation ExistsAsync() /// An object that represents the context for the current operation. /// true if the blob exists. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext) + public virtual Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext) { return this.ExistsAsync(false, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ExistsAsync(BlobRequestOptions options, OperationContext operationContext) - { - return this.ExistsAsync(false, options, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Checks existence of the blob. /// @@ -498,11 +435,10 @@ public IAsyncOperation ExistsAsync(BlobRequestOptions options, OperationCo /// A to observe while waiting for a task to complete. /// true if the blob exists. [DoesServiceRequest] - public Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.ExistsAsync(false, options, operationContext, cancellationToken); } -#endif /// /// Checks existence of the blob. @@ -510,7 +446,6 @@ public Task ExistsAsync(BlobRequestOptions options, OperationContext opera /// If true, the command will be executed against the primary location. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A to observe while waiting for a task to complete. /// true if the blob exists. private Task ExistsAsync(bool primaryOnly, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) @@ -522,31 +457,13 @@ private Task ExistsAsync(bool primaryOnly, BlobRequestOptions options, Ope operationContext, cancellationToken), cancellationToken); } -#else - /// true if the blob exists. - private IAsyncOperation ExistsAsync(bool primaryOnly, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.ExistsImpl(this.attributes, modifiedOptions, primaryOnly), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif /// /// Populates a blob's properties and metadata. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task FetchAttributesAsync() -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction FetchAttributesAsync() -#endif + public virtual Task FetchAttributesAsync() { return this.FetchAttributesAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -557,28 +474,13 @@ public IAsyncAction FetchAttributesAsync() /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.FetchAttributesAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.FetchAttributesImpl(this.attributes, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Populates a blob's properties and metadata. /// @@ -588,7 +490,7 @@ public IAsyncAction FetchAttributesAsync(AccessCondition accessCondition, BlobRe /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -597,17 +499,13 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOpt operationContext, cancellationToken), cancellationToken); } -#endif -#if ASPNET_K || PORTABLE + /// + /// Updates the blob's metadata. + /// /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetMetadataAsync() -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction SetMetadataAsync() -#endif + public virtual Task SetMetadataAsync() { return this.SetMetadataAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -618,29 +516,13 @@ public IAsyncAction SetMetadataAsync() /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.SetMetadataAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - this.attributes.AssertNoSnapshot(); - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetMetadataImpl(this.attributes, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Updates the blob's metadata. /// @@ -650,7 +532,7 @@ public IAsyncAction SetMetadataAsync(AccessCondition accessCondition, BlobReques /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); @@ -660,20 +542,13 @@ public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions operationContext, cancellationToken), cancellationToken); } -#endif /// /// Updates the blob's properties. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetPropertiesAsync() -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction SetPropertiesAsync() -#endif + public virtual Task SetPropertiesAsync() { return this.SetPropertiesAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -684,29 +559,13 @@ public IAsyncAction SetPropertiesAsync() /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.SetPropertiesAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - this.attributes.AssertNoSnapshot(); - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetPropertiesImpl(this.attributes, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Updates the blob's properties. /// @@ -714,9 +573,9 @@ public IAsyncAction SetPropertiesAsync(AccessCondition accessCondition, BlobRequ /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. - /// An that represents an asynchronous action. + /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); @@ -726,19 +585,13 @@ public Task SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptio operationContext, cancellationToken), cancellationToken); } -#endif + /// /// Deletes the blob. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteAsync() -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DeleteAsync() -#endif + public virtual Task DeleteAsync() { return this.DeleteAsync(DeleteSnapshotsOption.None, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -750,28 +603,13 @@ public IAsyncAction DeleteAsync() /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DeleteAsync(deleteSnapshotsOption, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.DeleteBlobImpl(this.attributes, deleteSnapshotsOption, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Deletes the blob. /// @@ -782,7 +620,7 @@ public IAsyncAction DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, Acc /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -791,18 +629,13 @@ public Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondi operationContext, cancellationToken), cancellationToken); } -#endif /// /// Deletes the blob if it already exists. /// /// true if the blob already existed and was deleted; otherwise, false. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task DeleteIfExistsAsync() -#else - public IAsyncOperation DeleteIfExistsAsync() -#endif + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(DeleteSnapshotsOption.None, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -816,8 +649,7 @@ public IAsyncOperation DeleteIfExistsAsync() /// An object that represents the context for the current operation. /// true if the blob already existed and was deleted; otherwise, false. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DeleteIfExistsAsync(deleteSnapshotsOption, accessCondition, options, operationContext, CancellationToken.None); } @@ -832,23 +664,14 @@ public Task DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOptio /// A to observe while waiting for a task to complete. /// true if the blob already existed and was deleted; otherwise, false. [DoesServiceRequest] - public Task DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, this.BlobType, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); -#if ASPNET_K || PORTABLE return Task.Run(async () => { bool exists = await this.ExistsAsync(true, modifiedOptions, operationContext, cancellationToken); -#else - return AsyncInfo.Run(async (token) => - { - bool exists = await this.ExistsAsync(true, modifiedOptions, operationContext).AsTask(token); -#endif if (!exists) { @@ -857,11 +680,7 @@ public IAsyncOperation DeleteIfExistsAsync(DeleteSnapshotsOption deleteSna try { -#if ASPNET_K || PORTABLE await this.DeleteAsync(deleteSnapshotsOption, accessCondition, modifiedOptions, operationContext, cancellationToken); -#else - await this.DeleteAsync(deleteSnapshotsOption, accessCondition, modifiedOptions, operationContext).AsTask(token); -#endif return true; } catch (Exception) @@ -896,11 +715,7 @@ public IAsyncOperation DeleteIfExistsAsync(DeleteSnapshotsOption deleteSna /// A string representing the proposed lease ID for the new lease, or null if no lease ID is proposed. /// The ID of the acquired lease. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId) -#else - public IAsyncOperation AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId) -#endif + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId = null) { return this.AcquireLeaseAsync(leaseTime, proposedLeaseId, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -917,24 +732,11 @@ public IAsyncOperation AcquireLeaseAsync(TimeSpan? leaseTime, string pro /// An object that represents the context for the current operation. /// The ID of the acquired lease. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.AcquireLeaseAsync(leaseTime, proposedLeaseId, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.AcquireLeaseImpl(this.attributes, leaseTime, proposedLeaseId, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Acquires a lease on this blob. /// @@ -948,7 +750,7 @@ public IAsyncOperation AcquireLeaseAsync(TimeSpan? leaseTime, string pro /// A to observe while waiting for a task to complete. /// The ID of the acquired lease. [DoesServiceRequest] - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -957,21 +759,14 @@ public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseI operationContext, cancellationToken), cancellationToken); } -#endif /// /// Renews a lease on this blob. /// /// An object that represents the access conditions for the blob, including a required lease ID. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction RenewLeaseAsync(AccessCondition accessCondition) -#endif + public virtual Task RenewLeaseAsync(AccessCondition accessCondition) { return this.RenewLeaseAsync(accessCondition, null /* options */, null /* operationContext */); } @@ -982,28 +777,13 @@ public IAsyncAction RenewLeaseAsync(AccessCondition accessCondition) /// An object that represents the access conditions for the blob, including a required lease ID. /// The options for this operation. If null, default options will be used. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.RenewLeaseAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.RenewLeaseImpl(this.attributes, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Renews a lease on this blob. /// @@ -1013,7 +793,7 @@ public IAsyncAction RenewLeaseAsync(AccessCondition accessCondition, BlobRequest /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1022,7 +802,6 @@ public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions operationContext, cancellationToken), cancellationToken); } -#endif /// /// Changes the lease ID on this blob. @@ -1031,11 +810,7 @@ public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions /// An object that represents the access conditions for the blob, including a required lease ID. /// The new lease ID. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition) -#else - public IAsyncOperation ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition) -#endif + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition) { return this.ChangeLeaseAsync(proposedLeaseId, accessCondition, null /* options */, null /* operationContext */); } @@ -1049,24 +824,11 @@ public IAsyncOperation ChangeLeaseAsync(string proposedLeaseId, AccessCo /// An object that represents the context for the current operation. /// The new lease ID. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.ChangeLeaseAsync(proposedLeaseId, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.ChangeLeaseImpl(this.attributes, proposedLeaseId, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Changes the lease ID on this blob. /// @@ -1077,7 +839,7 @@ public IAsyncOperation ChangeLeaseAsync(string proposedLeaseId, AccessCo /// A to observe while waiting for a task to complete. /// The new lease ID. [DoesServiceRequest] - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -1086,21 +848,14 @@ public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition acc operationContext, cancellationToken), cancellationToken); } -#endif /// /// Releases the lease on this blob. /// /// An object that represents the access conditions for the blob, including a required lease ID. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction ReleaseLeaseAsync(AccessCondition accessCondition) -#endif + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition) { return this.ReleaseLeaseAsync(accessCondition, null /* options */, null /* operationContext */); } @@ -1111,28 +866,13 @@ public IAsyncAction ReleaseLeaseAsync(AccessCondition accessCondition) /// An object that represents the access conditions for the blob, including a required lease ID. /// The options for this operation. If null, default options will be used. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.ReleaseLeaseAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.ReleaseLeaseImpl(this.attributes, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Releases the lease on this blob. /// @@ -1142,7 +882,7 @@ public IAsyncAction ReleaseLeaseAsync(AccessCondition accessCondition, BlobReque /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1151,7 +891,6 @@ public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOption operationContext, cancellationToken), cancellationToken); } -#endif /// /// Breaks the current lease on this blob. @@ -1161,11 +900,7 @@ public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOption /// or zero for infinite leases. /// A representing the amount of time before the lease ends, to the second. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task BreakLeaseAsync(TimeSpan? breakPeriod) -#else - public IAsyncOperation BreakLeaseAsync(TimeSpan? breakPeriod) -#endif + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod) { return this.BreakLeaseAsync(breakPeriod, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1181,24 +916,11 @@ public IAsyncOperation BreakLeaseAsync(TimeSpan? breakPeriod) /// An object that represents the context for the current operation. /// A representing the amount of time before the lease ends, to the second. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.BreakLeaseAsync(breakPeriod, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.BreakLeaseImpl(this.attributes, breakPeriod, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Breaks the current lease on this blob. /// @@ -1211,7 +933,7 @@ public IAsyncOperation BreakLeaseAsync(TimeSpan? breakPeriod, AccessCo /// A to observe while waiting for a task to complete. /// A representing the amount of time before the lease ends, to the second. [DoesServiceRequest] - public Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -1220,18 +942,13 @@ public Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition acc operationContext, cancellationToken), cancellationToken); } -#endif /// /// Creates a snapshot of the blob. /// /// A blob snapshot. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task SnapshotAsync() -#else - public IAsyncOperation SnapshotAsync() -#endif + public virtual Task SnapshotAsync() { return this.SnapshotAsync(null /* metadata */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1245,25 +962,11 @@ public IAsyncOperation SnapshotAsync() /// An object that represents the context for the current operation. /// A blob snapshot. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task SnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task SnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.SnapshotAsync(metadata, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation SnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - this.attributes.AssertNoSnapshot(); - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.SnapshotImpl(metadata, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Creates a snapshot of the blob. /// @@ -1274,7 +977,7 @@ public IAsyncOperation SnapshotAsync(IDictionary meta /// A to observe while waiting for a task to complete. /// A blob snapshot. [DoesServiceRequest] - public Task SnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); @@ -1284,81 +987,6 @@ public Task SnapshotAsync(IDictionary metadata, Acces operationContext, cancellationToken), cancellationToken); } -#endif - - /// - /// Begins an operation to start copying an existing blob's contents, properties, and metadata to a new blob. - /// - /// The URI of a source blob. - /// The copy ID associated with the copy operation. - /// - /// This method fetches the blob's ETag, last modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task StartCopyFromBlobAsync(Uri source) -#else - [DefaultOverload] - public IAsyncOperation StartCopyFromBlobAsync(Uri source) -#endif - { - return this.StartCopyAsync(source, null /* sourceAccessCondition */, null /* destAccessCondition */, null /* options */, null /* operationContext */); - } - - /// - /// Begins an operation to start copying an existing blob's contents, properties, and metadata to a new blob. - /// - /// The URI of a source blob. - /// The copy ID associated with the copy operation. - /// - /// This method fetches the blob's ETag, last modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task StartCopyFromBlobAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return this.StartCopyFromBlobAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); - } -#else - [DefaultOverload] - public IAsyncOperation StartCopyFromBlobAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext); - } -#endif - -#if ASPNET_K || PORTABLE - /// - /// Begins an operation to start copying a blob's contents, properties, and metadata to a new blob. - /// - /// The URI of a source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// A to observe while waiting for a task to complete. - /// The copy ID associated with the copy operation. - /// - /// This method fetches the blob's ETag, last modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) - { - CommonUtility.AssertNotNull("source", source); - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return Task.Run(async () => await Executor.ExecuteAsync( - this.StartCopyImpl(this.attributes, source, sourceAccessCondition, destAccessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - cancellationToken), cancellationToken); - } -#endif /// /// Begins an operation to start copying an existing blob's contents, properties, and metadata to a new blob. @@ -1370,12 +998,7 @@ public Task StartCopyFromBlobAsync(Uri source, AccessCondition sourceAcc /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task StartCopyAsync(Uri source) -#else - [DefaultOverload] - public IAsyncOperation StartCopyAsync(Uri source) -#endif + public virtual Task StartCopyAsync(Uri source) { return this.StartCopyAsync(source, null /* sourceAccessCondition */, null /* destAccessCondition */, null /* options */, null /* operationContext */); } @@ -1390,25 +1013,11 @@ public IAsyncOperation StartCopyAsync(Uri source) /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } -#else - [DefaultOverload] - public IAsyncOperation StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.StartCopyImpl(this.attributes, source, sourceAccessCondition, destAccessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Begins an operation to start copying a blob's contents, properties, and metadata to a new blob. /// @@ -1424,7 +1033,7 @@ public IAsyncOperation StartCopyAsync(Uri source, AccessCondition source /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("source", source); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); @@ -1434,21 +1043,14 @@ public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondi operationContext, cancellationToken), cancellationToken); } -#endif /// /// Aborts an ongoing blob copy operation. /// /// A string identifying the copy operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task AbortCopyAsync(string copyId) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction AbortCopyAsync(string copyId) -#endif + public virtual Task AbortCopyAsync(string copyId) { return this.AbortCopyAsync(copyId, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1460,29 +1062,14 @@ public IAsyncAction AbortCopyAsync(string copyId) /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.AbortCopyAsync(copyId, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.AbortCopyImpl(this.attributes, copyId, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Aborts an ongoing blob copy operation. /// @@ -1493,7 +1080,7 @@ public IAsyncAction AbortCopyAsync(string copyId, AccessCondition accessConditio /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.AppendBlob, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1502,7 +1089,6 @@ public Task AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobR operationContext, cancellationToken), cancellationToken); } -#endif /// /// Implements getting the blob. @@ -1535,9 +1121,7 @@ private RESTCommand GetBlobImpl(BlobAttributes attributes, Stream dest getCmd.RetrieveResponseStream = true; getCmd.DestinationStream = destStream; getCmd.CalculateMd5ForResponseStream = !options.DisableContentMD5Validation.Value; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Get(uri, serverTimeout, attributes.SnapshotTime, offset, length, options.UseTransactionalMD5.Value, accessCondition, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Get(uri, serverTimeout, attributes.SnapshotTime, offset, length, options.UseTransactionalMD5.Value, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.RecoveryAction = (cmd, ex, ctx) => { if ((lockedAccessCondition == null) && !string.IsNullOrEmpty(lockedETag)) @@ -1558,7 +1142,7 @@ private RESTCommand GetBlobImpl(BlobAttributes attributes, Stream dest } } - getCmd.BuildRequest = (command, uri, builder, cnt, serverTimeout, context) => BlobHttpRequestMessageFactory.Get(uri, serverTimeout, attributes.SnapshotTime, offset, length, options.UseTransactionalMD5.Value && !arePropertiesPopulated, lockedAccessCondition ?? accessCondition, cnt, context); + getCmd.BuildRequest = (command, uri, builder, cnt, serverTimeout, context) => BlobHttpRequestMessageFactory.Get(uri, serverTimeout, attributes.SnapshotTime, offset, length, options.UseTransactionalMD5.Value && !arePropertiesPopulated, lockedAccessCondition ?? accessCondition, cnt, context, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); }; getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => @@ -1621,9 +1205,7 @@ private RESTCommand FetchAttributesImpl(BlobAttributes attributes, Acc options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetProperties(uri, serverTimeout, attributes.SnapshotTime, accessCondition, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetProperties(uri, serverTimeout, attributes.SnapshotTime, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex); @@ -1647,9 +1229,7 @@ private RESTCommand ExistsImpl(BlobAttributes attributes, BlobRequestOptio options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = primaryOnly ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetProperties(uri, serverTimeout, attributes.SnapshotTime, null /* accessCondition */, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetProperties(uri, serverTimeout, attributes.SnapshotTime, null /* accessCondition */, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { if (resp.StatusCode == HttpStatusCode.NotFound) @@ -1678,11 +1258,9 @@ private RESTCommand SetMetadataImpl(BlobAttributes attributes, AccessC RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = BlobHttpRequestMessageFactory.SetMetadata(uri, serverTimeout, accessCondition, cnt, ctx); + StorageRequestMessage msg = BlobHttpRequestMessageFactory.SetMetadata(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); BlobHttpRequestMessageFactory.AddMetadata(msg, attributes.Metadata); return msg; }; @@ -1708,11 +1286,9 @@ private RESTCommand SetPropertiesImpl(BlobAttributes attributes, Acces RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = BlobHttpRequestMessageFactory.SetProperties(uri, serverTimeout, attributes.Properties, accessCondition, cnt, ctx); + StorageRequestMessage msg = BlobHttpRequestMessageFactory.SetProperties(uri, serverTimeout, attributes.Properties, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); BlobHttpRequestMessageFactory.AddMetadata(msg, attributes.Metadata); return msg; }; @@ -1739,9 +1315,7 @@ private RESTCommand DeleteBlobImpl(BlobAttributes attributes, DeleteSn RESTCommand deleteCmd = new RESTCommand(this.ServiceClient.Credentials, attributes.StorageUri); options.ApplyToStorageCommand(deleteCmd); - deleteCmd.Handler = this.ServiceClient.AuthenticationHandler; - deleteCmd.BuildClient = HttpClientFactory.BuildHttpClient; - deleteCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Delete(uri, serverTimeout, attributes.SnapshotTime, deleteSnapshotsOption, accessCondition, cnt, ctx); + deleteCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Delete(uri, serverTimeout, attributes.SnapshotTime, deleteSnapshotsOption, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); deleteCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, NullType.Value, cmd, ex); return deleteCmd; @@ -1768,9 +1342,7 @@ private RESTCommand AcquireLeaseImpl(BlobAttributes attributes, TimeSpan RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Acquire, proposedLeaseId, leaseDuration, null /* leaseBreakPeriod */, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Acquire, proposedLeaseId, leaseDuration, null /* leaseBreakPeriod */, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Created, resp, null /* retVal */, cmd, ex); @@ -1799,9 +1371,7 @@ private RESTCommand RenewLeaseImpl(BlobAttributes attributes, AccessCo RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Renew, null /* proposedLeaseId */, null /* leaseDuration */, null /* leaseBreakPeriod */, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Renew, null /* proposedLeaseId */, null /* leaseDuration */, null /* leaseBreakPeriod */, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex); @@ -1832,9 +1402,7 @@ private RESTCommand ChangeLeaseImpl(BlobAttributes attributes, string pr RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Change, proposedLeaseId, null /* leaseDuration */, null /* leaseBreakPeriod */, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Change, proposedLeaseId, null /* leaseDuration */, null /* leaseBreakPeriod */, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); @@ -1863,9 +1431,7 @@ private RESTCommand ReleaseLeaseImpl(BlobAttributes attributes, Access RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Release, null /* proposedLeaseId */, null /* leaseDuration */, null /* leaseBreakPeriod */, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Release, null /* proposedLeaseId */, null /* leaseDuration */, null /* leaseBreakPeriod */, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex); @@ -1896,9 +1462,7 @@ private RESTCommand BreakLeaseImpl(BlobAttributes attributes, TimeSpan RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Break, null /* proposedLeaseId */, null /* leaseDuration */, breakSeconds, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Break, null /* proposedLeaseId */, null /* leaseDuration */, breakSeconds, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, TimeSpan.Zero, cmd, ex); @@ -1937,11 +1501,9 @@ private RESTCommand StartCopyImpl(BlobAttributes attributes, Uri source, RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = BlobHttpRequestMessageFactory.CopyFrom(uri, serverTimeout, source, sourceAccessCondition, destAccessCondition, cnt, ctx); + StorageRequestMessage msg = BlobHttpRequestMessageFactory.CopyFrom(uri, serverTimeout, source, sourceAccessCondition, destAccessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); BlobHttpRequestMessageFactory.AddMetadata(msg, attributes.Metadata); return msg; }; @@ -1972,9 +1534,7 @@ private RESTCommand AbortCopyImpl(BlobAttributes attributes, string co RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.AbortCopy(uri, serverTimeout, copyId, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.AbortCopy(uri, serverTimeout, copyId, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.NoContent, resp, NullType.Value, cmd, ex); return putCmd; @@ -1994,11 +1554,9 @@ private RESTCommand SnapshotImpl(IDictionary metadata RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = BlobHttpRequestMessageFactory.Snapshot(uri, serverTimeout, accessCondition, cnt, ctx); + StorageRequestMessage msg = BlobHttpRequestMessageFactory.Snapshot(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); if (metadata != null) { BlobHttpRequestMessageFactory.AddMetadata(msg, metadata); diff --git a/Lib/WindowsRuntime/Blob/CloudBlobClient.cs b/Lib/WindowsRuntime/Blob/CloudBlobClient.cs index 2e650b928..6bb3ecee0 100644 --- a/Lib/WindowsRuntime/Blob/CloudBlobClient.cs +++ b/Lib/WindowsRuntime/Blob/CloudBlobClient.cs @@ -36,13 +36,14 @@ namespace Microsoft.WindowsAzure.Storage.Blob using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Foundation.Metadata; + using System.Threading; #endif /// /// Provides a client-side logical representation of the Windows Azure Blob Service. This client is used to configure and execute requests against the Blob Service. /// /// The service client encapsulates the base URI for the Blob service. If the service client will be used for authenticated access, it also encapsulates the credentials for accessing the storage account. - public sealed partial class CloudBlobClient + public partial class CloudBlobClient { /// /// Gets or sets the authentication scheme to use to sign HTTP requests. @@ -60,46 +61,13 @@ public AuthenticationScheme AuthenticationScheme } } - /// - /// Gets the authentication handler used to sign requests. - /// - /// Authentication handler. - internal HttpClientHandler AuthenticationHandler - { - get - { - HttpClientHandler authenticationHandler; - if (this.Credentials.IsSharedKey) - { -#if PORTABLE - throw new NotSupportedException(SR.PortableDoesNotSupportSharedKey); -#else - authenticationHandler = new SharedKeyAuthenticationHttpHandler( - this.GetCanonicalizer(), - this.Credentials, - this.Credentials.AccountName); -#endif - } - else - { - authenticationHandler = new NoOpAuthenticationHttpHandler(); - } - - return authenticationHandler; - } - } - /// /// Returns a result segment containing a collection of containers. /// /// A continuation token returned by a previous listing operation. /// A result segment of containers. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ListContainersSegmentedAsync(BlobContinuationToken currentToken) -#else - public IAsyncOperation ListContainersSegmentedAsync(BlobContinuationToken currentToken) -#endif + public virtual Task ListContainersSegmentedAsync(BlobContinuationToken currentToken) { return this.ListContainersSegmentedAsync(null /* prefix */, ContainerListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } @@ -110,11 +78,7 @@ public IAsyncOperation ListContainersSegmentedAsync(Blob /// A continuation token returned by a previous listing operation. /// A result segment of containers. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ListContainersSegmentedAsync(string prefix, BlobContinuationToken currentToken) -#else - public IAsyncOperation ListContainersSegmentedAsync(string prefix, BlobContinuationToken currentToken) -#endif + public virtual Task ListContainersSegmentedAsync(string prefix, BlobContinuationToken currentToken) { return this.ListContainersSegmentedAsync(prefix, ContainerListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } @@ -132,29 +96,11 @@ public IAsyncOperation ListContainersSegmentedAsync(stri /// An object that represents the context for the current operation. /// A result segment of containers. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) { return this.ListContainersSegmentedAsync(prefix, detailsIncluded, maxResults, currentToken, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) - { - return AsyncInfo.Run(async (token) => - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this); - ResultSegment resultSegment = await Executor.ExecuteAsync( - this.ListContainersImpl(prefix, detailsIncluded, currentToken, maxResults, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token); - - return new ContainerResultSegment(resultSegment.Results, (BlobContinuationToken)resultSegment.ContinuationToken); - }); - } -#endif -#if ASPNET_K || PORTABLE /// /// Returns a result segment containing a collection of containers /// whose names begin with the specified prefix. @@ -169,7 +115,7 @@ public IAsyncOperation ListContainersSegmentedAsync(stri /// A to observe while waiting for a task to complete. /// A result segment of containers. [DoesServiceRequest] - public Task ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ListContainersSegmentedAsync(string prefix, ContainerListingDetails detailsIncluded, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return Task.Run(async () => { @@ -183,7 +129,6 @@ public Task ListContainersSegmentedAsync(string prefix, return new ContainerResultSegment(resultSegment.Results, (BlobContinuationToken)resultSegment.ContinuationToken); }, cancellationToken); } -#endif /// /// Returns a result segment containing a collection of blob items @@ -193,17 +138,10 @@ public Task ListContainersSegmentedAsync(string prefix, /// The continuation token. /// A result segment containing objects that implement . [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken) + public virtual Task ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken) { return this.ListBlobsSegmentedAsync(prefix, false, BlobListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } -#else - public IAsyncOperation ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken) - { - return this.ListBlobsSegmentedAsync(prefix, false, BlobListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */); - } -#endif /// /// Returns a result segment containing a collection of blob items @@ -219,11 +157,7 @@ public IAsyncOperation ListBlobsSegmentedAsync(string prefix, /// An object that represents the context for the current operation. /// A result segment containing objects that implement . [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) -#else - public IAsyncOperation ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) { string containerName; string listingPrefix; @@ -233,18 +167,13 @@ public IAsyncOperation ListBlobsSegmentedAsync(string prefix, return container.ListBlobsSegmentedAsync(listingPrefix, useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext); } - /// - /// Gets a reference to a blob from the service. - /// - /// The URI of the blob. - /// A reference to the blob. - [DoesServiceRequest] - -#if ASPNET_K || PORTABLE - public Task GetBlobReferenceFromServerAsync(Uri blobUri) -#else - public IAsyncOperation GetBlobReferenceFromServerAsync(Uri blobUri) -#endif + /// + /// Gets a reference to a blob from the service. + /// + /// The URI of the blob. + /// A reference to the blob. + [DoesServiceRequest] + public virtual Task GetBlobReferenceFromServerAsync(Uri blobUri) { return this.GetBlobReferenceFromServerAsync(blobUri, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -258,12 +187,7 @@ public IAsyncOperation GetBlobReferenceFromServerAsync(Uri blobUri) /// An object that represents the context for the current operation. /// A reference to the blob. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetBlobReferenceFromServerAsync(Uri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - [DefaultOverload] - public IAsyncOperation GetBlobReferenceFromServerAsync(Uri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task GetBlobReferenceFromServerAsync(Uri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { CommonUtility.AssertNotNull("blobUri", blobUri); return this.GetBlobReferenceFromServerAsync(new StorageUri(blobUri), accessCondition, options, operationContext); @@ -278,26 +202,11 @@ public IAsyncOperation GetBlobReferenceFromServerAsync(Uri blobUri, /// An object that represents the context for the current operation. /// A reference to the blob. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetBlobReferenceFromServerAsync(StorageUri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task GetBlobReferenceFromServerAsync(StorageUri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.GetBlobReferenceFromServerAsync(blobUri, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation GetBlobReferenceFromServerAsync(StorageUri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - CommonUtility.AssertNotNull("blobUri", blobUri); - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.GetBlobReferenceImpl(blobUri, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Gets a reference to a blob from the service. /// @@ -308,7 +217,7 @@ public IAsyncOperation GetBlobReferenceFromServerAsync(StorageUri bl /// A to observe while waiting for a task to complete. /// A reference to the blob. [DoesServiceRequest] - public Task GetBlobReferenceFromServerAsync(StorageUri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetBlobReferenceFromServerAsync(StorageUri blobUri, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("blobUri", blobUri); @@ -319,7 +228,7 @@ public Task GetBlobReferenceFromServerAsync(StorageUri blobUri, Acce operationContext, cancellationToken), cancellationToken); } -#endif + /// /// Core implementation for the ListContainers method. /// @@ -342,9 +251,7 @@ private RESTCommand> ListContainersImpl(string options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommonUtility.GetListingLocationMode(currentToken); getCmd.RetrieveResponseStream = true; - getCmd.Handler = this.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.List(uri, serverTimeout, listingContext, detailsIncluded, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.List(uri, serverTimeout, listingContext, detailsIncluded, cnt, ctx, this.GetCanonicalizer(), this.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { @@ -392,9 +299,7 @@ private RESTCommand GetBlobReferenceFromServerImpl(StorageUri blobUri options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = client.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetProperties(uri, serverTimeout, parsedSnapshot, accessCondition, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetProperties(uri, serverTimeout, parsedSnapshot, accessCondition, cnt, ctx, client.GetCanonicalizer(), client.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); @@ -445,9 +350,7 @@ private RESTCommand GetBlobReferenceImpl(StorageUri blobUri, AccessC options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = client.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetProperties(uri, serverTimeout, parsedSnapshot, accessCondition, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetProperties(uri, serverTimeout, parsedSnapshot, accessCondition, cnt, ctx, client.GetCanonicalizer(), client.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); @@ -485,11 +388,7 @@ private RESTCommand GetBlobReferenceImpl(StorageUri blobUri, AccessC /// /// The blob service properties. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetServicePropertiesAsync() -#else - public IAsyncOperation GetServicePropertiesAsync() -#endif + public virtual Task GetServicePropertiesAsync() { return this.GetServicePropertiesAsync(null /* options */, null /* operationContext */); } @@ -501,27 +400,11 @@ public IAsyncOperation GetServicePropertiesAsync() /// An object that represents the context for the current operation. /// The blob service properties. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetServicePropertiesAsync(BlobRequestOptions options, OperationContext operationContext) + public virtual Task GetServicePropertiesAsync(BlobRequestOptions options, OperationContext operationContext) { return this.GetServicePropertiesAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation GetServicePropertiesAsync(BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run( - async (token) => await Executor.ExecuteAsync( - this.GetServicePropertiesImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Gets the properties of the blob service. /// @@ -530,7 +413,7 @@ public IAsyncOperation GetServicePropertiesAsync(BlobRequestO /// A to observe while waiting for a task to complete. /// The blob service properties. [DoesServiceRequest] - public Task GetServicePropertiesAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServicePropertiesAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this); operationContext = operationContext ?? new OperationContext(); @@ -542,17 +425,14 @@ public Task GetServicePropertiesAsync(BlobRequestOptions opti operationContext, cancellationToken), cancellationToken); } -#endif private RESTCommand GetServicePropertiesImpl(BlobRequestOptions requestOptions) { RESTCommand retCmd = new RESTCommand(this.Credentials, this.StorageUri); retCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetServiceProperties(uri, serverTimeout, ctx); + retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetServiceProperties(uri, serverTimeout, ctx, this.GetCanonicalizer(), this.Credentials); retCmd.RetrieveResponseStream = true; - retCmd.Handler = this.AuthenticationHandler; - retCmd.BuildClient = HttpClientFactory.BuildHttpClient; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); @@ -572,11 +452,7 @@ private RESTCommand GetServicePropertiesImpl(BlobRequestOptio /// The blob service properties. /// The properties of the blob service. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task SetServicePropertiesAsync(ServiceProperties properties) -#else - public IAsyncAction SetServicePropertiesAsync(ServiceProperties properties) -#endif + public virtual Task SetServicePropertiesAsync(ServiceProperties properties) { return this.SetServicePropertiesAsync(properties, null /* options */, null /* operationContext */); } @@ -589,25 +465,11 @@ public IAsyncAction SetServicePropertiesAsync(ServiceProperties properties) /// An object that represents the context for the current operation. /// The properties of the blob service. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task SetServicePropertiesAsync(ServiceProperties properties, BlobRequestOptions requestOptions, OperationContext operationContext) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, BlobRequestOptions requestOptions, OperationContext operationContext) { return this.SetServicePropertiesAsync(properties, requestOptions, operationContext, CancellationToken.None); } -#else - public IAsyncAction SetServicePropertiesAsync(ServiceProperties properties, BlobRequestOptions requestOptions, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(requestOptions, BlobType.Unspecified, this); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetServicePropertiesImpl(properties, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Gets the properties of the blob service. /// @@ -617,7 +479,7 @@ public IAsyncAction SetServicePropertiesAsync(ServiceProperties properties, Blob /// A to observe while waiting for a task to complete. /// The properties of the blob service. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties, BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(requestOptions, BlobType.Unspecified, this); operationContext = operationContext ?? new OperationContext(); @@ -627,7 +489,6 @@ public Task SetServicePropertiesAsync(ServiceProperties properties, BlobRequestO operationContext, cancellationToken), cancellationToken); } -#endif private RESTCommand SetServicePropertiesImpl(ServiceProperties properties, BlobRequestOptions requestOptions) { @@ -643,12 +504,10 @@ private RESTCommand SetServicePropertiesImpl(ServiceProperties propert RESTCommand retCmd = new RESTCommand(this.Credentials, this.StorageUri); requestOptions.ApplyToStorageCommand(retCmd); - retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.SetServiceProperties(uri, serverTimeout, cnt, ctx); + retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.SetServiceProperties(uri, serverTimeout, cnt, ctx, this.GetCanonicalizer(), this.Credentials); retCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, null /* md5 */, cmd, ctx); retCmd.StreamToDispose = memoryStream; retCmd.RetrieveResponseStream = true; - retCmd.Handler = this.AuthenticationHandler; - retCmd.BuildClient = HttpClientFactory.BuildHttpClient; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, null /* retVal */, cmd, ex); @@ -661,11 +520,7 @@ private RESTCommand SetServicePropertiesImpl(ServiceProperties propert /// /// The blob service stats. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetServiceStatsAsync() -#else - public IAsyncOperation GetServiceStatsAsync() -#endif + public virtual Task GetServiceStatsAsync() { return this.GetServiceStatsAsync(null /* options */, null /* operationContext */); } @@ -677,27 +532,11 @@ public IAsyncOperation GetServiceStatsAsync() /// An object that represents the context for the current operation. /// The blob service stats. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetServiceStatsAsync(BlobRequestOptions options, OperationContext operationContext) + public virtual Task GetServiceStatsAsync(BlobRequestOptions options, OperationContext operationContext) { return this.GetServiceStatsAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation GetServiceStatsAsync(BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run( - async (token) => await Executor.ExecuteAsync( - this.GetServiceStatsImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Gets service stats for the Blob service. /// @@ -706,7 +545,7 @@ public IAsyncOperation GetServiceStatsAsync(BlobRequestOptions opt /// A to observe while waiting for a task to complete. /// The blob service stats. [DoesServiceRequest] - public Task GetServiceStatsAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServiceStatsAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this); operationContext = operationContext ?? new OperationContext(); @@ -718,17 +557,14 @@ public Task GetServiceStatsAsync(BlobRequestOptions options, Opera operationContext, cancellationToken), cancellationToken); } -#endif private RESTCommand GetServiceStatsImpl(BlobRequestOptions requestOptions) { RESTCommand retCmd = new RESTCommand(this.Credentials, this.StorageUri); requestOptions.ApplyToStorageCommand(retCmd); retCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetServiceStats(uri, serverTimeout, ctx); + retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetServiceStats(uri, serverTimeout, ctx, this.GetCanonicalizer(), this.Credentials); retCmd.RetrieveResponseStream = true; - retCmd.Handler = this.AuthenticationHandler; - retCmd.BuildClient = HttpClientFactory.BuildHttpClient; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); retCmd.PostProcessResponse = (cmd, resp, ctx) => Task.Factory.StartNew(() => BlobHttpResponseParsers.ReadServiceStats(cmd.ResponseStream)); return retCmd; diff --git a/Lib/WindowsRuntime/Blob/CloudBlobContainer.cs b/Lib/WindowsRuntime/Blob/CloudBlobContainer.cs index fe5bc7c35..b4ba58407 100644 --- a/Lib/WindowsRuntime/Blob/CloudBlobContainer.cs +++ b/Lib/WindowsRuntime/Blob/CloudBlobContainer.cs @@ -29,8 +29,9 @@ namespace Microsoft.WindowsAzure.Storage.Blob using System.Net; using System.Net.Http; using System.Threading.Tasks; -#if ASPNET_K || PORTABLE using System.Threading; + +#if ASPNET_K || PORTABLE #else using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; @@ -40,20 +41,14 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// Represents a container in the Windows Azure Blob service. /// /// Containers hold directories, which are encapsulated as objects, and directories hold block blobs and page blobs. Directories can also contain sub-directories. - public sealed partial class CloudBlobContainer + public partial class CloudBlobContainer { /// /// Creates the container. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task CreateAsync() -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction CreateAsync() -#endif + public virtual Task CreateAsync() { return this.CreateAsync(null /* options */, null /* operationContext */); } @@ -63,15 +58,9 @@ public IAsyncAction CreateAsync() /// /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task CreateAsync(BlobRequestOptions options, OperationContext operationContext) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction CreateAsync(BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task CreateAsync(BlobRequestOptions options, OperationContext operationContext) { return this.CreateAsync(BlobContainerPublicAccessType.Off, options, operationContext); } @@ -82,28 +71,13 @@ public IAsyncAction CreateAsync(BlobRequestOptions options, OperationContext ope /// An object that specifies whether data in the container may be accessed publicly and what level of access is to be allowed. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task CreateAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext) { return CreateAsync(accessType, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction CreateAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.CreateContainerImpl(modifiedOptions, accessType), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Creates the container and specifies the level of access to the container's data. /// @@ -113,7 +87,7 @@ public IAsyncAction CreateAsync(BlobContainerPublicAccessType accessType, BlobRe /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task CreateAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -122,18 +96,14 @@ public Task CreateAsync(BlobContainerPublicAccessType accessType, BlobRequestOpt operationContext, cancellationToken), cancellationToken); } -#endif /// /// Creates the container if it does not already exist. /// /// true if the container did not already exist and was created; otherwise, false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task CreateIfNotExistsAsync() -#else - public IAsyncOperation CreateIfNotExistsAsync() -#endif + public virtual Task CreateIfNotExistsAsync() { return this.CreateIfNotExistsAsync(null /* options */, null /* operationContext */); } @@ -144,12 +114,9 @@ public IAsyncOperation CreateIfNotExistsAsync() /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// true if the container did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task CreateIfNotExistsAsync(BlobRequestOptions options, OperationContext operationContext) -#else - public IAsyncOperation CreateIfNotExistsAsync(BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task CreateIfNotExistsAsync(BlobRequestOptions options, OperationContext operationContext) { return this.CreateIfNotExistsAsync(BlobContainerPublicAccessType.Off, options, operationContext); } @@ -161,57 +128,13 @@ public IAsyncOperation CreateIfNotExistsAsync(BlobRequestOptions options, /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// true if the container did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task CreateIfNotExistsAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateIfNotExistsAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext) { return this.CreateIfNotExistsAsync(accessType, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation CreateIfNotExistsAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => - { - bool exists = await this.ExistsAsync(true, modifiedOptions, operationContext).AsTask(token); - - if (exists) - { - return false; - } - - try - { - await this.CreateAsync(accessType, modifiedOptions, operationContext).AsTask(token); - return true; - } - catch (Exception) - { - if (operationContext.LastResult.HttpStatusCode == (int)HttpStatusCode.Conflict) - { - StorageExtendedErrorInformation extendedInfo = operationContext.LastResult.ExtendedErrorInformation; - if ((extendedInfo == null) || - (extendedInfo.ErrorCode == BlobErrorCodeStrings.ContainerAlreadyExists)) - { - return false; - } - else - { - throw; - } - } - else - { - throw; - } - } - }); - } -#endif -#if ASPNET_K || PORTABLE /// /// Creates the container if it does not already exist and specifies the level of access to the container's data. /// @@ -220,8 +143,9 @@ public IAsyncOperation CreateIfNotExistsAsync(BlobContainerPublicAccessTyp /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// true if the container did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateIfNotExistsAsync(BlobContainerPublicAccessType accessType, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -262,20 +186,13 @@ public Task CreateIfNotExistsAsync(BlobContainerPublicAccessType accessTyp } }, cancellationToken); } -#endif /// /// Deletes the container. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteAsync() -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DeleteAsync() -#endif + public virtual Task DeleteAsync() { return this.DeleteAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -286,28 +203,14 @@ public IAsyncAction DeleteAsync() /// An object that represents the access conditions for the container. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DeleteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return DeleteAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DeleteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.DeleteContainerImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE + /// /// Deletes the container. /// @@ -317,7 +220,7 @@ public IAsyncAction DeleteAsync(AccessCondition accessCondition, BlobRequestOpti /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -326,18 +229,13 @@ public Task DeleteAsync(AccessCondition accessCondition, BlobRequestOptions opti operationContext, cancellationToken), cancellationToken); } -#endif /// /// Deletes the container if it already exists. /// /// true if the container already existed and was deleted; otherwise, false. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task DeleteIfExistsAsync() -#else - public IAsyncOperation DeleteIfExistsAsync() -#endif + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -350,56 +248,11 @@ public IAsyncOperation DeleteIfExistsAsync() /// An object that represents the context for the current operation. /// true if the container already existed and was deleted; otherwise, false. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task DeleteIfExistsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DeleteIfExistsAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation DeleteIfExistsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => - { - bool exists = await this.ExistsAsync(true, modifiedOptions, operationContext).AsTask(token); - - if (!exists) - { - return false; - } - - try - { - await this.DeleteAsync(accessCondition, modifiedOptions, operationContext).AsTask(token); - return true; - } - catch (Exception) - { - if (operationContext.LastResult.HttpStatusCode == (int)HttpStatusCode.NotFound) - { - StorageExtendedErrorInformation extendedInfo = operationContext.LastResult.ExtendedErrorInformation; - if ((extendedInfo == null) || - (extendedInfo.ErrorCode == BlobErrorCodeStrings.ContainerNotFound)) - { - return false; - } - else - { - throw; - } - } - else - { - throw; - } - } - }); - } -#endif -#if ASPNET_K || PORTABLE /// /// Deletes the container if it already exists. /// @@ -409,7 +262,7 @@ public IAsyncOperation DeleteIfExistsAsync(AccessCondition accessCondition /// A to observe while waiting for a task to complete. /// true if the container already existed and was deleted; otherwise, false. [DoesServiceRequest] - public Task DeleteIfExistsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -450,7 +303,6 @@ public Task DeleteIfExistsAsync(AccessCondition accessCondition, BlobReque } }, cancellationToken); } -#endif /// /// Gets a reference to a blob in this container. @@ -458,11 +310,7 @@ public Task DeleteIfExistsAsync(AccessCondition accessCondition, BlobReque /// The name of the blob. /// A reference to the blob. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetBlobReferenceFromServerAsync(string blobName) -#else - public IAsyncOperation GetBlobReferenceFromServerAsync(string blobName) -#endif + public virtual Task GetBlobReferenceFromServerAsync(string blobName) { return this.GetBlobReferenceFromServerAsync(blobName, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -476,11 +324,7 @@ public IAsyncOperation GetBlobReferenceFromServerAsync(string blobNa /// An object that represents the context for the current operation. /// A reference to the blob. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetBlobReferenceFromServerAsync(string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - public IAsyncOperation GetBlobReferenceFromServerAsync(string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task GetBlobReferenceFromServerAsync(string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { CommonUtility.AssertNotNullOrEmpty("blobName", blobName); StorageUri blobUri = NavigationHelper.AppendPathToUri(this.StorageUri, blobName); @@ -488,7 +332,6 @@ public IAsyncOperation GetBlobReferenceFromServerAsync(string blobNa return this.ServiceClient.GetBlobReferenceFromServerAsync(blobUri, accessCondition, options, operationContext); } -#if ASPNET_K || PORTABLE /// /// Gets a reference to a blob in this container. /// @@ -499,14 +342,13 @@ public IAsyncOperation GetBlobReferenceFromServerAsync(string blobNa /// A to observe while waiting for a task to complete. /// A reference to the blob. [DoesServiceRequest] - public Task GetBlobReferenceFromServerAsync(string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetBlobReferenceFromServerAsync(string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNullOrEmpty("blobName", blobName); StorageUri blobUri = NavigationHelper.AppendPathToUri(this.StorageUri, blobName); return this.ServiceClient.GetBlobReferenceFromServerAsync(blobUri, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Returns a result segment containing a collection of blob items @@ -515,11 +357,7 @@ public Task GetBlobReferenceFromServerAsync(string blobName, AccessC /// A token returned by a previous listing operation. /// A result segment containing objects that implement . [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ListBlobsSegmentedAsync(BlobContinuationToken currentToken) -#else - public IAsyncOperation ListBlobsSegmentedAsync(BlobContinuationToken currentToken) -#endif + public virtual Task ListBlobsSegmentedAsync(BlobContinuationToken currentToken) { return this.ListBlobsSegmentedAsync(null /* prefix */, false, BlobListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } @@ -532,11 +370,7 @@ public IAsyncOperation ListBlobsSegmentedAsync(BlobContinuati /// A token returned by a previous listing operation. /// A result segment containing objects that implement . [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken) -#else - public IAsyncOperation ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken) -#endif + public virtual Task ListBlobsSegmentedAsync(string prefix, BlobContinuationToken currentToken) { return this.ListBlobsSegmentedAsync(prefix, false, BlobListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } @@ -555,29 +389,11 @@ public IAsyncOperation ListBlobsSegmentedAsync(string prefix, /// An object that represents the context for the current operation. /// A result segment containing objects that implement . [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) { return ListBlobsSegmentedAsync(prefix, useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => - { - ResultSegment resultSegment = await Executor.ExecuteAsync( - this.ListBlobsImpl(prefix, maxResults, useFlatBlobListing, blobListingDetails, modifiedOptions, currentToken), - modifiedOptions.RetryPolicy, - operationContext, - token); - - return new BlobResultSegment(resultSegment.Results, (BlobContinuationToken)resultSegment.ContinuationToken); - }); - } -#endif -#if ASPNET_K || PORTABLE /// /// Returns a result segment containing a collection of blob items /// in the container. @@ -593,7 +409,7 @@ public IAsyncOperation ListBlobsSegmentedAsync(string prefix, /// A to observe while waiting for a task to complete. /// A result segment containing objects that implement . [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ListBlobsSegmentedAsync(string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => @@ -607,22 +423,15 @@ public Task ListBlobsSegmentedAsync(string prefix, bool useFl return new BlobResultSegment(resultSegment.Results, (BlobContinuationToken)resultSegment.ContinuationToken); }, cancellationToken); } -#endif #if !PORTABLE /// /// Sets permissions for the container. /// /// The permissions to apply to the container. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetPermissionsAsync(BlobContainerPermissions permissions) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction SetPermissionsAsync(BlobContainerPermissions permissions) -#endif + public virtual Task SetPermissionsAsync(BlobContainerPermissions permissions) { return this.SetPermissionsAsync(permissions, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -634,28 +443,13 @@ public IAsyncAction SetPermissionsAsync(BlobContainerPermissions permissions) /// An object that represents the access conditions for the container. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetPermissionsAsync(BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task SetPermissionsAsync(BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.SetPermissionsAsync(permissions, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction SetPermissionsAsync(BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetPermissionsImpl(permissions, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Sets permissions for the container. /// @@ -666,7 +460,7 @@ public IAsyncAction SetPermissionsAsync(BlobContainerPermissions permissions, Ac /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetPermissionsAsync(BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetPermissionsAsync(BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -675,18 +469,13 @@ public Task SetPermissionsAsync(BlobContainerPermissions permissions, AccessCond operationContext, cancellationToken), cancellationToken); } -#endif /// /// Gets the permissions settings for the container. /// /// The container's permissions. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetPermissionsAsync() -#else - public IAsyncOperation GetPermissionsAsync() -#endif + public virtual Task GetPermissionsAsync() { return this.GetPermissionsAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -699,24 +488,11 @@ public IAsyncOperation GetPermissionsAsync() /// An object that represents the context for the current operation. /// The container's permissions. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetPermissionsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task GetPermissionsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.GetPermissionsAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation GetPermissionsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.GetPermissionsImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Gets the permissions settings for the container. /// @@ -726,7 +502,7 @@ public IAsyncOperation GetPermissionsAsync(AccessCondi /// A to observe while waiting for a task to complete. /// The container's permissions. [DoesServiceRequest] - public Task GetPermissionsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetPermissionsAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -735,7 +511,6 @@ public Task GetPermissionsAsync(AccessCondition access operationContext, cancellationToken), cancellationToken); } -#endif #endif /// @@ -743,11 +518,7 @@ public Task GetPermissionsAsync(AccessCondition access /// /// true if the container exists. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ExistsAsync() -#else - public IAsyncOperation ExistsAsync() -#endif + public virtual Task ExistsAsync() { return this.ExistsAsync(null /* options */, null /* operationContext */); } @@ -759,19 +530,11 @@ public IAsyncOperation ExistsAsync() /// An object that represents the context for the current operation. /// true if the container exists. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext) + public virtual Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext) { return this.ExistsAsync(false, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ExistsAsync(BlobRequestOptions options, OperationContext operationContext) - { - return this.ExistsAsync(false, options, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Checks existence of the container. /// @@ -779,7 +542,7 @@ public IAsyncOperation ExistsAsync(BlobRequestOptions options, OperationCo /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// true if the container exists. - public Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.ExistsAsync(false, options, operationContext, cancellationToken); } @@ -793,35 +556,13 @@ private Task ExistsAsync(bool primaryOnly, BlobRequestOptions options, Ope operationContext, cancellationToken), cancellationToken); } -#else - /// - /// Checks existence of the container. - /// - /// If true, the command will be executed against the primary location. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// true if the container exists. - private IAsyncOperation ExistsAsync(bool primaryOnly, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.ExistsImpl(modifiedOptions, primaryOnly), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif /// /// Retrieves the container's attributes. /// - /// An that represents an asynchronous action. + /// A that represents an asynchronous action. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task FetchAttributesAsync() -#else - public IAsyncAction FetchAttributesAsync() -#endif + public virtual Task FetchAttributesAsync() { return this.FetchAttributesAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -832,28 +573,13 @@ public IAsyncAction FetchAttributesAsync() /// An object that represents the access conditions for the container. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.FetchAttributesAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.FetchAttributesImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Retrieves the container's attributes. /// @@ -863,7 +589,7 @@ public IAsyncAction FetchAttributesAsync(AccessCondition accessCondition, BlobRe /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -872,20 +598,13 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOpt operationContext, cancellationToken), cancellationToken); } -#endif /// /// Sets the container's user-defined metadata. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetMetadataAsync() -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction SetMetadataAsync() -#endif + public virtual Task SetMetadataAsync() { return this.SetMetadataAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -896,26 +615,13 @@ public IAsyncAction SetMetadataAsync() /// An object that represents the access conditions for the container. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. - /// An that represents an asynchronous action. + /// A that represents an asynchronous action. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.SetMetadataAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetMetadataImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Sets the container's user-defined metadata. /// @@ -925,7 +631,7 @@ public IAsyncAction SetMetadataAsync(AccessCondition accessCondition, BlobReques /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -934,7 +640,6 @@ public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions operationContext, cancellationToken), cancellationToken); } -#endif /// /// Acquires a lease on this container. @@ -945,11 +650,7 @@ public Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions /// A string representing the proposed lease ID for the new lease, or null if no lease ID is proposed. /// The ID of the acquired lease. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId) -#else - public IAsyncOperation AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId) -#endif + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId = null) { return this.AcquireLeaseAsync(leaseTime, proposedLeaseId, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -966,24 +667,11 @@ public IAsyncOperation AcquireLeaseAsync(TimeSpan? leaseTime, string pro /// An object that represents the context for the current operation. /// The ID of the acquired lease. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.AcquireLeaseAsync(leaseTime, proposedLeaseId, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.AcquireLeaseImpl(leaseTime, proposedLeaseId, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Acquires a lease on this container. /// @@ -997,7 +685,7 @@ public IAsyncOperation AcquireLeaseAsync(TimeSpan? leaseTime, string pro /// A to observe while waiting for a task to complete. /// The ID of the acquired lease. [DoesServiceRequest] - public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -1006,21 +694,14 @@ public Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseI operationContext, cancellationToken), cancellationToken); } -#endif /// /// Renews a lease on this container. /// /// An object that represents the access conditions for the container, including a required lease ID. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction RenewLeaseAsync(AccessCondition accessCondition) -#endif + public virtual Task RenewLeaseAsync(AccessCondition accessCondition) { return this.RenewLeaseAsync(accessCondition, null /* options */, null /* operationContext */); } @@ -1031,28 +712,13 @@ public IAsyncAction RenewLeaseAsync(AccessCondition accessCondition) /// An object that represents the access conditions for the container, including a required lease ID. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.RenewLeaseAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.RenewLeaseImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Renews a lease on this container. /// @@ -1062,7 +728,7 @@ public IAsyncAction RenewLeaseAsync(AccessCondition accessCondition, BlobRequest /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1071,7 +737,6 @@ public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions operationContext, cancellationToken), cancellationToken); } -#endif /// /// Changes the lease ID on this container. @@ -1080,11 +745,7 @@ public Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions /// An object that represents the access conditions for the container, including a required lease ID. /// The new lease ID. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition) -#else - public IAsyncOperation ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition) -#endif + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition) { return this.ChangeLeaseAsync(proposedLeaseId, accessCondition, null /* options */, null /* operationContext */); } @@ -1098,24 +759,11 @@ public IAsyncOperation ChangeLeaseAsync(string proposedLeaseId, AccessCo /// An object that represents the context for the current operation. /// The new lease ID. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.ChangeLeaseAsync(proposedLeaseId, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.ChangeLeaseImpl(proposedLeaseId, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Changes the lease ID on this container. /// @@ -1126,7 +774,7 @@ public IAsyncOperation ChangeLeaseAsync(string proposedLeaseId, AccessCo /// A to observe while waiting for a task to complete. /// The new lease ID. [DoesServiceRequest] - public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -1135,21 +783,14 @@ public Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition acc operationContext, cancellationToken), cancellationToken); } -#endif /// /// Releases the lease on this container. /// /// An object that represents the access conditions for the container, including a required lease ID. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction ReleaseLeaseAsync(AccessCondition accessCondition) -#endif + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition) { return this.ReleaseLeaseAsync(accessCondition, null /* options */, null /* operationContext */); } @@ -1160,28 +801,13 @@ public IAsyncAction ReleaseLeaseAsync(AccessCondition accessCondition) /// An object that represents the access conditions for the container, including a required lease ID. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. This object is used to track requests, and to provide additional runtime information about the operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.ReleaseLeaseAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.ReleaseLeaseImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Releases the lease on this container. /// @@ -1191,7 +817,7 @@ public IAsyncAction ReleaseLeaseAsync(AccessCondition accessCondition, BlobReque /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1200,7 +826,6 @@ public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOption operationContext, cancellationToken), cancellationToken); } -#endif /// /// Breaks the current lease on this container. @@ -1210,11 +835,7 @@ public Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOption /// or zero for infinite leases. /// A representing the amount of time before the lease ends, to the second. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task BreakLeaseAsync(TimeSpan? breakPeriod) -#else - public IAsyncOperation BreakLeaseAsync(TimeSpan? breakPeriod) -#endif + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod) { return this.BreakLeaseAsync(breakPeriod, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1230,24 +851,11 @@ public IAsyncOperation BreakLeaseAsync(TimeSpan? breakPeriod) /// An object that represents the context for the current operation. This object is used to track requests, and to provide additional runtime information about the operation. /// A representing the amount of time before the lease ends, to the second. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.BreakLeaseAsync(breakPeriod, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.BreakLeaseImpl(breakPeriod, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Breaks the current lease on this container. /// @@ -1260,7 +868,7 @@ public IAsyncOperation BreakLeaseAsync(TimeSpan? breakPeriod, AccessCo /// A to observe while waiting for a task to complete. /// A representing the amount of time before the lease ends, to the second. [DoesServiceRequest] - public Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.Unspecified, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -1269,7 +877,6 @@ public Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition acc operationContext, cancellationToken), cancellationToken); } -#endif /// /// Generates a RESTCommand for acquiring a lease. @@ -1293,9 +900,7 @@ internal RESTCommand AcquireLeaseImpl(TimeSpan? leaseTime, string propos RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Acquire, proposedLeaseId, leaseDuration, null /* leaseBreakPeriod */, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Acquire, proposedLeaseId, leaseDuration, null /* leaseBreakPeriod */, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Created, resp, null /* retVal */, cmd, ex); @@ -1324,9 +929,7 @@ internal RESTCommand RenewLeaseImpl(AccessCondition accessCondition, B RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Renew, null /* proposedLeaseId */, null /* leaseDuration */, null /* leaseBreakPeriod */, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Renew, null /* proposedLeaseId */, null /* leaseDuration */, null /* leaseBreakPeriod */, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex); @@ -1356,9 +959,7 @@ internal RESTCommand ChangeLeaseImpl(string proposedLeaseId, AccessCondi RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Change, proposedLeaseId, null /* leaseDuration */, null /* leaseBreakPeriod */, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Change, proposedLeaseId, null /* leaseDuration */, null /* leaseBreakPeriod */, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); @@ -1387,9 +988,7 @@ internal RESTCommand ReleaseLeaseImpl(AccessCondition accessCondition, RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Release, null /* proposedLeaseId */, null /* leaseDuration */, null /* leaseBreakPeriod */, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Release, null /* proposedLeaseId */, null /* leaseDuration */, null /* leaseBreakPeriod */, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex); @@ -1420,9 +1019,7 @@ internal RESTCommand BreakLeaseImpl(TimeSpan? breakPeriod, AccessCondi RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Break, null /* proposedLeaseId */, null /* leaseDuration */, breakSeconds, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.Lease(uri, serverTimeout, LeaseAction.Break, null /* proposedLeaseId */, null /* leaseDuration */, breakSeconds, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, TimeSpan.Zero, cmd, ex); @@ -1452,11 +1049,9 @@ private RESTCommand CreateContainerImpl(BlobRequestOptions options, Bl RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = ContainerHttpRequestMessageFactory.Create(uri, serverTimeout, cnt, ctx, accessType); + StorageRequestMessage msg = ContainerHttpRequestMessageFactory.Create(uri, serverTimeout, cnt, ctx, accessType, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); ContainerHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -1482,9 +1077,7 @@ private RESTCommand DeleteContainerImpl(AccessCondition accessConditio RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.Delete(uri, serverTimeout, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.Delete(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, NullType.Value, cmd, ex); return putCmd; @@ -1502,9 +1095,7 @@ private RESTCommand FetchAttributesImpl(AccessCondition accessConditio options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.GetProperties(uri, serverTimeout, accessCondition, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.GetProperties(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex); @@ -1528,9 +1119,7 @@ private RESTCommand ExistsImpl(BlobRequestOptions options, bool primaryOnl options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = primaryOnly ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.GetProperties(uri, serverTimeout, null /* accessCondition */, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.GetProperties(uri, serverTimeout, null /* accessCondition */, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { if (resp.StatusCode == HttpStatusCode.NotFound) @@ -1558,11 +1147,9 @@ private RESTCommand SetMetadataImpl(AccessCondition accessCondition, B RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = ContainerHttpRequestMessageFactory.SetMetadata(uri, serverTimeout, accessCondition, cnt, ctx); + StorageRequestMessage msg = ContainerHttpRequestMessageFactory.SetMetadata(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); ContainerHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -1592,9 +1179,7 @@ private RESTCommand SetPermissionsImpl(BlobContainerPermissions acl, A RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.SetAcl(uri, serverTimeout, acl.PublicAccess, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.SetAcl(uri, serverTimeout, acl.PublicAccess, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, null /* md5 */, cmd, ctx); putCmd.StreamToDispose = memoryStream; putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => @@ -1622,9 +1207,7 @@ private RESTCommand GetPermissionsImpl(AccessCondition options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; getCmd.RetrieveResponseStream = true; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.GetAcl(uri, serverTimeout, accessCondition, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.GetAcl(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); @@ -1717,9 +1300,7 @@ private RESTCommand> ListBlobsImpl(string prefix, i options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommonUtility.GetListingLocationMode(currentToken); getCmd.RetrieveResponseStream = true; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.ListBlobs(uri, serverTimeout, listingContext, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ContainerHttpRequestMessageFactory.ListBlobs(uri, serverTimeout, listingContext, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { diff --git a/Lib/WindowsRuntime/Blob/CloudBlobDirectory.cs b/Lib/WindowsRuntime/Blob/CloudBlobDirectory.cs index 991c42a28..b8d1cdae2 100644 --- a/Lib/WindowsRuntime/Blob/CloudBlobDirectory.cs +++ b/Lib/WindowsRuntime/Blob/CloudBlobDirectory.cs @@ -17,10 +17,10 @@ namespace Microsoft.WindowsAzure.Storage.Blob { -#if ASPNET_K || PORTABLE using System.Threading; using System.Threading.Tasks; -#else + +#if WINDOWS_RT using Windows.Foundation; #endif @@ -28,7 +28,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// Represents a virtual directory of blobs, designated by a delimiter character. /// /// Containers, which are encapsulated as objects, hold directories, and directories hold block blobs and page blobs. Directories can also contain sub-directories. - public sealed partial class CloudBlobDirectory + public partial class CloudBlobDirectory { /// /// Returns a result segment containing a collection of blob items @@ -37,11 +37,7 @@ public sealed partial class CloudBlobDirectory /// A token returned by a previous listing operation. /// A result segment containing objects that implement . [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ListBlobsSegmentedAsync(BlobContinuationToken currentToken) -#else - public IAsyncOperation ListBlobsSegmentedAsync(BlobContinuationToken currentToken) -#endif + public virtual Task ListBlobsSegmentedAsync(BlobContinuationToken currentToken) { return this.ListBlobsSegmentedAsync(false, BlobListingDetails.None, null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } @@ -59,19 +55,11 @@ public IAsyncOperation ListBlobsSegmentedAsync(BlobContinuati /// An object that represents the context for the current operation. /// A result segment containing objects that implement . [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ListBlobsSegmentedAsync(bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ListBlobsSegmentedAsync(bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) { return this.ListBlobsSegmentedAsync(useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ListBlobsSegmentedAsync(bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext) - { - return this.Container.ListBlobsSegmentedAsync(this.Prefix, useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Returns a result segment containing a collection of blob items /// in the container. @@ -86,10 +74,9 @@ public IAsyncOperation ListBlobsSegmentedAsync(bool useFlatBl /// A to observe while waiting for a task to complete. /// A result segment containing objects that implement . [DoesServiceRequest] - public Task ListBlobsSegmentedAsync(bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ListBlobsSegmentedAsync(bool useFlatBlobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.Container.ListBlobsSegmentedAsync(this.Prefix, useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext, cancellationToken); } -#endif } } diff --git a/Lib/WindowsRuntime/Blob/CloudBlockBlob.cs b/Lib/WindowsRuntime/Blob/CloudBlockBlob.cs index e40f4f47b..97e34e0e6 100644 --- a/Lib/WindowsRuntime/Blob/CloudBlockBlob.cs +++ b/Lib/WindowsRuntime/Blob/CloudBlockBlob.cs @@ -31,13 +31,13 @@ namespace Microsoft.WindowsAzure.Storage.Blob using System.Net.Http; using System.Text; using System.Threading.Tasks; + using System.Threading; #if !PORTABLE using Microsoft.WindowsAzure.Storage.File; #endif #if ASPNET_K || PORTABLE - using System.Threading; #else using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; @@ -49,7 +49,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// Represents a blob that is uploaded as a set of blocks. /// - public sealed partial class CloudBlockBlob : CloudBlob, ICloudBlob + public partial class CloudBlockBlob : CloudBlob, ICloudBlob { /// /// Opens a stream for writing to the blob. If the blob already exists, it will be overwritten. @@ -61,11 +61,7 @@ public sealed partial class CloudBlockBlob : CloudBlob, ICloudBlob /// ranging from between 16 KB and 4 MB inclusive. /// To throw an exception if the blob exists instead of overwriting it, see . /// -#if ASPNET_K || PORTABLE - public Task OpenWriteAsync() -#else - public IAsyncOperation OpenWriteAsync() -#endif + public virtual Task OpenWriteAsync() { return this.OpenWriteAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -84,54 +80,11 @@ public IAsyncOperation OpenWriteAsync() /// To throw an exception if the blob exists instead of overwriting it, pass in an /// object generated using . /// -#if ASPNET_K || PORTABLE - public Task OpenWriteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task OpenWriteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.OpenWriteAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation OpenWriteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - this.attributes.AssertNoSnapshot(); - operationContext = operationContext ?? new OperationContext(); - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, this.BlobType, this.ServiceClient, false); - - if ((accessCondition != null) && accessCondition.IsConditional) - { - return AsyncInfo.Run(async (token) => - { - try - { - await this.FetchAttributesAsync(accessCondition, options, operationContext).AsTask(token); - } - catch (Exception) - { - if ((operationContext.LastResult != null) && - (operationContext.LastResult.HttpStatusCode == (int)HttpStatusCode.NotFound) && - string.IsNullOrEmpty(accessCondition.IfMatchETag)) - { - // If we got a 404 and the condition was not an If-Match, - // we should continue with the operation. - } - else - { - throw; - } - } - ICloudBlobStream stream = new BlobWriteStreamHelper(this, accessCondition, modifiedOptions, operationContext); - return stream; - }); - } - else - { - ICloudBlobStream stream = new BlobWriteStreamHelper(this, accessCondition, modifiedOptions, operationContext); - return Task.FromResult(stream).AsAsyncOperation(); - } - } -#endif - -#if ASPNET_K || PORTABLE /// /// Opens a stream for writing to the blob. If the blob already exists, it will be overwritten. /// @@ -147,7 +100,7 @@ public IAsyncOperation OpenWriteAsync(AccessCondition accessCo /// To throw an exception if the blob exists instead of overwriting it, pass in an /// object generated using . /// - public Task OpenWriteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task OpenWriteAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { this.attributes.AssertNoSnapshot(); operationContext = operationContext ?? new OperationContext(); @@ -186,21 +139,14 @@ public Task OpenWriteAsync(AccessCondition accessCondition, Blo return Task.FromResult(stream); } } -#endif /// /// Uploads a stream to a block blob. If the blob already exists, it will be overwritten. /// /// The stream providing the blob content. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source) -#endif + public virtual Task UploadFromStreamAsync(Stream source) { return this.UploadFromStreamAsyncHelper(source, null /* length*/, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -210,15 +156,9 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source) /// /// The stream providing the blob content. /// The number of bytes to write from the source stream at its current position. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source, long length) -#endif + public virtual Task UploadFromStreamAsync(Stream source, long length) { return this.UploadFromStreamAsyncHelper(source, length, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -230,15 +170,9 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, long length) /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsyncHelper(source, null /* length */, accessCondition, options, operationContext); } @@ -251,20 +185,13 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, AccessCondition a /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsyncHelper(source, length, accessCondition, options, operationContext); } -#if ASPNET_K || PORTABLE /// /// Uploads a stream to a block blob. If the blob already exists, it will be overwritten. /// @@ -275,7 +202,7 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, long length, Acce /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.UploadFromStreamAsyncHelper(source, null /* length */, accessCondition, options, operationContext, cancellationToken); } @@ -291,11 +218,10 @@ public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.UploadFromStreamAsyncHelper(source, length, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Uploads a stream to a block blob. If the blob already exists, it will be overwritten. @@ -305,7 +231,6 @@ public Task UploadFromStreamAsync(Stream source, long length, AccessCondition ac /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] internal Task UploadFromStreamAsyncHelper(Stream source, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) @@ -325,15 +250,10 @@ internal Task UploadFromStreamAsyncHelper(Stream source, long? length, AccessCon /// A that represents an asynchronous action. [DoesServiceRequest] internal Task UploadFromStreamAsyncHelper(Stream source, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - internal IAsyncAction UploadFromStreamAsyncHelper(IInputStream source, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif { CommonUtility.AssertNotNull("source", source); - Stream sourceAsStream = source.AsStreamForRead(); + Stream sourceAsStream = source; if (length.HasValue) { CommonUtility.AssertInBounds("length", length.Value, 1); @@ -349,11 +269,7 @@ internal IAsyncAction UploadFromStreamAsyncHelper(IInputStream source, long? len operationContext = operationContext ?? new OperationContext(); ExecutionState tempExecutionState = CommonUtility.CreateTemporaryExecutionState(modifiedOptions); -#if ASPNET_K || PORTABLE return Task.Run(async () => -#else - return AsyncInfo.Run(async (cancellationToken) => -#endif { bool lessThanSingleBlobThreshold = sourceAsStream.CanSeek && (length ?? sourceAsStream.Length - sourceAsStream.Position) @@ -385,7 +301,6 @@ await Executor.ExecuteAsyncNullReturn( } else { -#if ASPNET_K || PORTABLE using (CloudBlobStream blobStream = await this.OpenWriteAsync(accessCondition, options, operationContext, cancellationToken)) { // We should always call AsStreamForWrite with bufferSize=0 to prevent buffering. Our @@ -393,21 +308,8 @@ await Executor.ExecuteAsyncNullReturn( await sourceAsStream.WriteToAsync(blobStream, length, null /* maxLength */, false, tempExecutionState, null /* streamCopyState */, cancellationToken); await blobStream.CommitAsync(); } -#else - using (ICloudBlobStream blobStream = await this.OpenWriteAsync(accessCondition, options, operationContext).AsTask(cancellationToken)) - { - // We should always call AsStreamForWrite with bufferSize=0 to prevent buffering. Our - // stream copier only writes 64K buffers at a time anyway, so no buffering is needed. - await sourceAsStream.WriteToAsync(blobStream.AsStreamForWrite(0), length, null /* maxLength */, false, tempExecutionState, null /* streamCopyState */, cancellationToken); - await blobStream.CommitAsync().AsTask(cancellationToken); - } -#endif } -#if ASPNET_K || PORTABLE }, cancellationToken); -#else - }); -#endif } #if !PORTABLE @@ -416,18 +318,17 @@ await Executor.ExecuteAsyncNullReturn( /// #if ASPNET_K /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A object that represents the asynchronous operation. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode) + public virtual Task UploadFromFileAsync(string path) { - return this.UploadFromFileAsync(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */); + return this.UploadFromFileAsync(path, null /* accessCondition */, null /* options */, null /* operationContext */); } #else /// The file providing the blob content. - /// An that represents an asynchronous action. + /// A that represents an asynchronous action. [DoesServiceRequest] - public IAsyncAction UploadFromFileAsync(StorageFile source) + public virtual Task UploadFromFileAsync(StorageFile source) { return this.UploadFromFileAsync(source, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -438,32 +339,46 @@ public IAsyncAction UploadFromFileAsync(StorageFile source) /// #if ASPNET_K /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { - return this.UploadFromFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); + return this.UploadFromFileAsync(path, accessCondition, options, operationContext, CancellationToken.None); } #else /// The file providing the blob content. /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. - /// An that represents an asynchronous action. + /// A that represents an asynchronous action. + [DoesServiceRequest] + public virtual Task UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + { + return this.UploadFromFileAsync(source, accessCondition, options, operationContext, CancellationToken.None); + } + + /// + /// Uploads a file to a block blob. If the blob already exists, it will be overwritten. + /// + /// The file providing the blob content. + /// An object that represents the access conditions for the blob. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// A to observe while waiting for a task to complete. + /// A that represents an asynchronous action. [DoesServiceRequest] - public IAsyncAction UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("source", source); - return AsyncInfo.Run(async (token) => + return Task.Run(async () => { - using (IRandomAccessStreamWithContentType stream = await source.OpenReadAsync().AsTask(token)) + using (IRandomAccessStreamWithContentType stream = await source.OpenReadAsync().AsTask(cancellationToken)) { - await this.UploadFromStreamAsync(stream, accessCondition, options, operationContext).AsTask(token); + await this.UploadFromStreamAsync(stream.AsStream(), accessCondition, options, operationContext, cancellationToken); } }); } @@ -474,20 +389,19 @@ public IAsyncAction UploadFromFileAsync(StorageFile source, AccessCondition acce /// Uploads a file to a block blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("path", path); return Task.Run(async () => { - using (Stream stream = new FileStream(path, mode, FileAccess.Read)) + using (Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { await this.UploadFromStreamAsync(stream, accessCondition, options, operationContext, cancellationToken); } @@ -502,21 +416,12 @@ public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition acce /// An array of bytes. /// The zero-based byte offset in buffer at which to begin uploading bytes to the blob. /// The number of bytes to be written to the blob. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) - { - return this.UploadFromByteArrayAsync(buffer, index, count, null /* accessCondition */, null /* options */, null /* operationContext */); - } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int index, int count) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) { return this.UploadFromByteArrayAsync(buffer, index, count, null /* accessCondition */, null /* options */, null /* operationContext */); } -#endif /// /// Uploads the contents of a byte array to a blob. If the blob already exists, it will be overwritten. @@ -527,26 +432,13 @@ public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromByteArrayAsync(buffer, index, count, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - CommonUtility.AssertNotNull("buffer", buffer); - SyncMemoryStream stream = new SyncMemoryStream(buffer, index, count); - return this.UploadFromStreamAsync(stream.AsInputStream(), accessCondition, options, operationContext); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Uploads the contents of a byte array to a blob. If the blob already exists, it will be overwritten. /// @@ -559,28 +451,21 @@ public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("buffer", buffer); SyncMemoryStream stream = new SyncMemoryStream(buffer, index, count); return this.UploadFromStreamAsync(stream, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Uploads a string of text to a blob. If the blob already exists, it will be overwritten. /// /// The text to upload, encoded as a UTF-8 string. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadTextAsync(string content) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadTextAsync(string content) -#endif + public virtual Task UploadTextAsync(string content) { return this.UploadTextAsync(content, null /* encoding */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -593,11 +478,7 @@ public IAsyncAction UploadTextAsync(string content) /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task UploadTextAsync(string content, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - public IAsyncAction UploadTextAsync(string content, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task UploadTextAsync(string content, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadTextAsync(content, null /* encoding */, accessCondition, options, operationContext); } @@ -610,26 +491,13 @@ public IAsyncAction UploadTextAsync(string content, AccessCondition accessCondit /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadTextAsync(content, encoding, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - CommonUtility.AssertNotNull("content", content); - byte[] contentAsBytes = (encoding ?? Encoding.UTF8).GetBytes(content); - return this.UploadFromByteArrayAsync(contentAsBytes, 0, contentAsBytes.Length, accessCondition, options, operationContext); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Uploads a string of text to a blob. If the blob already exists, it will be overwritten. /// @@ -641,24 +509,20 @@ public IAsyncAction UploadTextAsync(string content, Encoding encoding, AccessCon /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadTextAsync(string content, Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("content", content); byte[] contentAsBytes = (encoding ?? Encoding.UTF8).GetBytes(content); return this.UploadFromByteArrayAsync(contentAsBytes, 0, contentAsBytes.Length, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Downloads the blob's contents as a string. /// /// The contents of the blob, as a string. -#if ASPNET_K || PORTABLE - public Task DownloadTextAsync() -#else - public IAsyncOperation DownloadTextAsync() -#endif + [DoesServiceRequest] + public virtual Task DownloadTextAsync() { return this.DownloadTextAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -670,11 +534,8 @@ public IAsyncOperation DownloadTextAsync() /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// The contents of the blob, as a string. -#if ASPNET_K || PORTABLE - public Task DownloadTextAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - public IAsyncOperation DownloadTextAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + [DoesServiceRequest] + public virtual Task DownloadTextAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadTextAsync(null /* encoding */, accessCondition, options, operationContext); } @@ -687,37 +548,23 @@ public IAsyncOperation DownloadTextAsync(AccessCondition accessCondition /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// The contents of the blob, as a string. -#if ASPNET_K || PORTABLE - public Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadTextAsync(encoding, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return AsyncInfo.Run(async (token) => - { - using (SyncMemoryStream stream = new SyncMemoryStream()) - { - await this.DownloadToStreamAsync(stream.AsOutputStream(), accessCondition, options, operationContext).AsTask(token); - byte[] streamAsBytes = stream.ToArray(); - return (encoding ?? Encoding.UTF8).GetString(streamAsBytes, 0, streamAsBytes.Length); - } - }); - } -#endif -#if ASPNET_K || PORTABLE - /// - /// Downloads the blob's contents as a string. - /// - /// An object that indicates the text encoding to use. - /// An object that represents the access conditions for the blob. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// A to observe while waiting for a task to complete. - /// The contents of the blob, as a string. - public Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + /// + /// Downloads the blob's contents as a string. + /// + /// An object that indicates the text encoding to use. + /// An object that represents the access conditions for the blob. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// A to observe while waiting for a task to complete. + /// The contents of the blob, as a string. + [DoesServiceRequest] + public virtual Task DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return Task.Run(async () => { @@ -729,18 +576,13 @@ public Task DownloadTextAsync(Encoding encoding, AccessCondition accessC } }, cancellationToken); } -#endif /// /// Creates a snapshot of the blob. /// /// A blob snapshot. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task CreateSnapshotAsync() -#else - public IAsyncOperation CreateSnapshotAsync() -#endif + public virtual Task CreateSnapshotAsync() { return this.CreateSnapshotAsync(null /* metadata */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -754,25 +596,11 @@ public IAsyncOperation CreateSnapshotAsync() /// An object that represents the context for the current operation. /// A blob snapshot. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return CreateSnapshotAsync(metadata, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - this.attributes.AssertNoSnapshot(); - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.CreateSnapshotImpl(metadata, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Creates a snapshot of the blob. /// @@ -783,7 +611,7 @@ public IAsyncOperation CreateSnapshotAsync(IDictionaryA to observe while waiting for a task to complete. /// A blob snapshot. [DoesServiceRequest] - public Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient); @@ -793,7 +621,6 @@ public Task CreateSnapshotAsync(IDictionary meta operationContext, cancellationToken), cancellationToken); } -#endif /// /// Uploads a single block. @@ -802,15 +629,9 @@ public Task CreateSnapshotAsync(IDictionary meta /// A stream that provides the data for the block. /// An optional hash value that will be used to set the property /// on the blob. May be null or an empty string. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task PutBlockAsync(string blockId, Stream blockData, string contentMD5) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction PutBlockAsync(string blockId, IInputStream blockData, string contentMD5) -#endif + public virtual Task PutBlockAsync(string blockId, Stream blockData, string contentMD5) { return this.PutBlockAsync(blockId, blockData, contentMD5, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -825,10 +646,9 @@ public IAsyncAction PutBlockAsync(string blockId, IInputStream blockData, string /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task PutBlockAsync(string blockId, Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task PutBlockAsync(string blockId, Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.PutBlockAsync(blockId, blockData, contentMD5, accessCondition, options, operationContext, CancellationToken.None); } @@ -846,25 +666,16 @@ public Task PutBlockAsync(string blockId, Stream blockData, string contentMD5, A /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task PutBlockAsync(string blockId, Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction PutBlockAsync(string blockId, IInputStream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task PutBlockAsync(string blockId, Stream blockData, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient); bool requiresContentMD5 = string.IsNullOrEmpty(contentMD5) && modifiedOptions.UseTransactionalMD5.Value; operationContext = operationContext ?? new OperationContext(); ExecutionState tempExecutionState = CommonUtility.CreateTemporaryExecutionState(modifiedOptions); -#if ASPNET_K || PORTABLE return Task.Run(async () => -#else - return AsyncInfo.Run(async (cancellationToken) => -#endif { - Stream blockDataAsStream = blockData.AsStreamForRead(); + Stream blockDataAsStream = blockData; Stream seekableStream = blockDataAsStream; bool seekableStreamCreated = false; @@ -908,26 +719,16 @@ await Executor.ExecuteAsyncNullReturn( seekableStream.Dispose(); } } -#if ASPNET_K || PORTABLE }, cancellationToken); -#else - }); -#endif } /// /// Uploads a list of blocks to a new or existing blob. /// /// An enumerable collection of block IDs, as base64-encoded strings. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task PutBlockListAsync(IEnumerable blockList) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction PutBlockListAsync(IEnumerable blockList) -#endif + public virtual Task PutBlockListAsync(IEnumerable blockList) { return this.PutBlockListAsync(blockList, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -939,29 +740,13 @@ public IAsyncAction PutBlockListAsync(IEnumerable blockList) /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task PutBlockListAsync(IEnumerable blockList, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task PutBlockListAsync(IEnumerable blockList, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.PutBlockListAsync(blockList, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction PutBlockListAsync(IEnumerable blockList, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient); - IEnumerable items = blockList.Select(i => new PutBlockListItem(i, BlockSearchMode.Latest)); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.PutBlockListImpl(items, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Uploads a list of blocks to a new or existing blob. /// @@ -972,7 +757,7 @@ public IAsyncAction PutBlockListAsync(IEnumerable blockList, AccessCondi /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task PutBlockListAsync(IEnumerable blockList, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task PutBlockListAsync(IEnumerable blockList, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient); IEnumerable items = blockList.Select(i => new PutBlockListItem(i, BlockSearchMode.Latest)); @@ -982,18 +767,13 @@ public Task PutBlockListAsync(IEnumerable blockList, AccessCondition acc operationContext, cancellationToken), cancellationToken); } -#endif /// /// Returns an enumerable collection of the committed blocks comprising the blob. /// /// An enumerable collection of objects implementing . [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task> DownloadBlockListAsync() -#else - public IAsyncOperation> DownloadBlockListAsync() -#endif + public virtual Task> DownloadBlockListAsync() { return this.DownloadBlockListAsync(BlockListingFilter.Committed, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1008,24 +788,11 @@ public IAsyncOperation> DownloadBlockListAsync() /// An object that represents the context for the current operation. /// An enumerable collection of objects implementing . [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task> DownloadBlockListAsync(BlockListingFilter blockListingFilter, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task> DownloadBlockListAsync(BlockListingFilter blockListingFilter, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.DownloadBlockListAsync(blockListingFilter, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation> DownloadBlockListAsync(BlockListingFilter blockListingFilter, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.GetBlockListImpl(blockListingFilter, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Returns an enumerable collection of the blob's blocks, using the specified block list filter. /// @@ -1037,7 +804,7 @@ public IAsyncOperation> DownloadBlockListAsync(BlockL /// A to observe while waiting for a task to complete. /// An enumerable collection of objects implementing . [DoesServiceRequest] - public Task> DownloadBlockListAsync(BlockListingFilter blockListingFilter, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> DownloadBlockListAsync(BlockListingFilter blockListingFilter, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -1046,77 +813,6 @@ public Task> DownloadBlockListAsync(BlockListingFilte operationContext, cancellationToken), cancellationToken); } -#endif - - /// - /// Begins an operation to start copying an existing blob's contents, properties, and metadata to a new blob. - /// - /// The URI of a source blob. - /// The copy ID associated with the copy operation. - /// - /// This method fetches the blob's ETag, last modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task StartCopyFromBlobAsync(CloudBlockBlob source) -#else - public IAsyncOperation StartCopyFromBlobAsync(CloudBlockBlob source) -#endif - { - return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source)); - } - - /// - /// Begins an operation to start copying a blob's contents, properties, and metadata to a new blob. - /// - /// The URI of a source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// The copy ID associated with the copy operation. - /// - /// This method fetches the blob's ETag, last modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task StartCopyFromBlobAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return this.StartCopyFromBlobAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); - } -#else - public IAsyncOperation StartCopyFromBlobAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); - } -#endif - -#if ASPNET_K || PORTABLE - /// - /// Begins an operation to start copying another block blob's contents, properties, and metadata to a new blob. - /// - /// The source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// A to observe while waiting for a task to complete. - /// The copy ID associated with the copy operation. - /// - /// This method fetches the blob's ETag, last modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) - { - return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); - } -#endif /// /// Begins an operation to start copying an existing block blob's contents, properties, and metadata to a new blob. @@ -1128,11 +824,7 @@ public Task StartCopyFromBlobAsync(CloudBlockBlob source, AccessConditio /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task StartCopyAsync(CloudBlockBlob source) -#else - public IAsyncOperation StartCopyAsync(CloudBlockBlob source) -#endif + public virtual Task StartCopyAsync(CloudBlockBlob source) { return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source)); } @@ -1152,11 +844,7 @@ public IAsyncOperation StartCopyAsync(CloudBlockBlob source) /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] -#if ASPNET_K - public Task StartCopyAsync(CloudFile source) -#else - public IAsyncOperation StartCopyAsync(CloudFile source) -#endif + public virtual Task StartCopyAsync(CloudFile source) { return this.StartCopyAsync(CloudFile.SourceFileToUri(source)); } @@ -1175,19 +863,11 @@ public IAsyncOperation StartCopyAsync(CloudFile source) /// This method fetches the blob's ETag, last modified time, and part of the copy state. /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// -#if ASPNET_K || PORTABLE - public Task StartCopyAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation StartCopyAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Begins an operation to start copying another block blob's contents, properties, and metadata to a new blob. /// @@ -1203,11 +883,10 @@ public IAsyncOperation StartCopyAsync(CloudBlockBlob source, AccessCondi /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public Task StartCopyAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudBlockBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); } -#endif #if !PORTABLE /// @@ -1223,19 +902,11 @@ public Task StartCopyAsync(CloudBlockBlob source, AccessCondition source /// This method fetches the blob's ETag, last modified time, and part of the copy state. /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// -#if ASPNET_K - public Task StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return this.StartCopyAsync(CloudFile.SourceFileToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Begins an operation to start copying a file's contents, properties, and metadata to a new blob. /// @@ -1251,11 +922,10 @@ public IAsyncOperation StartCopyAsync(CloudFile source, AccessCondition /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public Task StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.StartCopyAsync(CloudFile.SourceFileToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); } -#endif #endif /// @@ -1271,11 +941,9 @@ internal RESTCommand CreateSnapshotImpl(IDictionary putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = BlobHttpRequestMessageFactory.Snapshot(uri, serverTimeout, accessCondition, cnt, ctx); + StorageRequestMessage msg = BlobHttpRequestMessageFactory.Snapshot(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); if (metadata != null) { BlobHttpRequestMessageFactory.AddMetadata(msg, metadata); @@ -1315,12 +983,10 @@ private RESTCommand PutBlobImpl(Stream stream, long? length, string co RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(cappedStream, offset, length, null /* md5 */, cmd, ctx); putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = BlobHttpRequestMessageFactory.Put(uri, serverTimeout, this.Properties, BlobType.BlockBlob, 0, accessCondition, cnt, ctx); + StorageRequestMessage msg = BlobHttpRequestMessageFactory.Put(uri, serverTimeout, this.Properties, BlobType.BlockBlob, 0, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); BlobHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -1352,10 +1018,8 @@ internal RESTCommand PutBlockImpl(Stream source, string blockId, strin RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(source, offset, length, contentMD5, cmd, ctx); - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.PutBlock(uri, serverTimeout, blockId, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.PutBlock(uri, serverTimeout, blockId, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Created, resp, NullType.Value, cmd, ex); return putCmd; @@ -1385,13 +1049,11 @@ internal RESTCommand PutBlockListImpl(IEnumerable bl RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, contentMD5, cmd, ctx); putCmd.StreamToDispose = memoryStream; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = BlobHttpRequestMessageFactory.PutBlockList(uri, serverTimeout, this.Properties, accessCondition, cnt, ctx); + StorageRequestMessage msg = BlobHttpRequestMessageFactory.PutBlockList(uri, serverTimeout, this.Properties, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); BlobHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -1420,9 +1082,7 @@ internal RESTCommand> GetBlockListImpl(BlockListingFi options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; getCmd.RetrieveResponseStream = true; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetBlockList(uri, serverTimeout, this.SnapshotTime, typesOfBlocks, accessCondition, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetBlockList(uri, serverTimeout, this.SnapshotTime, typesOfBlocks, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { diff --git a/Lib/WindowsRuntime/Blob/CloudPageBlob.cs b/Lib/WindowsRuntime/Blob/CloudPageBlob.cs index 0124fa853..28d39d015 100644 --- a/Lib/WindowsRuntime/Blob/CloudPageBlob.cs +++ b/Lib/WindowsRuntime/Blob/CloudPageBlob.cs @@ -27,9 +27,10 @@ namespace Microsoft.WindowsAzure.Storage.Blob using System.IO; using System.Net; using System.Net.Http; + using System.Threading; using System.Threading.Tasks; + #if ASPNET_K || PORTABLE - using System.Threading; #else using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; @@ -41,7 +42,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob /// /// Represents a Windows Azure page blob. /// - public sealed partial class CloudPageBlob : CloudBlob, ICloudBlob + public partial class CloudPageBlob : CloudBlob, ICloudBlob { /// /// Opens a stream for writing to the blob. If the blob already exists, then existing data in the blob may be overwritten. @@ -52,11 +53,7 @@ public sealed partial class CloudPageBlob : CloudBlob, ICloudBlob /// To avoid overwriting and instead throw an error, see . /// [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task OpenWriteAsync(long? size) -#else - public IAsyncOperation OpenWriteAsync(long? size) -#endif + public virtual Task OpenWriteAsync(long? size) { return this.OpenWriteAsync(size, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -74,8 +71,7 @@ public IAsyncOperation OpenWriteAsync(long? size) /// object generated using . /// [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task OpenWriteAsync(long? size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task OpenWriteAsync(long? size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.OpenWriteAsync(size, accessCondition, options, operationContext, CancellationToken.None); } @@ -94,10 +90,7 @@ public Task OpenWriteAsync(long? size, AccessCondition accessCo /// object generated using . /// [DoesServiceRequest] - public Task OpenWriteAsync(long? size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation OpenWriteAsync(long? size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task OpenWriteAsync(long? size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { this.attributes.AssertNoSnapshot(); bool createNew = size.HasValue; @@ -107,27 +100,15 @@ public IAsyncOperation OpenWriteAsync(long? size, AccessCondit throw new ArgumentException(SR.MD5NotPossible); } -#if ASPNET_K || PORTABLE return Task.Run(async () => -#else - return AsyncInfo.Run(async (token) => -#endif { if (createNew) { -#if ASPNET_K || PORTABLE await this.CreateAsync(size.Value, accessCondition, options, operationContext, cancellationToken); -#else - await this.CreateAsync(size.Value, accessCondition, options, operationContext).AsTask(token); -#endif } else { -#if ASPNET_K || PORTABLE await this.FetchAttributesAsync(accessCondition, options, operationContext, cancellationToken); -#else - await this.FetchAttributesAsync(accessCondition, options, operationContext).AsTask(token); -#endif size = this.Properties.Length; } @@ -136,32 +117,18 @@ public IAsyncOperation OpenWriteAsync(long? size, AccessCondit accessCondition = AccessCondition.GenerateLeaseCondition(accessCondition.LeaseId); } -#if ASPNET_K || PORTABLE CloudBlobStream stream = new BlobWriteStream(this, size.Value, createNew, accessCondition, modifiedOptions, operationContext); -#else - ICloudBlobStream stream = new BlobWriteStreamHelper(this, size.Value, createNew, accessCondition, modifiedOptions, operationContext); -#endif return stream; -#if ASPNET_K || PORTABLE }, cancellationToken); -#else - }); -#endif } /// /// Uploads a stream to a page blob. If the blob already exists, it will be overwritten. /// /// The stream providing the blob content. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source) -#endif + public virtual Task UploadFromStreamAsync(Stream source) { return this.UploadFromStreamAsyncHelper(source, null /* length */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -171,15 +138,9 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source) /// /// The stream providing the blob content. /// The number of bytes to write from the source stream at its current position. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source, long length) -#endif + public virtual Task UploadFromStreamAsync(Stream source, long length) { return this.UploadFromStreamAsyncHelper(source, length, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -191,15 +152,9 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, long length) /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsyncHelper(source, null /* length */, accessCondition, options, operationContext); } @@ -212,20 +167,13 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, AccessCondition a /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsyncHelper(source, length, accessCondition, options, operationContext); } -#if ASPNET_K || PORTABLE /// /// Uploads a stream to a page blob. If the blob already exists, it will be overwritten. /// @@ -236,7 +184,7 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, long length, Acce /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.UploadFromStreamAsyncHelper(source, null /*length */, accessCondition, options, operationContext, cancellationToken); } @@ -252,11 +200,10 @@ public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.UploadFromStreamAsyncHelper(source, length, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Uploads a stream to a page blob. If the blob already exists, it will be overwritten. @@ -266,7 +213,6 @@ public Task UploadFromStreamAsync(Stream source, long length, AccessCondition ac /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] internal Task UploadFromStreamAsyncHelper(Stream source, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) @@ -286,15 +232,10 @@ internal Task UploadFromStreamAsyncHelper(Stream source, long? length, AccessCon /// A that represents an asynchronous action. [DoesServiceRequest] internal Task UploadFromStreamAsyncHelper(Stream source, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - internal IAsyncAction UploadFromStreamAsyncHelper(IInputStream source, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif { CommonUtility.AssertNotNull("source", source); - Stream sourceAsStream = source.AsStreamForRead(); + Stream sourceAsStream = source; if (!sourceAsStream.CanSeek) { throw new InvalidOperationException(); @@ -319,7 +260,6 @@ internal IAsyncAction UploadFromStreamAsyncHelper(IInputStream source, long? len throw new ArgumentException(SR.InvalidPageSize, "source"); } -#if ASPNET_K || PORTABLE return Task.Run(async () => { using (CloudBlobStream blobStream = await this.OpenWriteAsync(length, accessCondition, options, operationContext, cancellationToken)) @@ -330,18 +270,6 @@ internal IAsyncAction UploadFromStreamAsyncHelper(IInputStream source, long? len await blobStream.CommitAsync(); } }, cancellationToken); -#else - return AsyncInfo.Run(async (token) => - { - using (ICloudBlobStream blobStream = await this.OpenWriteAsync(length, accessCondition, options, operationContext).AsTask(token)) - { - // We should always call AsStreamForWrite with bufferSize=0 to prevent buffering. Our - // stream copier only writes 64K buffers at a time anyway, so no buffering is needed. - await sourceAsStream.WriteToAsync(blobStream.AsStreamForWrite(0), length, null /* maxLength */, false, tempExecutionState, null /* streamCopyState */, token); - await blobStream.CommitAsync().AsTask(token); - } - }); -#endif } #if !PORTABLE @@ -350,18 +278,17 @@ internal IAsyncAction UploadFromStreamAsyncHelper(IInputStream source, long? len /// #if ASPNET_K /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode) + public virtual Task UploadFromFileAsync(string path) { - return this.UploadFromFileAsync(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */); + return this.UploadFromFileAsync(path, null /* accessCondition */, null /* options */, null /* operationContext */); } #else /// The file providing the blob content. - /// An that represents an asynchronous action. + /// An that represents an asynchronous action. [DoesServiceRequest] - public IAsyncAction UploadFromFileAsync(StorageFile source) + public virtual Task UploadFromFileAsync(StorageFile source) { return this.UploadFromFileAsync(source, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -370,30 +297,48 @@ public IAsyncAction UploadFromFileAsync(StorageFile source) /// /// Uploads a file to a page blob. If the blob already exists, it will be overwritten. /// +#if ASPNET_K /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { - return this.UploadFromFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); + return this.UploadFromFileAsync(path, accessCondition, options, operationContext, CancellationToken.None); } #else - /// An that represents an asynchronous action. + /// The file providing the blob content. + /// An object that represents the access conditions for the blob. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// An that represents an asynchronous action. + [DoesServiceRequest] + public virtual Task UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + { + return this.UploadFromFileAsync(source, accessCondition, options, operationContext, CancellationToken.None); + } + + /// + /// Uploads a file to a page blob. If the blob already exists, it will be overwritten. + /// + /// The file providing the blob content. + /// An object that represents the access conditions for the blob. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// A to observe while waiting for a task to complete. + /// A that represents an asynchronous action. [DoesServiceRequest] - public IAsyncAction UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("source", source); - return AsyncInfo.Run(async (token) => + return Task.Run(async () => { - using (IRandomAccessStreamWithContentType stream = await source.OpenReadAsync().AsTask(token)) + using (IRandomAccessStreamWithContentType stream = await source.OpenReadAsync().AsTask(cancellationToken)) { - await this.UploadFromStreamAsync(stream, accessCondition, options, operationContext).AsTask(token); + await this.UploadFromStreamAsync(stream.AsStream(), accessCondition, options, operationContext, cancellationToken); } }); } @@ -404,20 +349,19 @@ public IAsyncAction UploadFromFileAsync(StorageFile source, AccessCondition acce /// Uploads a file to a page blob. If the blob already exists, it will be overwritten. /// /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("path", path); return Task.Run(async () => { - using (Stream stream = new FileStream(path, mode, FileAccess.Read)) + using (Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { await this.UploadFromStreamAsync(stream, accessCondition, options, operationContext, cancellationToken); } @@ -432,15 +376,9 @@ public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition acce /// An array of bytes. /// The zero-based byte offset in buffer at which to begin uploading bytes to the blob. /// The number of bytes to be written to the blob. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int index, int count) -#endif + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) { return this.UploadFromByteArrayAsync(buffer, index, count, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -454,26 +392,13 @@ public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.UploadFromByteArrayAsync(buffer, index, count, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - CommonUtility.AssertNotNull("buffer", buffer); - SyncMemoryStream stream = new SyncMemoryStream(buffer, index, count); - return this.UploadFromStreamAsync(stream.AsInputStream(), accessCondition, options, operationContext); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Uploads the contents of a byte array to a page blob. If the blob already exists, it will be overwritten. /// @@ -486,29 +411,22 @@ public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("buffer", buffer); SyncMemoryStream stream = new SyncMemoryStream(buffer, index, count); return this.UploadFromStreamAsync(stream, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Creates a page blob. If the blob already exists, this operation will overwrite it. To throw an exception if the blob exists, instead of overwriting, /// use . /// /// The maximum size of the page blob, in bytes. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task CreateAsync(long size) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction CreateAsync(long size) -#endif + public virtual Task CreateAsync(long size) { return this.CreateAsync(size, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -521,28 +439,13 @@ public IAsyncAction CreateAsync(long size) /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task CreateAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.CreateAsync(size, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction CreateAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.CreateImpl(size, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Creates a page blob. If the blob already exists, this operation will overwrite it. To throw an exception if the blob exists, instead of overwriting, pass in an /// object generated using . @@ -554,7 +457,7 @@ public IAsyncAction CreateAsync(long size, AccessCondition accessCondition, Blob /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task CreateAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -563,21 +466,14 @@ public Task CreateAsync(long size, AccessCondition accessCondition, BlobRequestO operationContext, cancellationToken), cancellationToken); } -#endif /// /// Resizes the page blob to the specified size. /// /// The maximum size of the page blob, in bytes. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ResizeAsync(long size) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction ResizeAsync(long size) -#endif + public virtual Task ResizeAsync(long size) { return this.ResizeAsync(size, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -589,28 +485,13 @@ public IAsyncAction ResizeAsync(long size) /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ResizeAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ResizeAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.ResizeAsync(size, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction ResizeAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.ResizeImpl(size, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Resizes the page blob to the specified size. /// @@ -621,7 +502,7 @@ public IAsyncAction ResizeAsync(long size, AccessCondition accessCondition, Blob /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ResizeAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ResizeAsync(long size, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -630,22 +511,15 @@ public Task ResizeAsync(long size, AccessCondition accessCondition, BlobRequestO operationContext, cancellationToken), cancellationToken); } -#endif /// /// Sets the page blob's sequence number. /// /// A value of type , indicating the operation to perform on the sequence number. /// The sequence number. Set this parameter to null if is equal to . -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber) -#endif + public virtual Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber) { return this.SetSequenceNumberAsync(sequenceNumberAction, sequenceNumber, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -658,67 +532,99 @@ public IAsyncAction SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAc /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.SetSequenceNumberAsync(sequenceNumberAction, sequenceNumber, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. + + /// + /// Sets the page blob's sequence number. + /// + /// A value of type , indicating the operation to perform on the sequence number. + /// The sequence number. Set this parameter to null if is equal to . + /// An object that represents the access conditions for the blob. If null, no condition is used. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// A to observe while waiting for a task to complete. + /// A that represents an asynchronous action. [DoesServiceRequest] - public IAsyncAction SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( + return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( this.SetSequenceNumberImpl(sequenceNumberAction, sequenceNumber, accessCondition, modifiedOptions), modifiedOptions.RetryPolicy, operationContext, - token)); + cancellationToken), cancellationToken); } -#endif -#if ASPNET_K || PORTABLE /// - /// Sets the page blob's sequence number. + /// Gets a collection of valid page ranges and their starting and ending bytes. /// - /// A value of type , indicating the operation to perform on the sequence number. - /// The sequence number. Set this parameter to null if is equal to . + /// An enumerable collection of page ranges. + [DoesServiceRequest] + public virtual Task> GetPageRangesAsync() + { + return this.GetPageRangesAsync(null /* offset */, null /* length */, null /* accessCondition */, null /* options */, null /* operationContext */); + } + + /// + /// Gets a collection of valid page ranges and their starting and ending bytes. + /// + /// The starting offset of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// The length of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// An object that represents the access conditions for the blob. If null, no condition is used. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// An enumerable collection of page ranges. + [DoesServiceRequest] + public virtual Task> GetPageRangesAsync(long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + { + return this.GetPageRangesAsync(offset, length, accessCondition, options, operationContext, CancellationToken.None); + } + + /// + /// Gets a collection of valid page ranges and their starting and ending bytes. + /// + /// The starting offset of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// The length of the data range over which to list page ranges, in bytes. Must be a multiple of 512. /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. - /// An that represents an asynchronous action. + /// An enumerable collection of page ranges. [DoesServiceRequest] - public Task SetSequenceNumberAsync(SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> GetPageRangesAsync(long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); - return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( - this.SetSequenceNumberImpl(sequenceNumberAction, sequenceNumber, accessCondition, modifiedOptions), + return Task.Run(async () => await Executor.ExecuteAsync( + this.GetPageRangesImpl(offset, length, accessCondition, modifiedOptions), modifiedOptions.RetryPolicy, operationContext, cancellationToken), cancellationToken); } -#endif /// - /// Gets a collection of valid page ranges and their starting and ending bytes. + /// Gets the collection of page ranges that differ between a specified snapshot and this object. /// + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. /// An enumerable collection of page ranges. [DoesServiceRequest] #if ASPNET_K || PORTABLE - public Task> GetPageRangesAsync() + public Task> GetPageRangesDiffAsync(DateTimeOffset previousSnapshotTime) #else - public IAsyncOperation> GetPageRangesAsync() + public IAsyncOperation> GetPageRangesDiffAsync(DateTimeOffset previousSnapshotTime) #endif { - return this.GetPageRangesAsync(null /* offset */, null /* length */, null /* accessCondition */, null /* options */, null /* operationContext */); + return this.GetPageRangesDiffAsync(previousSnapshotTime, null /* offset */, null /* length */, null /* accessCondition */, null /* options */, null /* operationContext */); } /// - /// Gets a collection of valid page ranges and their starting and ending bytes. + /// Gets the collection of page ranges that differ between a specified snapshot and this object. /// + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. /// The starting offset of the data range over which to list page ranges, in bytes. Must be a multiple of 512. /// The length of the data range over which to list page ranges, in bytes. Must be a multiple of 512. /// An object that represents the access conditions for the blob. If null, no condition is used. @@ -727,16 +633,16 @@ public IAsyncOperation> GetPageRangesAsync() /// An enumerable collection of page ranges. [DoesServiceRequest] #if ASPNET_K || PORTABLE - public Task> GetPageRangesAsync(long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public Task> GetPageRangesDiffAsync(DateTimeOffset previousSnapshotTime, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { - return this.GetPageRangesAsync(offset, length, accessCondition, options, operationContext, CancellationToken.None); + return this.GetPageRangesDiffAsync(previousSnapshotTime, offset, length, accessCondition, options, operationContext, CancellationToken.None); } #else - public IAsyncOperation> GetPageRangesAsync(long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public IAsyncOperation> GetPageRangesDiffAsync(DateTimeOffset previousSnapshotTime, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.GetPageRangesImpl(offset, length, accessCondition, modifiedOptions), + this.GetPageRangesDiffImpl(previousSnapshotTime, offset, length, accessCondition, modifiedOptions), modifiedOptions.RetryPolicy, operationContext, token)); @@ -745,8 +651,9 @@ public IAsyncOperation> GetPageRangesAsync(long? offset, #if ASPNET_K || PORTABLE /// - /// Gets a collection of valid page ranges and their starting and ending bytes. + /// Gets the collection of page ranges that differ between a specified snapshot and this object. /// + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. /// The starting offset of the data range over which to list page ranges, in bytes. Must be a multiple of 512. /// The length of the data range over which to list page ranges, in bytes. Must be a multiple of 512. /// An object that represents the access conditions for the blob. If null, no condition is used. @@ -755,11 +662,11 @@ public IAsyncOperation> GetPageRangesAsync(long? offset, /// A to observe while waiting for a task to complete. /// An enumerable collection of page ranges. [DoesServiceRequest] - public Task> GetPageRangesAsync(long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public Task> GetPageRangesDiffAsync(DateTimeOffset previousSnapshotTime, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( - this.GetPageRangesImpl(offset, length, accessCondition, modifiedOptions), + this.GetPageRangesDiffImpl(previousSnapshotTime, offset, length, accessCondition, modifiedOptions), modifiedOptions.RetryPolicy, operationContext, cancellationToken), cancellationToken); @@ -771,11 +678,7 @@ public Task> GetPageRangesAsync(long? offset, long? lengt /// /// A blob snapshot. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task CreateSnapshotAsync() -#else - public IAsyncOperation CreateSnapshotAsync() -#endif + public virtual Task CreateSnapshotAsync() { return this.CreateSnapshotAsync(null /* metadata */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -789,25 +692,11 @@ public IAsyncOperation CreateSnapshotAsync() /// An object that represents the context for the current operation. /// A blob snapshot. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.CreateSnapshotAsync(metadata, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - this.attributes.AssertNoSnapshot(); - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.CreateSnapshotImpl(metadata, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Creates a snapshot of the blob. /// @@ -818,7 +707,7 @@ public IAsyncOperation CreateSnapshotAsync(IDictionaryA to observe while waiting for a task to complete. /// A blob snapshot. [DoesServiceRequest] - public Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateSnapshotAsync(IDictionary metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { this.attributes.AssertNoSnapshot(); BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); @@ -828,7 +717,6 @@ public Task CreateSnapshotAsync(IDictionary metad operationContext, cancellationToken), cancellationToken); } -#endif /// /// Writes pages to a page blob. @@ -837,15 +725,9 @@ public Task CreateSnapshotAsync(IDictionary metad /// The offset at which to begin writing, in bytes. The offset must be a multiple of 512. /// An optional hash value that will be used to set the property /// on the blob. May be null or an empty string. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction WritePagesAsync(IInputStream pageData, long startOffset, string contentMD5) -#endif + public virtual Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5) { return this.WritePagesAsync(pageData, startOffset, contentMD5, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -860,10 +742,9 @@ public IAsyncAction WritePagesAsync(IInputStream pageData, long startOffset, str /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.WritePagesAsync(pageData, startOffset, contentMD5, accessCondition, options, operationContext, CancellationToken.None); } @@ -881,24 +762,15 @@ public Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5 /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction WritePagesAsync(IInputStream pageData, long startOffset, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) -#endif + public virtual Task WritePagesAsync(Stream pageData, long startOffset, string contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); bool requiresContentMD5 = (contentMD5 == null) && modifiedOptions.UseTransactionalMD5.Value; operationContext = operationContext ?? new OperationContext(); ExecutionState tempExecutionState = CommonUtility.CreateTemporaryExecutionState(modifiedOptions); -#if ASPNET_K || PORTABLE return Task.Run(async () => -#else - return AsyncInfo.Run(async (cancellationToken) => -#endif { - Stream pageDataAsStream = pageData.AsStreamForRead(); + Stream pageDataAsStream = pageData; Stream seekableStream = pageDataAsStream; bool seekableStreamCreated = false; @@ -942,11 +814,7 @@ await Executor.ExecuteAsyncNullReturn( seekableStream.Dispose(); } } -#if ASPNET_K || PORTABLE }, cancellationToken); -#else - }); -#endif } /// @@ -954,15 +822,9 @@ await Executor.ExecuteAsyncNullReturn( /// /// The offset at which to begin clearing pages, in bytes. The offset must be a multiple of 512. /// The length of the data range to be cleared, in bytes. The length must be a multiple of 512. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ClearPagesAsync(long startOffset, long length) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction ClearPagesAsync(long startOffset, long length) -#endif + public virtual Task ClearPagesAsync(long startOffset, long length) { return this.ClearPagesAsync(startOffset, length, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -975,28 +837,13 @@ public IAsyncAction ClearPagesAsync(long startOffset, long length) /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ClearPagesAsync(long startOffset, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task ClearPagesAsync(long startOffset, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.ClearPagesAsync(startOffset, length, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction ClearPagesAsync(long startOffset, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) - { - BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.ClearPageImpl(startOffset, length, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Clears pages from a page blob. /// @@ -1008,7 +855,7 @@ public IAsyncAction ClearPagesAsync(long startOffset, long length, AccessConditi /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ClearPagesAsync(long startOffset, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ClearPagesAsync(long startOffset, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1017,7 +864,6 @@ public Task ClearPagesAsync(long startOffset, long length, AccessCondition acces operationContext, cancellationToken), cancellationToken); } -#endif /// /// Begins an operation to start copying an existing blob's contents, properties, and metadata to a new blob. @@ -1028,13 +874,8 @@ public Task ClearPagesAsync(long startOffset, long length, AccessCondition acces /// This method fetches the blob's ETag, last modified time, and part of the copy state. /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task StartCopyFromBlobAsync(CloudPageBlob source) -#else - public IAsyncOperation StartCopyFromBlobAsync(CloudPageBlob source) -#endif + public virtual Task StartCopyAsync(CloudPageBlob source) { return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source)); } @@ -1052,89 +893,12 @@ public IAsyncOperation StartCopyFromBlobAsync(CloudPageBlob source) /// This method fetches the blob's ETag, last modified time, and part of the copy state. /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task StartCopyFromBlobAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); - } -#else - public IAsyncOperation StartCopyFromBlobAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); - } -#endif - -#if ASPNET_K || PORTABLE - /// - /// Begins an operation to start copying another page blob's contents, properties, and metadata to a new blob. - /// - /// The URI of a source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// A to observe while waiting for a task to complete. - /// The copy ID associated with the copy operation. - /// - /// This method fetches the blob's ETag, last modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// - [Obsolete("Deprecated this method in favor of StartCopyAsync.")] - [DoesServiceRequest] - public Task StartCopyFromBlobAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) - { - return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); - } -#endif - - /// - /// Begins an operation to start copying an existing blob's contents, properties, and metadata to a new blob. - /// - /// The URI of a source blob. - /// The copy ID associated with the copy operation. - /// - /// This method fetches the blob's ETag, last modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// - [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task StartCopyAsync(CloudPageBlob source) -#else - public IAsyncOperation StartCopyAsync(CloudPageBlob source) -#endif - { - return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source)); - } - - /// - /// Begins an operation to start copying a blob's contents, properties, and metadata to a new blob. - /// - /// The URI of a source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination blob. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// The copy ID associated with the copy operation. - /// - /// This method fetches the blob's ETag, last modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// - [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task StartCopyAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation StartCopyAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext) - { - return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Begins an operation to start copying another page blob's contents, properties, and metadata to a new blob. /// @@ -1150,11 +914,10 @@ public IAsyncOperation StartCopyAsync(CloudPageBlob source, AccessCondit /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public Task StartCopyAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken); } -#endif /// /// Implements the Create method. @@ -1168,11 +931,9 @@ private RESTCommand CreateImpl(long sizeInBytes, AccessCondition acces RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = BlobHttpRequestMessageFactory.Put(uri, serverTimeout, this.Properties, BlobType.PageBlob, sizeInBytes, accessCondition, cnt, ctx); + StorageRequestMessage msg = BlobHttpRequestMessageFactory.Put(uri, serverTimeout, this.Properties, BlobType.PageBlob, sizeInBytes, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); BlobHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -1199,9 +960,7 @@ private RESTCommand ResizeImpl(long sizeInBytes, AccessCondition acces RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Resize(uri, serverTimeout, sizeInBytes, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.Resize(uri, serverTimeout, sizeInBytes, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex); @@ -1226,9 +985,7 @@ private RESTCommand SetSequenceNumberImpl(SequenceNumberAction sequenc RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.SetSequenceNumber(uri, serverTimeout, sequenceNumberAction, sequenceNumber, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.SetSequenceNumber(uri, serverTimeout, sequenceNumberAction, sequenceNumber, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex); @@ -1252,11 +1009,9 @@ private RESTCommand CreateSnapshotImpl(IDictionary putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = BlobHttpRequestMessageFactory.Snapshot(uri, serverTimeout, accessCondition, cnt, ctx); + StorageRequestMessage msg = BlobHttpRequestMessageFactory.Snapshot(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); if (metadata != null) { BlobHttpRequestMessageFactory.AddMetadata(msg, metadata); @@ -1294,12 +1049,9 @@ private RESTCommand> GetPageRangesImpl(long? offset, long options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; getCmd.RetrieveResponseStream = true; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = BlobHttpRequestMessageFactory.GetPageRanges(uri, serverTimeout, this.SnapshotTime, offset, length, accessCondition, cnt, ctx); - BlobHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); + StorageRequestMessage msg = BlobHttpRequestMessageFactory.GetPageRanges(uri, serverTimeout, this.SnapshotTime, offset, length, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); return msg; }; @@ -1318,6 +1070,43 @@ private RESTCommand> GetPageRangesImpl(long? offset, long return getCmd; } + /// + /// Implementation for the GetPageRangesDiff method. + /// + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. + /// The starting offset of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// The length of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// An object that represents the access conditions for the blob. If null, no condition is used. + /// A object that specifies additional options for the request. + /// A for getting the page ranges. + private RESTCommand> GetPageRangesDiffImpl(DateTimeOffset previousSnapshotTime, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options) + { + RESTCommand> getCmd = new RESTCommand>(this.ServiceClient.Credentials, this.attributes.StorageUri); + + options.ApplyToStorageCommand(getCmd); + getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; + getCmd.RetrieveResponseStream = true; + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => + { + StorageRequestMessage msg = BlobHttpRequestMessageFactory.GetPageRangesDiff(uri, serverTimeout, this.SnapshotTime, previousSnapshotTime, offset, length, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); + return msg; + }; + + getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); + getCmd.PostProcessResponse = (cmd, resp, ctx) => + { + CloudBlob.UpdateETagLMTLengthAndSequenceNumber(this.attributes, resp, true); + return Task.Factory.StartNew(() => + { + GetPageDiffRangesResponse getPageDiffRangesResponse = new GetPageDiffRangesResponse(cmd.ResponseStream); + IEnumerable pageDiffRanges = new List(getPageDiffRangesResponse.PageDiffRanges); + return pageDiffRanges; + }); + }; + + return getCmd; + } + /// /// Implementation method for the WritePage methods. /// @@ -1350,10 +1139,8 @@ private RESTCommand PutPageImpl(Stream pageData, long startOffset, str RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(pageData, offset, length, contentMD5, cmd, ctx); - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.PutPage(uri, serverTimeout, pageRange, pageWrite, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.PutPage(uri, serverTimeout, pageRange, pageWrite, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Created, resp, NullType.Value, cmd, ex); @@ -1392,9 +1179,7 @@ private RESTCommand ClearPageImpl(long startOffset, long length, Acces RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.PutPage(uri, serverTimeout, pageRange, pageWrite, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.PutPage(uri, serverTimeout, pageRange, pageWrite, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Created, resp, NullType.Value, cmd, ex); diff --git a/Lib/WindowsRuntime/Blob/ICloudBlob.cs b/Lib/WindowsRuntime/Blob/ICloudBlob.cs index 889aaac09..d97907857 100644 --- a/Lib/WindowsRuntime/Blob/ICloudBlob.cs +++ b/Lib/WindowsRuntime/Blob/ICloudBlob.cs @@ -18,24 +18,22 @@ namespace Microsoft.WindowsAzure.Storage.Blob { using System; + using System.Threading; + using System.Threading.Tasks; #if ASPNET_K || PORTABLE using System.Diagnostics.CodeAnalysis; using System.IO; - using System.Threading; - using System.Threading.Tasks; #else using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Storage; using Windows.Storage.Streams; + using System.IO; #endif /// /// An interface required for Windows Azure blob types. The and classes implement the interface. /// public partial interface ICloudBlob : IListBlobItem -#if !(ASPNET_K || PORTABLE) - ,IRandomAccessStreamReference -#endif { /// /// Opens a stream for reading from the blob. @@ -44,23 +42,14 @@ public partial interface ICloudBlob : IListBlobItem /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A stream to be used for reading from the blob. -#if ASPNET_K || PORTABLE Task OpenReadAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - IAsyncOperation OpenReadAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Uploads a stream to the Windows Azure Blob Service. /// /// The stream providing the blob content. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task UploadFromStreamAsync(Stream source); -#else - /// An that represents an asynchronous action. - IAsyncAction UploadFromStreamAsync(IInputStream source); -#endif /// /// Uploads a stream to a blob. @@ -69,26 +58,16 @@ public partial interface ICloudBlob : IListBlobItem /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - /// An that represents an asynchronous action. - IAsyncAction UploadFromStreamAsync(IInputStream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Uploads a stream to a blob. /// /// The stream providing the blob content. /// The number of bytes to write from the source stream at its current position. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task UploadFromStreamAsync(Stream source, long length); -#else - /// An that represents an asynchronous action. - IAsyncAction UploadFromStreamAsync(IInputStream source, long length); -#endif /// /// Uploads a stream to a blob. @@ -98,26 +77,20 @@ public partial interface ICloudBlob : IListBlobItem /// An object that represents the access conditions for the blob. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - /// An that represents an asynchronous action. - IAsyncAction UploadFromStreamAsync(IInputStream source, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif #if !PORTABLE /// Uploads a file to the Windows Azure Blob Service. /// #if ASPNET_K /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. /// A that represents an asynchronous action. - Task UploadFromFileAsync(string path, FileMode mode); + Task UploadFromFileAsync(string path); #else /// The file providing the blob content. - /// An that represents an asynchronous action. - IAsyncAction UploadFromFileAsync(StorageFile source); + /// A that represents an asynchronous action. + Task UploadFromFileAsync(StorageFile source); #endif /// @@ -125,7 +98,6 @@ public partial interface ICloudBlob : IListBlobItem /// #if ASPNET_K /// A string containing the file path providing the blob content. - /// A enumeration value that specifies how to open the file. #else /// The file providing the blob content. #endif @@ -134,10 +106,10 @@ public partial interface ICloudBlob : IListBlobItem /// An object that represents the context for the current operation. #if ASPNET_K /// A that represents an asynchronous action. - Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); + Task UploadFromFileAsync(string path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); #else - /// An that represents an asynchronous action. - IAsyncAction UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); + /// As that represents an asynchronous action. + Task UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); #endif #endif @@ -147,13 +119,8 @@ public partial interface ICloudBlob : IListBlobItem /// An array of bytes. /// The zero-based byte offset in buffer at which to begin uploading bytes to the blob. /// The number of bytes to be written to the blob. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task UploadFromByteArrayAsync(byte[] buffer, int index, int count); -#else - /// An that represents an asynchronous action. - IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int index, int count); -#endif /// /// Uploads the contents of a byte array to a blob. @@ -164,25 +131,15 @@ public partial interface ICloudBlob : IListBlobItem /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - /// An that represents an asynchronous action. - IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int index, int count, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Downloads the contents of a blob to a stream. /// /// The target stream. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task DownloadToStreamAsync(Stream target); -#else - /// An that represents an asynchronous action. - IAsyncAction DownloadToStreamAsync(IOutputStream target); -#endif /// /// Downloads the contents of a blob to a stream. @@ -191,13 +148,8 @@ public partial interface ICloudBlob : IListBlobItem /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - /// An that represents an asynchronous action. - IAsyncAction DownloadToStreamAsync(IOutputStream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif #if !PORTABLE /// @@ -210,8 +162,8 @@ public partial interface ICloudBlob : IListBlobItem Task DownloadToFileAsync(string path, FileMode mode); #else /// The target file. - /// An that represents an asynchronous action. - IAsyncAction DownloadToFileAsync(StorageFile target); + /// A that represents an asynchronous action. + Task DownloadToFileAsync(StorageFile target); #endif /// @@ -230,8 +182,8 @@ public partial interface ICloudBlob : IListBlobItem /// A that represents an asynchronous action. Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); #else - /// An that represents an asynchronous action. - IAsyncAction DownloadToFileAsync(StorageFile target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); + /// A that represents an asynchronous action. + Task DownloadToFileAsync(StorageFile target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); #endif #endif @@ -241,11 +193,7 @@ public partial interface ICloudBlob : IListBlobItem /// The target byte array. /// The starting offset in the byte array. /// The total number of bytes read into the buffer. -#if ASPNET_K || PORTABLE Task DownloadToByteArrayAsync(byte[] target, int index); -#else - IAsyncOperation DownloadToByteArrayAsync([WriteOnlyArray] byte[] target, int index); -#endif /// /// Downloads a range of bytes from a blob to a byte array. @@ -256,11 +204,7 @@ public partial interface ICloudBlob : IListBlobItem /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// The total number of bytes read into the buffer. -#if ASPNET_K || PORTABLE Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - IAsyncOperation DownloadToByteArrayAsync([WriteOnlyArray] byte[] target, int index, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Downloads a range of bytes from a blob to a stream. @@ -268,13 +212,8 @@ public partial interface ICloudBlob : IListBlobItem /// The target stream. /// The starting offset of the data range, in bytes. /// The length of the data range, in bytes. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length); -#else - /// An that represents an asynchronous action. - IAsyncAction DownloadRangeToStreamAsync(IOutputStream target, long? offset, long? length); -#endif /// /// Downloads a range of bytes from a blob to a stream. @@ -285,13 +224,8 @@ public partial interface ICloudBlob : IListBlobItem /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - /// An that represents an asynchronous action. - IAsyncAction DownloadRangeToStreamAsync(IOutputStream target, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Downloads a range of bytes from a blob to a byte array. @@ -301,11 +235,7 @@ public partial interface ICloudBlob : IListBlobItem /// The starting offset of the data range, in bytes. /// The length of the data range, in bytes. /// The total number of bytes read into the buffer. -#if ASPNET_K || PORTABLE Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length); -#else - IAsyncOperation DownloadRangeToByteArrayAsync([WriteOnlyArray] byte[] target, int index, long? blobOffset, long? length); -#endif /// /// Downloads a range of bytes from a blob to a byte array. @@ -318,21 +248,13 @@ public partial interface ICloudBlob : IListBlobItem /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// The total number of bytes read into the buffer. -#if ASPNET_K || PORTABLE Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - IAsyncOperation DownloadRangeToByteArrayAsync([WriteOnlyArray] byte[] target, int index, long? blobOffset, long? length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Checks whether the blob exists. /// /// true if the blob exists. -#if ASPNET_K || PORTABLE Task ExistsAsync(); -#else - IAsyncOperation ExistsAsync(); -#endif /// /// Checks whether the blob exists. @@ -340,22 +262,13 @@ public partial interface ICloudBlob : IListBlobItem /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// true if the blob exists. -#if ASPNET_K || PORTABLE Task ExistsAsync(BlobRequestOptions options, OperationContext operationContext); -#else - IAsyncOperation ExistsAsync(BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Populates a blob's properties and metadata. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task FetchAttributesAsync(); -#else - /// An that represents an asynchronous action. - IAsyncAction FetchAttributesAsync(); -#endif /// /// Populates a blob's properties and metadata. @@ -363,24 +276,14 @@ public partial interface ICloudBlob : IListBlobItem /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - /// An that represents an asynchronous action. - IAsyncAction FetchAttributesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Updates the blob's metadata. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task SetMetadataAsync(); -#else - /// An that represents an asynchronous action. - IAsyncAction SetMetadataAsync(); -#endif /// /// Updates the blob's metadata. @@ -388,24 +291,14 @@ public partial interface ICloudBlob : IListBlobItem /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - /// An that represents an asynchronous action. - IAsyncAction SetMetadataAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Updates the blob's properties. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task SetPropertiesAsync(); -#else - /// An that represents an asynchronous action. - IAsyncAction SetPropertiesAsync(); -#endif /// /// Updates the blob's properties. @@ -413,24 +306,14 @@ public partial interface ICloudBlob : IListBlobItem /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - /// An that represents an asynchronous action. - IAsyncAction SetPropertiesAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Deletes the blob. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task DeleteAsync(); -#else - /// An that represents an asynchronous action. - IAsyncAction DeleteAsync(); -#endif /// /// Deletes the blob. @@ -439,23 +322,14 @@ public partial interface ICloudBlob : IListBlobItem /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - /// An that represents an asynchronous action. - IAsyncAction DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Deletes the blob if it already exists. /// /// true if the blob did not already exist and was created; otherwise false. -#if ASPNET_K || PORTABLE Task DeleteIfExistsAsync(); -#else - IAsyncOperation DeleteIfExistsAsync(); -#endif /// /// Deletes the blob if it already exists. @@ -465,11 +339,7 @@ public partial interface ICloudBlob : IListBlobItem /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// true if the blob did not already exist and was created; otherwise false. -#if ASPNET_K || PORTABLE Task DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - IAsyncOperation DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Acquires a lease on this blob. @@ -478,11 +348,7 @@ public partial interface ICloudBlob : IListBlobItem /// which will be rounded down to seconds. /// A string representing the proposed lease ID for the new lease. /// The ID of the acquired lease. -#if ASPNET_K || PORTABLE - Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId); -#else - IAsyncOperation AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId); -#endif + Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId = null); /// /// Acquires a lease on this blob. @@ -494,23 +360,14 @@ public partial interface ICloudBlob : IListBlobItem /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// The ID of the acquired lease. -#if ASPNET_K || PORTABLE Task AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - IAsyncOperation AcquireLeaseAsync(TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Renews a lease on this blob. /// /// An object that represents the access conditions for the blob, including a required lease ID. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task RenewLeaseAsync(AccessCondition accessCondition); -#else - /// An that represents an asynchronous action. - IAsyncAction RenewLeaseAsync(AccessCondition accessCondition); -#endif /// /// Renews a lease on this blob. @@ -518,13 +375,8 @@ public partial interface ICloudBlob : IListBlobItem /// An object that represents the access conditions for the blob, including a required lease ID. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - /// An that represents an asynchronous action. - IAsyncAction RenewLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Changes the lease ID on this blob. @@ -532,11 +384,7 @@ public partial interface ICloudBlob : IListBlobItem /// A string representing the proposed lease ID for the new lease. /// An object that represents the access conditions for the blob, including a required lease ID. /// The new lease ID. -#if ASPNET_K || PORTABLE Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition); -#else - IAsyncOperation ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition); -#endif /// /// Changes the lease ID on this blob. @@ -546,23 +394,14 @@ public partial interface ICloudBlob : IListBlobItem /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// The new lease ID. -#if ASPNET_K || PORTABLE Task ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - IAsyncOperation ChangeLeaseAsync(string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Releases the lease on this blob. /// /// An object that represents the access conditions for the blob, including a required lease ID. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task ReleaseLeaseAsync(AccessCondition accessCondition); -#else - /// An that represents an asynchronous action. - IAsyncAction ReleaseLeaseAsync(AccessCondition accessCondition); -#endif /// /// Releases the lease on this blob. @@ -570,13 +409,8 @@ public partial interface ICloudBlob : IListBlobItem /// An object that represents the access conditions for the blob, including a required lease ID. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - /// An that represents an asynchronous action. - IAsyncAction ReleaseLeaseAsync(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Breaks the current lease on this blob. @@ -584,11 +418,7 @@ public partial interface ICloudBlob : IListBlobItem /// A representing the amount of time to allow the lease to remain, /// which will be rounded down to seconds. /// A representing the amount of time before the lease ends, to the second. -#if ASPNET_K || PORTABLE Task BreakLeaseAsync(TimeSpan? breakPeriod); -#else - IAsyncOperation BreakLeaseAsync(TimeSpan? breakPeriod); -#endif /// /// Breaks the current lease on this blob. @@ -599,23 +429,14 @@ public partial interface ICloudBlob : IListBlobItem /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A representing the amount of time before the lease ends, to the second. -#if ASPNET_K || PORTABLE Task BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - IAsyncOperation BreakLeaseAsync(TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif /// /// Aborts an ongoing blob copy operation. /// /// A string identifying the copy operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task AbortCopyAsync(string copyId); -#else - /// An that represents an asynchronous action. - IAsyncAction AbortCopyAsync(string copyId); -#endif /// /// Aborts an ongoing blob copy operation. @@ -624,12 +445,7 @@ public partial interface ICloudBlob : IListBlobItem /// An object that represents the access conditions for the blob. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. Task AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#else - /// An that represents an asynchronous action. - IAsyncAction AbortCopyAsync(string copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext); -#endif } } diff --git a/Lib/WindowsRuntime/Blob/ICloudBlobStream.cs b/Lib/WindowsRuntime/Blob/ICloudBlobStream.cs index aae467e31..60849e4f4 100644 --- a/Lib/WindowsRuntime/Blob/ICloudBlobStream.cs +++ b/Lib/WindowsRuntime/Blob/ICloudBlobStream.cs @@ -17,9 +17,11 @@ namespace Microsoft.WindowsAzure.Storage.Blob { -#if ASPNET_K || PORTABLE using System.IO; using System.Threading.Tasks; +#if WINDOWS_RT + using Windows.Storage.Streams; +#endif /// /// Represents a stream for writing to a blob. @@ -31,18 +33,6 @@ public abstract class CloudBlobStream : Stream /// /// A that represents an asynchronous action. public abstract Task CommitAsync(); - } -#else - using Windows.Foundation; - using Windows.Storage.Streams; - public interface ICloudBlobStream : IRandomAccessStream - { - /// - /// Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying blob, and commits the blob. - /// - /// An that represents an asynchronous action. - IAsyncAction CommitAsync(); } -#endif } diff --git a/Lib/WindowsRuntime/Blob/Protocol/BlobHttpRequestMessageFactory.cs b/Lib/WindowsRuntime/Blob/Protocol/BlobHttpRequestMessageFactory.cs index 3aa385d7a..879f3b73d 100644 --- a/Lib/WindowsRuntime/Blob/Protocol/BlobHttpRequestMessageFactory.cs +++ b/Lib/WindowsRuntime/Blob/Protocol/BlobHttpRequestMessageFactory.cs @@ -17,7 +17,9 @@ namespace Microsoft.WindowsAzure.Storage.Blob.Protocol { + using Microsoft.WindowsAzure.Storage.Auth; using Microsoft.WindowsAzure.Storage.Core; + using Microsoft.WindowsAzure.Storage.Core.Auth; using Microsoft.WindowsAzure.Storage.Core.Util; using Microsoft.WindowsAzure.Storage.Shared.Protocol; using System; @@ -37,12 +39,12 @@ internal static class BlobHttpRequestMessageFactory /// The HTTP entity body and content headers. /// An object that represents the context for the current operation. /// A object. - public static HttpRequestMessage AppendBlock(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage AppendBlock(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "appendblock"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); request.ApplyAppendCondition(accessCondition); return request; @@ -60,14 +62,14 @@ public static HttpRequestMessage AppendBlock(Uri uri, int? timeout, AccessCondit /// for block blobs. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Put(Uri uri, int? timeout, BlobProperties properties, BlobType blobType, long pageBlobSize, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Put(Uri uri, int? timeout, BlobProperties properties, BlobType blobType, long pageBlobSize, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { if (blobType == BlobType.Unspecified) { throw new InvalidOperationException(SR.UndefinedBlobType); } - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, null /* builder */, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, null /* builder */, content, operationContext, canonicalizer, credentials); if (properties.CacheControl != null) { @@ -144,7 +146,7 @@ private static void AddSnapshot(UriQueryBuilder builder, DateTimeOffset? snapsho /// The length of the data range over which to list page ranges, in bytes. Must be a multiple of 512. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage GetPageRanges(Uri uri, int? timeout, DateTimeOffset? snapshot, long? offset, long? count, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetPageRanges(Uri uri, int? timeout, DateTimeOffset? snapshot, long? offset, long? count, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { if (offset.HasValue) { @@ -155,7 +157,37 @@ public static HttpRequestMessage GetPageRanges(Uri uri, int? timeout, DateTimeOf builder.Add(Constants.QueryConstants.Component, "pagelist"); BlobHttpRequestMessageFactory.AddSnapshot(builder, snapshot); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials); + AddRange(request, offset, count); + request.ApplyAccessCondition(accessCondition); + return request; + } + + /// + /// Constructs a web request to return the list of page ranges that differ between a specified snapshot and this object. + /// + /// The absolute URI to the blob. + /// The server timeout interval. + /// The snapshot timestamp, if the blob is a snapshot. + /// A representing the snapshot timestamp to use as the starting point for the diff. If this CloudPageBlob represents a snapshot, the previousSnapshotTime parameter must be prior to the current snapshot timestamp. + /// The starting offset of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// The length of the data range over which to list page ranges, in bytes. Must be a multiple of 512. + /// The access condition to apply to the request. + /// An object that represents the context for the current operation. + /// A web request to use to perform the operation. + public static StorageRequestMessage GetPageRangesDiff(Uri uri, int? timeout, DateTimeOffset? snapshot, DateTimeOffset previousSnapshotTime, long? offset, long? count, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) + { + if (offset.HasValue) + { + CommonUtility.AssertNotNull("count", count); + } + + UriQueryBuilder builder = new UriQueryBuilder(); + builder.Add(Constants.QueryConstants.Component, "pagelist"); + BlobHttpRequestMessageFactory.AddSnapshot(builder, snapshot); + builder.Add("prevsnapshot", Request.ConvertDateTimeToSnapshotString(previousSnapshotTime)); + + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials); AddRange(request, offset, count); request.ApplyAccessCondition(accessCondition); return request; @@ -167,7 +199,7 @@ public static HttpRequestMessage GetPageRanges(Uri uri, int? timeout, DateTimeOf /// Request /// Starting byte of the range /// Number of bytes in the range - private static void AddRange(HttpRequestMessage request, long? offset, long? count) + private static void AddRange(StorageRequestMessage request, long? offset, long? count) { if (count.HasValue) { @@ -197,12 +229,12 @@ private static void AddRange(HttpRequestMessage request, long? offset, long? cou /// The snapshot timestamp, if the blob is a snapshot. /// The access condition to apply to the request. /// A web request for performing the operation. - public static HttpRequestMessage GetProperties(Uri uri, int? timeout, DateTimeOffset? snapshot, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetProperties(Uri uri, int? timeout, DateTimeOffset? snapshot, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); BlobHttpRequestMessageFactory.AddSnapshot(builder, snapshot); - HttpRequestMessage request = HttpRequestMessageFactory.GetProperties(uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetProperties(uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -215,12 +247,12 @@ public static HttpRequestMessage GetProperties(Uri uri, int? timeout, DateTimeOf /// The blob's properties. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage SetProperties(Uri uri, int? timeout, BlobProperties properties, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetProperties(Uri uri, int? timeout, BlobProperties properties, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "properties"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); if (properties != null) { @@ -244,12 +276,12 @@ public static HttpRequestMessage SetProperties(Uri uri, int? timeout, BlobProper /// The new blob size, if the blob is a page blob. Set this parameter to null to keep the existing blob size. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Resize(Uri uri, int? timeout, long newBlobSize, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Resize(Uri uri, int? timeout, long newBlobSize, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "properties"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.Headers.Add(Constants.HeaderConstants.BlobContentLengthHeader, newBlobSize.ToString(NumberFormatInfo.InvariantInfo)); @@ -266,7 +298,7 @@ public static HttpRequestMessage Resize(Uri uri, int? timeout, long newBlobSize, /// The sequence number. Set this parameter to null if this operation is an increment action. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage SetSequenceNumber(Uri uri, int? timeout, SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetSequenceNumber(Uri uri, int? timeout, SequenceNumberAction sequenceNumberAction, long? sequenceNumber, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { CommonUtility.AssertInBounds("sequenceNumberAction", sequenceNumberAction, SequenceNumberAction.Max, SequenceNumberAction.Increment); if (sequenceNumberAction == SequenceNumberAction.Increment) @@ -285,7 +317,7 @@ public static HttpRequestMessage SetSequenceNumber(Uri uri, int? timeout, Sequen UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "properties"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.Headers.Add(Constants.HeaderConstants.SequenceNumberAction, sequenceNumberAction.ToString()); if (sequenceNumberAction != SequenceNumberAction.Increment) @@ -305,12 +337,12 @@ public static HttpRequestMessage SetSequenceNumber(Uri uri, int? timeout, Sequen /// The snapshot timestamp, if the blob is a snapshot. /// The access condition to apply to the request. /// A web request for performing the operation. - public static HttpRequestMessage GetMetadata(Uri uri, int? timeout, DateTimeOffset? snapshot, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetMetadata(Uri uri, int? timeout, DateTimeOffset? snapshot, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); BlobHttpRequestMessageFactory.AddSnapshot(builder, snapshot); - HttpRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -322,9 +354,9 @@ public static HttpRequestMessage GetMetadata(Uri uri, int? timeout, DateTimeOffs /// The server timeout interval. /// The access condition to apply to the request. /// A web request for performing the operation. - public static HttpRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.SetMetadata(uri, timeout, null /* builder */, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.SetMetadata(uri, timeout, null /* builder */, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -334,7 +366,7 @@ public static HttpRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondit /// /// The web request. /// The user-defined metadata. - public static void AddMetadata(HttpRequestMessage request, IDictionary metadata) + public static void AddMetadata(StorageRequestMessage request, IDictionary metadata) { HttpRequestMessageFactory.AddMetadata(request, metadata); } @@ -345,7 +377,7 @@ public static void AddMetadata(HttpRequestMessage request, IDictionaryThe web request. /// The metadata name. /// The metadata value. - public static void AddMetadata(HttpRequestMessage request, string name, string value) + public static void AddMetadata(StorageRequestMessage request, string name, string value) { HttpRequestMessageFactory.AddMetadata(request, name, value); } @@ -359,7 +391,7 @@ public static void AddMetadata(HttpRequestMessage request, string name, string v /// A set of options indicating whether to delete only blobs, only snapshots, or both. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Delete(Uri uri, int? timeout, DateTimeOffset? snapshot, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Delete(Uri uri, int? timeout, DateTimeOffset? snapshot, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { if ((snapshot != null) && (deleteSnapshotsOption != DeleteSnapshotsOption.None)) { @@ -369,7 +401,7 @@ public static HttpRequestMessage Delete(Uri uri, int? timeout, DateTimeOffset? s UriQueryBuilder builder = new UriQueryBuilder(); BlobHttpRequestMessageFactory.AddSnapshot(builder, snapshot); - HttpRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, builder, content, operationContext, canonicalizer, credentials); switch (deleteSnapshotsOption) { @@ -401,12 +433,12 @@ public static HttpRequestMessage Delete(Uri uri, int? timeout, DateTimeOffset? s /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Snapshot(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Snapshot(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "snapshot"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -425,12 +457,12 @@ public static HttpRequestMessage Snapshot(Uri uri, int? timeout, AccessCondition /// If this is null then the default time is used. This should be null for acquire, renew, change, and release operations. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Lease(Uri uri, int? timeout, LeaseAction action, string proposedLeaseId, int? leaseDuration, int? leaseBreakPeriod, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Lease(Uri uri, int? timeout, LeaseAction action, string proposedLeaseId, int? leaseDuration, int? leaseBreakPeriod, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "lease"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); // Add lease headers @@ -447,7 +479,7 @@ public static HttpRequestMessage Lease(Uri uri, int? timeout, LeaseAction action /// /// The request. /// The proposed lease id. - internal static void AddProposedLeaseId(HttpRequestMessage request, string proposedLeaseId) + internal static void AddProposedLeaseId(StorageRequestMessage request, string proposedLeaseId) { request.AddOptionalHeader(Constants.HeaderConstants.ProposedLeaseIdHeader, proposedLeaseId); } @@ -457,7 +489,7 @@ internal static void AddProposedLeaseId(HttpRequestMessage request, string propo /// /// The request. /// The lease duration. - internal static void AddLeaseDuration(HttpRequestMessage request, int? leaseDuration) + internal static void AddLeaseDuration(StorageRequestMessage request, int? leaseDuration) { request.AddOptionalHeader(Constants.HeaderConstants.LeaseDurationHeader, leaseDuration); } @@ -467,7 +499,7 @@ internal static void AddLeaseDuration(HttpRequestMessage request, int? leaseDura /// /// The request. /// The lease break period. - internal static void AddLeaseBreakPeriod(HttpRequestMessage request, int? leaseBreakPeriod) + internal static void AddLeaseBreakPeriod(StorageRequestMessage request, int? leaseBreakPeriod) { request.AddOptionalHeader(Constants.HeaderConstants.LeaseBreakPeriodHeader, leaseBreakPeriod); } @@ -477,7 +509,7 @@ internal static void AddLeaseBreakPeriod(HttpRequestMessage request, int? leaseB /// /// The request. /// The lease action. - internal static void AddLeaseAction(HttpRequestMessage request, LeaseAction leaseAction) + internal static void AddLeaseAction(StorageRequestMessage request, LeaseAction leaseAction) { request.Headers.Add(Constants.HeaderConstants.LeaseActionHeader, leaseAction.ToString().ToLower()); } @@ -490,13 +522,13 @@ internal static void AddLeaseAction(HttpRequestMessage request, LeaseAction leas /// The block ID for this block. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage PutBlock(Uri uri, int? timeout, string blockId, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage PutBlock(Uri uri, int? timeout, string blockId, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "block"); builder.Add("blockid", blockId); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.ApplyLeaseId(accessCondition); return request; } @@ -509,12 +541,12 @@ public static HttpRequestMessage PutBlock(Uri uri, int? timeout, string blockId, /// The properties to set for the blob. /// The access condition to apply to the request. /// A web request for performing the operation. - public static HttpRequestMessage PutBlockList(Uri uri, int? timeout, BlobProperties properties, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage PutBlockList(Uri uri, int? timeout, BlobProperties properties, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "blocklist"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); if (properties != null) { @@ -540,14 +572,14 @@ public static HttpRequestMessage PutBlockList(Uri uri, int? timeout, BlobPropert /// The types of blocks to include in the list: committed, uncommitted, or both. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage GetBlockList(Uri uri, int? timeout, DateTimeOffset? snapshot, BlockListingFilter typesOfBlocks, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetBlockList(Uri uri, int? timeout, DateTimeOffset? snapshot, BlockListingFilter typesOfBlocks, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "blocklist"); builder.Add("blocklisttype", typesOfBlocks.ToString()); BlobHttpRequestMessageFactory.AddSnapshot(builder, snapshot); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -560,12 +592,12 @@ public static HttpRequestMessage GetBlockList(Uri uri, int? timeout, DateTimeOff /// The blob's properties. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage PutPage(Uri uri, int? timeout, PageRange pageRange, PageWrite pageWrite, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage PutPage(Uri uri, int? timeout, PageRange pageRange, PageWrite pageWrite, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "page"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.Headers.Add(Constants.HeaderConstants.RangeHeader, pageRange.ToString()); request.Headers.Add(Constants.HeaderConstants.PageWrite, pageWrite.ToString()); @@ -584,9 +616,9 @@ public static HttpRequestMessage PutPage(Uri uri, int? timeout, PageRange pageRa /// The access condition to apply to the source blob. /// The access condition to apply to the destination blob. /// A web request to use to perform the operation. - public static HttpRequestMessage CopyFrom(Uri uri, int? timeout, Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage CopyFrom(Uri uri, int? timeout, Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, null /* builder */, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, null /* builder */, content, operationContext, canonicalizer, credentials); request.Headers.Add(Constants.HeaderConstants.CopySourceHeader, source.AbsoluteUri); request.ApplyAccessCondition(destAccessCondition); @@ -604,13 +636,13 @@ public static HttpRequestMessage CopyFrom(Uri uri, int? timeout, Uri source, Acc /// The access condition to apply to the request. /// Only lease conditions are supported for this operation. /// A web request for performing the operation. - public static HttpRequestMessage AbortCopy(Uri uri, int? timeout, string copyId, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage AbortCopy(Uri uri, int? timeout, string copyId, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "copy"); builder.Add(Constants.QueryConstants.CopyId, copyId); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.Headers.Add(Constants.HeaderConstants.CopyActionHeader, Constants.HeaderConstants.CopyActionAbort); request.ApplyAccessCondition(accessCondition); @@ -626,7 +658,7 @@ public static HttpRequestMessage AbortCopy(Uri uri, int? timeout, string copyId, /// The snapshot version, if the blob is a snapshot. /// The access condition to apply to the request. /// A web request for performing the operation. - public static HttpRequestMessage Get(Uri uri, int? timeout, DateTimeOffset? snapshot, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Get(Uri uri, int? timeout, DateTimeOffset? snapshot, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); if (snapshot.HasValue) @@ -634,7 +666,7 @@ public static HttpRequestMessage Get(Uri uri, int? timeout, DateTimeOffset? snap builder.Add("snapshot", Request.ConvertDateTimeToSnapshotString(snapshot.Value)); } - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -649,7 +681,7 @@ public static HttpRequestMessage Get(Uri uri, int? timeout, DateTimeOffset? snap /// The number of bytes to return, or null to return all bytes through the end of the blob. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Get(Uri uri, int? timeout, DateTimeOffset? snapshot, long? offset, long? count, bool rangeContentMD5, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Get(Uri uri, int? timeout, DateTimeOffset? snapshot, long? offset, long? count, bool rangeContentMD5, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { if (offset.HasValue && offset.Value < 0) { @@ -662,7 +694,7 @@ public static HttpRequestMessage Get(Uri uri, int? timeout, DateTimeOffset? snap CommonUtility.AssertInBounds("count", count.Value, 1, Constants.MaxBlockSize); } - HttpRequestMessage request = Get(uri, timeout, snapshot, accessCondition, content, operationContext); + StorageRequestMessage request = Get(uri, timeout, snapshot, accessCondition, content, operationContext, canonicalizer, credentials); AddRange(request, offset, count); if (offset.HasValue && rangeContentMD5) @@ -678,10 +710,10 @@ public static HttpRequestMessage Get(Uri uri, int? timeout, DateTimeOffset? snap /// /// The absolute URI to the service. /// The server timeout interval. - /// A HttpRequestMessage to get the service properties. - public static HttpRequestMessage GetServiceProperties(Uri uri, int? timeout, OperationContext operationContext) + /// A StorageRequestMessage to get the service properties. + public static StorageRequestMessage GetServiceProperties(Uri uri, int? timeout, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - return HttpRequestMessageFactory.GetServiceProperties(uri, timeout, operationContext); + return HttpRequestMessageFactory.GetServiceProperties(uri, timeout, operationContext, canonicalizer, credentials); } /// @@ -690,9 +722,9 @@ public static HttpRequestMessage GetServiceProperties(Uri uri, int? timeout, Ope /// The absolute URI to the service. /// The server timeout interval. /// A web request to set the service properties. - internal static HttpRequestMessage SetServiceProperties(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + internal static StorageRequestMessage SetServiceProperties(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - return HttpRequestMessageFactory.SetServiceProperties(uri, timeout, content, operationContext); + return HttpRequestMessageFactory.SetServiceProperties(uri, timeout, content, operationContext, canonicalizer, credentials); } /// @@ -700,10 +732,10 @@ internal static HttpRequestMessage SetServiceProperties(Uri uri, int? timeout, H /// /// The absolute URI to the service. /// The server timeout interval. - /// A HttpRequestMessage to get the service stats. - public static HttpRequestMessage GetServiceStats(Uri uri, int? timeout, OperationContext operationContext) + /// A StorageRequestMessage to get the service stats. + public static StorageRequestMessage GetServiceStats(Uri uri, int? timeout, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - return HttpRequestMessageFactory.GetServiceStats(uri, timeout, operationContext); + return HttpRequestMessageFactory.GetServiceStats(uri, timeout, operationContext, canonicalizer, credentials); } } } diff --git a/Lib/WindowsRuntime/Blob/Protocol/ContainerHttpRequestMessageFactory.cs b/Lib/WindowsRuntime/Blob/Protocol/ContainerHttpRequestMessageFactory.cs index 4fb88797b..ee4c7d164 100644 --- a/Lib/WindowsRuntime/Blob/Protocol/ContainerHttpRequestMessageFactory.cs +++ b/Lib/WindowsRuntime/Blob/Protocol/ContainerHttpRequestMessageFactory.cs @@ -18,7 +18,9 @@ namespace Microsoft.WindowsAzure.Storage.Blob.Protocol { using Microsoft.WindowsAzure.Storage; + using Microsoft.WindowsAzure.Storage.Auth; using Microsoft.WindowsAzure.Storage.Core; + using Microsoft.WindowsAzure.Storage.Core.Auth; using Microsoft.WindowsAzure.Storage.Shared.Protocol; using System; using System.Collections.Generic; @@ -33,9 +35,9 @@ internal static class ContainerHttpRequestMessageFactory /// The absolute URI to the container. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage Create(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Create(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - return ContainerHttpRequestMessageFactory.Create(uri, timeout, content, operationContext, BlobContainerPublicAccessType.Off); + return ContainerHttpRequestMessageFactory.Create(uri, timeout, content, operationContext, BlobContainerPublicAccessType.Off, canonicalizer, credentials); } /// @@ -45,10 +47,10 @@ public static HttpRequestMessage Create(Uri uri, int? timeout, HttpContent conte /// The server timeout interval. /// An object that specifies whether data in the container may be accessed publicly and what level of access is to be allowed. /// A web request to use to perform the operation. - public static HttpRequestMessage Create(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, BlobContainerPublicAccessType accessType) + public static StorageRequestMessage Create(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, BlobContainerPublicAccessType accessType, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder containerBuilder = GetContainerUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.Create(uri, timeout, containerBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.Create(uri, timeout, containerBuilder, content, operationContext, canonicalizer, credentials); if (accessType != BlobContainerPublicAccessType.Off) { @@ -65,10 +67,10 @@ public static HttpRequestMessage Create(Uri uri, int? timeout, HttpContent conte /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Delete(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Delete(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder containerBuilder = GetContainerUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, containerBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, containerBuilder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -80,10 +82,10 @@ public static HttpRequestMessage Delete(Uri uri, int? timeout, AccessCondition a /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder containerBuilder = GetContainerUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, containerBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, containerBuilder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -95,10 +97,10 @@ public static HttpRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondit /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage GetProperties(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetProperties(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder containerBuilder = GetContainerUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.GetProperties(uri, timeout, containerBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetProperties(uri, timeout, containerBuilder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -110,10 +112,10 @@ public static HttpRequestMessage GetProperties(Uri uri, int? timeout, AccessCond /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder containerBuilder = GetContainerUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.SetMetadata(uri, timeout, containerBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.SetMetadata(uri, timeout, containerBuilder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -132,12 +134,12 @@ public static HttpRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondit /// If this is null then the default time is used. This should be null for acquire, renew, change, and release operations. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Lease(Uri uri, int? timeout, LeaseAction action, string proposedLeaseId, int? leaseDuration, int? leaseBreakPeriod, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Lease(Uri uri, int? timeout, LeaseAction action, string proposedLeaseId, int? leaseDuration, int? leaseBreakPeriod, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = GetContainerUriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "lease"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); // Add Headers BlobHttpRequestMessageFactory.AddLeaseAction(request, action); @@ -154,7 +156,7 @@ public static HttpRequestMessage Lease(Uri uri, int? timeout, LeaseAction action /// /// The web request. /// The user-defined metadata. - public static void AddMetadata(HttpRequestMessage request, IDictionary metadata) + public static void AddMetadata(StorageRequestMessage request, IDictionary metadata) { HttpRequestMessageFactory.AddMetadata(request, metadata); } @@ -165,7 +167,7 @@ public static void AddMetadata(HttpRequestMessage request, IDictionaryThe web request. /// The metadata name. /// The metadata value. - public static void AddMetadata(HttpRequestMessage request, string name, string value) + public static void AddMetadata(StorageRequestMessage request, string name, string value) { HttpRequestMessageFactory.AddMetadata(request, name, value); } @@ -178,7 +180,7 @@ public static void AddMetadata(HttpRequestMessage request, string name, string v /// A set of parameters for the listing operation. /// Additional details to return with the listing. /// A web request for the specified operation. - public static HttpRequestMessage List(Uri uri, int? timeout, ListingContext listingContext, ContainerListingDetails detailsIncluded, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage List(Uri uri, int? timeout, ListingContext listingContext, ContainerListingDetails detailsIncluded, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "list"); @@ -206,7 +208,7 @@ public static HttpRequestMessage List(Uri uri, int? timeout, ListingContext list builder.Add("include", "metadata"); } - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -217,9 +219,9 @@ public static HttpRequestMessage List(Uri uri, int? timeout, ListingContext list /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage GetAcl(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetAcl(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.GetAcl(uri, timeout, GetContainerUriQueryBuilder(), content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetAcl(uri, timeout, GetContainerUriQueryBuilder(), content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -232,9 +234,9 @@ public static HttpRequestMessage GetAcl(Uri uri, int? timeout, AccessCondition a /// The type of public access to allow for the container. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage SetAcl(Uri uri, int? timeout, BlobContainerPublicAccessType publicAccess, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetAcl(Uri uri, int? timeout, BlobContainerPublicAccessType publicAccess, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.SetAcl(uri, timeout, GetContainerUriQueryBuilder(), content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.SetAcl(uri, timeout, GetContainerUriQueryBuilder(), content, operationContext, canonicalizer, credentials); if (publicAccess != BlobContainerPublicAccessType.Off) { @@ -252,7 +254,7 @@ public static HttpRequestMessage SetAcl(Uri uri, int? timeout, BlobContainerPubl /// The server timeout interval. /// A set of parameters for the listing operation. /// A web request to use to perform the operation. - public static HttpRequestMessage ListBlobs(Uri uri, int? timeout, BlobListingContext listingContext, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage ListBlobs(Uri uri, int? timeout, BlobListingContext listingContext, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = ContainerHttpRequestMessageFactory.GetContainerUriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "list"); @@ -345,7 +347,7 @@ public static HttpRequestMessage ListBlobs(Uri uri, int? timeout, BlobListingCon } } - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } diff --git a/Lib/WindowsRuntime/Core/Executor/Executor.cs b/Lib/WindowsRuntime/Core/Executor/Executor.cs index 2fe326605..62ea11dff 100644 --- a/Lib/WindowsRuntime/Core/Executor/Executor.cs +++ b/Lib/WindowsRuntime/Core/Executor/Executor.cs @@ -58,14 +58,15 @@ private async static Task ExecuteAsyncInternal(RESTCommand cmd, IRetryP { // Note all code below will reference state, not params directly, this will allow common code with multiple executors (APM, Sync, Async) using (ExecutionState executionState = new ExecutionState(cmd, policy, operationContext)) + using (CancellationTokenSource timeoutTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token)) { bool shouldRetry = false; TimeSpan delay = TimeSpan.Zero; // Note - The service accepts both api-version and x-ms-version and therefore it is ok to add x-ms-version to all requests. + // Create a new client - HttpClient client = cmd.BuildClient(cmd, cmd.Handler, true, executionState.OperationContext); - client.Timeout = TimeSpan.FromMilliseconds(int.MaxValue); + HttpClient client = HttpClientFactory.Instance; do { @@ -100,7 +101,13 @@ private async static Task ExecuteAsyncInternal(RESTCommand cmd, IRetryP // 4. Set timeout if (executionState.OperationExpiryTime.HasValue) { - client.Timeout = executionState.RemainingTimeout; + // set the token to cancel after timing out, if the higher token hasn't already been cancelled + timeoutTokenSource.CancelAfter(executionState.RemainingTimeout); + } + else + { + // effectively prevent timeout + timeoutTokenSource.CancelAfter(int.MaxValue); } Executor.CheckTimeout(executionState, true); @@ -114,9 +121,7 @@ private async static Task ExecuteAsyncInternal(RESTCommand cmd, IRetryP storageEx.IsRetryable = false; executionState.ExceptionRef = storageEx; - // Need to throw wrapped Exception with message as serialized exception info stuff. - int hResult = WrappedStorageException.GenerateHResult(executionState.ExceptionRef, executionState.Cmd.CurrentResult); - throw new WrappedStorageException(executionState.Cmd.CurrentResult.WriteAsXml(), executionState.ExceptionRef, hResult); + throw executionState.ExceptionRef; } // Enter Retryable Section of execution @@ -125,14 +130,14 @@ private async static Task ExecuteAsyncInternal(RESTCommand cmd, IRetryP // Send Request executionState.CurrentOperation = ExecutorOperation.BeginGetResponse; Logger.LogInformational(executionState.OperationContext, SR.TraceGetResponse); - executionState.Resp = await client.SendAsync(executionState.Req, HttpCompletionOption.ResponseHeadersRead, token); + executionState.Resp = await client.SendAsync(executionState.Req, HttpCompletionOption.ResponseHeadersRead, timeoutTokenSource.Token); executionState.CurrentOperation = ExecutorOperation.EndGetResponse; // Since HttpClient wont throw for non success, manually check and populate an exception if (!executionState.Resp.IsSuccessStatusCode) { // At this point, don't try to read the stream to parse the error - executionState.ExceptionRef = await Exceptions.PopulateStorageExceptionFromHttpResponseMessage(executionState.Resp, executionState.Cmd.CurrentResult, executionState.Cmd.ParseError); + executionState.ExceptionRef = await Exceptions.PopulateStorageExceptionFromHttpResponseMessage(executionState.Resp, executionState.Cmd.CurrentResult, executionState.Cmd.ParseError); } Logger.LogInformational(executionState.OperationContext, SR.TraceResponse, executionState.Cmd.CurrentResult.HttpStatusCode, executionState.Cmd.CurrentResult.ServiceRequestID, executionState.Cmd.CurrentResult.ContentMd5, executionState.Cmd.CurrentResult.Etag); @@ -171,7 +176,7 @@ private async static Task ExecuteAsyncInternal(RESTCommand cmd, IRetryP try { cmd.ErrorStream = new MemoryStream(); - await cmd.ResponseStream.WriteToAsync(cmd.ErrorStream, null /* copyLength */, null /* maxLength */, false, executionState, new StreamDescriptor(), token); + await cmd.ResponseStream.WriteToAsync(cmd.ErrorStream, null /* copyLength */, null /* maxLength */, false, executionState, new StreamDescriptor(), timeoutTokenSource.Token); cmd.ErrorStream.Seek(0, SeekOrigin.Begin); #if ASPNET_K || PORTABLE executionState.ExceptionRef = StorageException.TranslateExceptionWithPreBufferedStream(executionState.ExceptionRef, executionState.Cmd.CurrentResult, stream => executionState.Cmd.ParseError(stream, executionState.Resp, null), cmd.ErrorStream, executionState.Resp); @@ -207,7 +212,7 @@ private async static Task ExecuteAsyncInternal(RESTCommand cmd, IRetryP { executionState.CurrentOperation = ExecutorOperation.BeginDownloadResponse; Logger.LogInformational(executionState.OperationContext, SR.TraceDownload); - await cmd.ResponseStream.WriteToAsync(cmd.DestinationStream, null /* copyLength */, null /* maxLength */, cmd.CalculateMd5ForResponseStream, executionState, cmd.StreamCopyState, token); + await cmd.ResponseStream.WriteToAsync(cmd.DestinationStream, null /* copyLength */, null /* maxLength */, cmd.CalculateMd5ForResponseStream, executionState, cmd.StreamCopyState, timeoutTokenSource.Token); } finally { @@ -303,13 +308,7 @@ private async static Task ExecuteAsyncInternal(RESTCommand cmd, IRetryP if (!shouldRetry || (executionState.OperationExpiryTime.HasValue && (DateTime.Now + delay).CompareTo(executionState.OperationExpiryTime.Value) > 0)) { Logger.LogError(executionState.OperationContext, shouldRetry ? SR.TraceRetryDecisionTimeout : SR.TraceRetryDecisionPolicy, executionState.ExceptionRef.Message); -#if WINDOWS_RT || ASPNET_K || PORTABLE - // Need to throw wrapped Exception with message as serialized exception info stuff. - int hResult = WrappedStorageException.GenerateHResult(executionState.ExceptionRef, executionState.Cmd.CurrentResult); - throw new WrappedStorageException(executionState.Cmd.CurrentResult.WriteAsXml(), executionState.ExceptionRef, hResult); -#else - throw executionState.ExceptionRef; // throw base exception for desktop -#endif + throw executionState.ExceptionRef; } else { diff --git a/Lib/WindowsRuntime/Core/StorageRequestMessage.cs b/Lib/WindowsRuntime/Core/StorageRequestMessage.cs new file mode 100644 index 000000000..354eaf37d --- /dev/null +++ b/Lib/WindowsRuntime/Core/StorageRequestMessage.cs @@ -0,0 +1,41 @@ +//----------------------------------------------------------------------- +// +// Copyright 2013 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//----------------------------------------------------------------------- + +namespace Microsoft.WindowsAzure.Storage.Core +{ + using Microsoft.WindowsAzure.Storage.Auth; + using Microsoft.WindowsAzure.Storage.Core.Auth; + using System; + using System.Net.Http; + + internal sealed class StorageRequestMessage : HttpRequestMessage + { + public ICanonicalizer Canonicalizer { get; private set; } + + public StorageCredentials Credentials { get; private set; } + + public string AccountName { get; private set; } + + public StorageRequestMessage(HttpMethod method, Uri requestUri, ICanonicalizer canonicalizer, StorageCredentials credentials, string accountName) + : base(method, requestUri) + { + this.Canonicalizer = canonicalizer; + this.Credentials = credentials; + this.AccountName = accountName; + } + } +} \ No newline at end of file diff --git a/Lib/WindowsRuntime/ExceptionInfo.cs b/Lib/WindowsRuntime/ExceptionInfo.cs index 7b263baed..966a238c2 100644 --- a/Lib/WindowsRuntime/ExceptionInfo.cs +++ b/Lib/WindowsRuntime/ExceptionInfo.cs @@ -32,12 +32,6 @@ public sealed class ExceptionInfo /// The type of the exception. public string Type { get; internal set; } - /// - /// Gets HRESULT, a coded numerical value that is assigned to a specific exception. - /// - /// The HRESULT value. - public int HResult { get; internal set; } - /// /// Gets a message that describes the current exception. /// @@ -76,9 +70,6 @@ internal ExceptionInfo(Exception ex) #endif this.Message = ex.Message; this.StackTrace = ex.StackTrace; -#if WINDOWS_RT || ASPNET_K || PORTABLE - this.HResult = ex.HResult; -#endif this.Source = ex.Source; if (ex.InnerException != null) @@ -108,9 +99,6 @@ internal void WriteXml(XmlWriter writer) { writer.WriteStartElement("ExceptionInfo"); writer.WriteElementString("Type", this.Type); -#if WINDOWS_RT || ASPNET_K || PORTABLE - writer.WriteElementString("HResult", Convert.ToString(this.HResult)); -#endif writer.WriteElementString("Message", this.Message); writer.WriteElementString("Source", this.Source); writer.WriteElementString("StackTrace", this.StackTrace); @@ -130,10 +118,6 @@ internal void ReadXml(XmlReader reader) { reader.ReadStartElement("ExceptionInfo"); this.Type = CommonUtility.ReadElementAsString("Type", reader); - -#if WINDOWS_RT || ASPNET_K || PORTABLE - this.HResult = int.Parse(CommonUtility.ReadElementAsString("HResult", reader)); -#endif this.Message = CommonUtility.ReadElementAsString("Message", reader); this.Source = CommonUtility.ReadElementAsString("Source", reader); this.StackTrace = CommonUtility.ReadElementAsString("StackTrace", reader); diff --git a/Lib/WindowsRuntime/File/CloudFile.cs b/Lib/WindowsRuntime/File/CloudFile.cs index 95ecc60fe..52a5c85c0 100644 --- a/Lib/WindowsRuntime/File/CloudFile.cs +++ b/Lib/WindowsRuntime/File/CloudFile.cs @@ -31,8 +31,8 @@ namespace Microsoft.WindowsAzure.Storage.File using System.Net.Http; using System.Text; using System.Threading.Tasks; -#if ASPNET_K using System.Threading; +#if ASPNET_K #else using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; @@ -41,18 +41,14 @@ namespace Microsoft.WindowsAzure.Storage.File using Windows.Storage.Streams; #endif - public sealed partial class CloudFile : IListFileItem + public partial class CloudFile : IListFileItem { /// /// Opens a stream for reading from the file. /// /// A stream to be used for reading from the file. [DoesServiceRequest] -#if ASPNET_K - public Task OpenReadAsync() -#else - public IAsyncOperation OpenReadAsync() -#endif + public virtual Task OpenReadAsync() { return this.OpenReadAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -65,26 +61,11 @@ public IAsyncOperation OpenReadAsync() /// An object that represents the context for the current operation. /// A stream to be used for reading from the file. [DoesServiceRequest] -#if ASPNET_K - public Task OpenReadAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task OpenReadAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.OpenReadAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation OpenReadAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run(async (token) => - { - await this.FetchAttributesAsync(accessCondition, options, operationContext); - AccessCondition streamAccessCondition = AccessCondition.CloneConditionWithETag(accessCondition, this.Properties.ETag); - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient, false); - return new FileReadStreamHelper(this, streamAccessCondition, modifiedOptions, operationContext); - }); - } -#endif -#if ASPNET_K /// /// Opens a stream for reading from the file. /// @@ -94,7 +75,7 @@ public IAsyncOperation OpenReadAsync(AccessC /// A to observe while waiting for a task to complete. /// A stream to be used for reading from the file. [DoesServiceRequest] - public Task OpenReadAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task OpenReadAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { operationContext = operationContext ?? new OperationContext(); return Task.Run(async () => @@ -105,7 +86,6 @@ public Task OpenReadAsync(AccessCondition accessCondition, FileRequestOp return new FileReadStream(this, streamAccessCondition, modifiedOptions, operationContext); }, cancellationToken); } -#endif /// /// Opens a stream for writing to the file. If the file already exists, then existing data in the file may be overwritten. @@ -113,11 +93,7 @@ public Task OpenReadAsync(AccessCondition accessCondition, FileRequestOp /// The size of the write operation, in bytes. /// A stream to be used for writing to the file. [DoesServiceRequest] -#if ASPNET_K - public Task OpenWriteAsync(long? size) -#else - public IAsyncOperation OpenWriteAsync(long? size) -#endif + public virtual Task OpenWriteAsync(long? size) { return this.OpenWriteAsync(size, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -131,8 +107,7 @@ public IAsyncOperation OpenWriteAsync(long? size) /// An object that represents the context for the current operation. /// A stream to be used for writing to the file. [DoesServiceRequest] -#if ASPNET_K - public Task OpenWriteAsync(long? size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task OpenWriteAsync(long? size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.OpenWriteAsync(size, accessCondition, options, operationContext, CancellationToken.None); } @@ -147,10 +122,7 @@ public Task OpenWriteAsync(long? size, AccessCondition accessCo /// A to observe while waiting for a task to complete. /// A stream to be used for writing to the file. [DoesServiceRequest] - public Task OpenWriteAsync(long? size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation OpenWriteAsync(long? size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) -#endif + public virtual Task OpenWriteAsync(long? size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient, false); operationContext = operationContext ?? new OperationContext(); @@ -160,7 +132,6 @@ public IAsyncOperation OpenWriteAsync(long? size, AccessCondit { throw new ArgumentException(SR.MD5NotPossible); } -#if ASPNET_K return Task.Run(async () => { if (createNew) @@ -170,17 +141,6 @@ public IAsyncOperation OpenWriteAsync(long? size, AccessCondit else { await this.FetchAttributesAsync(accessCondition, options, operationContext, cancellationToken); -#else - return AsyncInfo.Run(async (token) => - { - if (createNew) - { - await this.CreateAsync(size.Value, accessCondition, options, operationContext); - } - else - { - await this.FetchAttributesAsync(accessCondition, options, operationContext); -#endif size = this.Properties.Length; } @@ -189,28 +149,18 @@ public IAsyncOperation OpenWriteAsync(long? size, AccessCondit accessCondition = AccessCondition.GenerateLeaseCondition(accessCondition.LeaseId); } -#if ASPNET_K CloudFileStream stream = new FileWriteStream(this, size.Value, createNew, accessCondition, modifiedOptions, operationContext); return stream; }, cancellationToken); -#else - ICloudFileStream stream = new FileWriteStreamHelper(this, size.Value, createNew, accessCondition, modifiedOptions, operationContext); - return stream; - }); -#endif } /// /// Uploads a stream to a file. If the file already exists on the service, it will be overwritten. /// /// The stream providing the file content. - /// An that represents an asynchronous action. + /// A that represents an asynchronous action. [DoesServiceRequest] -#if ASPNET_K - public Task UploadFromStreamAsync(Stream source) -#else - public IAsyncAction UploadFromStreamAsync(IInputStream source) -#endif + public virtual Task UploadFromStreamAsync(Stream source) { return this.UploadFromStreamAsyncHelper(source, null /* length*/, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -220,15 +170,9 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source) /// /// The stream providing the file content. /// The number of bytes to write from the source stream at its current position. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source, long length) -#endif + public virtual Task UploadFromStreamAsync(Stream source, long length) { return this.UploadFromStreamAsyncHelper(source, length, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -240,15 +184,9 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, long length) /// An object that represents the access conditions for the file. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K - /// An that represents an asynchronous action. - [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) -#else - /// An that represents an asynchronous action. + /// A that represents an asynchronous action. [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) -#endif + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsyncHelper(source, null /* length */, accessCondition, options, operationContext); } @@ -261,20 +199,13 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, AccessCondition a /// An object that represents the access conditions for the file. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromStreamAsync(IInputStream source, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) -#endif + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.UploadFromStreamAsyncHelper(source, length, accessCondition, options, operationContext); } -#if ASPNET_K /// /// Uploads a stream to a file. /// @@ -285,7 +216,7 @@ public IAsyncAction UploadFromStreamAsync(IInputStream source, long length, Acce /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.UploadFromStreamAsyncHelper(source, null, accessCondition, options, operationContext, cancellationToken); } @@ -301,11 +232,10 @@ public Task UploadFromStreamAsync(Stream source, AccessCondition accessCondition /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromStreamAsync(Stream source, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.UploadFromStreamAsyncHelper(source, length, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Uploads a stream to a file. If the file already exists on the service, it will be overwritten. @@ -315,7 +245,6 @@ public Task UploadFromStreamAsync(Stream source, long length, AccessCondition ac /// An object that represents the access conditions for the file. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] internal Task UploadFromStreamAsyncHelper(Stream source, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) @@ -335,15 +264,10 @@ internal Task UploadFromStreamAsyncHelper(Stream source, long? length, AccessCon /// A that represents an asynchronous action. [DoesServiceRequest] internal Task UploadFromStreamAsyncHelper(Stream source, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - internal IAsyncAction UploadFromStreamAsyncHelper(IInputStream source, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) -#endif { CommonUtility.AssertNotNull("source", source); - Stream sourceAsStream = source.AsStreamForRead(); + Stream sourceAsStream = source; if (!sourceAsStream.CanSeek) { throw new InvalidOperationException(); @@ -362,7 +286,6 @@ internal IAsyncAction UploadFromStreamAsyncHelper(IInputStream source, long? len operationContext = operationContext ?? new OperationContext(); ExecutionState tempExecutionState = CommonUtility.CreateTemporaryExecutionState(modifiedOptions); -#if ASPNET_K return Task.Run(async () => { using (CloudFileStream fileStream = await this.OpenWriteAsync(length, accessCondition, options, operationContext, cancellationToken)) @@ -373,18 +296,6 @@ internal IAsyncAction UploadFromStreamAsyncHelper(IInputStream source, long? len await fileStream.CommitAsync(); } }, cancellationToken); -#else - return AsyncInfo.Run(async (token) => - { - using (ICloudFileStream fileStream = await this.OpenWriteAsync(length, accessCondition, options, operationContext).AsTask(token)) - { - // We should always call AsStreamForWrite with bufferSize=0 to prevent buffering. Our - // stream copier only writes 64K buffers at a time anyway, so no buffering is needed. - await sourceAsStream.WriteToAsync(fileStream.AsStreamForWrite(0), length, null /* maxLength */, false, tempExecutionState, null /* streamCopyState */, token); - await fileStream.CommitAsync().AsTask(token); - } - }); -#endif } /// @@ -392,18 +303,17 @@ internal IAsyncAction UploadFromStreamAsyncHelper(IInputStream source, long? len /// #if ASPNET_K /// A string containing the path to the target file. - /// A enumeration value that determines how to open or create the file. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode) + public virtual Task UploadFromFileAsync(string path) { - return this.UploadFromFileAsync(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */); + return this.UploadFromFileAsync(path, null /* accessCondition */, null /* options */, null /* operationContext */); } #else /// The file providing the file content. - /// An that represents an asynchronous action. + /// An that represents an asynchronous action. [DoesServiceRequest] - public IAsyncAction UploadFromFileAsync(StorageFile source) + public virtual Task UploadFromFileAsync(StorageFile source) { return this.UploadFromFileAsync(source, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -414,32 +324,46 @@ public IAsyncAction UploadFromFileAsync(StorageFile source) /// #if ASPNET_K /// A string containing the path to the target file. - /// A enumeration value that determines how to open or create the file. /// An object that represents the access conditions for the file. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { - return this.UploadFromFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); + return this.UploadFromFileAsync(path, accessCondition, options, operationContext, CancellationToken.None); } #else /// The file providing the file content. /// An object that represents the access conditions for the file. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. - /// An that represents an asynchronous action. + /// A that represents an asynchronous action. + [DoesServiceRequest] + public virtual Task UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + { + return this.UploadFromFileAsync(source, accessCondition, options, operationContext, CancellationToken.None); + } + + /// + /// Uploads a file to the Azure File Service. If the file already exists on the service, it will be overwritten. + /// + /// The file providing the file content. + /// An object that represents the access conditions for the file. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// A to observe while waiting for a task to complete. + /// A that represents an asynchronous action. [DoesServiceRequest] - public IAsyncAction UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("source", source); - return AsyncInfo.Run(async (token) => + return Task.Run(async () => { - using (IRandomAccessStreamWithContentType stream = await source.OpenReadAsync().AsTask(token)) + using (IRandomAccessStreamWithContentType stream = await source.OpenReadAsync().AsTask(cancellationToken)) { - await this.UploadFromStreamAsync(stream, accessCondition, options, operationContext).AsTask(token); + await this.UploadFromStreamAsync(stream.AsStream(), accessCondition, options, operationContext, cancellationToken); } }); } @@ -450,20 +374,19 @@ public IAsyncAction UploadFromFileAsync(StorageFile source, AccessCondition acce /// Uploads a file to the Azure File Service. If the file already exists on the service, it will be overwritten. /// /// A string containing the path to the target file. - /// A enumeration value that determines how to open or create the file. /// An object that represents the access conditions for the file. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromFileAsync(string path, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("path", path); return Task.Run(async () => { - using (Stream stream = new FileStream(path, mode, FileAccess.Read)) + using (Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { await this.UploadFromStreamAsync(stream, accessCondition, options, operationContext, cancellationToken); } @@ -477,15 +400,9 @@ public Task UploadFromFileAsync(string path, FileMode mode, AccessCondition acce /// An array of bytes. /// The zero-based byte offset in buffer at which to begin uploading bytes to the file. /// The number of bytes to be written to the file. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int index, int count) -#endif + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count) { return this.UploadFromByteArrayAsync(buffer, index, count, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -499,26 +416,13 @@ public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int /// An object that represents the access conditions for the file. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.UploadFromByteArrayAsync(buffer, index, count, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int index, int count, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - CommonUtility.AssertNotNull("buffer", buffer); - SyncMemoryStream stream = new SyncMemoryStream(buffer, index, count); - return this.UploadFromStreamAsync(stream.AsInputStream(), accessCondition, options, operationContext); - } -#endif - -#if ASPNET_K /// /// Uploads the contents of a byte array to a file. /// @@ -531,28 +435,21 @@ public IAsyncAction UploadFromByteArrayAsync([ReadOnlyArray] byte[] buffer, int /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadFromByteArrayAsync(byte[] buffer, int index, int count, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("buffer", buffer); SyncMemoryStream stream = new SyncMemoryStream(buffer, index, count); return this.UploadFromStreamAsync(stream, stream.Length, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Uploads a string of text to a file. If the file already exists on the service, it will be overwritten. /// /// The text to upload, encoded as a UTF-8 string. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadTextAsync(string content) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadTextAsync(string content) -#endif + public virtual Task UploadTextAsync(string content) { return this.UploadTextAsync(content, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -564,26 +461,13 @@ public IAsyncAction UploadTextAsync(string content) /// An object that represents the access conditions for the file. /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadTextAsync(string content, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task UploadTextAsync(string content, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.UploadTextAsync(content, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UploadTextAsync(string content, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - CommonUtility.AssertNotNull("content", content); - byte[] contentAsBytes = Encoding.UTF8.GetBytes(content); - return this.UploadFromByteArrayAsync(contentAsBytes, 0, contentAsBytes.Length, accessCondition, options, operationContext); - } -#endif - -#if ASPNET_K /// /// Uploads a string of text to a file. If the file already exists on the service, it will be overwritten. /// @@ -594,28 +478,21 @@ public IAsyncAction UploadTextAsync(string content, AccessCondition accessCondit /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UploadTextAsync(string content, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UploadTextAsync(string content, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("content", content); byte[] contentAsBytes = Encoding.UTF8.GetBytes(content); return this.UploadFromByteArrayAsync(contentAsBytes, 0, contentAsBytes.Length, accessCondition, options, operationContext); } -#endif /// /// Downloads the contents of a file to a stream. /// /// The target stream. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DownloadToStreamAsync(IOutputStream target) -#endif + public virtual Task DownloadToStreamAsync(Stream target) { return this.DownloadToStreamAsync(target, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -627,23 +504,13 @@ public IAsyncAction DownloadToStreamAsync(IOutputStream target) /// An object that represents the access conditions for the file. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DownloadToStreamAsync(target, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DownloadToStreamAsync(IOutputStream target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - return this.DownloadRangeToStreamAsync(target, null /* offset */, null /* length */, accessCondition, options, operationContext); - } -#endif -#if ASPNET_K /// /// Downloads the contents of a file to a stream. /// @@ -654,11 +521,10 @@ public IAsyncAction DownloadToStreamAsync(IOutputStream target, AccessCondition /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.DownloadRangeToStreamAsync(target, null /* offset */, null /* length */, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Downloads the contents of a file to a file. @@ -668,15 +534,15 @@ public Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition /// A enumeration value that specifies how to open the file. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode) + public virtual Task DownloadToFileAsync(string path, FileMode mode) { return this.DownloadToFileAsync(path, mode, null /* accessCondition */, null /* options */, null /* operationContext */); } #else /// The target file. - /// An that represents an asynchronous action. + /// An that represents an asynchronous action. [DoesServiceRequest] - public IAsyncAction DownloadToFileAsync(StorageFile target) + public virtual Task DownloadToFileAsync(StorageFile target) { return this.DownloadToFileAsync(target, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -693,7 +559,7 @@ public IAsyncAction DownloadToFileAsync(StorageFile target) /// An object that represents the context for the current operation. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DownloadToFileAsync(path, mode, accessCondition, options, operationContext, CancellationToken.None); } @@ -702,17 +568,32 @@ public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition acce /// An object that represents the access conditions for the file. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. - /// An that represents an asynchronous action. + /// An that represents an asynchronous action. + [DoesServiceRequest] + public virtual Task DownloadToFileAsync(StorageFile target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + { + return this.DownloadToFileAsync(target, accessCondition, options, operationContext, CancellationToken.None); + } + + /// + /// Downloads the contents of a file to a file. + /// + /// The target file. + /// An object that represents the access conditions for the file. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// A to observe while waiting for a task to complete. + /// A that represents an asynchronous action. [DoesServiceRequest] - public IAsyncAction DownloadToFileAsync(StorageFile target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DownloadToFileAsync(StorageFile target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("target", target); - return AsyncInfo.Run(async (token) => + return Task.Run(async () => { - using (StorageStreamTransaction transaction = await target.OpenTransactedWriteAsync().AsTask(token)) + using (StorageStreamTransaction transaction = await target.OpenTransactedWriteAsync().AsTask(cancellationToken)) { - await this.DownloadToStreamAsync(transaction.Stream, accessCondition, options, operationContext).AsTask(token); + await this.DownloadToStreamAsync(transaction.Stream.AsStream(), accessCondition, options, operationContext, cancellationToken); await transaction.CommitAsync(); } }); @@ -731,15 +612,37 @@ public IAsyncAction DownloadToFileAsync(StorageFile target, AccessCondition acce /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadToFileAsync(string path, FileMode mode, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("path", path); return Task.Run(async () => { - using (FileStream stream = new FileStream(path, mode, FileAccess.Write)) + FileStream stream = new FileStream(path, mode, FileAccess.Write); + + try { - await this.DownloadToStreamAsync(stream, accessCondition, options, operationContext, cancellationToken); + using (stream) + { + await this.DownloadToStreamAsync(stream, accessCondition, options, operationContext, cancellationToken); + } + } + catch (Exception) + { + if (mode == FileMode.Create || mode == FileMode.CreateNew) + { + try + { + File.Delete(path); + } + catch (Exception) + { + // Best effort to clean up in the event that download was unsuccessful. + // Do not throw as we want to throw original exception. + } + } + + throw; } }); } @@ -752,11 +655,7 @@ public Task DownloadToFileAsync(string path, FileMode mode, AccessCondition acce /// The starting offset in the byte array. /// The total number of bytes read into the buffer. [DoesServiceRequest] -#if ASPNET_K - public Task DownloadToByteArrayAsync(byte[] target, int index) -#else - public IAsyncOperation DownloadToByteArrayAsync([WriteOnlyArray] byte[] target, int index) -#endif + public virtual Task DownloadToByteArrayAsync(byte[] target, int index) { return this.DownloadToByteArrayAsync(target, index, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -771,19 +670,11 @@ public IAsyncOperation DownloadToByteArrayAsync([WriteOnlyArray] byte[] tar /// An object that represents the context for the current operation. /// The total number of bytes read into the buffer. [DoesServiceRequest] -#if ASPNET_K - public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DownloadToByteArrayAsync(target, index, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation DownloadToByteArrayAsync([WriteOnlyArray] byte[] target, int index, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - return this.DownloadRangeToByteArrayAsync(target, index, null /* fileOffset */, null /* length */, accessCondition, options, operationContext); - } -#endif -#if ASPNET_K /// /// Downloads the contents of a file to a byte array. /// @@ -795,11 +686,10 @@ public IAsyncOperation DownloadToByteArrayAsync([WriteOnlyArray] byte[] tar /// A to observe while waiting for a task to complete. /// The total number of bytes read into the buffer. [DoesServiceRequest] - public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.DownloadRangeToByteArrayAsync(target, index, null /* fileOffset */, null /* length */, accessCondition, options, operationContext, cancellationToken); } -#endif /// /// Downloads the contents of a file to a stream. @@ -807,15 +697,9 @@ public Task DownloadToByteArrayAsync(byte[] target, int index, AccessCondit /// The target stream. /// The offset at which to begin downloading the file, in bytes. /// The length of the data to download from the file, in bytes. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DownloadRangeToStreamAsync(IOutputStream target, long? offset, long? length) -#endif + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length) { return this.DownloadRangeToStreamAsync(target, offset, length, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -824,11 +708,8 @@ public IAsyncAction DownloadRangeToStreamAsync(IOutputStream target, long? offse /// Downloads the file's contents as a string. /// /// The contents of the file, as a string. -#if ASPNET_K - public Task DownloadTextAsync() -#else - public IAsyncOperation DownloadTextAsync() -#endif + [DoesServiceRequest] + public virtual Task DownloadTextAsync() { return this.DownloadTextAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -840,27 +721,12 @@ public IAsyncOperation DownloadTextAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. /// The contents of the file, as a string. -#if ASPNET_K - public Task DownloadTextAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task DownloadTextAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DownloadTextAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation DownloadTextAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - return AsyncInfo.Run(async (token) => - { - using (SyncMemoryStream stream = new SyncMemoryStream()) - { - await this.DownloadToStreamAsync(stream.AsOutputStream(), accessCondition, options, operationContext).AsTask(token); - byte[] streamAsBytes = stream.ToArray(); - return Encoding.UTF8.GetString(streamAsBytes, 0, streamAsBytes.Length); - } - }); - } -#endif -#if ASPNET_K /// /// Downloads the file's contents as a string. /// @@ -869,7 +735,8 @@ public IAsyncOperation DownloadTextAsync(AccessCondition accessCondition /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// The contents of the file, as a string. - public Task DownloadTextAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + [DoesServiceRequest] + public virtual Task DownloadTextAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return Task.Run(async () => { @@ -881,7 +748,6 @@ public Task DownloadTextAsync(AccessCondition accessCondition, FileReque } }, cancellationToken); } -#endif /// /// Downloads the contents of a file to a stream. @@ -892,33 +758,13 @@ public Task DownloadTextAsync(AccessCondition accessCondition, FileReque /// An object that represents the access conditions for the file. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DownloadRangeToStreamAsync(target, offset, length, accessCondition, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DownloadRangeToStreamAsync(IOutputStream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - CommonUtility.AssertNotNull("target", target); - - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - // We should always call AsStreamForWrite with bufferSize=0 to prevent buffering. Our - // stream copier only writes 64K buffers at a time anyway, so no buffering is needed. - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.GetFileImpl(target.AsStreamForWrite(0), offset, length, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif - -#if ASPNET_K /// /// Downloads the contents of a file to a stream. /// @@ -931,7 +777,7 @@ public IAsyncAction DownloadRangeToStreamAsync(IOutputStream target, long? offse /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("target", target); @@ -945,7 +791,6 @@ public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length operationContext, cancellationToken), cancellationToken); } -#endif /// /// Downloads the contents of a file to a byte array. @@ -956,11 +801,7 @@ public Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length /// The length of the data range, in bytes. /// The total number of bytes read into the buffer. [DoesServiceRequest] -#if ASPNET_K - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length) -#else - public IAsyncOperation DownloadRangeToByteArrayAsync([WriteOnlyArray] byte[] target, int index, long? fileOffset, long? length) -#endif + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length) { return this.DownloadRangeToByteArrayAsync(target, index, fileOffset, length, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -977,26 +818,11 @@ public IAsyncOperation DownloadRangeToByteArrayAsync([WriteOnlyArray] byte[ /// An object that represents the context for the current operation. /// The total number of bytes read into the buffer. [DoesServiceRequest] -#if ASPNET_K - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DownloadRangeToByteArrayAsync(target, index, fileOffset, length, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation DownloadRangeToByteArrayAsync([WriteOnlyArray] byte[] target, int index, long? fileOffset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - return AsyncInfo.Run(async (token) => - { - using (SyncMemoryStream stream = new SyncMemoryStream(target, index)) - { - await this.DownloadRangeToStreamAsync(stream.AsOutputStream(), fileOffset, length, accessCondition, options, operationContext).AsTask(token); - return (int)stream.Position; - } - }); - } -#endif -#if ASPNET_K /// /// Downloads the contents of a file to a byte array. /// @@ -1010,7 +836,7 @@ public IAsyncOperation DownloadRangeToByteArrayAsync([WriteOnlyArray] byte[ /// A to observe while waiting for a task to complete. /// The total number of bytes read into the buffer. [DoesServiceRequest] - public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? fileOffset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return Task.Run(async () => { @@ -1021,18 +847,13 @@ public Task DownloadRangeToByteArrayAsync(byte[] target, int index, long? f } }, cancellationToken); } -#endif /// /// Creates a file. If the file already exists, it will be overwritten. /// /// The maximum size of the file, in bytes. [DoesServiceRequest] -#if ASPNET_K - public Task CreateAsync(long size) -#else - public IAsyncAction CreateAsync(long size) -#endif + public virtual Task CreateAsync(long size) { return this.CreateAsync(size, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1045,24 +866,11 @@ public IAsyncAction CreateAsync(long size) /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task CreateAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task CreateAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.CreateAsync(size, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction CreateAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.CreateImpl(size, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Creates a file. If the file already exists, it will be overwritten. /// @@ -1072,7 +880,7 @@ public IAsyncAction CreateAsync(long size, AccessCondition accessCondition, File /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task CreateAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1081,18 +889,13 @@ public Task CreateAsync(long size, AccessCondition accessCondition, FileRequestO operationContext, cancellationToken), cancellationToken); } -#endif /// /// Checks existence of the file. /// /// true if the file exists. [DoesServiceRequest] -#if ASPNET_K - public Task ExistsAsync() -#else - public IAsyncOperation ExistsAsync() -#endif + public virtual Task ExistsAsync() { return this.ExistsAsync(null /* options */, null /* operationContext */); } @@ -1104,24 +907,11 @@ public IAsyncOperation ExistsAsync() /// An object that represents the context for the current operation. /// true if the file exists. [DoesServiceRequest] -#if ASPNET_K - public Task ExistsAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task ExistsAsync(FileRequestOptions options, OperationContext operationContext) { return this.ExistsAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ExistsAsync(FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.ExistsImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Checks existence of the file. /// @@ -1130,7 +920,7 @@ public IAsyncOperation ExistsAsync(FileRequestOptions options, OperationCo /// A to observe while waiting for a task to complete. /// true if the file exists. [DoesServiceRequest] - public Task ExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -1139,17 +929,12 @@ public Task ExistsAsync(FileRequestOptions options, OperationContext opera operationContext, cancellationToken), cancellationToken); } -#endif /// /// Populates a file's properties and metadata. /// [DoesServiceRequest] -#if ASPNET_K - public Task FetchAttributesAsync() -#else - public IAsyncAction FetchAttributesAsync() -#endif + public virtual Task FetchAttributesAsync() { return this.FetchAttributesAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1161,24 +946,11 @@ public IAsyncAction FetchAttributesAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.FetchAttributesAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.FetchAttributesImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Populates a file's properties and metadata. /// @@ -1187,7 +959,7 @@ public IAsyncAction FetchAttributesAsync(AccessCondition accessCondition, FileRe /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1196,17 +968,12 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOpt operationContext, cancellationToken), cancellationToken); } -#endif /// /// Deletes the file. /// [DoesServiceRequest] -#if ASPNET_K - public Task DeleteAsync() -#else - public IAsyncAction DeleteAsync() -#endif + public virtual Task DeleteAsync() { return this.DeleteAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1218,24 +985,11 @@ public IAsyncAction DeleteAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DeleteAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.DeleteFileImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Deletes the file. /// @@ -1244,7 +998,7 @@ public IAsyncAction DeleteAsync(AccessCondition accessCondition, FileRequestOpti /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1253,18 +1007,13 @@ public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions opti operationContext, cancellationToken), cancellationToken); } -#endif /// /// Deletes the file if it already exists. /// /// true if the file already existed and was deleted; otherwise, false. [DoesServiceRequest] -#if ASPNET_K - public Task DeleteIfExistsAsync() -#else - public IAsyncOperation DeleteIfExistsAsync() -#endif + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1277,8 +1026,7 @@ public IAsyncOperation DeleteIfExistsAsync() /// An object that represents the context for the current operation. /// true if the file already existed and was deleted; otherwise, false. [DoesServiceRequest] -#if ASPNET_K - public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DeleteIfExistsAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -1292,23 +1040,14 @@ public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileReque /// A to observe while waiting for a task to complete. /// true if the file already existed and was deleted; otherwise, false. [DoesServiceRequest] - public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) -#endif + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); -#if ASPNET_K return Task.Run(async () => { bool exists = await this.ExistsAsync(modifiedOptions, operationContext, cancellationToken); -#else - return AsyncInfo.Run(async (token) => - { - bool exists = await this.ExistsAsync(modifiedOptions, operationContext).AsTask(token); -#endif if (!exists) { return false; @@ -1316,11 +1055,7 @@ public IAsyncOperation DeleteIfExistsAsync(AccessCondition accessCondition try { -#if ASPNET_K await this.DeleteAsync(accessCondition, modifiedOptions, operationContext, cancellationToken); -#else - await this.DeleteAsync(accessCondition, modifiedOptions, operationContext).AsTask(token); -#endif return true; } catch (Exception) @@ -1343,22 +1078,14 @@ public IAsyncOperation DeleteIfExistsAsync(AccessCondition accessCondition throw; } } -#if ASPNET_K }, cancellationToken); -#else - }); -#endif } /// Gets a collection of valid ranges and their starting and ending bytes. /// /// An enumerable collection of ranges. [DoesServiceRequest] -#if ASPNET_K - public Task> ListRangesAsync() -#else - public IAsyncOperation> ListRangesAsync() -#endif + public virtual Task> ListRangesAsync() { return this.ListRangesAsync(null /* offset */, null /* length */, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1373,24 +1100,11 @@ public IAsyncOperation> ListRangesAsync() /// An object that represents the context for the current operation. /// An enumerable collection of ranges. [DoesServiceRequest] -#if ASPNET_K - public Task> ListRangesAsync(long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task> ListRangesAsync(long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.ListRangesAsync(offset, length, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation> ListRangesAsync(long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.ListRangesImpl(offset, length, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Gets a collection of valid ranges and their starting and ending bytes. @@ -1403,7 +1117,7 @@ public IAsyncOperation> ListRangesAsync(long? offset, lon /// A to observe while waiting for a task to complete. /// An enumerable collection of ranges. [DoesServiceRequest] - public Task> ListRangesAsync(long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> ListRangesAsync(long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -1412,17 +1126,12 @@ public Task> ListRangesAsync(long? offset, long? length, operationContext, cancellationToken), cancellationToken); } -#endif /// /// Updates the file's properties. /// [DoesServiceRequest] -#if ASPNET_K - public Task SetPropertiesAsync() -#else - public IAsyncAction SetPropertiesAsync() -#endif + public virtual Task SetPropertiesAsync() { return this.SetPropertiesAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1434,24 +1143,11 @@ public IAsyncAction SetPropertiesAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.SetPropertiesAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetPropertiesImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Updates the file's properties. /// @@ -1460,7 +1156,7 @@ public IAsyncAction SetPropertiesAsync(AccessCondition accessCondition, FileRequ /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1469,18 +1165,13 @@ public Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptio operationContext, cancellationToken), cancellationToken); } -#endif /// /// Resizes a file. /// /// The maximum size of the file, in bytes. [DoesServiceRequest] -#if ASPNET_K - public Task ResizeAsync(long size) -#else - public IAsyncAction ResizeAsync(long size) -#endif + public virtual Task ResizeAsync(long size) { return this.ResizeAsync(size, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1493,24 +1184,11 @@ public IAsyncAction ResizeAsync(long size) /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task ResizeAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task ResizeAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.ResizeAsync(size, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction ResizeAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.ResizeImpl(size, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Resizes a file. /// @@ -1520,7 +1198,7 @@ public IAsyncAction ResizeAsync(long size, AccessCondition accessCondition, File /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task ResizeAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ResizeAsync(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1529,17 +1207,12 @@ public Task ResizeAsync(long size, AccessCondition accessCondition, FileRequestO operationContext, cancellationToken), cancellationToken); } -#endif /// /// Updates the file's metadata. /// [DoesServiceRequest] -#if ASPNET_K - public Task SetMetadataAsync() -#else - public IAsyncAction SetMetadataAsync() -#endif + public virtual Task SetMetadataAsync() { return this.SetMetadataAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1551,24 +1224,11 @@ public IAsyncAction SetMetadataAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.SetMetadataAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetMetadataImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Updates the file's metadata. /// @@ -1577,7 +1237,7 @@ public IAsyncAction SetMetadataAsync(AccessCondition accessCondition, FileReques /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1586,7 +1246,6 @@ public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions operationContext, cancellationToken), cancellationToken); } -#endif /// /// Writes range to a file. @@ -1595,15 +1254,9 @@ public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions /// The offset at which to begin writing, in bytes. /// An optional hash value that will be used to set the property /// on the file. May be null or an empty string. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] - public Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction WriteRangeAsync(IInputStream rangeData, long startOffset, string contentMD5) -#endif + public virtual Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5) { return this.WriteRangeAsync(rangeData, startOffset, contentMD5, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1618,10 +1271,9 @@ public IAsyncAction WriteRangeAsync(IInputStream rangeData, long startOffset, st /// An object that represents the access conditions for the file. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K /// A that represents an asynchronous action. [DoesServiceRequest] - public Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.WriteRangeAsync(rangeData, startOffset, contentMD5, accessCondition, options, operationContext, CancellationToken.None); } @@ -1638,29 +1290,20 @@ public Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. - public Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction WriteRangeAsync(IInputStream rangeData, long startOffset, string contentMD5, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) -#endif + public virtual Task WriteRangeAsync(Stream rangeData, long startOffset, string contentMD5, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { - CommonUtility.AssertNotNull("rangeData", rangeData); + CommonUtility.AssertNotNull("rangeData", rangeData); FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); bool requiresContentMD5 = (contentMD5 == null) && modifiedOptions.UseTransactionalMD5.Value; operationContext = operationContext ?? new OperationContext(); ExecutionState tempExecutionState = CommonUtility.CreateTemporaryExecutionState(modifiedOptions); -#if ASPNET_K return Task.Run(async () => -#else - return AsyncInfo.Run(async (cancellationToken) => -#endif { DateTime streamCopyStartTime = DateTime.Now; - Stream rangeDataAsStream = rangeData.AsStreamForRead(); + Stream rangeDataAsStream = rangeData; Stream seekableStream = rangeDataAsStream; bool seekableStreamCreated = false; @@ -1709,24 +1352,16 @@ await Executor.ExecuteAsyncNullReturn( seekableStream.Dispose(); } } -#if ASPNET_K }, cancellationToken); -#else - }); -#endif } - /// - /// Clears ranges from a file. - /// - /// The offset at which to begin clearing file ranges, in bytes. - /// The length of the data range to be cleared, in bytes. - [DoesServiceRequest] -#if ASPNET_K - public Task ClearRangeAsync(long startOffset, long length) -#else - public IAsyncAction ClearRangeAsync(long startOffset, long length) -#endif + /// + /// Clears ranges from a file. + /// + /// The offset at which to begin clearing file ranges, in bytes. + /// The length of the data range to be cleared, in bytes. + [DoesServiceRequest] + public virtual Task ClearRangeAsync(long startOffset, long length) { return this.ClearRangeAsync(startOffset, length, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1740,24 +1375,11 @@ public IAsyncAction ClearRangeAsync(long startOffset, long length) /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task ClearRangeAsync(long startOffset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task ClearRangeAsync(long startOffset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.ClearRangeAsync(startOffset, length, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction ClearRangeAsync(long startOffset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.ClearRangeImpl(startOffset, length, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Clears ranges from a file. /// @@ -1768,7 +1390,7 @@ public IAsyncAction ClearRangeAsync(long startOffset, long length, AccessConditi /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task ClearRangeAsync(long startOffset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ClearRangeAsync(long startOffset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1777,7 +1399,6 @@ public Task ClearRangeAsync(long startOffset, long length, AccessCondition acces operationContext, cancellationToken), cancellationToken); } -#endif /// /// Begins an operation to start copying an existing blob or Azure file's contents, properties, and metadata to a new Azure file. @@ -1789,12 +1410,7 @@ public Task ClearRangeAsync(long startOffset, long length, AccessCondition acces /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] -#if ASPNET_K - public Task StartCopyAsync(Uri source) -#else - [DefaultOverload] - public IAsyncOperation StartCopyAsync(Uri source) -#endif + public virtual Task StartCopyAsync(Uri source) { return this.StartCopyAsync(source, null /* sourceAccessCondition */, null /* destAccessCondition */, null /* options */, null /* operationContext */); } @@ -1809,11 +1425,7 @@ public IAsyncOperation StartCopyAsync(Uri source) /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] -#if ASPNET_K - public Task StartCopyAsync(CloudBlob source) -#else - public IAsyncOperation StartCopyAsync(CloudBlob source) -#endif + public virtual Task StartCopyAsync(CloudBlob source) { return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source)); } @@ -1828,11 +1440,7 @@ public IAsyncOperation StartCopyAsync(CloudBlob source) /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] -#if ASPNET_K - public Task StartCopyAsync(CloudFile source) -#else - public IAsyncOperation StartCopyAsync(CloudFile source) -#endif + public virtual Task StartCopyAsync(CloudFile source) { return this.StartCopyAsync(CloudFile.SourceFileToUri(source)); } @@ -1851,27 +1459,11 @@ public IAsyncOperation StartCopyAsync(CloudFile source) /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] -#if ASPNET_K - public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext) { return StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None); } -#else - [DefaultOverload] - public IAsyncOperation StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext) - { - CommonUtility.AssertNotNull("source", source); - - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.StartCopyImpl(source, sourceAccessCondition, destAccessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Begins an operation to start copying a blob or file's contents, properties, and metadata to a new Azure file. /// @@ -1886,7 +1478,7 @@ public IAsyncOperation StartCopyAsync(Uri source, AccessCondition source /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. /// [DoesServiceRequest] - public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -1895,28 +1487,22 @@ public Task StartCopyAsync(Uri source, AccessCondition sourceAccessCondi operationContext, cancellationToken), cancellationToken); } -#endif - /// - /// Begins an operation to start copying a blob's contents, properties, and metadata to a new Azure file. - /// - /// The source blob. - /// An object that represents the access conditions for the source blob. If null, no condition is used. - /// An object that represents the access conditions for the destination file. If null, no condition is used. - /// A object that specifies additional options for the request. - /// An object that represents the context for the current operation. - /// The copy ID associated with the copy operation. - /// - /// This method fetches the file's ETag, last modified time, and part of the copy state. - /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. - /// + /// + /// Begins an operation to start copying a blob's contents, properties, and metadata to a new Azure file. + /// + /// The source blob. + /// An object that represents the access conditions for the source blob. If null, no condition is used. + /// An object that represents the access conditions for the destination file. If null, no condition is used. + /// A object that specifies additional options for the request. + /// An object that represents the context for the current operation. + /// The copy ID associated with the copy operation. + /// + /// This method fetches the file's ETag, last modified time, and part of the copy state. + /// The copy ID and copy status fields are fetched, and the rest of the copy state is cleared. + /// [DoesServiceRequest] -#if ASPNET_K - public Task StartCopyAsync(CloudBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext) -#else - public IAsyncOperation StartCopyAsync(CloudBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext) -#endif - + public virtual Task StartCopyAsync(CloudBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, FileRequestOptions options, OperationContext operationContext) { return this.StartCopyAsync(CloudBlob.SourceBlobToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext); } @@ -1925,14 +1511,9 @@ public IAsyncOperation StartCopyAsync(CloudBlob source, AccessCondition /// Aborts an ongoing copy operation. /// /// A string identifying the copy operation. - /// An that represents an asynchronous action. + /// A that represents an asynchronous action. [DoesServiceRequest] -#if ASPNET_K - public Task AbortCopyAsync(string copyId) -#else - public IAsyncAction AbortCopyAsync(string copyId) -#endif - + public virtual Task AbortCopyAsync(string copyId) { return this.AbortCopyAsync(copyId, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -1945,24 +1526,11 @@ public IAsyncAction AbortCopyAsync(string copyId) /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task AbortCopyAsync(string copyId, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task AbortCopyAsync(string copyId, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.AbortCopyAsync(copyId, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction AbortCopyAsync(string copyId, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.AbortCopyImpl(copyId, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Aborts an ongoing copy operation. /// @@ -1971,7 +1539,7 @@ public IAsyncAction AbortCopyAsync(string copyId, AccessCondition accessConditio /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] - public Task AbortCopyAsync(string copyId, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AbortCopyAsync(string copyId, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -1980,14 +1548,13 @@ public Task AbortCopyAsync(string copyId, AccessCondition accessCondition, FileR operationContext, cancellationToken), cancellationToken); } -#endif - /// - /// Implements getting the file. - /// - /// An object that represents the access conditions for the file. If null, no condition is used. - /// An object that specifies additional options for the request. - /// A that gets the stream. + /// + /// Implements getting the file. + /// + /// An object that represents the access conditions for the file. If null, no condition is used. + /// An object that specifies additional options for the request. + /// A that gets the stream. private RESTCommand GetFileImpl(Stream destStream, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options) { string lockedETag = null; @@ -2008,9 +1575,7 @@ private RESTCommand GetFileImpl(Stream destStream, long? offset, long? getCmd.RetrieveResponseStream = true; getCmd.DestinationStream = destStream; getCmd.CalculateMd5ForResponseStream = !options.DisableContentMD5Validation.Value; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.Get(uri, serverTimeout, offset, length, options.UseTransactionalMD5.Value, accessCondition, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.Get(uri, serverTimeout, offset, length, options.UseTransactionalMD5.Value, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.RecoveryAction = (cmd, ex, ctx) => { if ((lockedAccessCondition == null) && !string.IsNullOrEmpty(lockedETag)) @@ -2031,7 +1596,7 @@ private RESTCommand GetFileImpl(Stream destStream, long? offset, long? } } - getCmd.BuildRequest = (command, uri, builder, cnt, serverTimeout, context) => FileHttpRequestMessageFactory.Get(uri, serverTimeout, offset, length, options.UseTransactionalMD5.Value && !arePropertiesPopulated, accessCondition, cnt, context); + getCmd.BuildRequest = (command, uri, builder, cnt, serverTimeout, context) => FileHttpRequestMessageFactory.Get(uri, serverTimeout, offset, length, options.UseTransactionalMD5.Value && !arePropertiesPopulated, accessCondition, cnt, context, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); }; getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => @@ -2104,11 +1669,9 @@ private RESTCommand CreateImpl(long sizeInBytes, AccessCondition acces RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = FileHttpRequestMessageFactory.Create(uri, serverTimeout, this.Properties, sizeInBytes, accessCondition, cnt, ctx); + StorageRequestMessage msg = FileHttpRequestMessageFactory.Create(uri, serverTimeout, this.Properties, sizeInBytes, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); FileHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -2135,9 +1698,7 @@ private RESTCommand FetchAttributesImpl(AccessCondition accessConditio options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.GetProperties(uri, serverTimeout, accessCondition, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.GetProperties(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex); @@ -2159,9 +1720,7 @@ private RESTCommand ExistsImpl(FileRequestOptions options) options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.GetProperties(uri, serverTimeout, null /* accessCondition */, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.GetProperties(uri, serverTimeout, null /* accessCondition */, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { if (resp.StatusCode == HttpStatusCode.NotFound) @@ -2188,9 +1747,7 @@ private RESTCommand DeleteFileImpl(AccessCondition accessCondition, Fi RESTCommand deleteCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(deleteCmd); - deleteCmd.Handler = this.ServiceClient.AuthenticationHandler; - deleteCmd.BuildClient = HttpClientFactory.BuildHttpClient; - deleteCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.Delete(uri, serverTimeout, accessCondition, cnt, ctx); + deleteCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.Delete(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); deleteCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, NullType.Value, cmd, ex); return deleteCmd; @@ -2209,11 +1766,9 @@ private RESTCommand> ListRangesImpl(long? offset, long? l options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; getCmd.RetrieveResponseStream = true; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = FileHttpRequestMessageFactory.ListRanges(uri, serverTimeout, offset, length, accessCondition, cnt, ctx); + StorageRequestMessage msg = FileHttpRequestMessageFactory.ListRanges(uri, serverTimeout, offset, length, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); FileHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -2244,11 +1799,9 @@ private RESTCommand SetPropertiesImpl(AccessCondition accessCondition, RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = FileHttpRequestMessageFactory.SetProperties(uri, serverTimeout, this.Properties, accessCondition, cnt, ctx); + StorageRequestMessage msg = FileHttpRequestMessageFactory.SetProperties(uri, serverTimeout, this.Properties, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); FileHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -2274,9 +1827,7 @@ private RESTCommand ResizeImpl(long sizeInBytes, AccessCondition acces RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.Resize(uri, serverTimeout, sizeInBytes, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.Resize(uri, serverTimeout, sizeInBytes, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex); @@ -2299,11 +1850,9 @@ private RESTCommand SetMetadataImpl(AccessCondition accessCondition, F RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = FileHttpRequestMessageFactory.SetMetadata(uri, serverTimeout, accessCondition, cnt, ctx); + StorageRequestMessage msg = FileHttpRequestMessageFactory.SetMetadata(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); FileHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -2343,10 +1892,8 @@ private RESTCommand PutRangeImpl(Stream rangeData, long startOffset, s RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(rangeData, offset, length, contentMD5, cmd, ctx); - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.PutRange(uri, serverTimeout, fileRange, fileRangeWrite, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.PutRange(uri, serverTimeout, fileRange, fileRangeWrite, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Created, resp, NullType.Value, cmd, ex); @@ -2385,9 +1932,7 @@ private RESTCommand ClearRangeImpl(long startOffset, long length, Acce RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.PutRange(uri, serverTimeout, range, fileWrite, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.PutRange(uri, serverTimeout, range, fileWrite, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Created, resp, NullType.Value, cmd, ex); @@ -2417,11 +1962,9 @@ internal RESTCommand StartCopyImpl(Uri source, AccessCondition sourceAcc RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = FileHttpRequestMessageFactory.CopyFrom(uri, serverTimeout, source, sourceAccessCondition, destAccessCondition, cnt, ctx); + StorageRequestMessage msg = FileHttpRequestMessageFactory.CopyFrom(uri, serverTimeout, source, sourceAccessCondition, destAccessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); FileHttpRequestMessageFactory.AddMetadata(msg, attributes.Metadata); return msg; }; @@ -2452,9 +1995,7 @@ internal RESTCommand AbortCopyImpl(string copyId, AccessCondition acce RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.attributes.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.AbortCopy(uri, serverTimeout, copyId, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.AbortCopy(uri, serverTimeout, copyId, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.NoContent, resp, NullType.Value, cmd, ex); return putCmd; diff --git a/Lib/WindowsRuntime/File/CloudFileClient.cs b/Lib/WindowsRuntime/File/CloudFileClient.cs index 0ccf4ae12..875160fe8 100644 --- a/Lib/WindowsRuntime/File/CloudFileClient.cs +++ b/Lib/WindowsRuntime/File/CloudFileClient.cs @@ -29,14 +29,14 @@ namespace Microsoft.WindowsAzure.Storage.File using System.Net; using System.Net.Http; using System.Threading.Tasks; -#if ASPNET_K using System.Threading; +#if ASPNET_K #else using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; #endif - public sealed partial class CloudFileClient + public partial class CloudFileClient { /// /// Gets or sets the authentication scheme to use to sign HTTP requests. @@ -54,42 +54,13 @@ public AuthenticationScheme AuthenticationScheme } } - /// - /// Gets the authentication handler used to sign requests. - /// - /// Authentication handler. - internal HttpClientHandler AuthenticationHandler - { - get - { - HttpClientHandler authenticationHandler; - if (this.Credentials.IsSharedKey) - { - authenticationHandler = new SharedKeyAuthenticationHttpHandler( - this.GetCanonicalizer(), - this.Credentials, - this.Credentials.AccountName); - } - else - { - authenticationHandler = new NoOpAuthenticationHttpHandler(); - } - - return authenticationHandler; - } - } - /// /// Returns a result segment containing a collection of shares. /// /// A continuation token returned by a previous listing operation. /// A result segment of shares. [DoesServiceRequest] -#if ASPNET_K - public Task ListSharesSegmentedAsync(FileContinuationToken currentToken) -#else - public IAsyncOperation ListSharesSegmentedAsync(FileContinuationToken currentToken) -#endif + public virtual Task ListSharesSegmentedAsync(FileContinuationToken currentToken) { return this.ListSharesSegmentedAsync(null, ShareListingDetails.None, null, currentToken, null, null); } @@ -101,11 +72,7 @@ public IAsyncOperation ListSharesSegmentedAsync(FileContinua /// A continuation token returned by a previous listing operation. /// A result segment of shares. [DoesServiceRequest] -#if ASPNET_K - public Task ListSharesSegmentedAsync(string prefix, FileContinuationToken currentToken) -#else - public IAsyncOperation ListSharesSegmentedAsync(string prefix, FileContinuationToken currentToken) -#endif + public virtual Task ListSharesSegmentedAsync(string prefix, FileContinuationToken currentToken) { return this.ListSharesSegmentedAsync(prefix, ShareListingDetails.None, null, currentToken, null, null); } @@ -121,29 +88,11 @@ public IAsyncOperation ListSharesSegmentedAsync(string prefi /// A continuation token returned by a previous listing operation. /// A result segment of shares. [DoesServiceRequest] -#if ASPNET_K - public Task ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext) + public virtual Task ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext) { return this.ListSharesSegmentedAsync(prefix, detailsIncluded, maxResults, currentToken, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext) - { - return AsyncInfo.Run(async (token) => - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this); - ResultSegment resultSegment = await Executor.ExecuteAsync( - this.ListSharesImpl(prefix, detailsIncluded, currentToken, maxResults, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token); - - return new ShareResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken); - }); - } -#endif -#if ASPNET_K /// /// Returns a result segment containing a collection of shares /// whose names begin with the specified prefix. @@ -156,7 +105,7 @@ public IAsyncOperation ListSharesSegmentedAsync(string prefi /// A to observe while waiting for a task to complete. /// A result segment of shares. [DoesServiceRequest] - public Task ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return Task.Run(async () => { @@ -170,17 +119,13 @@ public Task ListSharesSegmentedAsync(string prefix, ShareLis return new ShareResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken); }, cancellationToken); } -#endif + /// /// Gets the properties of the File service. /// /// The File service properties. [DoesServiceRequest] -#if ASPNET_K - public Task GetServicePropertiesAsync() -#else - public IAsyncOperation GetServicePropertiesAsync() -#endif + public virtual Task GetServicePropertiesAsync() { return this.GetServicePropertiesAsync(null /* options */, null /* operationContext */); } @@ -192,27 +137,11 @@ public IAsyncOperation GetServicePropertiesAsync() /// An object that represents the context for the current operation. /// The File service properties. [DoesServiceRequest] -#if ASPNET_K - public Task GetServicePropertiesAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task GetServicePropertiesAsync(FileRequestOptions options, OperationContext operationContext) { return this.GetServicePropertiesAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation GetServicePropertiesAsync(FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run( - async (token) => await Executor.ExecuteAsync( - this.GetServicePropertiesImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Gets the properties of the File service. /// @@ -221,7 +150,7 @@ public IAsyncOperation GetServicePropertiesAsync(FileRequ /// A to observe while waiting for a task to complete. /// The File service properties. [DoesServiceRequest] - public Task GetServicePropertiesAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServicePropertiesAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this); operationContext = operationContext ?? new OperationContext(); @@ -233,8 +162,6 @@ public Task GetServicePropertiesAsync(FileRequestOptions operationContext, cancellationToken), cancellationToken); } -#endif - /// /// Sets the properties of the File service. @@ -242,11 +169,7 @@ public Task GetServicePropertiesAsync(FileRequestOptions /// The File service properties. /// The properties of the File service. [DoesServiceRequest] -#if ASPNET_K - public Task SetServicePropertiesAsync(FileServiceProperties properties) -#else - public IAsyncAction SetServicePropertiesAsync(FileServiceProperties properties) -#endif + public virtual Task SetServicePropertiesAsync(FileServiceProperties properties) { return this.SetServicePropertiesAsync(properties, null /* options */, null /* operationContext */); } @@ -259,25 +182,11 @@ public IAsyncAction SetServicePropertiesAsync(FileServiceProperties properties) /// An object that represents the context for the current operation. /// The properties of the File service. [DoesServiceRequest] -#if ASPNET_K - public Task SetServicePropertiesAsync(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext) + public virtual Task SetServicePropertiesAsync(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext) { return this.SetServicePropertiesAsync(properties, requestOptions, operationContext, CancellationToken.None); } -#else - public IAsyncAction SetServicePropertiesAsync(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(requestOptions, this); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetServicePropertiesImpl(properties, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Gets the properties of the File service. /// @@ -287,7 +196,7 @@ public IAsyncAction SetServicePropertiesAsync(FileServiceProperties properties, /// A to observe while waiting for a task to complete. /// The properties of the File service. [DoesServiceRequest] - public Task SetServicePropertiesAsync(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetServicePropertiesAsync(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -297,7 +206,6 @@ public Task SetServicePropertiesAsync(FileServiceProperties properties, FileRequ operationContext, cancellationToken), cancellationToken); } -#endif /// /// Core implementation for the ListShares method. @@ -320,9 +228,7 @@ private RESTCommand> ListSharesImpl(string prefix, options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommonUtility.GetListingLocationMode(currentToken); getCmd.RetrieveResponseStream = true; - getCmd.Handler = this.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.List(uri, serverTimeout, listingContext, detailsIncluded, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.List(uri, serverTimeout, listingContext, detailsIncluded, cnt, ctx, this.GetCanonicalizer(), this.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { @@ -355,10 +261,8 @@ private RESTCommand GetServicePropertiesImpl(FileRequestO RESTCommand retCmd = new RESTCommand(this.Credentials, this.StorageUri); retCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.GetServiceProperties(uri, serverTimeout, ctx); + retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.GetServiceProperties(uri, serverTimeout, ctx, this.GetCanonicalizer(), this.Credentials); retCmd.RetrieveResponseStream = true; - retCmd.Handler = this.AuthenticationHandler; - retCmd.BuildClient = HttpClientFactory.BuildHttpClient; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); @@ -386,12 +290,10 @@ private RESTCommand SetServicePropertiesImpl(FileServiceProperties pro RESTCommand retCmd = new RESTCommand(this.Credentials, this.StorageUri); requestOptions.ApplyToStorageCommand(retCmd); - retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.SetServiceProperties(uri, serverTimeout, cnt, ctx); + retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => FileHttpRequestMessageFactory.SetServiceProperties(uri, serverTimeout, cnt, ctx, this.GetCanonicalizer(), this.Credentials); retCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, null /* md5 */, cmd, ctx); retCmd.StreamToDispose = memoryStream; retCmd.RetrieveResponseStream = true; - retCmd.Handler = this.AuthenticationHandler; - retCmd.BuildClient = HttpClientFactory.BuildHttpClient; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, null /* retVal */, cmd, ex); diff --git a/Lib/WindowsRuntime/File/CloudFileDirectory.cs b/Lib/WindowsRuntime/File/CloudFileDirectory.cs index e15e906be..98bd73917 100644 --- a/Lib/WindowsRuntime/File/CloudFileDirectory.cs +++ b/Lib/WindowsRuntime/File/CloudFileDirectory.cs @@ -26,25 +26,21 @@ namespace Microsoft.WindowsAzure.Storage.File using System.Linq; using System.Net; using System.Net.Http; + using System.Threading; using System.Threading.Tasks; #if ASPNET_K - using System.Threading; #else using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; #endif - public sealed partial class CloudFileDirectory + public partial class CloudFileDirectory { /// /// Creates the directory. /// [DoesServiceRequest] -#if ASPNET_K - public Task CreateAsync() -#else - public IAsyncAction CreateAsync() -#endif + public virtual Task CreateAsync() { return this.CreateAsync(null, null); } @@ -55,24 +51,11 @@ public IAsyncAction CreateAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task CreateAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task CreateAsync(FileRequestOptions options, OperationContext operationContext) { return this.CreateAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncAction CreateAsync(FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.CreateDirectoryImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Creates the directory. /// @@ -80,7 +63,7 @@ public IAsyncAction CreateAsync(FileRequestOptions options, OperationContext ope /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task CreateAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async() => await Executor.ExecuteAsyncNullReturn( @@ -89,18 +72,14 @@ public Task CreateAsync(FileRequestOptions options, OperationContext operationCo operationContext, cancellationToken), cancellationToken); } -#endif /// /// Creates the directory if it does not already exist. /// /// true if the directory did not already exist and was created; otherwise, false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] -#if ASPNET_K - public Task CreateIfNotExistsAsync() -#else - public IAsyncOperation CreateIfNotExistsAsync() -#endif + public virtual Task CreateIfNotExistsAsync() { return this.CreateIfNotExistsAsync(null, null); } @@ -111,9 +90,9 @@ public IAsyncOperation CreateIfNotExistsAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. /// true if the directory did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] -#if ASPNET_K - public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext) { return this.CreateIfNotExistsAsync(options, operationContext, CancellationToken.None); } @@ -125,18 +104,12 @@ public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationCo /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// true if the directory did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext) -#endif + public virtual Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); -#if ASPNET_K return Task.Run(async () => -#else - return AsyncInfo.Run(async (cancellationToken) => -#endif { bool exists = await Executor.ExecuteAsync( this.ExistsImpl(modifiedOptions), @@ -171,22 +144,14 @@ await Executor.ExecuteAsync( throw; } } -#if ASPNET_K }, cancellationToken); -#else - }); -#endif } - /// - /// Deletes the directory. - /// - [DoesServiceRequest] -#if ASPNET_K - public Task DeleteAsync() -#else - public IAsyncAction DeleteAsync() -#endif + /// + /// Deletes the directory. + /// + [DoesServiceRequest] + public virtual Task DeleteAsync() { return this.DeleteAsync(null, null, null); } @@ -198,24 +163,11 @@ public IAsyncAction DeleteAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DeleteAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.DeleteDirectoryImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Deletes the directory. /// @@ -224,7 +176,7 @@ public IAsyncAction DeleteAsync(AccessCondition accessCondition, FileRequestOpti /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -233,18 +185,13 @@ public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions opti operationContext, cancellationToken), cancellationToken); } -#endif /// /// Deletes the directory if it already exists. /// /// true if the directory already existed and was deleted; otherwise, false. [DoesServiceRequest] -#if ASPNET_K - public Task DeleteIfExistsAsync() -#else - public IAsyncOperation DeleteIfExistsAsync() -#endif + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(null, null, null); } @@ -257,8 +204,7 @@ public IAsyncOperation DeleteIfExistsAsync() /// An object that represents the context for the current operation. /// true if the directory already existed and was deleted; otherwise, false. [DoesServiceRequest] -#if ASPNET_K - public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DeleteIfExistsAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -272,17 +218,10 @@ public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileReque /// A to observe while waiting for a task to complete. /// true if the directory already existed and was deleted; otherwise, false. [DoesServiceRequest] - public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) -#endif + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); -#if ASPNET_K return Task.Run(async () => -#else - return AsyncInfo.Run(async (cancellationToken) => -#endif { bool exists = await Executor.ExecuteAsync( this.ExistsImpl(modifiedOptions), @@ -316,23 +255,15 @@ await Executor.ExecuteAsync( throw; } } -#if ASPNET_K }, cancellationToken); -#else - }); -#endif } - /// - /// Checks existence of the directory. - /// - /// true if the directory exists. - [DoesServiceRequest] -#if ASPNET_K - public Task ExistsAsync() -#else - public IAsyncOperation ExistsAsync() -#endif + /// + /// Checks existence of the directory. + /// + /// true if the directory exists. + [DoesServiceRequest] + public virtual Task ExistsAsync() { return this.ExistsAsync(null, null); } @@ -344,24 +275,11 @@ public IAsyncOperation ExistsAsync() /// An object that represents the context for the current operation. /// true if the directory exists. [DoesServiceRequest] -#if ASPNET_K - public Task ExistsAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task ExistsAsync(FileRequestOptions options, OperationContext operationContext) { return this.ExistsAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ExistsAsync(FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.ExistsImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Checks existence of the directory. /// @@ -370,7 +288,7 @@ public IAsyncOperation ExistsAsync(FileRequestOptions options, OperationCo /// A to observe while waiting for a task to complete. /// true if the directory exists. [DoesServiceRequest] - public Task ExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -379,17 +297,12 @@ public Task ExistsAsync(FileRequestOptions options, OperationContext opera operationContext, cancellationToken), cancellationToken); } -#endif /// /// Populates a directory's properties and metadata. /// [DoesServiceRequest] -#if ASPNET_K - public Task FetchAttributesAsync() -#else - public IAsyncAction FetchAttributesAsync() -#endif + public virtual Task FetchAttributesAsync() { return this.FetchAttributesAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -401,24 +314,11 @@ public IAsyncAction FetchAttributesAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.FetchAttributesAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.FetchAttributesImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Populates a directory's properties and metadata. /// @@ -427,7 +327,7 @@ public IAsyncAction FetchAttributesAsync(AccessCondition accessCondition, FileRe /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -436,7 +336,6 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOpt operationContext, cancellationToken), cancellationToken); } -#endif /// /// Returns a result segment containing a collection of file items @@ -445,11 +344,7 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOpt /// A continuation token returned by a previous listing operation. /// A result segment containing objects that implement . [DoesServiceRequest] -#if ASPNET_K - public Task ListFilesAndDirectoriesSegmentedAsync(FileContinuationToken currentToken) -#else - public IAsyncOperation ListFilesAndDirectoriesSegmentedAsync(FileContinuationToken currentToken) -#endif + public virtual Task ListFilesAndDirectoriesSegmentedAsync(FileContinuationToken currentToken) { return this.ListFilesAndDirectoriesSegmentedAsync(null /* maxResults */, currentToken, null /* options */, null /* operationContext */); } @@ -465,29 +360,11 @@ public IAsyncOperation ListFilesAndDirectoriesSegmentedAsync( /// An object that represents the context for the current operation. /// A file result segment. [DoesServiceRequest] -#if ASPNET_K - public Task ListFilesAndDirectoriesSegmentedAsync(int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext) + public virtual Task ListFilesAndDirectoriesSegmentedAsync(int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext) { return this.ListFilesAndDirectoriesSegmentedAsync(maxResults, currentToken, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ListFilesAndDirectoriesSegmentedAsync(int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => - { - ResultSegment resultSegment = await Executor.ExecuteAsync( - this.ListFilesAndDirectoriesImpl(maxResults, modifiedOptions, currentToken), - modifiedOptions.RetryPolicy, - operationContext, - token); - return new FileResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken); - }); - } -#endif - -#if ASPNET_K /// /// Returns a result segment containing a collection of file items /// in the share. @@ -500,7 +377,7 @@ public IAsyncOperation ListFilesAndDirectoriesSegmentedAsync( /// A to observe while waiting for a task to complete. /// A file result segment. [DoesServiceRequest] - public Task ListFilesAndDirectoriesSegmentedAsync(int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ListFilesAndDirectoriesSegmentedAsync(int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => @@ -514,17 +391,12 @@ public Task ListFilesAndDirectoriesSegmentedAsync(int? maxRes return new FileResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken); }, cancellationToken); } -#endif /// /// Updates the directory's metadata. /// [DoesServiceRequest] -#if ASPNET_K - public Task SetMetdataAsync() -#else - public IAsyncAction SetMetadataAsync() -#endif + public virtual Task SetMetdataAsync() { return this.SetMetadataAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -536,24 +408,11 @@ public IAsyncAction SetMetadataAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.SetMetadataAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetMetadataImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Updates the directory's metadata. /// @@ -562,7 +421,7 @@ public IAsyncAction SetMetadataAsync(AccessCondition accessCondition, FileReques /// An object that represents the context for the current operation. /// Cancellation Token [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -571,7 +430,6 @@ public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions operationContext, cancellationToken), cancellationToken); } -#endif /// /// Implementation for the Create method. @@ -583,11 +441,9 @@ private RESTCommand CreateDirectoryImpl(FileRequestOptions options) RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = DirectoryHttpRequestMessageFactory.Create(uri, serverTimeout, cnt, ctx); + StorageRequestMessage msg = DirectoryHttpRequestMessageFactory.Create(uri, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); DirectoryHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -612,9 +468,7 @@ private RESTCommand DeleteDirectoryImpl(AccessCondition accessConditio RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => DirectoryHttpRequestMessageFactory.Delete(uri, serverTimeout, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => DirectoryHttpRequestMessageFactory.Delete(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, NullType.Value, cmd, ex); return putCmd; @@ -630,9 +484,7 @@ private RESTCommand ExistsImpl(FileRequestOptions options) RESTCommand getCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(getCmd); - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => DirectoryHttpRequestMessageFactory.GetProperties(uri, serverTimeout, null, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => DirectoryHttpRequestMessageFactory.GetProperties(uri, serverTimeout, null, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { if (resp.StatusCode == HttpStatusCode.NotFound) @@ -659,9 +511,7 @@ private RESTCommand FetchAttributesImpl(AccessCondition accessConditio RESTCommand getCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(getCmd); - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => DirectoryHttpRequestMessageFactory.GetProperties(uri, serverTimeout, accessCondition, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => DirectoryHttpRequestMessageFactory.GetProperties(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex); @@ -693,9 +543,7 @@ private RESTCommand> ListFilesAndDirectoriesImpl(in options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommonUtility.GetListingLocationMode(currentToken); getCmd.RetrieveResponseStream = true; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => DirectoryHttpRequestMessageFactory.List(uri, serverTimeout, listingContext, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => DirectoryHttpRequestMessageFactory.List(uri, serverTimeout, listingContext, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { @@ -734,11 +582,9 @@ private RESTCommand SetMetadataImpl(AccessCondition accessCondition, F RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = DirectoryHttpRequestMessageFactory.SetMetadata(uri, serverTimeout, accessCondition, cnt, ctx); + StorageRequestMessage msg = DirectoryHttpRequestMessageFactory.SetMetadata(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); DirectoryHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; diff --git a/Lib/WindowsRuntime/File/CloudFileShare.cs b/Lib/WindowsRuntime/File/CloudFileShare.cs index 1713a05b0..ee5a531b1 100644 --- a/Lib/WindowsRuntime/File/CloudFileShare.cs +++ b/Lib/WindowsRuntime/File/CloudFileShare.cs @@ -27,26 +27,21 @@ namespace Microsoft.WindowsAzure.Storage.File using System.Collections.Generic; using System.Net; using System.Net.Http; -#if ASPNET_K using System.Threading; using System.Threading.Tasks; +#if ASPNET_K #else using System.Runtime.InteropServices.WindowsRuntime; - using System.Threading.Tasks; using Windows.Foundation; #endif - public sealed partial class CloudFileShare + public partial class CloudFileShare { /// /// Creates the share. /// [DoesServiceRequest] -#if ASPNET_K - public Task CreateAsync() -#else - public IAsyncAction CreateAsync() -#endif + public virtual Task CreateAsync() { return this.CreateAsync(null, null); } @@ -57,24 +52,11 @@ public IAsyncAction CreateAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task CreateAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task CreateAsync(FileRequestOptions options, OperationContext operationContext) { return this.CreateAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncAction CreateAsync(FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.CreateShareImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Creates the share. /// @@ -82,7 +64,7 @@ public IAsyncAction CreateAsync(FileRequestOptions options, OperationContext ope /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task CreateAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -91,18 +73,14 @@ public Task CreateAsync(FileRequestOptions options, OperationContext operationCo operationContext, cancellationToken), cancellationToken); } -#endif /// /// Creates the share if it does not already exist. /// /// true if the share did not already exist and was created; otherwise, false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] -#if ASPNET_K - public Task CreateIfNotExistsAsync() -#else - public IAsyncOperation CreateIfNotExistsAsync() -#endif + public virtual Task CreateIfNotExistsAsync() { return this.CreateIfNotExistsAsync(null, null); } @@ -113,9 +91,9 @@ public IAsyncOperation CreateIfNotExistsAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. /// true if the share did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] -#if ASPNET_K - public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext) { return this.CreateIfNotExistsAsync(options, operationContext, CancellationToken.None); } @@ -127,24 +105,16 @@ public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationCo /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// true if the share did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext) -#endif + public virtual Task CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); -#if ASPNET_K return Task.Run(async () => { bool exists = await this.ExistsAsync(modifiedOptions, operationContext, cancellationToken); -#else - return AsyncInfo.Run(async (token) => - { - bool exists = await this.ExistsAsync(modifiedOptions, operationContext).AsTask(token); -#endif if (exists) { @@ -153,11 +123,7 @@ public IAsyncOperation CreateIfNotExistsAsync(FileRequestOptions options, try { -#if ASPNET_K await this.CreateAsync(modifiedOptions, operationContext, cancellationToken); -#else - await this.CreateAsync(modifiedOptions, operationContext).AsTask(token); -#endif return true; } catch (Exception) @@ -180,22 +146,14 @@ public IAsyncOperation CreateIfNotExistsAsync(FileRequestOptions options, throw; } } -#if ASPNET_K }, cancellationToken); -#else - }); -#endif } - /// - /// Deletes the share. - /// - [DoesServiceRequest] -#if ASPNET_K - public Task DeleteAsync() -#else - public IAsyncAction DeleteAsync() -#endif + /// + /// Deletes the share. + /// + [DoesServiceRequest] + public virtual Task DeleteAsync() { return this.DeleteAsync(null, null, null); } @@ -207,24 +165,11 @@ public IAsyncAction DeleteAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DeleteAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.DeleteShareImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Deletes the share. /// @@ -233,7 +178,7 @@ public IAsyncAction DeleteAsync(AccessCondition accessCondition, FileRequestOpti /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -242,18 +187,13 @@ public Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions opti operationContext, cancellationToken), cancellationToken); } -#endif /// /// Deletes the share if it already exists. /// /// true if the share already existed and was deleted; otherwise, false. [DoesServiceRequest] -#if ASPNET_K - public Task DeleteIfExistsAsync() -#else - public IAsyncOperation DeleteIfExistsAsync() -#endif + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(null, null, null); } @@ -266,8 +206,7 @@ public IAsyncOperation DeleteIfExistsAsync() /// An object that represents the context for the current operation. /// true if the share already existed and was deleted; otherwise, false. [DoesServiceRequest] -#if ASPNET_K - public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.DeleteIfExistsAsync(accessCondition, options, operationContext, CancellationToken.None); } @@ -280,23 +219,14 @@ public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileReque /// A to observe while waiting for a task to complete. /// true if the share already existed and was deleted; otherwise, false. [DoesServiceRequest] - public Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) -#endif + public virtual Task DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); -#if ASPNET_K return Task.Run(async () => { bool exists = await this.ExistsAsync(modifiedOptions, operationContext, cancellationToken); -#else - return AsyncInfo.Run(async (token) => - { - bool exists = await this.ExistsAsync(modifiedOptions, operationContext).AsTask(token); -#endif if (!exists) { @@ -305,11 +235,7 @@ public IAsyncOperation DeleteIfExistsAsync(AccessCondition accessCondition try { -#if ASPNET_K await this.DeleteAsync(accessCondition, modifiedOptions, operationContext, cancellationToken); -#else - await this.DeleteAsync(accessCondition, modifiedOptions, operationContext).AsTask(token); -#endif return true; } catch (Exception) @@ -332,11 +258,7 @@ public IAsyncOperation DeleteIfExistsAsync(AccessCondition accessCondition throw; } } -#if ASPNET_K }, cancellationToken); -#else - }); -#endif } /// @@ -344,11 +266,7 @@ public IAsyncOperation DeleteIfExistsAsync(AccessCondition accessCondition /// /// true if the share exists. [DoesServiceRequest] -#if ASPNET_K - public Task ExistsAsync() -#else - public IAsyncOperation ExistsAsync() -#endif + public virtual Task ExistsAsync() { return this.ExistsAsync(null, null); } @@ -360,24 +278,11 @@ public IAsyncOperation ExistsAsync() /// An object that represents the context for the current operation. /// true if the share exists. [DoesServiceRequest] -#if ASPNET_K - public Task ExistsAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task ExistsAsync(FileRequestOptions options, OperationContext operationContext) { return this.ExistsAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ExistsAsync(FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.ExistsImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Checks existence of the share. @@ -387,7 +292,7 @@ public IAsyncOperation ExistsAsync(FileRequestOptions options, OperationCo /// A to observe while waiting for a task to complete. /// true if the share exists. [DoesServiceRequest] - public Task ExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -396,17 +301,13 @@ public Task ExistsAsync(FileRequestOptions options, OperationContext opera operationContext, cancellationToken), cancellationToken); } -#endif /// /// Retrieves the share's attributes. /// + /// A that represents an asynchronous action. [DoesServiceRequest] -#if ASPNET_K - public Task FetchAttributesAsync() -#else - public IAsyncAction FetchAttributesAsync() -#endif + public virtual Task FetchAttributesAsync() { return this.FetchAttributesAsync(null, null, null); } @@ -417,26 +318,13 @@ public IAsyncAction FetchAttributesAsync() /// An object that represents the access conditions for the share. If null, no condition is used. /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. + /// A that represents an asynchronous action. [DoesServiceRequest] -#if ASPNET_K - public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.FetchAttributesAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.FetchAttributesImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif - -#if ASPNET_K /// /// Retrieves the share's attributes. /// @@ -444,8 +332,9 @@ public IAsyncAction FetchAttributesAsync(AccessCondition accessCondition, FileRe /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. + /// A that represents an asynchronous action. [DoesServiceRequest] - public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -454,20 +343,14 @@ public Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOpt operationContext, cancellationToken), cancellationToken); } -#endif /// /// Sets permissions for the share. /// /// The permissions to apply to the share. - /// An that represents an asynchronous action. - [DoesServiceRequest] -#if ASPNET_K /// A that represents an asynchronous action. - public Task SetPermissionsAsync(FileSharePermissions permissions) -#else - public IAsyncAction SetPermissionsAsync(FileSharePermissions permissions) -#endif + [DoesServiceRequest] + public virtual Task SetPermissionsAsync(FileSharePermissions permissions) { return this.SetPermissionsAsync(permissions, null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -479,27 +362,13 @@ public IAsyncAction SetPermissionsAsync(FileSharePermissions permissions) /// An object that represents the access conditions for the share. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. - /// An that represents an asynchronous action. - [DoesServiceRequest] -#if ASPNET_K /// A that represents an asynchronous action. - public Task SetPermissionsAsync(FileSharePermissions permissions, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task SetPermissionsAsync(FileSharePermissions permissions, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.SetPermissionsAsync(permissions, accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction SetPermissionsAsync(FileSharePermissions permissions, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetPermissionsImpl(permissions, accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Sets permissions for the share. /// @@ -510,7 +379,7 @@ public IAsyncAction SetPermissionsAsync(FileSharePermissions permissions, Access /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetPermissionsAsync(FileSharePermissions permissions, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetPermissionsAsync(FileSharePermissions permissions, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -519,59 +388,39 @@ public Task SetPermissionsAsync(FileSharePermissions permissions, AccessConditio operationContext, cancellationToken), cancellationToken); } -#endif /// /// Updates the share's properties. /// - /// An that represents an asynchronous action. - [DoesServiceRequest] -#if ASPNET_K /// A that represents an asynchronous action. - public Task SetPropertiesAsync() -#else - public IAsyncAction SetPropertiesAsync() -#endif + [DoesServiceRequest] + public virtual Task SetPropertiesAsync() { return this.SetPropertiesAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } - /// /// Updates the share's properties. /// /// An object that represents the access conditions for the share. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. - /// An that represents an asynchronous action. + /// A that represents an asynchronous action. [DoesServiceRequest] -#if ASPNET_K - public Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.SetPropertiesAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetPropertiesImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Updates the share's properties. /// /// An object that represents the access conditions for the share. If null, no condition is used. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. - /// An that represents an asynchronous action. + /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -580,19 +429,13 @@ public Task SetPropertiesAsync(AccessCondition accessCondition, FileRequestOptio operationContext, cancellationToken), cancellationToken); } -#endif - /// /// Gets the permissions settings for the share. /// /// The share's permissions. [DoesServiceRequest] -#if ASPNET_K - public Task GetPermissionsAsync() -#else - public IAsyncOperation GetPermissionsAsync() -#endif + public virtual Task GetPermissionsAsync() { return this.GetPermissionsAsync(null /* accessCondition */, null /* options */, null /* operationContext */); } @@ -605,25 +448,11 @@ public IAsyncOperation GetPermissionsAsync() /// An object that represents the context for the current operation. /// The share's permissions. [DoesServiceRequest] -#if ASPNET_K - public Task GetPermissionsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task GetPermissionsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.GetPermissionsAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - - public IAsyncOperation GetPermissionsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.GetPermissionsImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Gets the permissions settings for the share. /// @@ -632,7 +461,7 @@ public IAsyncOperation GetPermissionsAsync(AccessCondition /// An object that represents the context for the current operation. /// The share's permissions. [DoesServiceRequest] - public Task GetPermissionsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetPermissionsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -641,18 +470,13 @@ public Task GetPermissionsAsync(AccessCondition accessCond operationContext, cancellationToken), cancellationToken); } -#endif /// /// Gets the stats of share. /// /// The share stats. [DoesServiceRequest] -#if ASPNET_K - public Task GetStatsAsync() -#else - public IAsyncOperation GetStatsAsync() -#endif + public virtual Task GetStatsAsync() { return this.GetStatsAsync(null /* options */, null /* operationContext */); } @@ -664,27 +488,11 @@ public IAsyncOperation GetStatsAsync() /// An object that represents the context for the current operation. /// The share stats. [DoesServiceRequest] -#if ASPNET_K - public Task GetStatsAsync(FileRequestOptions options, OperationContext operationContext) + public virtual Task GetStatsAsync(FileRequestOptions options, OperationContext operationContext) { return this.GetStatsAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation GetStatsAsync(FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run( - async (token) => await Executor.ExecuteAsync( - this.GetStatsImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Gets the stats of the share. /// @@ -692,7 +500,7 @@ public IAsyncOperation GetStatsAsync(FileRequestOptions options, Ope /// An object that represents the context for the current operation. /// The share stats. [DoesServiceRequest] - public Task GetStatsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetStatsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsync( @@ -701,17 +509,12 @@ public Task GetStatsAsync(FileRequestOptions options, OperationConte operationContext, cancellationToken), cancellationToken); } -#endif - /// - /// Sets the share's user-defined metadata. - /// + /// + /// Sets the share's user-defined metadata. + /// [DoesServiceRequest] -#if ASPNET_K - public Task SetMetadataAsync() -#else - public IAsyncAction SetMetadataAsync() -#endif + public virtual Task SetMetadataAsync() { return this.SetMetadataAsync(null, null, null); } @@ -723,24 +526,11 @@ public IAsyncAction SetMetadataAsync() /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. [DoesServiceRequest] -#if ASPNET_K - public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { return this.SetMetadataAsync(accessCondition, options, operationContext, CancellationToken.None); } -#else - public IAsyncAction SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) - { - FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetMetadataImpl(accessCondition, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K /// /// Sets the share's user-defined metadata. /// @@ -749,7 +539,7 @@ public IAsyncAction SetMetadataAsync(AccessCondition accessCondition, FileReques /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient); return Task.Run(async () => await Executor.ExecuteAsyncNullReturn( @@ -758,7 +548,6 @@ public Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions operationContext, cancellationToken), cancellationToken); } -#endif /// /// Implementation for the Create method. @@ -770,11 +559,9 @@ private RESTCommand CreateShareImpl(FileRequestOptions options) RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = ShareHttpRequestMessageFactory.Create(uri, this.Properties, serverTimeout, cnt, ctx); + StorageRequestMessage msg = ShareHttpRequestMessageFactory.Create(uri, this.Properties, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); ShareHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -800,9 +587,7 @@ private RESTCommand DeleteShareImpl(AccessCondition accessCondition, F RESTCommand deleteCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(deleteCmd); - deleteCmd.Handler = this.ServiceClient.AuthenticationHandler; - deleteCmd.BuildClient = HttpClientFactory.BuildHttpClient; - deleteCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.Delete(uri, serverTimeout, accessCondition, cnt, ctx); + deleteCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.Delete(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); deleteCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, NullType.Value, cmd, ex); return deleteCmd; @@ -820,9 +605,7 @@ private RESTCommand FetchAttributesImpl(AccessCondition accessConditio options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.GetProperties(uri, serverTimeout, accessCondition, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.GetProperties(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex); @@ -845,9 +628,7 @@ private RESTCommand ExistsImpl(FileRequestOptions options) options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.GetProperties(uri, serverTimeout, null, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.GetProperties(uri, serverTimeout, null, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { if (resp.StatusCode == HttpStatusCode.NotFound) @@ -879,9 +660,7 @@ private RESTCommand SetPermissionsImpl(FileSharePermissions acl, Acces RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.SetAcl(uri, serverTimeout, FileSharePublicAccessType.Off, accessCondition, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.SetAcl(uri, serverTimeout, FileSharePublicAccessType.Off, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, null /* md5 */, cmd, ctx); putCmd.StreamToDispose = memoryStream; putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => @@ -909,9 +688,7 @@ private RESTCommand GetPermissionsImpl(AccessCondition acc options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; getCmd.RetrieveResponseStream = true; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.GetAcl(uri, serverTimeout, accessCondition, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.GetAcl(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); @@ -941,10 +718,8 @@ private RESTCommand GetStatsImpl(FileRequestOptions requestOptions) RESTCommand retCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); requestOptions.ApplyToStorageCommand(retCmd); retCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.GetStats(uri, serverTimeout, ctx); + retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.GetStats(uri, serverTimeout, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); retCmd.RetrieveResponseStream = true; - retCmd.Handler = this.ServiceClient.AuthenticationHandler; - retCmd.BuildClient = HttpClientFactory.BuildHttpClient; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); retCmd.PostProcessResponse = (cmd, resp, ctx) => Task.Factory.StartNew(() => ShareHttpResponseParsers.ReadShareStats(cmd.ResponseStream)); return retCmd; @@ -961,11 +736,9 @@ private RESTCommand SetMetadataImpl(AccessCondition accessCondition, F RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = ShareHttpRequestMessageFactory.SetMetadata(uri, serverTimeout, accessCondition, cnt, ctx); + StorageRequestMessage msg = ShareHttpRequestMessageFactory.SetMetadata(uri, serverTimeout, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); ShareHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -990,11 +763,9 @@ private RESTCommand SetPropertiesImpl(AccessCondition accessCondition, RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = ShareHttpRequestMessageFactory.SetProperties(uri, serverTimeout, this.Properties, accessCondition, cnt, ctx); + StorageRequestMessage msg = ShareHttpRequestMessageFactory.SetProperties(uri, serverTimeout, this.Properties, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); ShareHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; diff --git a/Lib/WindowsRuntime/File/FileReadStream.cs b/Lib/WindowsRuntime/File/FileReadStream.cs index 4a1f4f49b..0af0aae2c 100644 --- a/Lib/WindowsRuntime/File/FileReadStream.cs +++ b/Lib/WindowsRuntime/File/FileReadStream.cs @@ -136,7 +136,7 @@ private async Task DispatchReadASync(byte[] buffer, int offset, int count) { this.internalBuffer.SetLength(0); await this.file.DownloadRangeToStreamAsync( - this.internalBuffer.AsOutputStream(), + this.internalBuffer, this.currentOffset, this.GetReadSize(), null /* accessCondition */, diff --git a/Lib/WindowsRuntime/File/FileWriteStream.cs b/Lib/WindowsRuntime/File/FileWriteStream.cs index 3f4277982..880ef80d5 100644 --- a/Lib/WindowsRuntime/File/FileWriteStream.cs +++ b/Lib/WindowsRuntime/File/FileWriteStream.cs @@ -195,11 +195,7 @@ protected override void Dispose(bool disposing) /// Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying file, and commits the file. /// /// A task that represents the asynchronous commit operation. -#if ASPNET_K public override async Task CommitAsync() -#else - public async Task CommitAsync() -#endif { await this.FlushAsync(); this.committed = true; @@ -258,7 +254,7 @@ private async Task WriteRangeAsync(Stream rangeData, long offset, string content { this.noPendingWritesEvent.Increment(); await this.parallelOperationSemaphore.WaitAsync(); - Task writePagesTask = this.file.WriteRangeAsync(rangeData.AsInputStream(), offset, contentMD5, this.accessCondition, this.options, this.operationContext).AsTask().ContinueWith(task => + Task writePagesTask = this.file.WriteRangeAsync(rangeData, offset, contentMD5, this.accessCondition, this.options, this.operationContext).ContinueWith(task => { if (task.Exception != null) { diff --git a/Lib/WindowsRuntime/File/FileWriteStreamHelper.cs b/Lib/WindowsRuntime/File/FileWriteStreamHelper.cs index 41b1223f3..0bc40246a 100644 --- a/Lib/WindowsRuntime/File/FileWriteStreamHelper.cs +++ b/Lib/WindowsRuntime/File/FileWriteStreamHelper.cs @@ -29,7 +29,7 @@ namespace Microsoft.WindowsAzure.Storage.File /// This class implements IRandomAccessStream and acts like a proxy between /// the caller and the actual Stream implementation. /// - internal class FileWriteStreamHelper : ICloudFileStream + internal class FileWriteStreamHelper { private FileWriteStream originalStream; private IOutputStream originalStreamAsOutputStream; diff --git a/Lib/WindowsRuntime/File/ICloudFileStream.cs b/Lib/WindowsRuntime/File/ICloudFileStream.cs index f849a494a..698454806 100644 --- a/Lib/WindowsRuntime/File/ICloudFileStream.cs +++ b/Lib/WindowsRuntime/File/ICloudFileStream.cs @@ -17,9 +17,12 @@ namespace Microsoft.WindowsAzure.Storage.File { -#if ASPNET_K using System.IO; using System.Threading; +#if !(ASPNET_K || PORTABLE) + using Windows.Foundation; + using Windows.Storage.Streams; +#endif using System.Threading.Tasks; public abstract class CloudFileStream : Stream @@ -29,23 +32,5 @@ public abstract class CloudFileStream : Stream /// /// A that represents an asynchronous action. public abstract Task CommitAsync(); - - internal Stream AsStreamForWrite() - { - return this; - } } -#else - using Windows.Foundation; - using Windows.Storage.Streams; - - public interface ICloudFileStream : IRandomAccessStream - { - /// - /// Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying file, and commits the file. - /// - /// An that represents an asynchronous action. - IAsyncAction CommitAsync(); - } -#endif } diff --git a/Lib/WindowsRuntime/File/Protocol/DirectoryHttpRequestMessageFactory.cs b/Lib/WindowsRuntime/File/Protocol/DirectoryHttpRequestMessageFactory.cs index a07221b08..46cad184f 100644 --- a/Lib/WindowsRuntime/File/Protocol/DirectoryHttpRequestMessageFactory.cs +++ b/Lib/WindowsRuntime/File/Protocol/DirectoryHttpRequestMessageFactory.cs @@ -18,7 +18,9 @@ namespace Microsoft.WindowsAzure.Storage.File.Protocol { using Microsoft.WindowsAzure.Storage; + using Microsoft.WindowsAzure.Storage.Auth; using Microsoft.WindowsAzure.Storage.Core; + using Microsoft.WindowsAzure.Storage.Core.Auth; using Microsoft.WindowsAzure.Storage.Shared.Protocol; using System; using System.Collections.Generic; @@ -32,10 +34,10 @@ internal static class DirectoryHttpRequestMessageFactory /// The absolute URI to the directory. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage Create(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Create(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder directoryBuilder = GetDirectoryUriQueryBuilder(); - return HttpRequestMessageFactory.Create(uri, timeout, directoryBuilder, content, operationContext); + return HttpRequestMessageFactory.Create(uri, timeout, directoryBuilder, content, operationContext, canonicalizer, credentials); } /// @@ -45,10 +47,10 @@ public static HttpRequestMessage Create(Uri uri, int? timeout, HttpContent conte /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Delete(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Delete(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder directoryBuilder = GetDirectoryUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, directoryBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, directoryBuilder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -60,11 +62,11 @@ public static HttpRequestMessage Delete(Uri uri, int? timeout, AccessCondition a /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage GetProperties(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetProperties(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder directoryBuilder = GetDirectoryUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.GetProperties(uri, timeout, directoryBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetProperties(uri, timeout, directoryBuilder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -76,11 +78,11 @@ public static HttpRequestMessage GetProperties(Uri uri, int? timeout, AccessCond /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder directoryBuilder = GetDirectoryUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, directoryBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, directoryBuilder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -92,7 +94,7 @@ public static HttpRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondit /// The server timeout interval. /// A set of parameters for the listing operation. /// A web request to use to perform the operation. - public static HttpRequestMessage List(Uri uri, int? timeout, FileListingContext listingContext, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage List(Uri uri, int? timeout, FileListingContext listingContext, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder directoryBuilder = GetDirectoryUriQueryBuilder(); directoryBuilder.Add(Constants.QueryConstants.Component, "list"); @@ -110,7 +112,7 @@ public static HttpRequestMessage List(Uri uri, int? timeout, FileListingContext } } - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, directoryBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, directoryBuilder, content, operationContext, canonicalizer, credentials); return request; } @@ -121,10 +123,10 @@ public static HttpRequestMessage List(Uri uri, int? timeout, FileListingContext /// The server timeout interval. /// The access condition to apply to the request. /// A web request for performing the operation. - public static HttpRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder directoryBuilder = GetDirectoryUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.SetMetadata(uri, timeout, directoryBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.SetMetadata(uri, timeout, directoryBuilder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -134,7 +136,7 @@ public static HttpRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondit /// /// The web request. /// The user-defined metadata. - public static void AddMetadata(HttpRequestMessage request, IDictionary metadata) + public static void AddMetadata(StorageRequestMessage request, IDictionary metadata) { HttpRequestMessageFactory.AddMetadata(request, metadata); } diff --git a/Lib/WindowsRuntime/File/Protocol/FileHttpRequestMessageFactory.cs b/Lib/WindowsRuntime/File/Protocol/FileHttpRequestMessageFactory.cs index 81cffb114..fc4330616 100644 --- a/Lib/WindowsRuntime/File/Protocol/FileHttpRequestMessageFactory.cs +++ b/Lib/WindowsRuntime/File/Protocol/FileHttpRequestMessageFactory.cs @@ -17,7 +17,9 @@ namespace Microsoft.WindowsAzure.Storage.File.Protocol { + using Microsoft.WindowsAzure.Storage.Auth; using Microsoft.WindowsAzure.Storage.Core; + using Microsoft.WindowsAzure.Storage.Core.Auth; using Microsoft.WindowsAzure.Storage.Core.Util; using Microsoft.WindowsAzure.Storage.Shared.Protocol; using System; @@ -38,9 +40,9 @@ internal static class FileHttpRequestMessageFactory /// for block files. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Create(Uri uri, int? timeout, FileProperties properties, long fileSize, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Create(Uri uri, int? timeout, FileProperties properties, long fileSize, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, null /* builder */, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, null /* builder */, content, operationContext, canonicalizer, credentials); if (properties.CacheControl != null) { @@ -90,11 +92,11 @@ public static HttpRequestMessage Create(Uri uri, int? timeout, FileProperties pr /// The server timeout interval. /// The access condition to apply to the request. /// A web request for performing the operation. - public static HttpRequestMessage GetProperties(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetProperties(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.GetProperties(uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetProperties(uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -106,11 +108,11 @@ public static HttpRequestMessage GetProperties(Uri uri, int? timeout, AccessCond /// The server timeout interval. /// The access condition to apply to the request. /// A web request for performing the operation. - public static HttpRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -122,9 +124,9 @@ public static HttpRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondit /// The server timeout interval. /// The access condition to apply to the request. /// A web request for performing the operation. - public static HttpRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.SetMetadata(uri, timeout, null /* builder */, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.SetMetadata(uri, timeout, null /* builder */, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -134,7 +136,7 @@ public static HttpRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondit /// /// The web request. /// The user-defined metadata. - public static void AddMetadata(HttpRequestMessage request, IDictionary metadata) + public static void AddMetadata(StorageRequestMessage request, IDictionary metadata) { HttpRequestMessageFactory.AddMetadata(request, metadata); } @@ -145,7 +147,7 @@ public static void AddMetadata(HttpRequestMessage request, IDictionaryThe web request. /// The metadata name. /// The metadata value. - public static void AddMetadata(HttpRequestMessage request, string name, string value) + public static void AddMetadata(StorageRequestMessage request, string name, string value) { HttpRequestMessageFactory.AddMetadata(request, name, value); } @@ -157,9 +159,9 @@ public static void AddMetadata(HttpRequestMessage request, string name, string v /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Delete(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Delete(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, null /* builder */, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, null /* builder */, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -170,7 +172,7 @@ public static HttpRequestMessage Delete(Uri uri, int? timeout, AccessCondition a /// Request /// Starting byte of the range /// Number of bytes in the range - private static void AddRange(HttpRequestMessage request, long? offset, long? count) + private static void AddRange(StorageRequestMessage request, long? offset, long? count) { if (count.HasValue) { @@ -199,11 +201,11 @@ private static void AddRange(HttpRequestMessage request, long? offset, long? cou /// The server timeout interval. /// The access condition to apply to the request. /// A web request for performing the operation. - public static HttpRequestMessage Get(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Get(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -217,7 +219,7 @@ public static HttpRequestMessage Get(Uri uri, int? timeout, AccessCondition acce /// The length of the data range over which to list file ranges, in bytes. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage ListRanges(Uri uri, int? timeout, long? offset, long? count, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage ListRanges(Uri uri, int? timeout, long? offset, long? count, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { if (offset.HasValue) { @@ -227,7 +229,7 @@ public static HttpRequestMessage ListRanges(Uri uri, int? timeout, long? offset, UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "rangelist"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials); AddRange(request, offset, count); request.ApplyAccessCondition(accessCondition); return request; @@ -241,12 +243,12 @@ public static HttpRequestMessage ListRanges(Uri uri, int? timeout, long? offset, /// The file's properties. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage SetProperties(Uri uri, int? timeout, FileProperties properties, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetProperties(Uri uri, int? timeout, FileProperties properties, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "properties"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); if (properties != null) { @@ -271,7 +273,7 @@ public static HttpRequestMessage SetProperties(Uri uri, int? timeout, FileProper /// The number of bytes to return, or null to return all bytes through the end of the file. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Get(Uri uri, int? timeout, long? offset, long? count, bool rangeContentMD5, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Get(Uri uri, int? timeout, long? offset, long? count, bool rangeContentMD5, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { if (offset.HasValue && offset.Value < 0) { @@ -284,7 +286,7 @@ public static HttpRequestMessage Get(Uri uri, int? timeout, long? offset, long? CommonUtility.AssertInBounds("count", count.Value, 1, Constants.MaxBlockSize); } - HttpRequestMessage request = Get(uri, timeout, accessCondition, content, operationContext); + StorageRequestMessage request = Get(uri, timeout, accessCondition, content, operationContext, canonicalizer, credentials); AddRange(request, offset, count); if (offset.HasValue && rangeContentMD5) @@ -302,12 +304,12 @@ public static HttpRequestMessage Get(Uri uri, int? timeout, long? offset, long? /// The new file size. Set this parameter to null to keep the existing file size. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Resize(Uri uri, int? timeout, long newFileSize, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Resize(Uri uri, int? timeout, long newFileSize, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "properties"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.Headers.Add(Constants.HeaderConstants.FileContentLengthHeader, newFileSize.ToString(NumberFormatInfo.InvariantInfo)); @@ -326,12 +328,12 @@ public static HttpRequestMessage Resize(Uri uri, int? timeout, long newFileSize, /// The corresponding Http content. /// An object that represents the context for the current operation. /// A web request to use to perform the operation. - public static HttpRequestMessage PutRange(Uri uri, int? timeout, FileRange fileRange, FileRangeWrite fileRangeWrite, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage PutRange(Uri uri, int? timeout, FileRange fileRange, FileRangeWrite fileRangeWrite, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "range"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.AddOptionalHeader(Constants.HeaderConstants.RangeHeader, fileRange.ToString()); request.Headers.Add(Constants.HeaderConstants.FileRangeWrite, fileRangeWrite.ToString()); @@ -349,9 +351,9 @@ public static HttpRequestMessage PutRange(Uri uri, int? timeout, FileRange fileR /// The access condition to apply to the source object. /// The access condition to apply to the destination file. /// A web request to use to perform the operation. - public static HttpRequestMessage CopyFrom(Uri uri, int? timeout, Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage CopyFrom(Uri uri, int? timeout, Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, null /* builder */, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, null /* builder */, content, operationContext, canonicalizer, credentials); request.Headers.Add(Constants.HeaderConstants.CopySourceHeader, source.AbsoluteUri); request.ApplyAccessCondition(destAccessCondition); @@ -365,10 +367,10 @@ public static HttpRequestMessage CopyFrom(Uri uri, int? timeout, Uri source, Acc /// /// The absolute URI to the service. /// The server timeout interval. - /// A HttpRequestMessage to get the service properties. - public static HttpRequestMessage GetServiceProperties(Uri uri, int? timeout, OperationContext operationContext) + /// A StorageRequestMessage to get the service properties. + public static StorageRequestMessage GetServiceProperties(Uri uri, int? timeout, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - return HttpRequestMessageFactory.GetServiceProperties(uri, timeout, operationContext); + return HttpRequestMessageFactory.GetServiceProperties(uri, timeout, operationContext, canonicalizer, credentials); } /// @@ -377,9 +379,9 @@ public static HttpRequestMessage GetServiceProperties(Uri uri, int? timeout, Ope /// The absolute URI to the service. /// The server timeout interval. /// A web request to set the service properties. - internal static HttpRequestMessage SetServiceProperties(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + internal static StorageRequestMessage SetServiceProperties(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - return HttpRequestMessageFactory.SetServiceProperties(uri, timeout, content, operationContext); + return HttpRequestMessageFactory.SetServiceProperties(uri, timeout, content, operationContext, canonicalizer, credentials); } /// @@ -391,13 +393,13 @@ internal static HttpRequestMessage SetServiceProperties(Uri uri, int? timeout, H /// The access condition to apply to the request. /// Only lease conditions are supported for this operation. /// A web request for performing the operation. - public static HttpRequestMessage AbortCopy(Uri uri, int? timeout, string copyId, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage AbortCopy(Uri uri, int? timeout, string copyId, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "copy"); builder.Add(Constants.QueryConstants.CopyId, copyId); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); request.Headers.Add(Constants.HeaderConstants.CopyActionHeader, Constants.HeaderConstants.CopyActionAbort); request.ApplyAccessCondition(accessCondition); diff --git a/Lib/WindowsRuntime/File/Protocol/ShareHttpRequestMessageFactory.cs b/Lib/WindowsRuntime/File/Protocol/ShareHttpRequestMessageFactory.cs index 1a4054929..43b214c48 100644 --- a/Lib/WindowsRuntime/File/Protocol/ShareHttpRequestMessageFactory.cs +++ b/Lib/WindowsRuntime/File/Protocol/ShareHttpRequestMessageFactory.cs @@ -18,7 +18,9 @@ namespace Microsoft.WindowsAzure.Storage.File.Protocol { using Microsoft.WindowsAzure.Storage; + using Microsoft.WindowsAzure.Storage.Auth; using Microsoft.WindowsAzure.Storage.Core; + using Microsoft.WindowsAzure.Storage.Core.Auth; using Microsoft.WindowsAzure.Storage.Core.Util; using Microsoft.WindowsAzure.Storage.Shared.Protocol; using System; @@ -35,11 +37,11 @@ internal static class ShareHttpRequestMessageFactory /// Properties to set on the share. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage Create(Uri uri, FileShareProperties properties, int? timeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Create(Uri uri, FileShareProperties properties, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder shareBuilder = GetShareUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.Create(uri, timeout, shareBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.Create(uri, timeout, shareBuilder, content, operationContext, canonicalizer, credentials); if (properties != null && properties.Quota.HasValue) { request.AddOptionalHeader(Constants.HeaderConstants.ShareQuota, properties.Quota.Value); @@ -55,11 +57,11 @@ public static HttpRequestMessage Create(Uri uri, FileShareProperties properties, /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage Delete(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Delete(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder shareBuilder = GetShareUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, shareBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, shareBuilder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -71,11 +73,11 @@ public static HttpRequestMessage Delete(Uri uri, int? timeout, AccessCondition a /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder shareBuilder = GetShareUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, shareBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, shareBuilder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -87,11 +89,11 @@ public static HttpRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondit /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage GetProperties(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetProperties(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder shareBuilder = GetShareUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.GetProperties(uri, timeout, shareBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetProperties(uri, timeout, shareBuilder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -103,10 +105,10 @@ public static HttpRequestMessage GetProperties(Uri uri, int? timeout, AccessCond /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder shareBuilder = GetShareUriQueryBuilder(); - HttpRequestMessage request = HttpRequestMessageFactory.SetMetadata(uri, timeout, shareBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.SetMetadata(uri, timeout, shareBuilder, content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -119,14 +121,14 @@ public static HttpRequestMessage SetMetadata(Uri uri, int? timeout, AccessCondit /// The share's properties. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage SetProperties(Uri uri, int? timeout, FileShareProperties properties, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetProperties(Uri uri, int? timeout, FileShareProperties properties, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { CommonUtility.AssertNotNull("properties", properties); UriQueryBuilder shareBuilder = GetShareUriQueryBuilder(); shareBuilder.Add(Constants.QueryConstants.Component, "properties"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, shareBuilder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, shareBuilder, content, operationContext, canonicalizer, credentials); if (properties.Quota.HasValue) { request.AddOptionalHeader(Constants.HeaderConstants.ShareQuota, properties.Quota.Value); @@ -141,7 +143,7 @@ public static HttpRequestMessage SetProperties(Uri uri, int? timeout, FileShareP /// /// The web request. /// The user-defined metadata. - public static void AddMetadata(HttpRequestMessage request, IDictionary metadata) + public static void AddMetadata(StorageRequestMessage request, IDictionary metadata) { HttpRequestMessageFactory.AddMetadata(request, metadata); } @@ -152,7 +154,7 @@ public static void AddMetadata(HttpRequestMessage request, IDictionaryThe web request. /// The metadata name. /// The metadata value. - public static void AddMetadata(HttpRequestMessage request, string name, string value) + public static void AddMetadata(StorageRequestMessage request, string name, string value) { HttpRequestMessageFactory.AddMetadata(request, name, value); } @@ -165,7 +167,7 @@ public static void AddMetadata(HttpRequestMessage request, string name, string v /// A set of parameters for the listing operation. /// Additional details to return with the listing. /// A web request for the specified operation. - public static HttpRequestMessage List(Uri uri, int? timeout, ListingContext listingContext, ShareListingDetails detailsIncluded, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage List(Uri uri, int? timeout, ListingContext listingContext, ShareListingDetails detailsIncluded, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "list"); @@ -193,7 +195,7 @@ public static HttpRequestMessage List(Uri uri, int? timeout, ListingContext list builder.Add("include", "metadata"); } - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -204,9 +206,9 @@ public static HttpRequestMessage List(Uri uri, int? timeout, ListingContext list /// The server timeout interval. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage GetAcl(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetAcl(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.GetAcl(uri, timeout, GetShareUriQueryBuilder(), content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetAcl(uri, timeout, GetShareUriQueryBuilder(), content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; } @@ -219,9 +221,9 @@ public static HttpRequestMessage GetAcl(Uri uri, int? timeout, AccessCondition a /// The type of public access to allow for the share. /// The access condition to apply to the request. /// A web request to use to perform the operation. - public static HttpRequestMessage SetAcl(Uri uri, int? timeout, FileSharePublicAccessType publicAccess, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetAcl(Uri uri, int? timeout, FileSharePublicAccessType publicAccess, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.SetAcl(uri, timeout, GetShareUriQueryBuilder(), content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.SetAcl(uri, timeout, GetShareUriQueryBuilder(), content, operationContext, canonicalizer, credentials); request.ApplyAccessCondition(accessCondition); return request; @@ -232,13 +234,13 @@ public static HttpRequestMessage SetAcl(Uri uri, int? timeout, FileSharePublicAc /// /// The absolute URI to the service. /// The server timeout interval. - /// A HttpRequestMessage to get the service stats. - public static HttpRequestMessage GetStats(Uri uri, int? timeout, OperationContext operationContext) + /// A StorageRequestMessage to get the service stats. + public static StorageRequestMessage GetStats(Uri uri, int? timeout, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder shareBuilder = GetShareUriQueryBuilder(); shareBuilder.Add(Constants.QueryConstants.Component, "stats"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, shareBuilder, null /* content */, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, shareBuilder, null /* content */, operationContext, canonicalizer, credentials); return request; } diff --git a/Lib/WindowsRuntime/Microsoft.WindowsAzure.Storage.csproj b/Lib/WindowsRuntime/Microsoft.WindowsAzure.Storage.csproj index ccb6ff004..ce9316117 100644 --- a/Lib/WindowsRuntime/Microsoft.WindowsAzure.Storage.csproj +++ b/Lib/WindowsRuntime/Microsoft.WindowsAzure.Storage.csproj @@ -58,8 +58,8 @@ - - + + @@ -84,10 +84,10 @@ + - @@ -130,7 +130,6 @@ - diff --git a/Lib/WindowsRuntime/Properties/AssemblyInfo.cs b/Lib/WindowsRuntime/Properties/AssemblyInfo.cs index 99fe75f24..12f727c6b 100644 --- a/Lib/WindowsRuntime/Properties/AssemblyInfo.cs +++ b/Lib/WindowsRuntime/Properties/AssemblyInfo.cs @@ -25,8 +25,8 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("6.2.2.0")] -[assembly: AssemblyFileVersion("6.2.2.0")] +[assembly: AssemblyVersion("7.0.0.0")] +[assembly: AssemblyFileVersion("7.0.0.0")] [assembly: ComVisible(false)] #if SIGN diff --git a/Lib/WindowsRuntime/Queue/CloudQueue.cs b/Lib/WindowsRuntime/Queue/CloudQueue.cs index 6eead5749..38019b5ab 100644 --- a/Lib/WindowsRuntime/Queue/CloudQueue.cs +++ b/Lib/WindowsRuntime/Queue/CloudQueue.cs @@ -29,8 +29,8 @@ namespace Microsoft.WindowsAzure.Storage.Queue using System.Net; using System.Net.Http; using System.Threading.Tasks; -#if ASPNET_K || PORTABLE using System.Threading; +#if ASPNET_K || PORTABLE #else using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; @@ -39,20 +39,14 @@ namespace Microsoft.WindowsAzure.Storage.Queue /// /// This class represents a queue in the Windows Azure Queue service. /// - public sealed partial class CloudQueue + public partial class CloudQueue { /// /// Creates the queue. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task CreateAsync() -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction CreateAsync() -#endif + public virtual Task CreateAsync() { return this.CreateAsync(null /* options */, null /* operationContext */); } @@ -62,30 +56,13 @@ public IAsyncAction CreateAsync() /// /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task CreateAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task CreateAsync(QueueRequestOptions options, OperationContext operationContext) { return this.CreateAsync(options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction CreateAsync(QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.CreateQueueImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Creates the queue. /// @@ -94,7 +71,7 @@ public IAsyncAction CreateAsync(QueueRequestOptions options, OperationContext op /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task CreateAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task CreateAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -105,18 +82,14 @@ public Task CreateAsync(QueueRequestOptions options, OperationContext operationC operationContext, cancellationToken), cancellationToken); } -#endif /// /// Creates the queue if it does not already exist. /// /// true if the queue did not already exist and was created; otherwise, false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task CreateIfNotExistsAsync() -#else - public IAsyncOperation CreateIfNotExistsAsync() -#endif + public virtual Task CreateIfNotExistsAsync() { return this.CreateIfNotExistsAsync(null /* options */, null /* operationContext */); } @@ -127,9 +100,9 @@ public IAsyncOperation CreateIfNotExistsAsync() /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. /// true if the queue did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task CreateIfNotExistsAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task CreateIfNotExistsAsync(QueueRequestOptions options, OperationContext operationContext) { return this.CreateIfNotExistsAsync(options, operationContext, CancellationToken.None); } @@ -141,24 +114,16 @@ public Task CreateIfNotExistsAsync(QueueRequestOptions options, OperationC /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// true if the queue did not already exist and was created; otherwise false. + /// This API performs an existence check and therefore requires read permissions. [DoesServiceRequest] - public Task CreateIfNotExistsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation CreateIfNotExistsAsync(QueueRequestOptions options, OperationContext operationContext) -#endif + public virtual Task CreateIfNotExistsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); -#if ASPNET_K || PORTABLE return Task.Run(async () => { bool exists = await this.ExistsAsync(true, modifiedOptions, operationContext, cancellationToken); -#else - return AsyncInfo.Run(async (token) => - { - bool exists = await this.ExistsAsync(true, modifiedOptions, operationContext).AsTask(token); -#endif if (exists) { @@ -167,11 +132,7 @@ public IAsyncOperation CreateIfNotExistsAsync(QueueRequestOptions options, try { -#if ASPNET_K || PORTABLE await this.CreateAsync(modifiedOptions, operationContext, cancellationToken); -#else - await this.CreateAsync(modifiedOptions, operationContext).AsTask(token); -#endif if (operationContext.LastResult.HttpStatusCode == (int)HttpStatusCode.NoContent) { return false; @@ -199,25 +160,15 @@ public IAsyncOperation CreateIfNotExistsAsync(QueueRequestOptions options, throw; } } -#if ASPNET_K || PORTABLE }, cancellationToken); -#else - }); -#endif } /// /// Deletes the queue. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteAsync() -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DeleteAsync() -#endif + public virtual Task DeleteAsync() { return this.DeleteAsync(null /* options */, null /* operationContext */); } @@ -227,30 +178,13 @@ public IAsyncAction DeleteAsync() /// /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task DeleteAsync(QueueRequestOptions options, OperationContext operationContext) { return this.DeleteAsync(options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DeleteAsync(QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.DeleteQueueImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Deletes the queue. /// @@ -259,7 +193,7 @@ public IAsyncAction DeleteAsync(QueueRequestOptions options, OperationContext op /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -270,18 +204,13 @@ public Task DeleteAsync(QueueRequestOptions options, OperationContext operationC operationContext, cancellationToken), cancellationToken); } -#endif /// /// Deletes the queue if it already exists. /// /// true if the queue already existed and was deleted; otherwise, false. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task DeleteIfExistsAsync() -#else - public IAsyncOperation DeleteIfExistsAsync() -#endif + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(null /* options */, null /* operationContext */); } @@ -293,8 +222,7 @@ public IAsyncOperation DeleteIfExistsAsync() /// An object that represents the context for the current operation. /// true if the queue already existed and was deleted; otherwise, false. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task DeleteIfExistsAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task DeleteIfExistsAsync(QueueRequestOptions options, OperationContext operationContext) { return this.DeleteIfExistsAsync(options, operationContext, CancellationToken.None); } @@ -307,23 +235,14 @@ public Task DeleteIfExistsAsync(QueueRequestOptions options, OperationCont /// A to observe while waiting for a task to complete. /// true if the queue already existed and was deleted; otherwise, false. [DoesServiceRequest] - public Task DeleteIfExistsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation DeleteIfExistsAsync(QueueRequestOptions options, OperationContext operationContext) -#endif + public virtual Task DeleteIfExistsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); -#if ASPNET_K || PORTABLE return Task.Run(async () => { bool exists = await this.ExistsAsync(true, modifiedOptions, operationContext, cancellationToken); -#else - return AsyncInfo.Run(async (token) => - { - bool exists = await this.ExistsAsync(true, modifiedOptions, operationContext).AsTask(token); -#endif if (!exists) { @@ -332,11 +251,7 @@ public IAsyncOperation DeleteIfExistsAsync(QueueRequestOptions options, Op try { -#if ASPNET_K || PORTABLE await this.DeleteAsync(modifiedOptions, operationContext, cancellationToken); -#else - await this.DeleteAsync(modifiedOptions, operationContext).AsTask(token); -#endif return true; } catch (Exception) @@ -359,11 +274,7 @@ public IAsyncOperation DeleteIfExistsAsync(QueueRequestOptions options, Op throw; } } -#if ASPNET_K || PORTABLE }, cancellationToken); -#else - }); -#endif } #if !PORTABLE @@ -371,15 +282,9 @@ public IAsyncOperation DeleteIfExistsAsync(QueueRequestOptions options, Op /// Sets permissions for the queue. /// /// The permissions to apply to the queue. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetPermissionsAsync(QueuePermissions permissions) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction SetPermissionsAsync(QueuePermissions permissions) -#endif + public virtual Task SetPermissionsAsync(QueuePermissions permissions) { return this.SetPermissionsAsync(permissions, null /* options */, null /* operationContext */); } @@ -390,30 +295,13 @@ public IAsyncAction SetPermissionsAsync(QueuePermissions permissions) /// The permissions to apply to the queue. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetPermissionsAsync(QueuePermissions permissions, QueueRequestOptions options, OperationContext operationContext) + public virtual Task SetPermissionsAsync(QueuePermissions permissions, QueueRequestOptions options, OperationContext operationContext) { return this.SetPermissionsAsync(permissions, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction SetPermissionsAsync(QueuePermissions permissions, QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetPermissionsImpl(permissions, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Sets permissions for the queue. /// @@ -423,7 +311,7 @@ public IAsyncAction SetPermissionsAsync(QueuePermissions permissions, QueueReque /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetPermissionsAsync(QueuePermissions permissions, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetPermissionsAsync(QueuePermissions permissions, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -434,18 +322,13 @@ public Task SetPermissionsAsync(QueuePermissions permissions, QueueRequestOption operationContext, cancellationToken), cancellationToken); } -#endif /// /// Gets the permissions settings for the queue. /// /// The queue's permissions. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetPermissionsAsync() -#else - public IAsyncOperation GetPermissionsAsync() -#endif + public virtual Task GetPermissionsAsync() { return this.GetPermissionsAsync(null /* options */, null /* operationContext */); } @@ -457,26 +340,11 @@ public IAsyncOperation GetPermissionsAsync() /// An object that represents the context for the current operation. /// The queue's permissions. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetPermissionsAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task GetPermissionsAsync(QueueRequestOptions options, OperationContext operationContext) { return this.GetPermissionsAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation GetPermissionsAsync(QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.GetPermissionsImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Gets the permissions settings for the queue. /// @@ -485,7 +353,7 @@ public IAsyncOperation GetPermissionsAsync(QueueRequestOptions /// A to observe while waiting for a task to complete. /// The queue's permissions. [DoesServiceRequest] - public Task GetPermissionsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetPermissionsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -496,7 +364,6 @@ public Task GetPermissionsAsync(QueueRequestOptions options, O operationContext, cancellationToken), cancellationToken); } -#endif #endif /// @@ -504,11 +371,7 @@ public Task GetPermissionsAsync(QueueRequestOptions options, O /// /// true if the queue exists. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ExistsAsync() -#else - public IAsyncOperation ExistsAsync() -#endif + public virtual Task ExistsAsync() { return this.ExistsAsync(null /* options */, null /* operationContext */); } @@ -520,19 +383,11 @@ public IAsyncOperation ExistsAsync() /// An object that represents the context for the current operation. /// true if the queue exists. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task ExistsAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task ExistsAsync(QueueRequestOptions options, OperationContext operationContext) { return this.ExistsAsync(false, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ExistsAsync(QueueRequestOptions options, OperationContext operationContext) - { - return this.ExistsAsync(false, options, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Checks existence of the queue. /// @@ -541,11 +396,10 @@ public IAsyncOperation ExistsAsync(QueueRequestOptions options, OperationC /// A to observe while waiting for a task to complete. /// true if the queue exists. [DoesServiceRequest] - public Task ExistsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ExistsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return this.ExistsAsync(false, options, operationContext, cancellationToken); } -#endif /// /// Checks existence of the queue. @@ -553,7 +407,6 @@ public Task ExistsAsync(QueueRequestOptions options, OperationContext oper /// If true, the command will be executed against the primary location. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A to observe while waiting for a task to complete. /// true if the queue exists. private Task ExistsAsync(bool primaryOnly, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) @@ -567,33 +420,13 @@ private Task ExistsAsync(bool primaryOnly, QueueRequestOptions options, Op operationContext, cancellationToken), cancellationToken); } -#else - /// true if the queue exists. - private IAsyncOperation ExistsAsync(bool primaryOnly, QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.ExistsImpl(modifiedOptions, primaryOnly), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif /// /// Retrieves the queue's attributes. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task FetchAttributesAsync() -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction FetchAttributesAsync() -#endif + public virtual Task FetchAttributesAsync() { return this.FetchAttributesAsync(null /* options */, null /* operationContext */); } @@ -603,30 +436,13 @@ public IAsyncAction FetchAttributesAsync() /// /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task FetchAttributesAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task FetchAttributesAsync(QueueRequestOptions options, OperationContext operationContext) { return this.FetchAttributesAsync(options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction FetchAttributesAsync(QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.FetchAttributesImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Retrieves the queue's attributes. /// @@ -635,7 +451,7 @@ public IAsyncAction FetchAttributesAsync(QueueRequestOptions options, OperationC /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task FetchAttributesAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task FetchAttributesAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -646,20 +462,13 @@ public Task FetchAttributesAsync(QueueRequestOptions options, OperationContext o operationContext, cancellationToken), cancellationToken); } -#endif /// /// Sets the queue's user-defined metadata. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetMetadataAsync() -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction SetMetadataAsync() -#endif + public virtual Task SetMetadataAsync() { return this.SetMetadataAsync(null /* options */, null /* operationContext */); } @@ -669,30 +478,13 @@ public IAsyncAction SetMetadataAsync() /// /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetMetadataAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task SetMetadataAsync(QueueRequestOptions options, OperationContext operationContext) { return this.SetMetadataAsync(options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction SetMetadataAsync(QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetMetadataImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Sets the queue's user-defined metadata. /// @@ -701,7 +493,7 @@ public IAsyncAction SetMetadataAsync(QueueRequestOptions options, OperationConte /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetMetadataAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetMetadataAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -712,21 +504,14 @@ public Task SetMetadataAsync(QueueRequestOptions options, OperationContext opera operationContext, cancellationToken), cancellationToken); } -#endif /// /// Adds a message to the queue. /// /// The message to add. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task AddMessageAsync(CloudQueueMessage message) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction AddMessageAsync(CloudQueueMessage message) -#endif + public virtual Task AddMessageAsync(CloudQueueMessage message) { return this.AddMessageAsync(message, null /* timeToLive */, null /* initialVisibilityDelay */, null /* options */, null /* operationContext */); } @@ -740,30 +525,13 @@ public IAsyncAction AddMessageAsync(CloudQueueMessage message) /// If null then the message will be visible immediately. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay, QueueRequestOptions options, OperationContext operationContext) + public virtual Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay, QueueRequestOptions options, OperationContext operationContext) { return this.AddMessageAsync(message, timeToLive, initialVisibilityDelay, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay, QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.AddMessageImpl(message, timeToLive, initialVisibilityDelay, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Adds a message to the queue. /// @@ -776,7 +544,7 @@ public IAsyncAction AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToL /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -787,7 +555,6 @@ public Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, Tim operationContext, cancellationToken), cancellationToken); } -#endif /// /// Updates a message. @@ -795,15 +562,9 @@ public Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, Tim /// The message to update. /// The visibility timeout interval. /// The message update fields. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields) -#endif + public virtual Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields) { return this.UpdateMessageAsync(message, visibilityTimeout, updateFields, null /* options */, null /* operationContext */); } @@ -816,30 +577,13 @@ public IAsyncAction UpdateMessageAsync(CloudQueueMessage message, TimeSpan visib /// The message update fields. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, QueueRequestOptions options, OperationContext operationContext) + public virtual Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, QueueRequestOptions options, OperationContext operationContext) { return this.UpdateMessageAsync(message, visibilityTimeout, updateFields, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.UpdateMessageImpl(message, visibilityTimeout, updateFields, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Updates a message. /// @@ -851,7 +595,7 @@ public IAsyncAction UpdateMessageAsync(CloudQueueMessage message, TimeSpan visib /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -862,21 +606,14 @@ public Task UpdateMessageAsync(CloudQueueMessage message, TimeSpan visibilityTim operationContext, cancellationToken), cancellationToken); } -#endif /// /// Deletes the message. /// /// The message to delete. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteMessageAsync(CloudQueueMessage message) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DeleteMessageAsync(CloudQueueMessage message) -#endif + public virtual Task DeleteMessageAsync(CloudQueueMessage message) { return this.DeleteMessageAsync(message, null /* options */, null /* operationContext */); } @@ -887,15 +624,9 @@ public IAsyncAction DeleteMessageAsync(CloudQueueMessage message) /// The message to delete. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteMessageAsync(CloudQueueMessage message, QueueRequestOptions options, OperationContext operationContext) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DeleteMessageAsync(CloudQueueMessage message, QueueRequestOptions options, OperationContext operationContext) -#endif + public virtual Task DeleteMessageAsync(CloudQueueMessage message, QueueRequestOptions options, OperationContext operationContext) { return this.DeleteMessageAsync(message.Id, message.PopReceipt, options, operationContext); } @@ -905,15 +636,9 @@ public IAsyncAction DeleteMessageAsync(CloudQueueMessage message, QueueRequestOp /// /// The message ID. /// The pop receipt value. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteMessageAsync(string messageId, string popReceipt) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DeleteMessageAsync(string messageId, string popReceipt) -#endif + public virtual Task DeleteMessageAsync(string messageId, string popReceipt) { return this.DeleteMessageAsync(messageId, popReceipt, null /* options */, null /* operationContext */); } @@ -925,30 +650,13 @@ public IAsyncAction DeleteMessageAsync(string messageId, string popReceipt) /// The pop receipt value. /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteMessageAsync(string messageId, string popReceipt, QueueRequestOptions options, OperationContext operationContext) + public virtual Task DeleteMessageAsync(string messageId, string popReceipt, QueueRequestOptions options, OperationContext operationContext) { return this.DeleteMessageAsync(messageId, popReceipt, options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction DeleteMessageAsync(string messageId, string popReceipt, QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.DeleteMessageImpl(messageId, popReceipt, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Deletes the message. /// @@ -959,7 +667,7 @@ public IAsyncAction DeleteMessageAsync(string messageId, string popReceipt, Queu /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task DeleteMessageAsync(string messageId, string popReceipt, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task DeleteMessageAsync(string messageId, string popReceipt, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -970,21 +678,14 @@ public Task DeleteMessageAsync(string messageId, string popReceipt, QueueRequest operationContext, cancellationToken), cancellationToken); } -#endif /// /// Gets a list of messages from the queue. /// /// The number of messages to retrieve. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task> GetMessagesAsync(int messageCount) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncOperation> GetMessagesAsync(int messageCount) -#endif + public virtual Task> GetMessagesAsync(int messageCount) { return this.GetMessagesAsync(messageCount, null /* visibilityTimeout */, null /* options */, null /* operationContext */); } @@ -998,26 +699,11 @@ public IAsyncOperation> GetMessagesAsync(int mess /// An object that represents the context for the current operation. /// An enumerable collection of messages. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task> GetMessagesAsync(int messageCount, TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext) + public virtual Task> GetMessagesAsync(int messageCount, TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext) { return this.GetMessagesAsync(messageCount, visibilityTimeout, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation> GetMessagesAsync(int messageCount, TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.GetMessagesImpl(messageCount, visibilityTimeout, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Gets a list of messages from the queue. /// @@ -1028,7 +714,7 @@ public IAsyncOperation> GetMessagesAsync(int mess /// A to observe while waiting for a task to complete. /// An enumerable collection of messages. [DoesServiceRequest] - public Task> GetMessagesAsync(int messageCount, TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> GetMessagesAsync(int messageCount, TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1039,18 +725,13 @@ public Task> GetMessagesAsync(int messageCount, T operationContext, cancellationToken), cancellationToken); } -#endif /// /// Gets a single message from the queue. /// /// A message. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetMessageAsync() -#else - public IAsyncOperation GetMessageAsync() -#endif + public virtual Task GetMessageAsync() { return this.GetMessageAsync(null /* visibilityTimeout */, null /* options */, null /* operationContext */); } @@ -1063,26 +744,11 @@ public IAsyncOperation GetMessageAsync() /// An object that represents the context for the current operation. /// A message. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetMessageAsync(TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext) + public virtual Task GetMessageAsync(TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext) { return this.GetMessageAsync(visibilityTimeout, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation GetMessageAsync(TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.GetMessageImpl(visibilityTimeout, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Gets a single message from the queue. /// @@ -1092,7 +758,7 @@ public IAsyncOperation GetMessageAsync(TimeSpan? visibilityTi /// A to observe while waiting for a task to complete. /// A message. [DoesServiceRequest] - public Task GetMessageAsync(TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetMessageAsync(TimeSpan? visibilityTimeout, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1103,21 +769,14 @@ public Task GetMessageAsync(TimeSpan? visibilityTimeout, Queu operationContext, cancellationToken), cancellationToken); } -#endif /// /// Peeks a list of messages from the queue. /// /// The number of messages to retrieve. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task> PeekMessagesAsync(int messageCount) -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncOperation> PeekMessagesAsync(int messageCount) -#endif + public virtual Task> PeekMessagesAsync(int messageCount) { return this.PeekMessagesAsync(messageCount, null /* options */, null /* operationContext */); } @@ -1130,26 +789,11 @@ public IAsyncOperation> PeekMessagesAsync(int mes /// An object that represents the context for the current operation. /// An enumerable collection of messages. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task> PeekMessagesAsync(int messageCount, QueueRequestOptions options, OperationContext operationContext) + public virtual Task> PeekMessagesAsync(int messageCount, QueueRequestOptions options, OperationContext operationContext) { return this.PeekMessagesAsync(messageCount, null /* options */, null /* operationContext */, CancellationToken.None); } -#else - public IAsyncOperation> PeekMessagesAsync(int messageCount, QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.PeekMessagesImpl(messageCount, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Peeks a list of messages from the queue. /// @@ -1159,7 +803,7 @@ public IAsyncOperation> PeekMessagesAsync(int mes /// A to observe while waiting for a task to complete. /// An enumerable collection of messages. [DoesServiceRequest] - public Task> PeekMessagesAsync(int messageCount, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task> PeekMessagesAsync(int messageCount, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1170,18 +814,13 @@ public Task> PeekMessagesAsync(int messageCount, operationContext, cancellationToken), cancellationToken); } -#endif /// /// Peeks a single message from the queue. /// /// A message. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task PeekMessageAsync() -#else - public IAsyncOperation PeekMessageAsync() -#endif + public virtual Task PeekMessageAsync() { return this.PeekMessageAsync(null /* options */, null /* operationContext */); } @@ -1193,26 +832,11 @@ public IAsyncOperation PeekMessageAsync() /// An object that represents the context for the current operation. /// A message. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task PeekMessageAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task PeekMessageAsync(QueueRequestOptions options, OperationContext operationContext) { return this.PeekMessageAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation PeekMessageAsync(QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.PeekMessageImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Peeks a single message from the queue. /// @@ -1221,7 +845,7 @@ public IAsyncOperation PeekMessageAsync(QueueRequestOptions o /// A to observe while waiting for a task to complete. /// A message. [DoesServiceRequest] - public Task PeekMessageAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task PeekMessageAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1232,20 +856,13 @@ public Task PeekMessageAsync(QueueRequestOptions options, Ope operationContext, cancellationToken), cancellationToken); } -#endif /// /// Clears the messages of the queue. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ClearAsync() -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction ClearAsync() -#endif + public virtual Task ClearAsync() { return this.ClearAsync(null /* options */, null /* operationContext */); } @@ -1255,30 +872,13 @@ public IAsyncAction ClearAsync() /// /// A object that specifies additional options for the request. /// An object that represents the context for the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ClearAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task ClearAsync(QueueRequestOptions options, OperationContext operationContext) { return this.ClearAsync(options, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction ClearAsync(QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.ClearImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Clears the messages of the queue. /// @@ -1287,7 +887,7 @@ public IAsyncAction ClearAsync(QueueRequestOptions options, OperationContext ope /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task ClearAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task ClearAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -1298,7 +898,6 @@ public Task ClearAsync(QueueRequestOptions options, OperationContext operationCo operationContext, cancellationToken), cancellationToken); } -#endif /// /// Implementation for the Create method. @@ -1310,11 +909,9 @@ private RESTCommand CreateQueueImpl(QueueRequestOptions options) RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = QueueHttpRequestMessageFactory.Create(uri, serverTimeout, cnt, ctx); + StorageRequestMessage msg = QueueHttpRequestMessageFactory.Create(uri, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); QueueHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -1341,9 +938,7 @@ private RESTCommand DeleteQueueImpl(QueueRequestOptions options) RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.Delete(uri, serverTimeout, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.Delete(uri, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.NoContent, resp, NullType.Value, cmd, ex); return putCmd; @@ -1359,9 +954,7 @@ private RESTCommand ClearImpl(QueueRequestOptions options) RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.GetMessageRequestAddress()); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.Delete(uri, serverTimeout, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.Delete(uri, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.NoContent, resp, NullType.Value, cmd, ex); return putCmd; @@ -1378,9 +971,7 @@ private RESTCommand FetchAttributesImpl(QueueRequestOptions options) options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetMetadata(uri, serverTimeout, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetMetadata(uri, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex); @@ -1403,9 +994,7 @@ private RESTCommand ExistsImpl(QueueRequestOptions options, bool primaryOn options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = primaryOnly ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetMetadata(uri, serverTimeout, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetMetadata(uri, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { if (resp.StatusCode == HttpStatusCode.NotFound) @@ -1434,11 +1023,9 @@ private RESTCommand SetMetadataImpl(QueueRequestOptions options) RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => { - HttpRequestMessage msg = QueueHttpRequestMessageFactory.SetMetadata(uri, serverTimeout, cnt, ctx); + StorageRequestMessage msg = QueueHttpRequestMessageFactory.SetMetadata(uri, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); QueueHttpRequestMessageFactory.AddMetadata(msg, this.Metadata); return msg; }; @@ -1467,9 +1054,7 @@ private RESTCommand SetPermissionsImpl(QueuePermissions acl, QueueRequ RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.SetAcl(uri, serverTimeout, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.SetAcl(uri, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, null /* md5 */, cmd, ctx); putCmd.StreamToDispose = memoryStream; putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => @@ -1493,10 +1078,8 @@ private RESTCommand GetPermissionsImpl(QueueRequestOptions opt options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; getCmd.RetrieveResponseStream = true; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetAcl(uri, serverTimeout, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetAcl(uri, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { @@ -1546,9 +1129,7 @@ private RESTCommand AddMessageImpl(CloudQueueMessage message, TimeSpan RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.GetMessageRequestAddress()); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.AddMessage(uri, serverTimeout, timeToLiveInSeconds, initialVisibilityDelayInSeconds, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.AddMessage(uri, serverTimeout, timeToLiveInSeconds, initialVisibilityDelayInSeconds, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, null, cmd, ctx); putCmd.StreamToDispose = memoryStream; putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => @@ -1585,9 +1166,7 @@ private RESTCommand UpdateMessageImpl(CloudQueueMessage message, TimeS RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, messageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.UpdateMessage(uri, serverTimeout, message.PopReceipt, visibilityTimeout, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.UpdateMessage(uri, serverTimeout, message.PopReceipt, visibilityTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); if ((updateFields & MessageUpdateFields.Content) != 0) { @@ -1622,9 +1201,7 @@ private RESTCommand DeleteMessageImpl(string messageId, string popRece RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, messageUri); options.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.DeleteMessage(uri, serverTimeout, popReceipt, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.DeleteMessage(uri, serverTimeout, popReceipt, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.NoContent, resp, NullType.Value, cmd, ex); return putCmd; @@ -1642,10 +1219,8 @@ private RESTCommand> GetMessagesImpl(int messageC RESTCommand> getCmd = new RESTCommand>(this.ServiceClient.Credentials, this.GetMessageRequestAddress()); options.ApplyToStorageCommand(getCmd); - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; getCmd.RetrieveResponseStream = true; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetMessages(uri, serverTimeout, messageCount, visibilityTimeout, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetMessages(uri, serverTimeout, messageCount, visibilityTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { @@ -1674,10 +1249,8 @@ private RESTCommand> PeekMessagesImpl(int message options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; getCmd.RetrieveResponseStream = true; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.PeekMessages(uri, serverTimeout, messageCount, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.PeekMessages(uri, serverTimeout, messageCount, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { @@ -1705,10 +1278,8 @@ private RESTCommand GetMessageImpl(TimeSpan? visibilityTimeou RESTCommand getCmd = new RESTCommand(this.ServiceClient.Credentials, this.GetMessageRequestAddress()); options.ApplyToStorageCommand(getCmd); - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; getCmd.RetrieveResponseStream = true; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetMessages(uri, serverTimeout, 1, visibilityTimeout, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetMessages(uri, serverTimeout, 1, visibilityTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { @@ -1739,10 +1310,8 @@ private RESTCommand PeekMessageImpl(QueueRequestOptions optio RESTCommand getCmd = new RESTCommand(this.ServiceClient.Credentials, this.GetMessageRequestAddress()); options.ApplyToStorageCommand(getCmd); - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; getCmd.RetrieveResponseStream = true; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.PeekMessages(uri, serverTimeout, 1, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.PeekMessages(uri, serverTimeout, 1, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { diff --git a/Lib/WindowsRuntime/Queue/CloudQueueClient.cs b/Lib/WindowsRuntime/Queue/CloudQueueClient.cs index 46179caf2..42deceec4 100644 --- a/Lib/WindowsRuntime/Queue/CloudQueueClient.cs +++ b/Lib/WindowsRuntime/Queue/CloudQueueClient.cs @@ -29,8 +29,9 @@ namespace Microsoft.WindowsAzure.Storage.Queue using System.Net; using System.Net.Http; using System.Threading.Tasks; -#if ASPNET_K || PORTABLE using System.Threading; +#if ASPNET_K || PORTABLE + #else using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; @@ -40,7 +41,7 @@ namespace Microsoft.WindowsAzure.Storage.Queue /// Provides a client-side logical representation of the Windows Azure Queue Service. This client is used to configure and execute requests against the Queue Service. /// /// The service client encapsulates the base URI for the Queue service. If the service client will be used for authenticated access, it also encapsulates the credentials for accessing the storage account. - public sealed partial class CloudQueueClient + public partial class CloudQueueClient { /// /// Gets or sets the authentication scheme to use to sign HTTP requests. @@ -58,45 +59,13 @@ public AuthenticationScheme AuthenticationScheme } } - /// - /// Gets the authentication handler used to sign requests. - /// - /// Authentication handler. - internal HttpClientHandler AuthenticationHandler - { - get - { - HttpClientHandler authenticationHandler; - if (this.Credentials.IsSharedKey) - { -#if PORTABLE - throw new NotSupportedException(SR.PortableDoesNotSupportSharedKey); -#else - authenticationHandler = new SharedKeyAuthenticationHttpHandler( - this.GetCanonicalizer(), - this.Credentials, - this.Credentials.AccountName); -#endif - } - else - { - authenticationHandler = new NoOpAuthenticationHttpHandler(); - } - - return authenticationHandler; - } - } - /// /// Returns a result segment containing a collection of queues. /// /// A token returned by a previous listing operation. /// A result segment of queues. -#if ASPNET_K || PORTABLE - public Task ListQueuesSegmentedAsync(QueueContinuationToken currentToken) -#else - public IAsyncOperation ListQueuesSegmentedAsync(QueueContinuationToken currentToken) -#endif + [DoesServiceRequest] + public virtual Task ListQueuesSegmentedAsync(QueueContinuationToken currentToken) { return this.ListQueuesSegmentedAsync(null, QueueListingDetails.None, null, currentToken, null, null); } @@ -107,11 +76,8 @@ public IAsyncOperation ListQueuesSegmentedAsync(QueueContinu /// The queue name prefix. /// A token returned by a previous listing operation. /// A result segment of queues. -#if ASPNET_K || PORTABLE - public Task ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken) -#else - public IAsyncOperation ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken) -#endif + [DoesServiceRequest] + public virtual Task ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken) { return this.ListQueuesSegmentedAsync(prefix, QueueListingDetails.None, null, currentToken, null, null); } @@ -128,31 +94,12 @@ public IAsyncOperation ListQueuesSegmentedAsync(string prefi /// An object that specifies additional options for the request. /// An object that represents the context for the current operation. /// A result segment of queues. -#if ASPNET_K || PORTABLE - public Task ListQueuesSegmentedAsync(string prefix, QueueListingDetails detailsIncluded, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task ListQueuesSegmentedAsync(string prefix, QueueListingDetails detailsIncluded, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext) { return this.ListQueuesSegmentedAsync(prefix, detailsIncluded, maxResults, currentToken, options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ListQueuesSegmentedAsync(string prefix, QueueListingDetails detailsIncluded, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run(async (token) => - { - ResultSegment resultSegment = await Executor.ExecuteAsync( - this.ListQueuesImpl(prefix, maxResults, detailsIncluded, modifiedOptions, currentToken), - modifiedOptions.RetryPolicy, - operationContext, - token); - - return new QueueResultSegment(resultSegment.Results, (QueueContinuationToken)resultSegment.ContinuationToken); - }); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Returns a result segment containing a collection of queues /// whose names begin with the specified prefix. @@ -166,7 +113,8 @@ public IAsyncOperation ListQueuesSegmentedAsync(string prefi /// An object that represents the context for the current operation. /// A to observe while waiting for a task to complete. /// A result segment of queues. - public Task ListQueuesSegmentedAsync(string prefix, QueueListingDetails detailsIncluded, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + [DoesServiceRequest] + public virtual Task ListQueuesSegmentedAsync(string prefix, QueueListingDetails detailsIncluded, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this); operationContext = operationContext ?? new OperationContext(); @@ -182,7 +130,6 @@ public Task ListQueuesSegmentedAsync(string prefix, QueueLis return new QueueResultSegment(resultSegment.Results, (QueueContinuationToken)resultSegment.ContinuationToken); }, cancellationToken); } -#endif /// /// Core implementation for the ListQueues method. @@ -205,9 +152,7 @@ private RESTCommand> ListQueuesImpl(string prefix, int options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommonUtility.GetListingLocationMode(currentToken); getCmd.RetrieveResponseStream = true; - getCmd.Handler = this.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.List(uri, serverTimeout, listingContext, detailsIncluded, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.List(uri, serverTimeout, listingContext, detailsIncluded, cnt, ctx, this.GetCanonicalizer(), this.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { @@ -244,11 +189,7 @@ private RESTCommand> ListQueuesImpl(string prefix, int /// /// The blob service properties. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetServicePropertiesAsync() -#else - public IAsyncOperation GetServicePropertiesAsync() -#endif + public virtual Task GetServicePropertiesAsync() { return this.GetServicePropertiesAsync(null, null); } @@ -260,26 +201,11 @@ public IAsyncOperation GetServicePropertiesAsync() /// An object that represents the context for the current operation. /// The blob service properties. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetServicePropertiesAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task GetServicePropertiesAsync(QueueRequestOptions options, OperationContext operationContext) { return this.GetServicePropertiesAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation GetServicePropertiesAsync(QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsync( - this.GetServicePropertiesImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Gets the properties of the blob service. /// @@ -288,7 +214,7 @@ public IAsyncOperation GetServicePropertiesAsync(QueueRequest /// A to observe while waiting for a task to complete. /// The blob service properties. [DoesServiceRequest] - public Task GetServicePropertiesAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServicePropertiesAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this); operationContext = operationContext ?? new OperationContext(); @@ -299,16 +225,13 @@ public Task GetServicePropertiesAsync(QueueRequestOptions opt operationContext, cancellationToken), cancellationToken); } -#endif private RESTCommand GetServicePropertiesImpl(QueueRequestOptions requestOptions) { RESTCommand retCmd = new RESTCommand(this.Credentials, this.StorageUri); retCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetServiceProperties(uri, serverTimeout, ctx); + retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetServiceProperties(uri, serverTimeout, ctx, this.GetCanonicalizer(), this.Credentials); retCmd.RetrieveResponseStream = true; - retCmd.Handler = this.AuthenticationHandler; - retCmd.BuildClient = HttpClientFactory.BuildHttpClient; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); @@ -327,11 +250,7 @@ private RESTCommand GetServicePropertiesImpl(QueueRequestOpti /// The queue service properties. /// The blob service properties. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task SetServicePropertiesAsync(ServiceProperties properties) -#else - public IAsyncAction SetServicePropertiesAsync(ServiceProperties properties) -#endif + public virtual Task SetServicePropertiesAsync(ServiceProperties properties) { return this.SetServicePropertiesAsync(properties, null, null); } @@ -344,25 +263,11 @@ public IAsyncAction SetServicePropertiesAsync(ServiceProperties properties) /// An object that represents the context for the current operation. /// The blob service properties. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task SetServicePropertiesAsync(ServiceProperties properties, QueueRequestOptions requestOptions, OperationContext operationContext) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, QueueRequestOptions requestOptions, OperationContext operationContext) { return this.SetServicePropertiesAsync(properties, requestOptions, operationContext, CancellationToken.None); } -#else - public IAsyncAction SetServicePropertiesAsync(ServiceProperties properties, QueueRequestOptions requestOptions, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(requestOptions, this); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn( - this.SetServicePropertiesImpl(properties, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Gets the properties of the blob service. /// @@ -372,7 +277,7 @@ public IAsyncAction SetServicePropertiesAsync(ServiceProperties properties, Queu /// A to observe while waiting for a task to complete. /// The blob service properties. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties, QueueRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, QueueRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -382,7 +287,6 @@ public Task SetServicePropertiesAsync(ServiceProperties properties, QueueRequest operationContext, cancellationToken), cancellationToken); } -#endif private RESTCommand SetServicePropertiesImpl(ServiceProperties properties, QueueRequestOptions requestOptions) { @@ -398,11 +302,9 @@ private RESTCommand SetServicePropertiesImpl(ServiceProperties propert RESTCommand retCmd = new RESTCommand(this.Credentials, this.StorageUri); requestOptions.ApplyToStorageCommand(retCmd); - retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.SetServiceProperties(uri, serverTimeout, cnt, ctx); + retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.SetServiceProperties(uri, serverTimeout, cnt, ctx, this.GetCanonicalizer(), this.Credentials); retCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, null /* md5 */, cmd, ctx); retCmd.StreamToDispose = memoryStream; - retCmd.Handler = this.AuthenticationHandler; - retCmd.BuildClient = HttpClientFactory.BuildHttpClient; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, null /* retVal */, cmd, ex); @@ -415,12 +317,8 @@ private RESTCommand SetServicePropertiesImpl(ServiceProperties propert /// /// The queue service stats. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetServiceStatsAsync() -#else - public IAsyncOperation GetServiceStatsAsync() -#endif - { + public virtual Task GetServiceStatsAsync() +{ return this.GetServiceStatsAsync(null /* options */, null /* operationContext */); } @@ -431,27 +329,11 @@ public IAsyncOperation GetServiceStatsAsync() /// An object that represents the context for the current operation. /// The queue service stats. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetServiceStatsAsync(QueueRequestOptions options, OperationContext operationContext) + public virtual Task GetServiceStatsAsync(QueueRequestOptions options, OperationContext operationContext) { return this.GetServiceStatsAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation GetServiceStatsAsync(QueueRequestOptions options, OperationContext operationContext) - { - QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run( - async (token) => await Executor.ExecuteAsync( - this.GetServiceStatsImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Gets the stats of the queue service. /// @@ -460,7 +342,7 @@ public IAsyncOperation GetServiceStatsAsync(QueueRequestOptions op /// A to observe while waiting for a task to complete. /// The queue service stats. [DoesServiceRequest] - public Task GetServiceStatsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServiceStatsAsync(QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this); operationContext = operationContext ?? new OperationContext(); @@ -472,17 +354,14 @@ public Task GetServiceStatsAsync(QueueRequestOptions options, Oper operationContext, cancellationToken), cancellationToken); } -#endif private RESTCommand GetServiceStatsImpl(QueueRequestOptions requestOptions) { RESTCommand retCmd = new RESTCommand(this.Credentials, this.StorageUri); requestOptions.ApplyToStorageCommand(retCmd); retCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetServiceStats(uri, serverTimeout, ctx); + retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetServiceStats(uri, serverTimeout, ctx, this.GetCanonicalizer(), this.Credentials); retCmd.RetrieveResponseStream = true; - retCmd.Handler = this.AuthenticationHandler; - retCmd.BuildClient = HttpClientFactory.BuildHttpClient; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); retCmd.PostProcessResponse = (cmd, resp, ctx) => Task.Factory.StartNew(() => QueueHttpResponseParsers.ReadServiceStats(cmd.ResponseStream)); return retCmd; diff --git a/Lib/WindowsRuntime/Queue/Protocol/QueueHttpRequestMessageFactory.cs b/Lib/WindowsRuntime/Queue/Protocol/QueueHttpRequestMessageFactory.cs index 63935b7f0..b7a4c20a4 100644 --- a/Lib/WindowsRuntime/Queue/Protocol/QueueHttpRequestMessageFactory.cs +++ b/Lib/WindowsRuntime/Queue/Protocol/QueueHttpRequestMessageFactory.cs @@ -17,7 +17,9 @@ namespace Microsoft.WindowsAzure.Storage.Queue.Protocol { + using Microsoft.WindowsAzure.Storage.Auth; using Microsoft.WindowsAzure.Storage.Core; + using Microsoft.WindowsAzure.Storage.Core.Auth; using Microsoft.WindowsAzure.Storage.Core.Util; using Microsoft.WindowsAzure.Storage.Shared.Protocol; using System; @@ -32,9 +34,9 @@ internal static class QueueHttpRequestMessageFactory /// The absolute URI to the queue. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage Create(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Create(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - return HttpRequestMessageFactory.Create(uri, timeout, null, content, operationContext); + return HttpRequestMessageFactory.Create(uri, timeout, null, content, operationContext, canonicalizer, credentials); } /// @@ -43,9 +45,9 @@ public static HttpRequestMessage Create(Uri uri, int? timeout, HttpContent conte /// The absolute URI to the queue. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage Delete(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Delete(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, null, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, null, content, operationContext, canonicalizer, credentials); return request; } @@ -55,9 +57,9 @@ public static HttpRequestMessage Delete(Uri uri, int? timeout, HttpContent conte /// The absolute URI to the queue. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage GetMetadata(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetMetadata(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, null, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, null, content, operationContext, canonicalizer, credentials); return request; } @@ -67,9 +69,9 @@ public static HttpRequestMessage GetMetadata(Uri uri, int? timeout, HttpContent /// The absolute URI to the queue. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage SetMetadata(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetMetadata(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.SetMetadata(uri, timeout, null, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.SetMetadata(uri, timeout, null, content, operationContext, canonicalizer, credentials); return request; } @@ -78,7 +80,7 @@ public static HttpRequestMessage SetMetadata(Uri uri, int? timeout, HttpContent /// /// The web request. /// The user-defined metadata. - public static void AddMetadata(HttpRequestMessage request, IDictionary metadata) + public static void AddMetadata(StorageRequestMessage request, IDictionary metadata) { HttpRequestMessageFactory.AddMetadata(request, metadata); } @@ -89,7 +91,7 @@ public static void AddMetadata(HttpRequestMessage request, IDictionaryThe web request. /// The metadata name. /// The metadata value. - public static void AddMetadata(HttpRequestMessage request, string name, string value) + public static void AddMetadata(StorageRequestMessage request, string name, string value) { HttpRequestMessageFactory.AddMetadata(request, name, value); } @@ -102,7 +104,7 @@ public static void AddMetadata(HttpRequestMessage request, string name, string v /// A set of parameters for the listing operation. /// Additional details to return with the listing. /// A web request for the specified operation. - public static HttpRequestMessage List(Uri uri, int? timeout, ListingContext listingContext, QueueListingDetails detailsIncluded, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage List(Uri uri, int? timeout, ListingContext listingContext, QueueListingDetails detailsIncluded, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "list"); @@ -130,7 +132,7 @@ public static HttpRequestMessage List(Uri uri, int? timeout, ListingContext list builder.Add("include", "metadata"); } - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -140,9 +142,9 @@ public static HttpRequestMessage List(Uri uri, int? timeout, ListingContext list /// The absolute URI to the queue. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage GetAcl(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetAcl(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.GetAcl(uri, timeout, null, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetAcl(uri, timeout, null, content, operationContext, canonicalizer, credentials); return request; } @@ -152,9 +154,9 @@ public static HttpRequestMessage GetAcl(Uri uri, int? timeout, HttpContent conte /// The absolute URI to the queue. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage SetAcl(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetAcl(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.SetAcl(uri, timeout, null, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.SetAcl(uri, timeout, null, content, operationContext, canonicalizer, credentials); return request; } @@ -168,7 +170,7 @@ public static HttpRequestMessage SetAcl(Uri uri, int? timeout, HttpContent conte /// The contents of the HTTP request message. /// An object that represents the context for the current operation. /// A web request to use to perform the operation. - public static HttpRequestMessage AddMessage(Uri uri, int? timeout, int? timeToLiveInSeconds, int? visibilityTimeoutInSeconds, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage AddMessage(Uri uri, int? timeout, int? timeToLiveInSeconds, int? visibilityTimeoutInSeconds, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); @@ -182,7 +184,7 @@ public static HttpRequestMessage AddMessage(Uri uri, int? timeout, int? timeToLi builder.Add(Constants.QueryConstants.VisibilityTimeout, visibilityTimeoutInSeconds.Value.ToString()); } - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Post, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Post, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -192,7 +194,7 @@ public static HttpRequestMessage AddMessage(Uri uri, int? timeout, int? timeToLi /// The absolute URI to the queue. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage UpdateMessage(Uri uri, int? timeout, string popReceipt, TimeSpan? visibilityTimeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage UpdateMessage(Uri uri, int? timeout, string popReceipt, TimeSpan? visibilityTimeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); @@ -206,7 +208,7 @@ public static HttpRequestMessage UpdateMessage(Uri uri, int? timeout, string pop builder.Add(Constants.QueryConstants.VisibilityTimeout, "0"); } - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -216,12 +218,12 @@ public static HttpRequestMessage UpdateMessage(Uri uri, int? timeout, string pop /// The absolute URI to the queue. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage DeleteMessage(Uri uri, int? timeout, string popReceipt, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage DeleteMessage(Uri uri, int? timeout, string popReceipt, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.QueryConstants.PopReceipt, popReceipt); - HttpRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -231,7 +233,7 @@ public static HttpRequestMessage DeleteMessage(Uri uri, int? timeout, string pop /// The absolute URI to the queue. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage GetMessages(Uri uri, int? timeout, int numberOfMessages, TimeSpan? visibilityTimeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetMessages(Uri uri, int? timeout, int numberOfMessages, TimeSpan? visibilityTimeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); @@ -242,7 +244,7 @@ public static HttpRequestMessage GetMessages(Uri uri, int? timeout, int numberOf builder.Add(Constants.QueryConstants.VisibilityTimeout, visibilityTimeout.Value.RoundUpToSeconds().ToString()); } - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -252,13 +254,13 @@ public static HttpRequestMessage GetMessages(Uri uri, int? timeout, int numberOf /// The absolute URI to the queue. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage PeekMessages(Uri uri, int? timeout, int numberOfMessages, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage PeekMessages(Uri uri, int? timeout, int numberOfMessages, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = new UriQueryBuilder(); builder.Add(Constants.HeaderConstants.PeekOnly, Constants.HeaderConstants.TrueHeader); builder.Add(Constants.QueryConstants.NumOfMessages, numberOfMessages.ToString()); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -267,10 +269,10 @@ public static HttpRequestMessage PeekMessages(Uri uri, int? timeout, int numberO /// /// The absolute URI to the service. /// The server timeout interval. - /// A HttpRequestMessage to get the service properties. - public static HttpRequestMessage GetServiceProperties(Uri uri, int? timeout, OperationContext operationContext) + /// A StorageRequestMessage to get the service properties. + public static StorageRequestMessage GetServiceProperties(Uri uri, int? timeout, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - return HttpRequestMessageFactory.GetServiceProperties(uri, timeout, operationContext); + return HttpRequestMessageFactory.GetServiceProperties(uri, timeout, operationContext, canonicalizer, credentials); } /// @@ -279,9 +281,9 @@ public static HttpRequestMessage GetServiceProperties(Uri uri, int? timeout, Ope /// The absolute URI to the service. /// The server timeout interval. /// A web request to set the service properties. - internal static HttpRequestMessage SetServiceProperties(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + internal static StorageRequestMessage SetServiceProperties(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - return HttpRequestMessageFactory.SetServiceProperties(uri, timeout, content, operationContext); + return HttpRequestMessageFactory.SetServiceProperties(uri, timeout, content, operationContext, canonicalizer, credentials); } /// @@ -289,10 +291,10 @@ internal static HttpRequestMessage SetServiceProperties(Uri uri, int? timeout, H /// /// The absolute URI to the service. /// The server timeout interval. - /// A HttpRequestMessage to get the service stats. - public static HttpRequestMessage GetServiceStats(Uri uri, int? timeout, OperationContext operationContext) + /// A StorageRequestMessage to get the service stats. + public static StorageRequestMessage GetServiceStats(Uri uri, int? timeout, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - return HttpRequestMessageFactory.GetServiceStats(uri, timeout, operationContext); + return HttpRequestMessageFactory.GetServiceStats(uri, timeout, operationContext, canonicalizer, credentials); } } } diff --git a/Lib/WindowsRuntime/Shared/Protocol/HttpClientFactory.cs b/Lib/WindowsRuntime/Shared/Protocol/HttpClientFactory.cs index e7a385c9e..bea9e9d46 100644 --- a/Lib/WindowsRuntime/Shared/Protocol/HttpClientFactory.cs +++ b/Lib/WindowsRuntime/Shared/Protocol/HttpClientFactory.cs @@ -17,33 +17,32 @@ namespace Microsoft.WindowsAzure.Storage.Shared.Protocol { - using Microsoft.WindowsAzure.Storage.Core.Executor; + using Microsoft.WindowsAzure.Storage.Auth.Protocol; + using System; using System.Net.Http; using System.Net.Http.Headers; internal static class HttpClientFactory { - public static HttpClient BuildHttpClient(RESTCommand cmd, HttpMessageHandler handler, bool useVersionHeader, OperationContext operationContext) - { - HttpClient client = handler != null ? new HttpClient(handler, false) : new HttpClient(); - client.DefaultRequestHeaders.ExpectContinue = false; - client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(Constants.HeaderConstants.UserAgentProductName, Constants.HeaderConstants.UserAgentProductVersion)); - client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(Constants.HeaderConstants.UserAgentComment)); + private static Lazy instance = new Lazy( + () => + { + HttpClient newClient = new HttpClient(StorageAuthenticationHttpHandler.Instance, false); - if (useVersionHeader) - { - client.DefaultRequestHeaders.TryAddWithoutValidation(Constants.HeaderConstants.StorageVersionHeader, Constants.HeaderConstants.TargetStorageVersion); - } + newClient.DefaultRequestHeaders.ExpectContinue = false; + newClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(Constants.HeaderConstants.UserAgentProductName, Constants.HeaderConstants.UserAgentProductVersion)); + newClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(Constants.HeaderConstants.UserAgentComment)); + newClient.DefaultRequestHeaders.TryAddWithoutValidation(Constants.HeaderConstants.StorageVersionHeader, Constants.HeaderConstants.TargetStorageVersion); - if (operationContext != null && operationContext.UserHeaders != null) + return newClient; + }); + + public static HttpClient Instance + { + get { - foreach (string key in operationContext.UserHeaders.Keys) - { - client.DefaultRequestHeaders.Add(key, operationContext.UserHeaders[key]); - } + return instance.Value; } - - return client; } } } diff --git a/Lib/WindowsRuntime/Shared/Protocol/HttpRequestMessageFactory.cs b/Lib/WindowsRuntime/Shared/Protocol/HttpRequestMessageFactory.cs index 18887f5b8..092b44e40 100644 --- a/Lib/WindowsRuntime/Shared/Protocol/HttpRequestMessageFactory.cs +++ b/Lib/WindowsRuntime/Shared/Protocol/HttpRequestMessageFactory.cs @@ -17,7 +17,9 @@ namespace Microsoft.WindowsAzure.Storage.Shared.Protocol { + using Microsoft.WindowsAzure.Storage.Auth; using Microsoft.WindowsAzure.Storage.Core; + using Microsoft.WindowsAzure.Storage.Core.Auth; using Microsoft.WindowsAzure.Storage.Core.Util; using System; using System.Collections.Generic; @@ -32,7 +34,7 @@ internal static class HttpRequestMessageFactory /// The timeout. /// The builder. /// A web request for performing the operation. - internal static HttpRequestMessage CreateRequestMessage(HttpMethod method, Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext) + internal static StorageRequestMessage CreateRequestMessage(HttpMethod method, Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { if (builder == null) { @@ -52,7 +54,7 @@ internal static HttpRequestMessage CreateRequestMessage(HttpMethod method, Uri u Uri uriRequest = builder.AddToUri(uri); - HttpRequestMessage msg = new HttpRequestMessage(method, uriRequest); + StorageRequestMessage msg = new StorageRequestMessage(method, uriRequest, canonicalizer, credentials, credentials.AccountName); msg.Content = content; return msg; @@ -65,9 +67,9 @@ internal static HttpRequestMessage CreateRequestMessage(HttpMethod method, Uri u /// The timeout. /// The builder. /// A web request for performing the operation. - internal static HttpRequestMessage Create(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext) + internal static StorageRequestMessage Create(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -78,7 +80,7 @@ internal static HttpRequestMessage Create(Uri uri, int? timeout, UriQueryBuilder /// The server timeout interval. /// An optional query builder to use. /// A web request to use to perform the operation. - internal static HttpRequestMessage GetAcl(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext) + internal static StorageRequestMessage GetAcl(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { if (builder == null) { @@ -87,7 +89,7 @@ internal static HttpRequestMessage GetAcl(Uri uri, int? timeout, UriQueryBuilder builder.Add(Constants.QueryConstants.Component, "acl"); - HttpRequestMessage request = CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials); #if WINDOWS_PHONE // Windows phone adds */* as the Accept type when we don't set one explicitly. @@ -103,7 +105,7 @@ internal static HttpRequestMessage GetAcl(Uri uri, int? timeout, UriQueryBuilder /// The server timeout interval. /// An optional query builder to use. /// A web request to use to perform the operation. - internal static HttpRequestMessage SetAcl(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext) + internal static StorageRequestMessage SetAcl(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { if (builder == null) { @@ -112,7 +114,7 @@ internal static HttpRequestMessage SetAcl(Uri uri, int? timeout, UriQueryBuilder builder.Add(Constants.QueryConstants.Component, "acl"); - HttpRequestMessage request = CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); #if WINDOWS_PHONE // Windows phone adds */* as the Accept type when we don't set one explicitly. @@ -128,9 +130,9 @@ internal static HttpRequestMessage SetAcl(Uri uri, int? timeout, UriQueryBuilder /// The timeout. /// The builder. /// A web request for performing the operation. - internal static HttpRequestMessage GetProperties(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext) + internal static StorageRequestMessage GetProperties(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = CreateRequestMessage(HttpMethod.Head, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = CreateRequestMessage(HttpMethod.Head, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -141,7 +143,7 @@ internal static HttpRequestMessage GetProperties(Uri uri, int? timeout, UriQuery /// The timeout. /// The builder. /// A web request for performing the operation. - internal static HttpRequestMessage GetMetadata(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext) + internal static StorageRequestMessage GetMetadata(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { if (builder == null) { @@ -150,7 +152,7 @@ internal static HttpRequestMessage GetMetadata(Uri uri, int? timeout, UriQueryBu builder.Add(Constants.QueryConstants.Component, "metadata"); - HttpRequestMessage request = CreateRequestMessage(HttpMethod.Head, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = CreateRequestMessage(HttpMethod.Head, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -161,7 +163,7 @@ internal static HttpRequestMessage GetMetadata(Uri uri, int? timeout, UriQueryBu /// The timeout. /// The builder. /// A web request for performing the operation. - internal static HttpRequestMessage SetMetadata(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext) + internal static StorageRequestMessage SetMetadata(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { if (builder == null) { @@ -170,7 +172,7 @@ internal static HttpRequestMessage SetMetadata(Uri uri, int? timeout, UriQueryBu builder.Add(Constants.QueryConstants.Component, "metadata"); - HttpRequestMessage request = CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -179,7 +181,7 @@ internal static HttpRequestMessage SetMetadata(Uri uri, int? timeout, UriQueryBu /// /// The request. /// The metadata. - internal static void AddMetadata(HttpRequestMessage request, IDictionary metadata) + internal static void AddMetadata(StorageRequestMessage request, IDictionary metadata) { if (metadata != null) { @@ -196,7 +198,7 @@ internal static void AddMetadata(HttpRequestMessage request, IDictionaryThe request. /// The metadata name. /// The metadata value. - internal static void AddMetadata(HttpRequestMessage request, string name, string value) + internal static void AddMetadata(StorageRequestMessage request, string name, string value) { CommonUtility.AssertNotNull("value", value); if (string.IsNullOrWhiteSpace(value)) @@ -214,9 +216,9 @@ internal static void AddMetadata(HttpRequestMessage request, string name, string /// The timeout. /// The builder. /// A web request for performing the operation. - internal static HttpRequestMessage Delete(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext) + internal static StorageRequestMessage Delete(Uri uri, int? timeout, UriQueryBuilder builder, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = CreateRequestMessage(HttpMethod.Delete, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = CreateRequestMessage(HttpMethod.Delete, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -226,12 +228,12 @@ internal static HttpRequestMessage Delete(Uri uri, int? timeout, UriQueryBuilder /// The absolute URI to the service. /// The server timeout interval. /// A web request to get the service properties. - internal static HttpRequestMessage GetServiceProperties(Uri uri, int? timeout, OperationContext operationContext) + internal static StorageRequestMessage GetServiceProperties(Uri uri, int? timeout, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = GetServiceUriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "properties"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, null /* content */, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, null /* content */, operationContext, canonicalizer, credentials); return request; } @@ -241,12 +243,12 @@ internal static HttpRequestMessage GetServiceProperties(Uri uri, int? timeout, O /// The absolute URI to the service. /// The server timeout interval. /// A web request to set the service properties. - internal static HttpRequestMessage SetServiceProperties(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + internal static StorageRequestMessage SetServiceProperties(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = GetServiceUriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "properties"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, builder, content, operationContext, canonicalizer, credentials); return request; } @@ -256,12 +258,12 @@ internal static HttpRequestMessage SetServiceProperties(Uri uri, int? timeout, H /// The absolute URI to the service. /// The server timeout interval. /// A web request to get the service stats. - internal static HttpRequestMessage GetServiceStats(Uri uri, int? timeout, OperationContext operationContext) + internal static StorageRequestMessage GetServiceStats(Uri uri, int? timeout, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { UriQueryBuilder builder = GetServiceUriQueryBuilder(); builder.Add(Constants.QueryConstants.Component, "stats"); - HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, null /* content */, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, null /* content */, operationContext, canonicalizer, credentials); return request; } diff --git a/Lib/WindowsRuntime/Shared/Protocol/RequestMessageExtensions.cs b/Lib/WindowsRuntime/Shared/Protocol/RequestMessageExtensions.cs index 79298c9f2..f78a2d9bb 100644 --- a/Lib/WindowsRuntime/Shared/Protocol/RequestMessageExtensions.cs +++ b/Lib/WindowsRuntime/Shared/Protocol/RequestMessageExtensions.cs @@ -30,7 +30,7 @@ internal static class RequestMessageExtensions /// /// The request. /// The lease id. - internal static void AddLeaseId(this HttpRequestMessage request, string leaseId) + internal static void AddLeaseId(this StorageRequestMessage request, string leaseId) { if (leaseId != null) { @@ -44,7 +44,7 @@ internal static void AddLeaseId(this HttpRequestMessage request, string leaseId) /// The web request. /// The metadata name. /// The metadata value. - internal static void AddOptionalHeader(this HttpRequestMessage request, string name, string value) + internal static void AddOptionalHeader(this StorageRequestMessage request, string name, string value) { if (!string.IsNullOrEmpty(value)) { @@ -58,7 +58,7 @@ internal static void AddOptionalHeader(this HttpRequestMessage request, string n /// The web request. /// The header name. /// The header value. - internal static void AddOptionalHeader(this HttpRequestMessage request, string name, int? value) + internal static void AddOptionalHeader(this StorageRequestMessage request, string name, int? value) { if (value.HasValue) { @@ -72,7 +72,7 @@ internal static void AddOptionalHeader(this HttpRequestMessage request, string n /// The web request. /// The header name. /// The header value. - internal static void AddOptionalHeader(this HttpRequestMessage request, string name, long? value) + internal static void AddOptionalHeader(this StorageRequestMessage request, string name, long? value) { if (value.HasValue) { @@ -85,7 +85,7 @@ internal static void AddOptionalHeader(this HttpRequestMessage request, string n /// /// The request to be modified. /// Access condition to be added to the request. - internal static void ApplyLeaseId(this HttpRequestMessage request, AccessCondition accessCondition) + internal static void ApplyLeaseId(this StorageRequestMessage request, AccessCondition accessCondition) { if (accessCondition != null) { @@ -101,7 +101,7 @@ internal static void ApplyLeaseId(this HttpRequestMessage request, AccessConditi /// /// The request to be modified. /// Access condition to be added to the request. - internal static void ApplySequenceNumberCondition(this HttpRequestMessage request, AccessCondition accessCondition) + internal static void ApplySequenceNumberCondition(this StorageRequestMessage request, AccessCondition accessCondition) { if (accessCondition != null) { @@ -116,7 +116,7 @@ internal static void ApplySequenceNumberCondition(this HttpRequestMessage reques /// /// The request to be modified. /// Access condition to be added to the request. - internal static void ApplyAccessCondition(this HttpRequestMessage request, AccessCondition accessCondition) + internal static void ApplyAccessCondition(this StorageRequestMessage request, AccessCondition accessCondition) { if (accessCondition != null) { @@ -149,7 +149,7 @@ internal static void ApplyAccessCondition(this HttpRequestMessage request, Acces /// /// The request to be modified. /// Access condition to be added to the request. - internal static void ApplyAppendCondition(this HttpRequestMessage request, AccessCondition accessCondition) + internal static void ApplyAppendCondition(this StorageRequestMessage request, AccessCondition accessCondition) { if (accessCondition != null) { @@ -163,7 +163,7 @@ internal static void ApplyAppendCondition(this HttpRequestMessage request, Acces /// /// The request to be modified. /// Access condition to be added to the request. - internal static void ApplyAccessConditionToSource(this HttpRequestMessage request, AccessCondition accessCondition) + internal static void ApplyAccessConditionToSource(this StorageRequestMessage request, AccessCondition accessCondition) { if (accessCondition != null) { diff --git a/Lib/WindowsRuntime/Table/CloudTable.cs b/Lib/WindowsRuntime/Table/CloudTable.cs index 47880872d..38cbab1ca 100644 --- a/Lib/WindowsRuntime/Table/CloudTable.cs +++ b/Lib/WindowsRuntime/Table/CloudTable.cs @@ -25,8 +25,8 @@ namespace Microsoft.WindowsAzure.Storage.Table using System; using System.Collections.Generic; using System.Net; -#if ASPNET_K || PORTABLE using System.Threading; +#if ASPNET_K || PORTABLE #else using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; @@ -36,7 +36,7 @@ namespace Microsoft.WindowsAzure.Storage.Table /// /// Represents a Windows Azure Table. /// - public sealed partial class CloudTable + public partial class CloudTable { #region TableOperation Execute Methods /// @@ -44,11 +44,8 @@ public sealed partial class CloudTable /// /// A object that represents the operation to perform. /// A containing the result of executing the operation on the table. -#if ASPNET_K || PORTABLE - public Task ExecuteAsync(TableOperation operation) -#else - public IAsyncOperation ExecuteAsync(TableOperation operation) -#endif + [DoesServiceRequest] + public virtual Task ExecuteAsync(TableOperation operation) { return this.ExecuteAsync(operation, null /* RequestOptions */, null /* OperationContext */); } @@ -60,21 +57,12 @@ public IAsyncOperation ExecuteAsync(TableOperation operation) /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. /// An object for tracking the current operation. /// A containing the result of executing the operation on the table. -#if ASPNET_K || PORTABLE - public Task ExecuteAsync(TableOperation operation, TableRequestOptions requestOptions, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task ExecuteAsync(TableOperation operation, TableRequestOptions requestOptions, OperationContext operationContext) { return this.ExecuteAsync(operation, requestOptions, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ExecuteAsync(TableOperation operation, TableRequestOptions requestOptions, OperationContext operationContext) - { - CommonUtility.AssertNotNull("operation", operation); - - return operation.ExecuteAsync(this.ServiceClient, this.Name, requestOptions, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Executes the operation on a table, using the specified and . /// @@ -83,13 +71,13 @@ public IAsyncOperation ExecuteAsync(TableOperation operation, Table /// An object for tracking the current operation. /// A containing the result of executing the operation on the table. /// A to observe while waiting for a task to complete. + [DoesServiceRequest] public Task ExecuteAsync(TableOperation operation, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("operation", operation); return operation.ExecuteAsync(this.ServiceClient, this.Name, requestOptions, operationContext, cancellationToken); } -#endif #endregion @@ -99,11 +87,8 @@ public Task ExecuteAsync(TableOperation operation, TableRequestOpti /// /// The object representing the operations to execute on the table. /// An enumerable collection of objects that contains the results, in order, of each operation in the on the table. -#if ASPNET_K || PORTABLE + [DoesServiceRequest] public Task> ExecuteBatchAsync(TableBatchOperation batch) -#else - public IAsyncOperation> ExecuteBatchAsync(TableBatchOperation batch) -#endif { return this.ExecuteBatchAsync(batch, null /* RequestOptions */, null /* OperationContext */); } @@ -115,20 +100,12 @@ public IAsyncOperation> ExecuteBatchAsync(TableBatchOperation /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. /// An object for tracking the current operation. /// An enumerable collection of objects that contains the results, in order, of each operation in the on the table. -#if ASPNET_K || PORTABLE + [DoesServiceRequest] public Task> ExecuteBatchAsync(TableBatchOperation batch, TableRequestOptions requestOptions, OperationContext operationContext) { return this.ExecuteBatchAsync(batch, requestOptions, operationContext, CancellationToken.None); } -#else - public IAsyncOperation> ExecuteBatchAsync(TableBatchOperation batch, TableRequestOptions requestOptions, OperationContext operationContext) - { - CommonUtility.AssertNotNull("batch", batch); - return batch.ExecuteAsync(this.ServiceClient, this.Name, requestOptions, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Executes a batch operation on a table as an atomic operation, using the specified and . /// @@ -137,12 +114,12 @@ public IAsyncOperation> ExecuteBatchAsync(TableBatchOperation /// An object for tracking the current operation. /// An enumerable collection of objects that contains the results, in order, of each operation in the on the table. /// A to observe while waiting for a task to complete. - public Task> ExecuteBatchAsync(TableBatchOperation batch, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + [DoesServiceRequest] + public virtual Task> ExecuteBatchAsync(TableBatchOperation batch, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("batch", batch); return batch.ExecuteAsync(this.ServiceClient, this.Name, requestOptions, operationContext, cancellationToken); } -#endif #endregion @@ -164,11 +141,8 @@ internal IEnumerable ExecuteQuery(TableQuery query, TableReq /// A representing the query to execute. /// A object representing a continuation token from the server when the operation returns a partial result. /// A object containing the results of executing the query. -#if ASPNET_K || PORTABLE - public Task ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token) -#else - public IAsyncOperation ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token) -#endif + [DoesServiceRequest] + public virtual Task ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token) { return this.ExecuteQuerySegmentedAsync(query, token, null /* RequestOptions */, null /* OperationContext */); } @@ -181,20 +155,12 @@ public IAsyncOperation ExecuteQuerySegmentedAsync(TableQuery /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. /// An object for tracking the current operation. /// A object containing the results of executing the query. -#if ASPNET_K || PORTABLE - public Task ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) { return this.ExecuteQuerySegmentedAsync(query, token, requestOptions, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) - { - CommonUtility.AssertNotNull("query", query); - return query.ExecuteQuerySegmentedAsync(token, this.ServiceClient, this.Name, requestOptions, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Executes a query in segmented mode with the specified continuation token, , and . /// @@ -204,26 +170,22 @@ public IAsyncOperation ExecuteQuerySegmentedAsync(TableQuery /// An object for tracking the current operation. /// A to observe while waiting for a task to complete. /// A object containing the results of executing the query. - public Task ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + [DoesServiceRequest] + public virtual Task ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("query", query); return query.ExecuteQuerySegmentedAsync(token, this.ServiceClient, this.Name, requestOptions, operationContext, cancellationToken); } -#endif #endregion -#region Create + #region Create /// /// Creates the Table. /// -#if ASPNET_K || PORTABLE + [DoesServiceRequest] /// A that represents an asynchronous action. - public Task CreateAsync() -#else - /// An that represents an asynchronous action. - public IAsyncAction CreateAsync() -#endif + public virtual Task CreateAsync() { return this.CreateAsync(null /* RequestOptions */, null /* OperationContext */); } @@ -233,9 +195,9 @@ public IAsyncAction CreateAsync() /// /// A object that specifies additional options for the request. /// An object for tracking the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. - public Task CreateAsync(TableRequestOptions requestOptions, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task CreateAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.CreateAsync(requestOptions, operationContext, CancellationToken.None); } @@ -247,11 +209,8 @@ public Task CreateAsync(TableRequestOptions requestOptions, OperationContext ope /// An object for tracking the current operation. /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. - public Task CreateAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) -#else - /// An that represents an asynchronous action. - public IAsyncAction CreateAsync(TableRequestOptions requestOptions, OperationContext operationContext) -#endif + [DoesServiceRequest] + public virtual Task CreateAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -261,11 +220,7 @@ public IAsyncAction CreateAsync(TableRequestOptions requestOptions, OperationCon TableOperation operation = new TableOperation(tblEntity, TableOperationType.Insert, false); operation.IsTableEntity = true; -#if ASPNET_K || PORTABLE return this.ServiceClient.ExecuteAsync(TableConstants.TableServiceTablesName, operation, requestOptions, operationContext, cancellationToken); -#else - return this.ServiceClient.ExecuteAsync(TableConstants.TableServiceTablesName, operation, requestOptions, operationContext).AsTask().AsAsyncAction(); -#endif } #endregion @@ -276,11 +231,9 @@ public IAsyncAction CreateAsync(TableRequestOptions requestOptions, OperationCon /// Creates the table if it does not already exist. /// /// true if table was created; otherwise, false. -#if ASPNET_K || PORTABLE - public Task CreateIfNotExistsAsync() -#else - public IAsyncOperation CreateIfNotExistsAsync() -#endif + /// This API performs an existence check and therefore requires list permissions. + [DoesServiceRequest] + public virtual Task CreateIfNotExistsAsync() { return this.CreateIfNotExistsAsync(null /* RequestOptions */, null /* OperationContext */); } @@ -291,8 +244,9 @@ public IAsyncOperation CreateIfNotExistsAsync() /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. /// An object for tracking the current operation. /// true if table was created; otherwise, false. -#if ASPNET_K || PORTABLE - public Task CreateIfNotExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) + /// This API performs an existence check and therefore requires list permissions. + [DoesServiceRequest] + public virtual Task CreateIfNotExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.CreateIfNotExistsAsync(requestOptions, operationContext, CancellationToken.None); } @@ -304,23 +258,16 @@ public Task CreateIfNotExistsAsync(TableRequestOptions requestOptions, Ope /// An object for tracking the current operation. /// A to observe while waiting for a task to complete. /// true if table was created; otherwise, false. - public Task CreateIfNotExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation CreateIfNotExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) -#endif + /// This API performs an existence check and therefore requires list permissions. + [DoesServiceRequest] + public virtual Task CreateIfNotExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); -#if ASPNET_K || PORTABLE return Task.Run(async () => { if (await this.ExistsAsync(true, requestOptions, operationContext, cancellationToken)) -#else - return AsyncInfo.Run(async (cancellationToken) => - { - if (await this.ExistsAsync(true, requestOptions, operationContext).AsTask(cancellationToken)) -#endif { return false; } @@ -328,11 +275,7 @@ public IAsyncOperation CreateIfNotExistsAsync(TableRequestOptions requestO { try { -#if ASPNET_K || PORTABLE await this.CreateAsync(requestOptions, operationContext, cancellationToken); -#else - await this.CreateAsync(requestOptions, operationContext).AsTask(cancellationToken); -#endif return true; } catch (Exception) @@ -356,11 +299,7 @@ public IAsyncOperation CreateIfNotExistsAsync(TableRequestOptions requestO } } } -#if ASPNET_K || PORTABLE }, cancellationToken); -#else - }); -#endif } #endregion @@ -369,13 +308,9 @@ public IAsyncOperation CreateIfNotExistsAsync(TableRequestOptions requestO /// /// Deletes the Table. /// -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. - public Task DeleteAsync() -#else - /// An that represents an asynchronous action. - public IAsyncAction DeleteAsync() -#endif + [DoesServiceRequest] + public virtual Task DeleteAsync() { return this.DeleteAsync(null /* RequestOptions */, null /* OperationContext */); } @@ -385,9 +320,9 @@ public IAsyncAction DeleteAsync() /// /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. /// An object for tracking the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. - public Task DeleteAsync(TableRequestOptions requestOptions, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task DeleteAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.DeleteAsync(requestOptions, operationContext, CancellationToken.None); } @@ -399,11 +334,8 @@ public Task DeleteAsync(TableRequestOptions requestOptions, OperationContext ope /// An object for tracking the current operation. /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. - public Task DeleteAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) -#else - /// An that represents an asynchronous action. - public IAsyncAction DeleteAsync(TableRequestOptions requestOptions, OperationContext operationContext) -#endif + [DoesServiceRequest] + public virtual Task DeleteAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -413,11 +345,7 @@ public IAsyncAction DeleteAsync(TableRequestOptions requestOptions, OperationCon TableOperation operation = new TableOperation(tblEntity, TableOperationType.Delete); operation.IsTableEntity = true; -#if ASPNET_K || PORTABLE return this.ServiceClient.ExecuteAsync(TableConstants.TableServiceTablesName, operation, requestOptions, operationContext, cancellationToken); -#else - return this.ServiceClient.ExecuteAsync(TableConstants.TableServiceTablesName, operation, requestOptions, operationContext).AsTask().AsAsyncAction(); -#endif } #endregion @@ -427,11 +355,8 @@ public IAsyncAction DeleteAsync(TableRequestOptions requestOptions, OperationCon /// Deletes the table if it already exists. /// /// true if the table already existed and was deleted; otherwise, false. -#if ASPNET_K || PORTABLE - public Task DeleteIfExistsAsync() -#else - public IAsyncOperation DeleteIfExistsAsync() -#endif + [DoesServiceRequest] + public virtual Task DeleteIfExistsAsync() { return this.DeleteIfExistsAsync(null /* RequestOptions */, null /* OperationContext */); } @@ -442,8 +367,8 @@ public IAsyncOperation DeleteIfExistsAsync() /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. /// An object for tracking the current operation. /// true if the table already existed and was deleted; otherwise, false. -#if ASPNET_K || PORTABLE - public Task DeleteIfExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task DeleteIfExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.DeleteIfExistsAsync(requestOptions, operationContext, CancellationToken.None); } @@ -455,24 +380,16 @@ public Task DeleteIfExistsAsync(TableRequestOptions requestOptions, Operat /// An object for tracking the current operation. /// true if the table already existed and was deleted; otherwise, false. /// A to observe while waiting for a task to complete. - public Task DeleteIfExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation DeleteIfExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) -#endif + [DoesServiceRequest] + public virtual Task DeleteIfExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); -#if ASPNET_K || PORTABLE return Task.Run(async () => { if (!await this.ExistsAsync(true, requestOptions, operationContext, cancellationToken)) -#else - return AsyncInfo.Run(async (cancellationToken) => - { - if (!await this.ExistsAsync(true, requestOptions, operationContext).AsTask(cancellationToken)) -#endif { return false; } @@ -480,11 +397,7 @@ public IAsyncOperation DeleteIfExistsAsync(TableRequestOptions requestOpti { try { -#if ASPNET_K || PORTABLE await this.DeleteAsync(requestOptions, operationContext, cancellationToken); -#else - await this.DeleteAsync(requestOptions, operationContext).AsTask(cancellationToken); -#endif return true; } catch (Exception) @@ -508,11 +421,7 @@ public IAsyncOperation DeleteIfExistsAsync(TableRequestOptions requestOpti } } } -#if ASPNET_K || PORTABLE }, cancellationToken); -#else - }); -#endif } #endregion @@ -521,11 +430,8 @@ public IAsyncOperation DeleteIfExistsAsync(TableRequestOptions requestOpti /// Checks existence of the table. /// /// true if the table exists. -#if ASPNET_K || PORTABLE - public Task ExistsAsync() -#else - public IAsyncOperation ExistsAsync() -#endif + [DoesServiceRequest] + public virtual Task ExistsAsync() { return this.ExistsAsync(null /* RequestOptions */, null /* OperationContext */); } @@ -536,19 +442,12 @@ public IAsyncOperation ExistsAsync() /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. /// An object for tracking the current operation. /// true if the table exists. -#if ASPNET_K || PORTABLE - public Task ExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task ExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.ExistsAsync(false, requestOptions, operationContext, CancellationToken.None); } -#else - public IAsyncOperation ExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext) - { - return this.ExistsAsync(false, requestOptions, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Checks existence of the table. /// @@ -556,11 +455,11 @@ public IAsyncOperation ExistsAsync(TableRequestOptions requestOptions, Ope /// An object for tracking the current operation. /// A to observe while waiting for a task to complete. /// true if the table exists. - public Task ExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + [DoesServiceRequest] + public virtual Task ExistsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { return this.ExistsAsync(false, requestOptions, operationContext, cancellationToken); } -#endif /// /// Checks existence of the table. @@ -570,11 +469,8 @@ public Task ExistsAsync(TableRequestOptions requestOptions, OperationConte /// An object for tracking the current operation. /// A to observe while waiting for a task to complete. /// true if the table exists. -#if ASPNET_K || PORTABLE + [DoesServiceRequest] private Task ExistsAsync(bool primaryOnly, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) -#else - private IAsyncOperation ExistsAsync(bool primaryOnly, TableRequestOptions requestOptions, OperationContext operationContext) -#endif { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -585,7 +481,6 @@ private IAsyncOperation ExistsAsync(bool primaryOnly, TableRequestOptions operation.IsTableEntity = true; operation.IsPrimaryOnlyRetrieve = primaryOnly; -#if ASPNET_K || PORTABLE return Task.Run(async () => { TableResult res = await this.ServiceClient.ExecuteAsync(TableConstants.TableServiceTablesName, operation, requestOptions, operationContext, cancellationToken); @@ -593,15 +488,6 @@ private IAsyncOperation ExistsAsync(bool primaryOnly, TableRequestOptions // Only other option is not found, other status codes will throw prior to this. return res.HttpStatusCode == (int)HttpStatusCode.OK; }, cancellationToken); -#else - return AsyncInfo.Run(async (cancellationToken) => - { - TableResult res = await this.ServiceClient.ExecuteAsync(TableConstants.TableServiceTablesName, operation, requestOptions, operationContext).AsTask(cancellationToken); - - // Only other option is not found, other status codes will throw prior to this. - return res.HttpStatusCode == (int)HttpStatusCode.OK; - }); -#endif } #endregion @@ -611,13 +497,9 @@ private IAsyncOperation ExistsAsync(bool primaryOnly, TableRequestOptions /// Sets permissions for the Table. /// /// The permissions to apply to the Table. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. - public Task SetPermissionsAsync(TablePermissions permissions) -#else - /// An that represents an asynchronous action. - public IAsyncAction SetPermissionsAsync(TablePermissions permissions) -#endif + [DoesServiceRequest] + public virtual Task SetPermissionsAsync(TablePermissions permissions) { return this.SetPermissionsAsync(permissions, null /* RequestOptions */, null /* OperationContext */); } @@ -628,36 +510,23 @@ public IAsyncAction SetPermissionsAsync(TablePermissions permissions) /// The permissions to apply to the Table. /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. /// An object for tracking the current operation. - /// An that represents an asynchronous action. -#if ASPNET_K || PORTABLE - public Task SetPermissionsAsync(TablePermissions permissions, TableRequestOptions requestOptions, OperationContext operationContext) + /// An that represents an asynchronous action. + [DoesServiceRequest] + public virtual Task SetPermissionsAsync(TablePermissions permissions, TableRequestOptions requestOptions, OperationContext operationContext) { return this.SetPermissionsAsync(permissions, requestOptions, operationContext, CancellationToken.None); } -#else - public IAsyncAction SetPermissionsAsync(TablePermissions permissions, TableRequestOptions requestOptions, OperationContext operationContext) - { - TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run(async (cancellationToken) => await Executor.ExecuteAsyncNullReturn( - this.SetPermissionsImpl(permissions, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - cancellationToken)); - } -#endif - -#if ASPNET_K || PORTABLE - /// - /// Sets permissions for the Table. - /// - /// The permissions to apply to the Table. - /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. - /// An object for tracking the current operation. - /// A to observe while waiting for a task to complete. - /// A that represents an asynchronous action. - public Task SetPermissionsAsync(TablePermissions permissions, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + /// + /// Sets permissions for the Table. + /// + /// The permissions to apply to the Table. + /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. + /// An object for tracking the current operation. + /// A to observe while waiting for a task to complete. + /// A that represents an asynchronous action. + [DoesServiceRequest] + public virtual Task SetPermissionsAsync(TablePermissions permissions, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -668,7 +537,6 @@ public Task SetPermissionsAsync(TablePermissions permissions, TableRequestOption operationContext, cancellationToken), cancellationToken); } -#endif /// /// Implementation for the SetPermissions method. @@ -684,10 +552,8 @@ private RESTCommand SetPermissionsImpl(TablePermissions acl, TableRequ RESTCommand putCmd = new RESTCommand(this.ServiceClient.Credentials, this.StorageUri); requestOptions.ApplyToStorageCommand(putCmd); - putCmd.Handler = this.ServiceClient.AuthenticationHandler; - putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; - putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableHttpRequestMessageFactory.SetAcl(uri, serverTimeout, cnt, ctx); + putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableHttpRequestMessageFactory.SetAcl(uri, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, null /* md5 */, cmd, ctx); putCmd.StreamToDispose = memoryStream; putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => @@ -703,11 +569,8 @@ private RESTCommand SetPermissionsImpl(TablePermissions acl, TableRequ /// Gets the permissions settings for the Table. /// /// The Table's permissions. -#if ASPNET_K || PORTABLE - public Task GetPermissionsAsync() -#else - public IAsyncOperation GetPermissionsAsync() -#endif + [DoesServiceRequest] + public virtual Task GetPermissionsAsync() { return this.GetPermissionsAsync(null /* RequestOptions */, null /* OperationContext */); } @@ -718,34 +581,21 @@ public IAsyncOperation GetPermissionsAsync() /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. /// An object for tracking the current operation. /// The Table's permissions. -#if ASPNET_K || PORTABLE - public Task GetPermissionsAsync(TableRequestOptions requestOptions, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task GetPermissionsAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.GetPermissionsAsync(requestOptions, operationContext, CancellationToken.None); } -#else - public IAsyncOperation GetPermissionsAsync(TableRequestOptions requestOptions, OperationContext operationContext) - { - TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); - operationContext = operationContext ?? new OperationContext(); - - return AsyncInfo.Run(async (cancellationToken) => await Executor.ExecuteAsync( - this.GetPermissionsImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - cancellationToken)); - } -#endif -#if ASPNET_K || PORTABLE - /// - /// Gets the permissions settings for the Table. - /// - /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. - /// An object for tracking the current operation. - /// A to observe while waiting for a task to complete. - /// The Table's permissions. - public Task GetPermissionsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + /// + /// Gets the permissions settings for the Table. + /// + /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. + /// An object for tracking the current operation. + /// A to observe while waiting for a task to complete. + /// The Table's permissions. + [DoesServiceRequest] + public virtual Task GetPermissionsAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient); operationContext = operationContext ?? new OperationContext(); @@ -756,7 +606,6 @@ public Task GetPermissionsAsync(TableRequestOptions requestOpt operationContext, cancellationToken), cancellationToken); } -#endif /// /// Implementation for the GetPermissions method. @@ -769,11 +618,9 @@ private RESTCommand GetPermissionsImpl(TableRequestOptions req requestOptions.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - getCmd.Handler = this.ServiceClient.AuthenticationHandler; - getCmd.BuildClient = HttpClientFactory.BuildHttpClient; getCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; getCmd.RetrieveResponseStream = true; - getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableHttpRequestMessageFactory.GetAcl(uri, serverTimeout, cnt, ctx); + getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableHttpRequestMessageFactory.GetAcl(uri, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { @@ -799,11 +646,8 @@ private RESTCommand GetPermissionsImpl(TableRequestOptions req /// A representing the query to execute. /// A object representing a continuation token from the server when the operation returns a partial result. /// A object containing the results of executing the query. -#if ASPNET_K || PORTABLE - public Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token) where T : ITableEntity, new() -#else - public IAsyncOperation> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token) where T : ITableEntity, new() -#endif + [DoesServiceRequest] + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token) where T : ITableEntity, new() { return this.ExecuteQuerySegmentedAsync(query, token, null /* requestOptions */, null /* operationContext */); } @@ -818,20 +662,12 @@ private RESTCommand GetPermissionsImpl(TableRequestOptions req /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. /// An object for tracking the current operation. /// A object containing the results of executing the query. -#if ASPNET_K || PORTABLE - public Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) where T : ITableEntity, new() + [DoesServiceRequest] + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) where T : ITableEntity, new() { return this.ExecuteQuerySegmentedAsync(query, token, requestOptions, operationContext, CancellationToken.None); } -#else - public IAsyncOperation> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) where T : ITableEntity, new() - { - CommonUtility.AssertNotNull("query", query); - return query.ExecuteQuerySegmentedAsync(token, this.ServiceClient, this.Name, requestOptions, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Executes a query asynchronously in segmented mode with the specified query, continuation token, options, and context. /// @@ -843,12 +679,12 @@ private RESTCommand GetPermissionsImpl(TableRequestOptions req /// An object for tracking the current operation. /// A to observe while waiting for a task to complete. /// A object containing the results of executing the query. - public Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) where T : ITableEntity, new() + [DoesServiceRequest] + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) where T : ITableEntity, new() { CommonUtility.AssertNotNull("query", query); return query.ExecuteQuerySegmentedAsync(token, this.ServiceClient, this.Name, requestOptions, operationContext, cancellationToken); } -#endif /// /// Executes a query asynchronously in segmented mode, using the specified query and continuation token, and applies the to the result. @@ -860,11 +696,8 @@ private RESTCommand GetPermissionsImpl(TableRequestOptions req /// An instance which creates a projection of the table query result entities into the specified type TResult. /// A object representing a continuation token from the server when the operation returns a partial result. /// A containing the projection into type TResult of the results of executing the query. -#if ASPNET_K || PORTABLE - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token) where T : ITableEntity, new() -#else - public IAsyncOperation> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token) where T : ITableEntity, new() -#endif + [DoesServiceRequest] + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token) where T : ITableEntity, new() { return this.ExecuteQuerySegmentedAsync(query, resolver, token, null /* requestOptions */, null /* operationContext */); } @@ -881,21 +714,12 @@ private RESTCommand GetPermissionsImpl(TableRequestOptions req /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. /// An object for tracking the current operation. /// A containing the projection into type TResult of the results of executing the query. -#if ASPNET_K || PORTABLE - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) where T : ITableEntity, new() + [DoesServiceRequest] + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) where T : ITableEntity, new() { return this.ExecuteQuerySegmentedAsync(query, resolver, token, requestOptions, operationContext, CancellationToken.None); } -#else - public IAsyncOperation> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) where T : ITableEntity, new() - { - CommonUtility.AssertNotNull("query", query); - CommonUtility.AssertNotNull("resolver", resolver); - return query.ExecuteQuerySegmentedAsync(token, this.ServiceClient, this.Name, resolver, requestOptions, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Executes a query asynchronously in segmented mode, using the specified query, continuation token, options, and context, and applies the to the result. /// @@ -909,15 +733,14 @@ private RESTCommand GetPermissionsImpl(TableRequestOptions req /// An object for tracking the current operation. /// A to observe while waiting for a task to complete. /// A containing the projection into type TResult of the results of executing the query. - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) where T : ITableEntity, new() + [DoesServiceRequest] + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) where T : ITableEntity, new() { CommonUtility.AssertNotNull("query", query); CommonUtility.AssertNotNull("resolver", resolver); return query.ExecuteQuerySegmentedAsync(token, this.ServiceClient, this.Name, resolver, requestOptions, operationContext, cancellationToken); } -#endif - /// /// Executes a query asynchronously in segmented mode, using the specified continuation token, and applies the to the result. /// @@ -927,11 +750,8 @@ private RESTCommand GetPermissionsImpl(TableRequestOptions req /// An instance which creates a projection of the table query result entities into the specified type TResult. /// A object representing a continuation token from the server when the operation returns a partial result. /// A containing the projection into type TResult of the results of executing the query. -#if ASPNET_K || PORTABLE - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token) -#else - public IAsyncOperation> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token) -#endif + [DoesServiceRequest] + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token) { return this.ExecuteQuerySegmentedAsync(query, resolver, token, null /* requestOptions */, null /* operationContext */); } @@ -947,21 +767,12 @@ public IAsyncOperation> ExecuteQuerySegmentedAsyncA object that specifies execution options, such as retry policy and timeout settings, for the operation. /// An object for tracking the current operation. /// A containing the projection into type TResult of the results of executing the query. -#if ASPNET_K || PORTABLE - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) { return this.ExecuteQuerySegmentedAsync(query, resolver, token, requestOptions, operationContext, CancellationToken.None); } -#else - public IAsyncOperation> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) - { - CommonUtility.AssertNotNull("query", query); - CommonUtility.AssertNotNull("resolver", resolver); - return query.ExecuteQuerySegmentedAsync(token, this.ServiceClient, this.Name, resolver, requestOptions, operationContext); - } -#endif -#if ASPNET_K || PORTABLE /// /// Executes a query asynchronously in segmented mode, using the specified continuation token, options, and context, and applies the to the result. /// @@ -974,13 +785,13 @@ public IAsyncOperation> ExecuteQuerySegmentedAsyncAn object for tracking the current operation. /// A to observe while waiting for a task to complete. /// A containing the projection into type TResult of the results of executing the query. - public Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + [DoesServiceRequest] + public virtual Task> ExecuteQuerySegmentedAsync(TableQuery query, EntityResolver resolver, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("query", query); CommonUtility.AssertNotNull("resolver", resolver); return query.ExecuteQuerySegmentedAsync(token, this.ServiceClient, this.Name, resolver, requestOptions, operationContext, cancellationToken); } -#endif #endregion } diff --git a/Lib/WindowsRuntime/Table/CloudTableClient.cs b/Lib/WindowsRuntime/Table/CloudTableClient.cs index ffcc97fad..51ae0ce27 100644 --- a/Lib/WindowsRuntime/Table/CloudTableClient.cs +++ b/Lib/WindowsRuntime/Table/CloudTableClient.cs @@ -28,8 +28,9 @@ namespace Microsoft.WindowsAzure.Storage.Table using System.Linq; using System.Net; using System.Net.Http; -#if ASPNET_K || PORTABLE using System.Threading; +#if ASPNET_K || PORTABLE + #else using Windows.Foundation; using System.Runtime.InteropServices.WindowsRuntime; @@ -40,7 +41,7 @@ namespace Microsoft.WindowsAzure.Storage.Table /// Provides a client-side logical representation of the Windows Azure Table Service. This client is used to configure and execute requests against the Table Service. /// /// The service client encapsulates the base URI for the Table service. If the service client will be used for authenticated access, it also encapsulates the credentials for accessing the storage account. - public sealed partial class CloudTableClient + public partial class CloudTableClient { /// /// Gets or sets the authentication scheme to use to sign HTTP requests. @@ -58,75 +59,27 @@ public AuthenticationScheme AuthenticationScheme } } - /// - /// Gets the authentication handler used to sign HTTP requests. - /// - /// The authentication handler. - internal HttpClientHandler AuthenticationHandler - { - get - { - HttpClientHandler authenticationHandler; - if (this.Credentials.IsSharedKey) - { -#if PORTABLE - throw new NotSupportedException(SR.PortableDoesNotSupportSharedKey); -#else - authenticationHandler = new SharedKeyAuthenticationHttpHandler( - this.GetCanonicalizer(), - this.Credentials, - this.Credentials.AccountName); -#endif - } - else - { - authenticationHandler = new NoOpAuthenticationHttpHandler(); - } - - return authenticationHandler; - } - } - #region TableOperation Execute Methods -#if ASPNET_K || PORTABLE internal Task ExecuteAsync(string tableName, TableOperation operation, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("operation", operation); return operation.ExecuteAsync(this, tableName, requestOptions, operationContext, cancellationToken); } -#else - internal IAsyncOperation ExecuteAsync(string tableName, TableOperation operation, TableRequestOptions requestOptions, OperationContext operationContext) - { - CommonUtility.AssertNotNull("operation", operation); - - return operation.ExecuteAsync(this, tableName, requestOptions, operationContext); - } -#endif #endregion #region TableQuery Execute Methods -#if ASPNET_K || PORTABLE internal Task ExecuteQuerySegmentedAsync(string tableName, TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) { CommonUtility.AssertNotNull("query", query); return query.ExecuteQuerySegmentedAsync(token, this, tableName, requestOptions, operationContext, CancellationToken.None); } -#else - internal IAsyncOperation ExecuteQuerySegmentedAsync(string tableName, TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext) - { - CommonUtility.AssertNotNull("query", query); - return query.ExecuteQuerySegmentedAsync(token, this, tableName, requestOptions, operationContext); - } -#endif -#if ASPNET_K || PORTABLE internal Task ExecuteQuerySegmentedAsync(string tableName, TableQuery query, TableContinuationToken token, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { CommonUtility.AssertNotNull("query", query); return query.ExecuteQuerySegmentedAsync(token, this, tableName, requestOptions, operationContext, cancellationToken); } -#endif #endregion #region List Tables @@ -177,11 +130,8 @@ internal IEnumerable ListTables(string prefix, TableRequestOptions r /// /// A token returned by a previous listing operation. /// The result segment containing the collection of tables. -#if ASPNET_K || PORTABLE - public Task ListTablesSegmentedAsync(TableContinuationToken currentToken) -#else - public IAsyncOperation ListTablesSegmentedAsync(TableContinuationToken currentToken) -#endif + [DoesServiceRequest] + public virtual Task ListTablesSegmentedAsync(TableContinuationToken currentToken) { return this.ListTablesSegmentedAsync(null, null /* maxResults */, currentToken, null /* TableRequestOptions */, null /* OperationContext */); } @@ -192,11 +142,8 @@ public IAsyncOperation ListTablesSegmentedAsync(TableContinu /// The table name prefix. /// A token returned by a previous listing operation. /// The result segment containing the collection of tables. -#if ASPNET_K || PORTABLE - public Task ListTablesSegmentedAsync(string prefix, TableContinuationToken currentToken) -#else - public IAsyncOperation ListTablesSegmentedAsync(string prefix, TableContinuationToken currentToken) -#endif + [DoesServiceRequest] + public virtual Task ListTablesSegmentedAsync(string prefix, TableContinuationToken currentToken) { return this.ListTablesSegmentedAsync(prefix, null /* maxResults */, currentToken, null /* TableRequestOptions */, null /* OperationContext */); } @@ -211,8 +158,8 @@ public IAsyncOperation ListTablesSegmentedAsync(string prefi /// A object that specifies additional options for the request. /// An object that provides information on how the operation executed. /// The result segment containing the collection of tables. -#if ASPNET_K || PORTABLE - public Task ListTablesSegmentedAsync(string prefix, int? maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext) + [DoesServiceRequest] + public virtual Task ListTablesSegmentedAsync(string prefix, int? maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext) { return this.ListTablesSegmentedAsync(prefix, maxResults, currentToken, requestOptions, operationContext, CancellationToken.None); } @@ -228,34 +175,21 @@ public Task ListTablesSegmentedAsync(string prefix, int? max /// An object that provides information on how the operation executed. /// A to observe while waiting for a task to complete. /// The result segment containing the collection of tables. - public Task ListTablesSegmentedAsync(string prefix, int? maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) -#else - public IAsyncOperation ListTablesSegmentedAsync(string prefix, int? maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext) -#endif + [DoesServiceRequest] + public virtual Task ListTablesSegmentedAsync(string prefix, int? maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { requestOptions = TableRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); TableQuery query = this.GenerateListTablesQuery(prefix, maxResults); -#if ASPNET_K || PORTABLE return Task.Run(async () => { TableQuerySegment seg = await this.ExecuteQuerySegmentedAsync(TableConstants.TableServiceTablesName, query, currentToken, requestOptions, operationContext, cancellationToken); -#else - return AsyncInfo.Run(async (cancellationToken) => - { - TableQuerySegment seg = await this.ExecuteQuerySegmentedAsync(TableConstants.TableServiceTablesName, query, currentToken, requestOptions, operationContext).AsTask(cancellationToken); -#endif - TableResultSegment retSegment = new TableResultSegment(seg.Results.Select(tbl => new CloudTable(tbl.Properties[TableConstants.TableName].StringValue, this)).ToList()); retSegment.ContinuationToken = seg.ContinuationToken; return retSegment; -#if ASPNET_K || PORTABLE }, cancellationToken); -#else - }); -#endif } #endregion @@ -265,11 +199,7 @@ public IAsyncOperation ListTablesSegmentedAsync(string prefi /// /// The table service properties as a object. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetServicePropertiesAsync() -#else - public IAsyncOperation GetServicePropertiesAsync() -#endif + public virtual Task GetServicePropertiesAsync() { return this.GetServicePropertiesAsync(null /* RequestOptions */, null /* OperationContext */); } @@ -281,26 +211,11 @@ public IAsyncOperation GetServicePropertiesAsync() /// An object for tracking the current operation. /// The table service properties as a object. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetServicePropertiesAsync(TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task GetServicePropertiesAsync(TableRequestOptions requestOptions, OperationContext operationContext) { return this.GetServicePropertiesAsync(requestOptions, operationContext, CancellationToken.None); } -#else - public IAsyncOperation GetServicePropertiesAsync(TableRequestOptions requestOptions, OperationContext operationContext) - { - TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run(async (cancellationToken) => await Executor.ExecuteAsync( - this.GetServicePropertiesImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - cancellationToken)); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Gets the properties of the table service. /// @@ -309,7 +224,7 @@ public IAsyncOperation GetServicePropertiesAsync(TableRequest /// The table service properties as a object. /// A to observe while waiting for a task to complete. [DoesServiceRequest] - public Task GetServicePropertiesAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServicePropertiesAsync(TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -320,17 +235,14 @@ public Task GetServicePropertiesAsync(TableRequestOptions req operationContext, cancellationToken), cancellationToken); } -#endif private RESTCommand GetServicePropertiesImpl(TableRequestOptions requestOptions) { RESTCommand retCmd = new RESTCommand(this.Credentials, this.StorageUri); retCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableHttpRequestMessageFactory.GetServiceProperties(uri, serverTimeout, ctx); + retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableHttpRequestMessageFactory.GetServiceProperties(uri, serverTimeout, ctx, this.GetCanonicalizer(), this.Credentials); retCmd.RetrieveResponseStream = true; retCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; - retCmd.Handler = this.AuthenticationHandler; - retCmd.BuildClient = HttpClientFactory.BuildHttpClient; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); @@ -349,13 +261,8 @@ private RESTCommand GetServicePropertiesImpl(TableRequestOpti /// /// The table service properties. [DoesServiceRequest] -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. - public Task SetServicePropertiesAsync(ServiceProperties properties) -#else - /// An that represents an asynchronous action. - public IAsyncAction SetServicePropertiesAsync(ServiceProperties properties) -#endif + public virtual Task SetServicePropertiesAsync(ServiceProperties properties) { return this.SetServicePropertiesAsync(properties, null /* RequestOptions */, null /* OperationContext */); } @@ -366,29 +273,13 @@ public IAsyncAction SetServicePropertiesAsync(ServiceProperties properties) /// The table service properties. /// A object that specifies execution options, such as retry policy and timeout settings, for the operation. /// An object for tracking the current operation. -#if ASPNET_K || PORTABLE /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties, TableRequestOptions requestOptions, OperationContext operationContext) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, TableRequestOptions requestOptions, OperationContext operationContext) { return this.SetServicePropertiesAsync(properties, requestOptions, operationContext, CancellationToken.None); } -#else - /// An that represents an asynchronous action. - [DoesServiceRequest] - public IAsyncAction SetServicePropertiesAsync(ServiceProperties properties, TableRequestOptions requestOptions, OperationContext operationContext) - { - TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run(async (cancellationToken) => await Executor.ExecuteAsyncNullReturn( - this.SetServicePropertiesImpl(properties, modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - cancellationToken)); - } -#endif -#if ASPNET_K || PORTABLE /// /// Gets the properties of the table service. /// @@ -398,7 +289,7 @@ public IAsyncAction SetServicePropertiesAsync(ServiceProperties properties, Tabl /// A to observe while waiting for a task to complete. /// A that represents an asynchronous action. [DoesServiceRequest] - public Task SetServicePropertiesAsync(ServiceProperties properties, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task SetServicePropertiesAsync(ServiceProperties properties, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) { TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this); operationContext = operationContext ?? new OperationContext(); @@ -408,7 +299,6 @@ public Task SetServicePropertiesAsync(ServiceProperties properties, TableRequest operationContext, cancellationToken), cancellationToken); } -#endif private RESTCommand SetServicePropertiesImpl(ServiceProperties properties, TableRequestOptions requestOptions) { @@ -424,11 +314,9 @@ private RESTCommand SetServicePropertiesImpl(ServiceProperties propert RESTCommand retCmd = new RESTCommand(this.Credentials, this.StorageUri); requestOptions.ApplyToStorageCommand(retCmd); - retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableHttpRequestMessageFactory.SetServiceProperties(uri, serverTimeout, cnt, ctx); + retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableHttpRequestMessageFactory.SetServiceProperties(uri, serverTimeout, cnt, ctx, this.GetCanonicalizer(), this.Credentials); retCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, null /* md5 */, cmd, ctx); retCmd.StreamToDispose = memoryStream; - retCmd.Handler = this.AuthenticationHandler; - retCmd.BuildClient = HttpClientFactory.BuildHttpClient; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, null /* retVal */, cmd, ex); @@ -442,11 +330,7 @@ private RESTCommand SetServicePropertiesImpl(ServiceProperties propert /// /// The table service stats. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetServiceStatsAsync() -#else - public IAsyncOperation GetServiceStatsAsync() -#endif + public virtual Task GetServiceStatsAsync() { return this.GetServiceStatsAsync(null /* options */, null /* operationContext */); } @@ -458,27 +342,11 @@ public IAsyncOperation GetServiceStatsAsync() /// An object that represents the context for the current operation. /// The table service stats. [DoesServiceRequest] -#if ASPNET_K || PORTABLE - public Task GetServiceStatsAsync(TableRequestOptions options, OperationContext operationContext) + public virtual Task GetServiceStatsAsync(TableRequestOptions options, OperationContext operationContext) { return this.GetServiceStatsAsync(options, operationContext, CancellationToken.None); } -#else - public IAsyncOperation GetServiceStatsAsync(TableRequestOptions options, OperationContext operationContext) - { - TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(options, this); - operationContext = operationContext ?? new OperationContext(); - return AsyncInfo.Run( - async (token) => await Executor.ExecuteAsync( - this.GetServiceStatsImpl(modifiedOptions), - modifiedOptions.RetryPolicy, - operationContext, - token)); - } -#endif - -#if ASPNET_K || PORTABLE /// /// Gets the stats of the table service. /// @@ -487,7 +355,7 @@ public IAsyncOperation GetServiceStatsAsync(TableRequestOptions op /// A to observe while waiting for a task to complete. /// The table service stats. [DoesServiceRequest] - public Task GetServiceStatsAsync(TableRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public virtual Task GetServiceStatsAsync(TableRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(options, this); operationContext = operationContext ?? new OperationContext(); @@ -500,18 +368,15 @@ public Task GetServiceStatsAsync(TableRequestOptions options, Oper cancellationToken), cancellationToken); } -#endif private RESTCommand GetServiceStatsImpl(TableRequestOptions requestOptions) { RESTCommand retCmd = new RESTCommand(this.Credentials, this.StorageUri); requestOptions.ApplyToStorageCommand(retCmd); retCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary; - retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableHttpRequestMessageFactory.GetServiceStats(uri, serverTimeout, ctx); + retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableHttpRequestMessageFactory.GetServiceStats(uri, serverTimeout, ctx, this.GetCanonicalizer(), this.Credentials); retCmd.RetrieveResponseStream = true; retCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; - retCmd.Handler = this.AuthenticationHandler; - retCmd.BuildClient = HttpClientFactory.BuildHttpClient; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); retCmd.PostProcessResponse = (cmd, resp, ctx) => Task.Factory.StartNew(() => HttpResponseParsers.ReadServiceStats(cmd.ResponseStream)); return retCmd; diff --git a/Lib/WindowsRuntime/Table/Protocol/HttpRequestAdapterMessage.cs b/Lib/WindowsRuntime/Table/Protocol/HttpRequestAdapterMessage.cs index 29ae2dd70..11b342bfc 100644 --- a/Lib/WindowsRuntime/Table/Protocol/HttpRequestAdapterMessage.cs +++ b/Lib/WindowsRuntime/Table/Protocol/HttpRequestAdapterMessage.cs @@ -28,16 +28,20 @@ namespace Microsoft.WindowsAzure.Storage.Table.Protocol internal class HttpRequestAdapterMessage : IODataRequestMessage, IDisposable { - public HttpRequestMessage GetPopulatedMessage() + public StorageRequestMessage GetPopulatedMessage() { this.msg.Content = this.content; this.outStr.Seek(0, SeekOrigin.Begin); return this.msg; } - // Summary: - // Initializes a new instance of the System.Net.Http.HttpRequestMessage class. - public HttpRequestAdapterMessage(HttpRequestMessage msg, IBufferManager bufferManager, int bufferSize) + /// + /// Initializes a new instance of HttpRequestAdapterMessage. + /// + /// The message to adapt. + /// The to use to acquire and return buffers for the stream. May be null. + /// The buffer size to use for each block. The default size is 64 KB. Note that this parameter is disregarded when an is specified. + public HttpRequestAdapterMessage(StorageRequestMessage msg, IBufferManager bufferManager, int bufferSize) { this.msg = msg; this.outStr = new MultiBufferMemoryStream(bufferManager, bufferSize); @@ -46,7 +50,7 @@ public HttpRequestAdapterMessage(HttpRequestMessage msg, IBufferManager bufferMa private StreamContent content = null; - private HttpRequestMessage msg = null; + private StorageRequestMessage msg = null; private MultiBufferMemoryStream outStr = null; diff --git a/Lib/WindowsRuntime/Table/Protocol/TableHttpRequestMessageFactory.cs b/Lib/WindowsRuntime/Table/Protocol/TableHttpRequestMessageFactory.cs index 9cdfcecd1..ce25a1eb6 100644 --- a/Lib/WindowsRuntime/Table/Protocol/TableHttpRequestMessageFactory.cs +++ b/Lib/WindowsRuntime/Table/Protocol/TableHttpRequestMessageFactory.cs @@ -17,6 +17,9 @@ namespace Microsoft.WindowsAzure.Storage.Table.Protocol { + using Microsoft.WindowsAzure.Storage.Auth; + using Microsoft.WindowsAzure.Storage.Core; + using Microsoft.WindowsAzure.Storage.Core.Auth; using Microsoft.WindowsAzure.Storage.Shared.Protocol; using System; using System.Net.Http; @@ -29,9 +32,9 @@ internal static class TableHttpRequestMessageFactory /// The absolute URI to the table. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage Create(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Create(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.Create(uri, timeout, null /* builder */, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.Create(uri, timeout, null /* builder */, content, operationContext, canonicalizer, credentials); return request; } @@ -41,9 +44,9 @@ public static HttpRequestMessage Create(Uri uri, int? timeout, HttpContent conte /// The absolute URI to the table. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage Delete(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage Delete(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, null /* builder */, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, null /* builder */, content, operationContext, canonicalizer, credentials); return request; } @@ -53,9 +56,9 @@ public static HttpRequestMessage Delete(Uri uri, int? timeout, HttpContent conte /// The absolute URI to the table. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage GetAcl(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage GetAcl(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.GetAcl(uri, timeout, null /* builder */, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetAcl(uri, timeout, null /* builder */, content, operationContext, canonicalizer, credentials); return request; } @@ -65,9 +68,9 @@ public static HttpRequestMessage GetAcl(Uri uri, int? timeout, HttpContent conte /// The absolute URI to the table. /// The server timeout interval. /// A web request to use to perform the operation. - public static HttpRequestMessage SetAcl(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + public static StorageRequestMessage SetAcl(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.SetAcl(uri, timeout, null /* builder */, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.SetAcl(uri, timeout, null /* builder */, content, operationContext, canonicalizer, credentials); return request; } @@ -76,10 +79,10 @@ public static HttpRequestMessage SetAcl(Uri uri, int? timeout, HttpContent conte /// /// The absolute URI to the service. /// The server timeout interval. - /// A HttpRequestMessage to get the service properties. - public static HttpRequestMessage GetServiceProperties(Uri uri, int? timeout, OperationContext operationContext) + /// A StorageRequestMessage to get the service properties. + public static StorageRequestMessage GetServiceProperties(Uri uri, int? timeout, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.GetServiceProperties(uri, timeout, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.GetServiceProperties(uri, timeout, operationContext, canonicalizer, credentials); return request; } @@ -89,9 +92,9 @@ public static HttpRequestMessage GetServiceProperties(Uri uri, int? timeout, Ope /// The absolute URI to the service. /// The server timeout interval. /// A web request to set the service properties. - internal static HttpRequestMessage SetServiceProperties(Uri uri, int? timeout, HttpContent content, OperationContext operationContext) + internal static StorageRequestMessage SetServiceProperties(Uri uri, int? timeout, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage request = HttpRequestMessageFactory.SetServiceProperties(uri, timeout, content, operationContext); + StorageRequestMessage request = HttpRequestMessageFactory.SetServiceProperties(uri, timeout, content, operationContext, canonicalizer, credentials); return request; } @@ -100,10 +103,10 @@ internal static HttpRequestMessage SetServiceProperties(Uri uri, int? timeout, H /// /// The absolute URI to the service. /// The server timeout interval. - /// A HttpRequestMessage to get the service stats. - public static HttpRequestMessage GetServiceStats(Uri uri, int? timeout, OperationContext operationContext) + /// A StorageRequestMessage to get the service stats. + public static StorageRequestMessage GetServiceStats(Uri uri, int? timeout, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials) { - return HttpRequestMessageFactory.GetServiceStats(uri, timeout, operationContext); + return HttpRequestMessageFactory.GetServiceStats(uri, timeout, operationContext, canonicalizer, credentials); } } } diff --git a/Lib/WindowsRuntime/Table/Protocol/TableOperationHttpRequestFactory.cs b/Lib/WindowsRuntime/Table/Protocol/TableOperationHttpRequestFactory.cs index 2a14de074..549967b7d 100644 --- a/Lib/WindowsRuntime/Table/Protocol/TableOperationHttpRequestFactory.cs +++ b/Lib/WindowsRuntime/Table/Protocol/TableOperationHttpRequestFactory.cs @@ -18,7 +18,9 @@ namespace Microsoft.WindowsAzure.Storage.Table.Protocol { using Microsoft.Data.OData; + using Microsoft.WindowsAzure.Storage.Auth; using Microsoft.WindowsAzure.Storage.Core; + using Microsoft.WindowsAzure.Storage.Core.Auth; using Microsoft.WindowsAzure.Storage.Core.Executor; using Microsoft.WindowsAzure.Storage.Core.Util; using Microsoft.WindowsAzure.Storage.Shared.Protocol; @@ -29,9 +31,9 @@ namespace Microsoft.WindowsAzure.Storage.Table.Protocol internal class TableOperationHttpRequestMessageFactory { - internal static HttpRequestMessage BuildRequestCore(Uri uri, UriQueryBuilder builder, HttpMethod method, int? timeout, HttpContent content, OperationContext ctx) + internal static StorageRequestMessage BuildRequestCore(Uri uri, UriQueryBuilder builder, HttpMethod method, int? timeout, HttpContent content, OperationContext ctx, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage msg = HttpRequestMessageFactory.CreateRequestMessage(method, uri, timeout, builder, content, ctx); + StorageRequestMessage msg = HttpRequestMessageFactory.CreateRequestMessage(method, uri, timeout, builder, content, ctx, canonicalizer, credentials); msg.Headers.Add("Accept-Charset", "UTF-8"); msg.Headers.Add("MaxDataServiceVersion", "3.0;NetFx"); @@ -39,9 +41,9 @@ internal static HttpRequestMessage BuildRequestCore(Uri uri, UriQueryBuilder bui return msg; } - internal static HttpRequestMessage BuildRequestForTableQuery(Uri uri, UriQueryBuilder builder, int? timeout, HttpContent content, OperationContext ctx, TablePayloadFormat payloadFormat) + internal static StorageRequestMessage BuildRequestForTableQuery(Uri uri, UriQueryBuilder builder, int? timeout, HttpContent content, OperationContext ctx, TablePayloadFormat payloadFormat, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage msg = BuildRequestCore(uri, builder, HttpMethod.Get, timeout, content, ctx); + StorageRequestMessage msg = BuildRequestCore(uri, builder, HttpMethod.Get, timeout, content, ctx, canonicalizer, credentials); // Set Accept and Content-Type based on the payload format. SetAcceptHeaderForHttpWebRequest(msg, payloadFormat); @@ -49,9 +51,9 @@ internal static HttpRequestMessage BuildRequestForTableQuery(Uri uri, UriQueryBu return msg; } - internal static HttpRequestMessage BuildRequestForTableOperation(RESTCommand cmd, Uri uri, UriQueryBuilder builder, int? timeout, TableOperation operation, CloudTableClient client, HttpContent content, OperationContext ctx, TablePayloadFormat payloadFormat) + internal static StorageRequestMessage BuildRequestForTableOperation(RESTCommand cmd, Uri uri, UriQueryBuilder builder, int? timeout, TableOperation operation, CloudTableClient client, HttpContent content, OperationContext ctx, TablePayloadFormat payloadFormat, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage msg = BuildRequestCore(uri, builder, operation.HttpMethod, timeout, content, ctx); + StorageRequestMessage msg = BuildRequestCore(uri, builder, operation.HttpMethod, timeout, content, ctx, canonicalizer, credentials); // Set Accept and Content-Type based on the payload format. SetAcceptHeaderForHttpWebRequest(msg, payloadFormat); @@ -59,7 +61,7 @@ internal static HttpRequestMessage BuildRequestForTableOperation(RESTCommand< if (!operation.HttpMethod.Equals("HEAD") && !operation.HttpMethod.Equals("GET")) { - SetContentTypeForHttpWebRequest(msg, payloadFormat); + SetContentTypeForHttpWebRequest(msg); } if (operation.OperationType == TableOperationType.InsertOrMerge || operation.OperationType == TableOperationType.Merge) @@ -98,7 +100,7 @@ internal static HttpRequestMessage BuildRequestForTableOperation(RESTCommand< HttpRequestAdapterMessage adapterMsg = new HttpRequestAdapterMessage(msg, client.BufferManager, (int)Constants.KB); if (!operation.HttpMethod.Equals("HEAD") && !operation.HttpMethod.Equals("GET")) { - SetContentTypeForAdapterMessage(adapterMsg, payloadFormat); + adapterMsg.SetHeader(Constants.HeaderConstants.PayloadContentTypeHeader, Constants.JsonContentTypeHeaderValue); } cmd.StreamToDispose = adapterMsg.GetStream(); @@ -113,9 +115,9 @@ internal static HttpRequestMessage BuildRequestForTableOperation(RESTCommand< return msg; } - internal static HttpRequestMessage BuildRequestForTableBatchOperation(RESTCommand cmd, Uri uri, UriQueryBuilder builder, int? timeout, string tableName, TableBatchOperation batch, CloudTableClient client, HttpContent content, OperationContext ctx, TablePayloadFormat payloadFormat) + internal static StorageRequestMessage BuildRequestForTableBatchOperation(RESTCommand cmd, Uri uri, UriQueryBuilder builder, int? timeout, string tableName, TableBatchOperation batch, CloudTableClient client, HttpContent content, OperationContext ctx, TablePayloadFormat payloadFormat, ICanonicalizer canonicalizer, StorageCredentials credentials) { - HttpRequestMessage msg = BuildRequestCore(NavigationHelper.AppendPathToSingleUri(uri, "$batch"), builder, HttpMethod.Post, timeout, content, ctx); + StorageRequestMessage msg = BuildRequestCore(NavigationHelper.AppendPathToSingleUri(uri, "$batch"), builder, HttpMethod.Post, timeout, content, ctx, canonicalizer, credentials); Logger.LogInformational(ctx, SR.PayloadFormat, payloadFormat); // create the writer, indent for readability of the examples. @@ -235,14 +237,9 @@ internal static List GetPropertiesWithKeys(ITableEntity entity, O #endregion #region Set Headers - #pragma warning disable 0618 - private static void SetAcceptHeaderForHttpWebRequest(HttpRequestMessage msg, TablePayloadFormat payloadFormat) + private static void SetAcceptHeaderForHttpWebRequest(StorageRequestMessage msg, TablePayloadFormat payloadFormat) { - if (payloadFormat == TablePayloadFormat.AtomPub) - { - msg.Headers.Add(Constants.HeaderConstants.PayloadAcceptHeader, Constants.AtomAcceptHeaderValue); - } - else if (payloadFormat == TablePayloadFormat.JsonFullMetadata) + if (payloadFormat == TablePayloadFormat.JsonFullMetadata) { msg.Headers.Add(Constants.HeaderConstants.PayloadAcceptHeader, Constants.JsonFullMetadataAcceptHeaderValue); } @@ -256,43 +253,19 @@ private static void SetAcceptHeaderForHttpWebRequest(HttpRequestMessage msg, Tab } } - private static void SetContentTypeForHttpWebRequest(HttpRequestMessage msg, TablePayloadFormat payloadFormat) + private static void SetContentTypeForHttpWebRequest(StorageRequestMessage msg) { if (msg.Content == null || msg.Content.Headers == null) { return; } - if (payloadFormat == TablePayloadFormat.AtomPub) - { - msg.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(Constants.AtomContentTypeHeaderValue); - } - else - { - msg.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(Constants.JsonContentTypeHeaderValue); - } - } - - private static void SetContentTypeForAdapterMessage(HttpRequestAdapterMessage adapterMsg, TablePayloadFormat payloadFormat) - { - if (payloadFormat == TablePayloadFormat.AtomPub) - { - adapterMsg.SetHeader(Constants.HeaderConstants.PayloadContentTypeHeader, Constants.AtomContentTypeHeaderValue); - } - else - { - adapterMsg.SetHeader(Constants.HeaderConstants.PayloadContentTypeHeader, Constants.JsonContentTypeHeaderValue); - } + msg.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(Constants.JsonContentTypeHeaderValue); } private static void SetAcceptAndContentTypeForODataBatchMessage(ODataBatchOperationRequestMessage mimePartMsg, TablePayloadFormat payloadFormat) { - if (payloadFormat == TablePayloadFormat.AtomPub) - { - mimePartMsg.SetHeader(Constants.HeaderConstants.PayloadAcceptHeader, Constants.AtomAcceptHeaderValue); - mimePartMsg.SetHeader(Constants.HeaderConstants.PayloadContentTypeHeader, Constants.AtomContentTypeHeaderValue); - } - else if (payloadFormat == TablePayloadFormat.JsonFullMetadata) + if (payloadFormat == TablePayloadFormat.JsonFullMetadata) { mimePartMsg.SetHeader(Constants.HeaderConstants.PayloadAcceptHeader, Constants.JsonFullMetadataAcceptHeaderValue); mimePartMsg.SetHeader(Constants.HeaderConstants.PayloadContentTypeHeader, Constants.JsonContentTypeHeaderValue); @@ -308,7 +281,6 @@ private static void SetAcceptAndContentTypeForODataBatchMessage(ODataBatchOperat mimePartMsg.SetHeader(Constants.HeaderConstants.PayloadContentTypeHeader, Constants.JsonContentTypeHeaderValue); } } - #pragma warning restore 0618 #endregion } } diff --git a/Lib/WindowsRuntime/Table/Protocol/TableOperationHttpResponseParsers.cs b/Lib/WindowsRuntime/Table/Protocol/TableOperationHttpResponseParsers.cs index f02e5cc40..54a358aff 100644 --- a/Lib/WindowsRuntime/Table/Protocol/TableOperationHttpResponseParsers.cs +++ b/Lib/WindowsRuntime/Table/Protocol/TableOperationHttpResponseParsers.cs @@ -220,8 +220,18 @@ internal static Task> TableBatchOperationPostProcess(IList> TableBatchOperationPostProcess(IList public sealed partial class TableBatchOperation : IList { -#if ASPNET_K || PORTABLE internal Task> ExecuteAsync(CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) -#else - internal IAsyncOperation> ExecuteAsync(CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext) -#endif { TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client); operationContext = operationContext ?? new OperationContext(); @@ -53,21 +49,18 @@ internal IAsyncOperation> ExecuteAsync(CloudTableClient clien throw new InvalidOperationException(SR.EmptyBatchOperation); } + if (this.operations.Count > 100) + { + throw new InvalidOperationException(SR.BatchExceededMaximumNumberOfOperations); + } + RESTCommand> cmdToExecute = BatchImpl(this, client, tableName, modifiedOptions); -#if ASPNET_K || PORTABLE return Task.Run(async () => await Executor.ExecuteAsync( cmdToExecute, modifiedOptions.RetryPolicy, operationContext, cancellationToken), cancellationToken); -#else - return AsyncInfo.Run(async (cancellationToken) => await Executor.ExecuteAsync( - cmdToExecute, - modifiedOptions.RetryPolicy, - operationContext, - cancellationToken)); -#endif } private static RESTCommand> BatchImpl(TableBatchOperation batch, CloudTableClient client, string tableName, TableRequestOptions requestOptions) @@ -79,10 +72,8 @@ private static RESTCommand> BatchImpl(TableBatchOperation bat batchCmd.CommandLocationMode = batch.ContainsWrites ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary; batchCmd.RetrieveResponseStream = true; - batchCmd.Handler = client.AuthenticationHandler; - batchCmd.BuildClient = HttpClientFactory.BuildHttpClient; batchCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; - batchCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableBatchOperation(cmd, uri, builder, serverTimeout, tableName, batch, client, cnt, ctx, requestOptions.PayloadFormat.Value); + batchCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableBatchOperation(cmd, uri, builder, serverTimeout, tableName, batch, client, cnt, ctx, requestOptions.PayloadFormat.Value, client.GetCanonicalizer(), client.Credentials); batchCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp.StatusCode, results, cmd, ex); batchCmd.PostProcessResponse = (cmd, resp, ctx) => TableOperationHttpResponseParsers.TableBatchOperationPostProcess(results, batch, cmd, resp, ctx, requestOptions, client.AccountName); batchCmd.RecoveryAction = (cmd, ex, ctx) => results.Clear(); @@ -90,18 +81,6 @@ private static RESTCommand> BatchImpl(TableBatchOperation bat return batchCmd; } - /// - /// Adds a table operation that retrieves an entity with the specified partition key and row key to the batch operation. The entity will be deserialized into the specified class type which extends . - /// - /// The class of type for the entity to retrieve. - /// The input , which acts as the this instance for the extension method. - /// A string containing the partition key of the entity to be retrieved. - /// A string containing the row key of the entity to be retrieved. - public void Retrieve(string partitionKey, string rowkey) where TElement : ITableEntity - { - Retrieve(partitionKey, rowkey, selectedColumns: null); - } - /// /// Adds a table operation that retrieves an entity with the specified partition key and row key to the batch operation. The entity will be deserialized into the specified class type which extends . /// @@ -119,19 +98,6 @@ public void Retrieve(string partitionKey, string rowkey, List this.Add(new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowkey, SelectColumns = selectedColumns, RetrieveResolver = (pk, rk, ts, prop, etag) => EntityUtilities.ResolveEntityByType(pk, rk, ts, prop, etag) }); } - /// - /// Adds a table operation that retrieves an entity with the specified partition key and row key to the batch operation. - /// - /// The return type which the specified will resolve the given entity to. - /// The input , which acts as the this instance for the extension method. - /// A string containing the partition key of the entity to be retrieved. - /// A string containing the row key of the entity to be retrieved. - /// The implementation to project the entity to retrieve as a particular type in the result. - public void Retrieve(string partitionKey, string rowkey, EntityResolver resolver) - { - Retrieve(partitionKey, rowkey, resolver, selectedColumns: null); - } - /// /// Adds a table operation that retrieves an entity with the specified partition key and row key to the batch operation. /// diff --git a/Lib/WindowsRuntime/Table/TableOperation.cs b/Lib/WindowsRuntime/Table/TableOperation.cs index 84b2f6d82..f89496cc8 100644 --- a/Lib/WindowsRuntime/Table/TableOperation.cs +++ b/Lib/WindowsRuntime/Table/TableOperation.cs @@ -25,8 +25,9 @@ namespace Microsoft.WindowsAzure.Storage.Table using System; using System.Net; using System.Net.Http; -#if ASPNET_K || PORTABLE using System.Threading; + +#if ASPNET_K || PORTABLE #else using Windows.Foundation; using System.Runtime.InteropServices.WindowsRuntime; @@ -36,13 +37,9 @@ namespace Microsoft.WindowsAzure.Storage.Table /// /// Represents a single table operation. /// - public sealed partial class TableOperation + public partial class TableOperation { -#if ASPNET_K || PORTABLE internal Task ExecuteAsync(CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) -#else - internal IAsyncOperation ExecuteAsync(CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext) -#endif { TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client); operationContext = operationContext ?? new OperationContext(); @@ -98,19 +95,11 @@ internal IAsyncOperation ExecuteAsync(CloudTableClient client, stri throw new NotSupportedException(); } -#if ASPNET_K || PORTABLE return Task.Run(() => Executor.ExecuteAsync( cmdToExecute, modifiedOptions.RetryPolicy, operationContext, cancellationToken), cancellationToken); -#else - return AsyncInfo.Run((cancellationToken) => Executor.ExecuteAsync( - cmdToExecute, - modifiedOptions.RetryPolicy, - operationContext, - cancellationToken)); -#endif } private static RESTCommand InsertImpl(TableOperation operation, CloudTableClient client, string tableName, TableRequestOptions requestOptions) @@ -120,10 +109,8 @@ private static RESTCommand InsertImpl(TableOperation operation, Clo TableResult result = new TableResult() { Result = operation.Entity }; insertCmd.RetrieveResponseStream = true; - insertCmd.Handler = client.AuthenticationHandler; - insertCmd.BuildClient = HttpClientFactory.BuildHttpClient; insertCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; - insertCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableOperation(cmd, uri, builder, serverTimeout, operation, client, cnt, ctx, requestOptions.PayloadFormat.Value); + insertCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableOperation(cmd, uri, builder, serverTimeout, operation, client, cnt, ctx, requestOptions.PayloadFormat.Value, client.GetCanonicalizer(), client.Credentials); insertCmd.PreProcessResponse = (cmd, resp, ex, ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex, cmd, ctx); insertCmd.PostProcessResponse = (cmd, resp, ctx) => TableOperationHttpResponseParsers.TableOperationPostProcess(result, operation, cmd, resp, ctx, requestOptions, client.AccountName); @@ -138,10 +125,8 @@ private static RESTCommand DeleteImpl(TableOperation operation, Clo TableResult result = new TableResult() { Result = operation.Entity }; deleteCmd.RetrieveResponseStream = false; - deleteCmd.Handler = client.AuthenticationHandler; deleteCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; - deleteCmd.BuildClient = HttpClientFactory.BuildHttpClient; - deleteCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableOperation(cmd, uri, builder, serverTimeout, operation, client, cnt, ctx, requestOptions.PayloadFormat.Value); + deleteCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableOperation(cmd, uri, builder, serverTimeout, operation, client, cnt, ctx, requestOptions.PayloadFormat.Value, client.GetCanonicalizer(), client.Credentials); deleteCmd.PreProcessResponse = (cmd, resp, ex, ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex, cmd, ctx); return deleteCmd; @@ -154,10 +139,8 @@ private static RESTCommand MergeImpl(TableOperation operation, Clou TableResult result = new TableResult() { Result = operation.Entity }; mergeCmd.RetrieveResponseStream = false; - mergeCmd.Handler = client.AuthenticationHandler; mergeCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; - mergeCmd.BuildClient = HttpClientFactory.BuildHttpClient; - mergeCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableOperation(cmd, uri, builder, serverTimeout, operation, client, cnt, ctx, requestOptions.PayloadFormat.Value); + mergeCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableOperation(cmd, uri, builder, serverTimeout, operation, client, cnt, ctx, requestOptions.PayloadFormat.Value, client.GetCanonicalizer(), client.Credentials); mergeCmd.PreProcessResponse = (cmd, resp, ex, ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex, cmd, ctx); return mergeCmd; @@ -170,10 +153,8 @@ private static RESTCommand ReplaceImpl(TableOperation operation, Cl TableResult result = new TableResult() { Result = operation.Entity }; replaceCmd.RetrieveResponseStream = false; - replaceCmd.Handler = client.AuthenticationHandler; - replaceCmd.BuildClient = HttpClientFactory.BuildHttpClient; replaceCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; - replaceCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableOperation(cmd, uri, builder, serverTimeout, operation, client, cnt, ctx, requestOptions.PayloadFormat.Value); + replaceCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableOperation(cmd, uri, builder, serverTimeout, operation, client, cnt, ctx, requestOptions.PayloadFormat.Value, client.GetCanonicalizer(), client.Credentials); replaceCmd.PreProcessResponse = (cmd, resp, ex, ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex, cmd, ctx); return replaceCmd; @@ -187,15 +168,13 @@ private static RESTCommand RetrieveImpl(TableOperation operation, C TableResult result = new TableResult(); if (operation.SelectColumns != null && operation.SelectColumns.Count > 0) { - retrieveCmd.Builder = operation.GenerateQueryBuilder(); + retrieveCmd.Builder = operation.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); } retrieveCmd.CommandLocationMode = operation.isPrimaryOnlyRetrieve ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary; retrieveCmd.RetrieveResponseStream = true; - retrieveCmd.Handler = client.AuthenticationHandler; - retrieveCmd.BuildClient = HttpClientFactory.BuildHttpClient; retrieveCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; - retrieveCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableOperation(cmd, uri, builder, serverTimeout, operation, client, cnt, ctx, requestOptions.PayloadFormat.Value); + retrieveCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableOperation(cmd, uri, builder, serverTimeout, operation, client, cnt, ctx, requestOptions.PayloadFormat.Value, client.GetCanonicalizer(), client.Credentials); retrieveCmd.PreProcessResponse = (cmd, resp, ex, ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex, cmd, ctx); retrieveCmd.PostProcessResponse = (cmd, resp, ctx) => Task.Run(async () => diff --git a/Lib/WindowsRuntime/Table/TableQuery.cs b/Lib/WindowsRuntime/Table/TableQuery.cs index bf2bae7e4..919706276 100644 --- a/Lib/WindowsRuntime/Table/TableQuery.cs +++ b/Lib/WindowsRuntime/Table/TableQuery.cs @@ -25,8 +25,9 @@ namespace Microsoft.WindowsAzure.Storage.Table using System; using System.Collections.Generic; using System.Net; -#if ASPNET_K || PORTABLE using System.Threading; +#if ASPNET_K || PORTABLE + #else using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; @@ -49,7 +50,7 @@ internal IEnumerable Execute(CloudTableClient client, string CommonUtility.LazyEnumerable( (continuationToken) => { - Task task = Task.Run(() => this.ExecuteQuerySegmentedAsync((TableContinuationToken)continuationToken, client, tableName, modifiedOptions, operationContext).AsTask()); + Task task = Task.Run(() => this.ExecuteQuerySegmentedAsync((TableContinuationToken)continuationToken, client, tableName, modifiedOptions, operationContext)); task.Wait(); TableQuerySegment seg = task.Result; @@ -61,16 +62,12 @@ internal IEnumerable Execute(CloudTableClient client, string return enumerable; } -#if ASPNET_K || PORTABLE internal Task ExecuteQuerySegmentedAsync(TableContinuationToken continuationToken, CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext) { return ExecuteQuerySegmentedAsync(continuationToken, client, tableName, requestOptions, operationContext, CancellationToken.None); } internal Task ExecuteQuerySegmentedAsync(TableContinuationToken continuationToken, CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) -#else - internal IAsyncOperation ExecuteQuerySegmentedAsync(TableContinuationToken continuationToken, CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext) -#endif { CommonUtility.AssertNotNullOrEmpty("tableName", tableName); TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client); @@ -78,24 +75,16 @@ internal IAsyncOperation ExecuteQuerySegmentedAsync(TableCont RESTCommand cmdToExecute = QueryImpl(this, continuationToken, client, tableName, EntityUtilities.ResolveEntityByType, modifiedOptions); -#if ASPNET_K || PORTABLE return Task.Run(async () => await Executor.ExecuteAsync( cmdToExecute, modifiedOptions.RetryPolicy, operationContext, cancellationToken), cancellationToken); -#else - return AsyncInfo.Run(async (cancellationToken) => await Executor.ExecuteAsync( - cmdToExecute, - modifiedOptions.RetryPolicy, - operationContext, - cancellationToken)); -#endif } private static RESTCommand QueryImpl(TableQuery query, TableContinuationToken token, CloudTableClient client, string tableName, EntityResolver resolver, TableRequestOptions requestOptions) { - UriQueryBuilder builder = query.GenerateQueryBuilder(); + UriQueryBuilder builder = query.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); if (token != null) { @@ -108,11 +97,9 @@ private static RESTCommand QueryImpl(TableQuery query, TableC queryCmd.CommandLocationMode = CommonUtility.GetListingLocationMode(token); queryCmd.RetrieveResponseStream = true; - queryCmd.Handler = client.AuthenticationHandler; - queryCmd.BuildClient = HttpClientFactory.BuildHttpClient; queryCmd.Builder = builder; queryCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; - queryCmd.BuildRequest = (cmd, uri, queryBuilder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableQuery(uri, builder, serverTimeout, cnt, ctx, requestOptions.PayloadFormat.Value); + queryCmd.BuildRequest = (cmd, uri, queryBuilder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableQuery(uri, builder, serverTimeout, cnt, ctx, requestOptions.PayloadFormat.Value, client.GetCanonicalizer(), client.Credentials); queryCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp.StatusCode, null /* retVal */, cmd, ex); queryCmd.PostProcessResponse = async (cmd, resp, ctx) => { @@ -128,11 +115,7 @@ private static RESTCommand QueryImpl(TableQuery query, TableC return queryCmd; } -#if ASPNET_K || PORTABLE internal Task> ExecuteQuerySegmentedAsync(TableContinuationToken continuationToken, CloudTableClient client, string tableName, EntityResolver resolver, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) -#else - internal IAsyncOperation> ExecuteQuerySegmentedAsync(TableContinuationToken continuationToken, CloudTableClient client, string tableName, EntityResolver resolver, TableRequestOptions requestOptions, OperationContext operationContext) -#endif { CommonUtility.AssertNotNullOrEmpty("tableName", tableName); TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client); @@ -140,24 +123,16 @@ internal IAsyncOperation> ExecuteQuerySegmentedAsync< RESTCommand> cmdToExecute = this.QueryImpl(continuationToken, client, tableName, resolver, modifiedOptions); -#if ASPNET_K || PORTABLE return Task.Run(async () => await Executor.ExecuteAsync( cmdToExecute, modifiedOptions.RetryPolicy, operationContext, cancellationToken), cancellationToken); -#else - return AsyncInfo.Run(async (cancellationToken) => await Executor.ExecuteAsync( - cmdToExecute, - modifiedOptions.RetryPolicy, - operationContext, - cancellationToken)); -#endif } private RESTCommand> QueryImpl(TableContinuationToken token, CloudTableClient client, string tableName, EntityResolver resolver, TableRequestOptions requestOptions) { - UriQueryBuilder builder = this.GenerateQueryBuilder(); + UriQueryBuilder builder = this.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); if (token != null) { @@ -170,11 +145,9 @@ private RESTCommand> QueryImpl(Table queryCmd.CommandLocationMode = CommonUtility.GetListingLocationMode(token); queryCmd.RetrieveResponseStream = true; - queryCmd.Handler = client.AuthenticationHandler; - queryCmd.BuildClient = HttpClientFactory.BuildHttpClient; queryCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; queryCmd.Builder = builder; - queryCmd.BuildRequest = (cmd, uri, queryBuilder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableQuery(uri, builder, serverTimeout, cnt, ctx, requestOptions.PayloadFormat.Value); + queryCmd.BuildRequest = (cmd, uri, queryBuilder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableQuery(uri, builder, serverTimeout, cnt, ctx, requestOptions.PayloadFormat.Value, client.GetCanonicalizer(), client.Credentials); queryCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp.StatusCode, null /* retVal */, cmd, ex); queryCmd.PostProcessResponse = async (cmd, resp, ctx) => { diff --git a/Lib/WindowsRuntime/Table/TableQueryGeneric.cs b/Lib/WindowsRuntime/Table/TableQueryGeneric.cs index 9396e001e..c698e32c9 100644 --- a/Lib/WindowsRuntime/Table/TableQueryGeneric.cs +++ b/Lib/WindowsRuntime/Table/TableQueryGeneric.cs @@ -25,8 +25,8 @@ namespace Microsoft.WindowsAzure.Storage.Table using System; using System.Collections.Generic; using System.Net; -#if ASPNET_K || PORTABLE using System.Threading; +#if ASPNET_K || PORTABLE #else using Windows.Foundation; using System.Runtime.InteropServices.WindowsRuntime; @@ -58,7 +58,7 @@ internal IEnumerable Execute(CloudTableClient client, string tableName CommonUtility.LazyEnumerable( (continuationToken) => { - Task> task = Task.Run(() => this.ExecuteQuerySegmentedAsync((TableContinuationToken)continuationToken, client, tableName, modifiedOptions, operationContext).AsTask()); + Task> task = Task.Run(() => this.ExecuteQuerySegmentedAsync((TableContinuationToken)continuationToken, client, tableName, modifiedOptions, operationContext)); task.Wait(); TableQuerySegment seg = task.Result; @@ -70,16 +70,12 @@ internal IEnumerable Execute(CloudTableClient client, string tableName return enumerable; } -#if ASPNET_K || PORTABLE internal Task> ExecuteQuerySegmentedAsync(TableContinuationToken token, CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext) { return ExecuteQuerySegmentedAsync(token, client, tableName, requestOptions, operationContext, CancellationToken.None); } internal Task> ExecuteQuerySegmentedAsync(TableContinuationToken token, CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) -#else - internal IAsyncOperation> ExecuteQuerySegmentedAsync(TableContinuationToken token, CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext) -#endif { CommonUtility.AssertNotNullOrEmpty("tableName", tableName); TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client); @@ -87,19 +83,11 @@ internal IAsyncOperation> ExecuteQuerySegmentedAsync RESTCommand> cmdToExecute = QueryImpl(this, token, client, tableName, EntityUtilities.ResolveEntityByType, modifiedOptions); -#if ASPNET_K || PORTABLE return Task.Run(async () => await Executor.ExecuteAsync( cmdToExecute, modifiedOptions.RetryPolicy, operationContext, cancellationToken), cancellationToken); -#else - return AsyncInfo.Run(async (cancellationToken) => await Executor.ExecuteAsync( - cmdToExecute, - modifiedOptions.RetryPolicy, - operationContext, - cancellationToken)); -#endif } internal IEnumerable Execute(CloudTableClient client, string tableName, EntityResolver resolver, TableRequestOptions requestOptions, OperationContext operationContext) @@ -114,7 +102,7 @@ internal IEnumerable Execute(CloudTableClient client, string t CommonUtility.LazyEnumerable( (continuationToken) => { - Task> task = Task.Run(() => this.ExecuteQuerySegmentedAsync((TableContinuationToken)continuationToken, client, tableName, resolver, modifiedOptions, operationContext).AsTask()); + Task> task = Task.Run(() => this.ExecuteQuerySegmentedAsync((TableContinuationToken)continuationToken, client, tableName, resolver, modifiedOptions, operationContext)); task.Wait(); TableQuerySegment seg = task.Result; @@ -126,16 +114,12 @@ internal IEnumerable Execute(CloudTableClient client, string t return enumerable; } -#if ASPNET_K || PORTABLE internal Task> ExecuteQuerySegmentedAsync(TableContinuationToken token, CloudTableClient client, string tableName, EntityResolver resolver, TableRequestOptions requestOptions, OperationContext operationContext) { return ExecuteQuerySegmentedAsync(token, client, tableName, resolver, requestOptions, operationContext, CancellationToken.None); } internal Task> ExecuteQuerySegmentedAsync(TableContinuationToken token, CloudTableClient client, string tableName, EntityResolver resolver, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken) -#else - internal IAsyncOperation> ExecuteQuerySegmentedAsync(TableContinuationToken token, CloudTableClient client, string tableName, EntityResolver resolver, TableRequestOptions requestOptions, OperationContext operationContext) -#endif { CommonUtility.AssertNotNullOrEmpty("tableName", tableName); CommonUtility.AssertNotNull("resolver", resolver); @@ -145,24 +129,16 @@ internal IAsyncOperation> ExecuteQuerySegmentedAsync< RESTCommand> cmdToExecute = QueryImpl(this, token, client, tableName, resolver, modifiedOptions); -#if ASPNET_K || PORTABLE return Task.Run(() => Executor.ExecuteAsync( cmdToExecute, modifiedOptions.RetryPolicy, operationContext, cancellationToken), cancellationToken); -#else - return AsyncInfo.Run((cancellationToken) => Executor.ExecuteAsync( - cmdToExecute, - modifiedOptions.RetryPolicy, - operationContext, - cancellationToken)); -#endif } private static RESTCommand> QueryImpl(TableQuery query, TableContinuationToken token, CloudTableClient client, string tableName, EntityResolver resolver, TableRequestOptions requestOptions) where T : ITableEntity, new() { - UriQueryBuilder builder = query.GenerateQueryBuilder(); + UriQueryBuilder builder = query.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); if (token != null) { @@ -175,11 +151,9 @@ internal IAsyncOperation> ExecuteQuerySegmentedAsync< queryCmd.CommandLocationMode = CommonUtility.GetListingLocationMode(token); queryCmd.RetrieveResponseStream = true; - queryCmd.Handler = client.AuthenticationHandler; - queryCmd.BuildClient = HttpClientFactory.BuildHttpClient; queryCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; queryCmd.Builder = builder; - queryCmd.BuildRequest = (cmd, uri, queryBuilder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableQuery(uri, builder, serverTimeout, cnt, ctx, requestOptions.PayloadFormat.Value); + queryCmd.BuildRequest = (cmd, uri, queryBuilder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableQuery(uri, builder, serverTimeout, cnt, ctx, requestOptions.PayloadFormat.Value, client.GetCanonicalizer(), client.Credentials); queryCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp.StatusCode, null /* retVal */, cmd, ex); queryCmd.PostProcessResponse = async (cmd, resp, ctx) => { diff --git a/README.md b/README.md index b522c27b3..57583ab92 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Microsoft Azure Storage SDK for .NET (6.2.0) +# Microsoft Azure Storage SDK for .NET (7.0.0) The Microsoft Azure Storage SDK for .NET allows you to build Azure applications that take advantage of scalable cloud computing resources. @@ -50,15 +50,14 @@ For the best development experience, developers should use the official Microsof ## Use with the Azure Storage Emulator -- The Client Library uses a particular Storage Service version. In order to use the Storage Client Library with the Storage Emulator, a corresponding minimum version of the Azure Storage Emulator must be used. Older versions of the Storage Emulator do not have the necessary code to successfully respond to new requests. -- Currently, the minimum version of the Azure Storage Emulator needed for this library is 4.2. If you encounter a `VersionNotSupportedByEmulator` (400 Bad Request) error, please [update the Storage Emulator.](https://azure.microsoft.com/en-us/downloads/) +- The Client Library uses a particular Storage Service version. In order to use the Storage Client Library with the Storage Emulator, a corresponding minimum version of the Azure Storage Emulator must be used. Older versions of the Storage Emulator do not have the necessary code to successfully respond to new requests. +- Currently, the minimum version of the Azure Storage Emulator needed for this library is 4.3. If you encounter a `VersionNotSupportedByEmulator` (400 Bad Request) error, please [update the Storage Emulator.](https://azure.microsoft.com/en-us/downloads/) ## Download & Install The Storage Client Library ships with the Microsoft Azure SDK for .NET and also on NuGet. You'll find the latest version and hotfixes on NuGet via the `WindowsAzure.Storage` package. -This version of the Storage Client Library ships with the storage version 2015-02-21. This storage version provides a preview of the Microsoft Azure File Service. For more details, -please see the [Introducing Microsoft Azure File Service blog on MSDN] (http://blogs.msdn.com/b/windowsazurestorage/archive/2014/05/11/introducing-microsoft-azure-file-service.aspx). +This version of the Storage Client Library ships with the storage version 2015-07-08. ### Via Git diff --git a/Test/ClassLibraryCommon/AccountSASTests.cs b/Test/ClassLibraryCommon/AccountSASTests.cs index 71da582a5..52545fb4e 100644 --- a/Test/ClassLibraryCommon/AccountSASTests.cs +++ b/Test/ClassLibraryCommon/AccountSASTests.cs @@ -205,7 +205,7 @@ public void RunPermissionsTestTables(SharedAccessAccountPolicy policy) TestHelper.ExpectedException(() => tableClientWithSAS.ListTables(tableName).First(), "Listing tables with SAS should fail without Read and Container-level permissions."); } - ServiceProperties properties = new ServiceProperties(); + ServiceProperties properties = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties(), new CorsProperties()); properties.Logging = initialProperties.Logging; properties.HourMetrics = initialProperties.HourMetrics; properties.MinuteMetrics = initialProperties.MinuteMetrics; @@ -1262,8 +1262,7 @@ private IPAddress GetMyBlobIPAddressFromService() } catch (StorageException e) { - string[] parts = e.RequestInformation.HttpStatusMessage.Split(' '); - actualIP = IPAddress.Parse(parts[parts.Length - 1].Trim('.')); + actualIP = IPAddress.Parse(e.RequestInformation.ExtendedErrorInformation.AdditionalDetails["SourceIP"]); exceptionThrown = true; Assert.IsNotNull(actualIP); } @@ -1307,8 +1306,7 @@ private IPAddress GetMyQueueIPAddressFromService() } catch (StorageException e) { - string[] parts = e.RequestInformation.HttpStatusMessage.Split(' '); - actualIP = IPAddress.Parse(parts[parts.Length - 1].Trim('.')); + actualIP = IPAddress.Parse(e.RequestInformation.ExtendedErrorInformation.AdditionalDetails["SourceIP"]); exceptionThrown = true; Assert.IsNotNull(actualIP); } @@ -1415,8 +1413,7 @@ private IPAddress GetMyFileIPAddressFromService() } catch (StorageException e) { - string[] parts = e.RequestInformation.HttpStatusMessage.Split(' '); - actualIP = IPAddress.Parse(parts[parts.Length - 1].Trim('.')); + actualIP = IPAddress.Parse(e.RequestInformation.ExtendedErrorInformation.AdditionalDetails["SourceIP"]); exceptionThrown = true; Assert.IsNotNull(actualIP); } diff --git a/Test/ClassLibraryCommon/Blob/BlobAnalyticsUnitTests.cs b/Test/ClassLibraryCommon/Blob/BlobAnalyticsUnitTests.cs index ffbb96c8d..216bb4f51 100644 --- a/Test/ClassLibraryCommon/Blob/BlobAnalyticsUnitTests.cs +++ b/Test/ClassLibraryCommon/Blob/BlobAnalyticsUnitTests.cs @@ -842,11 +842,7 @@ public void CloudBlobTestAnalyticsOptionalPropertiesSync() client.SetServiceProperties(props); - ServiceProperties newProps = new ServiceProperties(); - - newProps.Logging = null; - newProps.HourMetrics = null; - newProps.MinuteMetrics = null; + ServiceProperties newProps = new ServiceProperties(cors: new CorsProperties()); newProps.Cors.CorsRules.Add( new CorsRule() @@ -889,6 +885,65 @@ public void CloudBlobTestAnalyticsOptionalPropertiesSync() } #endregion + + [TestMethod] + [Description("Test Blob SetServiceProperties with empty Logging and Metrics properties")] + [TestCategory(ComponentCategory.Blob)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.Cloud)] + public void TestSetServicePropertiesWithoutMetricsAndLoggingProperties() + { + ServiceProperties serviceProperties = new ServiceProperties(cors: new CorsProperties()); + Microsoft.WindowsAzure.Storage.Shared.Protocol.CorsRule rule = new Microsoft.WindowsAzure.Storage.Shared.Protocol.CorsRule(); + rule.AllowedHeaders.Add("x-ms-meta-xyz"); + rule.AllowedHeaders.Add("x-ms-meta-data*"); + rule.AllowedMethods = CorsHttpMethods.Get | CorsHttpMethods.Put; + rule.ExposedHeaders.Add("x-ms-meta-source*"); + rule.AllowedOrigins.Add("*"); + rule.AllowedMethods = CorsHttpMethods.Get; + serviceProperties.Cors.CorsRules.Add(rule); + + client.SetServiceProperties(serviceProperties); + } + + [TestMethod] + [Description("Test Blob SetServiceProperties with empty cors properties")] + [TestCategory(ComponentCategory.Blob)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.Cloud)] + public void TestSetServicePropertiesWithoutCorsProperties() + { + ServiceProperties serviceProperties = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties()); + + serviceProperties.Logging.LoggingOperations = LoggingOperations.Read | LoggingOperations.Write; + serviceProperties.Logging.RetentionDays = 5; + serviceProperties.Logging.Version = Constants.AnalyticsConstants.LoggingVersionV1; + + serviceProperties.HourMetrics.MetricsLevel = MetricsLevel.Service; + serviceProperties.HourMetrics.RetentionDays = 6; + serviceProperties.HourMetrics.Version = Constants.AnalyticsConstants.MetricsVersionV1; + + serviceProperties.MinuteMetrics.MetricsLevel = MetricsLevel.Service; + serviceProperties.MinuteMetrics.RetentionDays = 6; + serviceProperties.MinuteMetrics.Version = Constants.AnalyticsConstants.MetricsVersionV1; + + client.SetServiceProperties(serviceProperties); + } + + [TestMethod] + [Description("Test Blob SetServiceProperties with no properties set")] + [TestCategory(ComponentCategory.Blob)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.Cloud)] + public void TestSetServicePropertiesWithNoProperties() + { + ServiceProperties serviceProperties = new ServiceProperties(); + TestHelper.ExpectedException(() => client.SetServiceProperties(serviceProperties), "At least one service property needs to be non-null for SetServiceProperties API."); + } + #region Test Helpers private void TestCorsRules(CloudBlobClient client, IList corsProps) { @@ -905,7 +960,7 @@ private void TestCorsRules(CloudBlobClient client, IList corsProps) private static ServiceProperties DefaultServiceProperties() { - ServiceProperties props = new ServiceProperties(); + ServiceProperties props = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties(), new CorsProperties()); props.Logging.LoggingOperations = LoggingOperations.None; props.Logging.RetentionDays = null; diff --git a/Test/ClassLibraryCommon/Blob/BlobEncryptionTests.cs b/Test/ClassLibraryCommon/Blob/BlobEncryptionTests.cs index a5d93577d..2f14ec83a 100644 --- a/Test/ClassLibraryCommon/Blob/BlobEncryptionTests.cs +++ b/Test/ClassLibraryCommon/Blob/BlobEncryptionTests.cs @@ -286,7 +286,7 @@ public void CloudBlobEncryptionWithFile() } // Upload the encrypted contents to the blob. - blob.UploadFromFile(inputFileName, FileMode.Open, null, uploadOptions, null); + blob.UploadFromFile(inputFileName, null, uploadOptions, null); // Download the encrypted blob. // Create the decryption policy to be used for download. There is no need to specify the diff --git a/Test/ClassLibraryCommon/Blob/BlobUploadDownloadTest.cs b/Test/ClassLibraryCommon/Blob/BlobUploadDownloadTest.cs index 64744aa37..cb445506d 100644 --- a/Test/ClassLibraryCommon/Blob/BlobUploadDownloadTest.cs +++ b/Test/ClassLibraryCommon/Blob/BlobUploadDownloadTest.cs @@ -256,7 +256,7 @@ public void BlobEmptyHeaderSigningTest() } [TestMethod] - [Description("Upload from file to a block blob")] + [Description("Upload from file to a block blob with file cleanup for failure cases")] [TestCategory(ComponentCategory.Blob)] [TestCategory(TestTypeCategory.UnitTest)] [TestCategory(SmokeTestCategory.NonSmoke)] @@ -270,19 +270,30 @@ public void CloudBlockBlobUploadDownloadFile() this.DoUploadDownloadFile(blob, 4097, false); TestHelper.ExpectedException( - () => blob.UploadFromFile("non_existent.file", FileMode.Open), + () => blob.UploadFromFile("non_existent.file"), "UploadFromFile requires an existing file"); TestHelper.ExpectedException( () => nullBlob.DownloadToFile("garbage.file", FileMode.Create), - "DownloadToFile should not leave an empty file behind after failing."); + "DownloadToFile should leave an unchanged file behind after failing."); Assert.IsFalse(File.Exists("garbage.file")); TestHelper.ExpectedException( () => nullBlob.DownloadToFile("garbage.file", FileMode.CreateNew), - "DownloadToFile should not leave an empty file behind after failing."); + "DownloadToFile should leave an unchanged file behind after failing."); Assert.IsFalse(File.Exists("garbage.file")); + byte[] buffer = GetRandomBuffer(100); + using (FileStream file = new FileStream("garbage.file", FileMode.Create, FileAccess.Write)) + { + file.Write(buffer, 0, buffer.Length); + } + TestHelper.ExpectedException( + () => nullBlob.DownloadToFile("garbage.file", FileMode.CreateNew), + "DownloadToFileAsync should leave an unchanged file behind after failing, depending on the mode."); + Assert.IsTrue(System.IO.File.Exists("garbage.file")); + System.IO.File.Delete("garbage.file"); + TestHelper.ExpectedException( () => nullBlob.DownloadToFile("garbage.file", FileMode.Append), "DownloadToFile should leave an empty file behind after failing depending on file mode."); @@ -291,7 +302,7 @@ public void CloudBlockBlobUploadDownloadFile() } [TestMethod] - [Description("Upload from file to a page blob")] + [Description("Upload from file to a page blob with file cleanup for failure cases")] [TestCategory(ComponentCategory.Blob)] [TestCategory(TestTypeCategory.UnitTest)] [TestCategory(SmokeTestCategory.NonSmoke)] @@ -308,19 +319,30 @@ public void CloudPageBlobUploadDownloadFile() "Page blobs must be 512-byte aligned"); TestHelper.ExpectedException( - () => blob.UploadFromFile("non_existent.file", FileMode.Open), + () => blob.UploadFromFile("non_existent.file"), "UploadFromFile requires an existing file"); TestHelper.ExpectedException( () => nullBlob.DownloadToFile("garbage.file", FileMode.Create), - "DownloadToFile should not leave an empty file behind after failing."); + "DownloadToFile should leave an unchanged file behind after failing."); Assert.IsFalse(File.Exists("garbage.file")); TestHelper.ExpectedException( () => nullBlob.DownloadToFile("garbage.file", FileMode.CreateNew), - "DownloadToFile should not leave an empty file behind after failing."); + "DownloadToFile should leave an unchanged file behind after failing."); Assert.IsFalse(File.Exists("garbage.file")); + byte[] buffer = GetRandomBuffer(100); + using (FileStream file = new FileStream("garbage.file", FileMode.Create, FileAccess.Write)) + { + file.WriteAsync(buffer, 0, buffer.Length); + } + TestHelper.ExpectedException( + () => nullBlob.DownloadToFile("garbage.file", FileMode.CreateNew), + "DownloadToFileAsync should leave an unchanged file behind after failing, depending on the mode."); + Assert.IsTrue(System.IO.File.Exists("garbage.file")); + System.IO.File.Delete("garbage.file"); + TestHelper.ExpectedException( () => nullBlob.DownloadToFile("garbage.file", FileMode.OpenOrCreate), "DownloadToFile should leave an empty file behind after failing, depending on file mode."); @@ -329,7 +351,7 @@ public void CloudPageBlobUploadDownloadFile() } [TestMethod] - [Description("Upload from file to an append blob")] + [Description("Upload from file to an append blob with file cleanup for failure cases")] [TestCategory(ComponentCategory.Blob)] [TestCategory(TestTypeCategory.UnitTest)] [TestCategory(SmokeTestCategory.NonSmoke)] @@ -343,19 +365,30 @@ public void CloudAppendBlobUploadDownloadFile() this.DoUploadDownloadFile(blob, 4097, false); TestHelper.ExpectedException( - () => blob.UploadFromFile("non_existent.file", FileMode.Open), + () => blob.UploadFromFile("non_existent.file"), "UploadFromFile requires an existing file"); TestHelper.ExpectedException( () => nullBlob.DownloadToFile("garbage.file", FileMode.Create), - "DownloadToFile should not leave an empty file behind after failing."); + "DownloadToFile should leave an unchanged file behind after failing."); Assert.IsFalse(File.Exists("garbage.file")); TestHelper.ExpectedException( () => nullBlob.DownloadToFile("garbage.file", FileMode.CreateNew), - "DownloadToFile should not leave an empty file behind after failing."); + "DownloadToFile should leave an unchanged file behind after failing."); Assert.IsFalse(File.Exists("garbage.file")); + byte[] buffer = GetRandomBuffer(100); + using (FileStream file = new FileStream("garbage.file", FileMode.Create, FileAccess.Write)) + { + file.WriteAsync(buffer, 0, buffer.Length); + } + TestHelper.ExpectedException( + () => nullBlob.DownloadToFile("garbage.file", FileMode.CreateNew), + "DownloadToFileAsync should leave an unchanged file behind after failing, depending on the mode."); + Assert.IsTrue(System.IO.File.Exists("garbage.file")); + System.IO.File.Delete("garbage.file"); + TestHelper.ExpectedException( () => nullBlob.DownloadToFile("garbage.file", FileMode.Append), "DownloadToFile should leave an empty file behind after failing depending on file mode."); @@ -364,7 +397,7 @@ public void CloudAppendBlobUploadDownloadFile() } [TestMethod] - [Description("Upload from file to a block blob")] + [Description("Upload from file to a block blob with file cleanup for failure cases")] [TestCategory(ComponentCategory.Blob)] [TestCategory(TestTypeCategory.UnitTest)] [TestCategory(SmokeTestCategory.NonSmoke)] @@ -378,7 +411,7 @@ public void CloudBlockBlobUploadDownloadFileAPM() this.DoUploadDownloadFile(blob, 4097, true); TestHelper.ExpectedException( - () => blob.BeginUploadFromFile("non_existent.file", FileMode.Open, null, null), + () => blob.BeginUploadFromFile("non_existent.file", null, null), "UploadFromFile requires an existing file"); IAsyncResult result; @@ -418,7 +451,7 @@ public void CloudBlockBlobUploadDownloadFileAPM() } [TestMethod] - [Description("Upload from file to a page blob")] + [Description("Upload from file to a page blob with file cleanup for failure cases")] [TestCategory(ComponentCategory.Blob)] [TestCategory(TestTypeCategory.UnitTest)] [TestCategory(SmokeTestCategory.NonSmoke)] @@ -435,7 +468,7 @@ public void CloudPageBlobUploadDownloadFileAPM() "Page blobs must be 512-byte aligned"); TestHelper.ExpectedException( - () => blob.BeginUploadFromFile("non_existent.file", FileMode.Open, null, null), + () => blob.BeginUploadFromFile("non_existent.file", null, null), "UploadFromFile requires an existing file"); IAsyncResult result; @@ -475,7 +508,7 @@ public void CloudPageBlobUploadDownloadFileAPM() } [TestMethod] - [Description("Upload from file to an append blob")] + [Description("Upload from file to an append blob with file cleanup for failure cases")] [TestCategory(ComponentCategory.Blob)] [TestCategory(TestTypeCategory.UnitTest)] [TestCategory(SmokeTestCategory.NonSmoke)] @@ -489,7 +522,7 @@ public void CloudAppendBlobUploadDownloadFileAPM() this.DoUploadDownloadFile(blob, 4097, true); TestHelper.ExpectedException( - () => blob.BeginUploadFromFile("non_existent.file", FileMode.Open, null, null), + () => blob.BeginUploadFromFile("non_existent.file", null, null), "UploadFromFile requires an existing file"); IAsyncResult result; @@ -530,7 +563,7 @@ public void CloudAppendBlobUploadDownloadFileAPM() #if TASK [TestMethod] - [Description("Upload from file to a block blob")] + [Description("Upload from file to a block blob with file cleanup for failure cases")] [TestCategory(ComponentCategory.Blob)] [TestCategory(TestTypeCategory.UnitTest)] [TestCategory(SmokeTestCategory.NonSmoke)] @@ -544,7 +577,7 @@ public void CloudBlockBlobUploadDownloadFileTask() this.DoUploadDownloadFileTask(blob, 4097); TestHelper.ExpectedException( - () => blob.UploadFromFileAsync("non_existent.file", FileMode.Open), + () => blob.UploadFromFileAsync("non_existent.file"), "UploadFromFile requires an existing file"); AggregateException e = TestHelper.ExpectedException( @@ -559,6 +592,23 @@ public void CloudBlockBlobUploadDownloadFileTask() Assert.IsTrue(e.InnerException is StorageException); Assert.IsFalse(File.Exists("garbage.file")); + byte[] buffer = GetRandomBuffer(100); + using (FileStream systemFile = new FileStream("garbage.file", FileMode.Create, FileAccess.Write)) + { + systemFile.WriteAsync(buffer, 0, buffer.Length); + } + try + { + nullBlob.DownloadToFileAsync("garbage.file", FileMode.CreateNew).Wait(); + Assert.Fail("DownloadToFileAsync should leave an unchanged file behind after failing, depending on the mode."); + } + catch (System.IO.IOException) + { + // Success if test reaches here meaning the expected exception was thrown. + Assert.IsTrue(System.IO.File.Exists("garbage.file")); + System.IO.File.Delete("garbage.file"); + } + e = TestHelper.ExpectedException( () => nullBlob.DownloadToFileAsync("garbage.file", FileMode.OpenOrCreate).Wait(), "DownloadToFile should leave an empty file behind after failing depending on file mode."); @@ -568,7 +618,7 @@ public void CloudBlockBlobUploadDownloadFileTask() } [TestMethod] - [Description("Upload from file to a page blob")] + [Description("Upload from file to a page blob with file cleanup for failure cases")] [TestCategory(ComponentCategory.Blob)] [TestCategory(TestTypeCategory.UnitTest)] [TestCategory(SmokeTestCategory.NonSmoke)] @@ -585,7 +635,7 @@ public void CloudPageBlobUploadDownloadFileTask() "Page blobs must be 512-byte aligned"); TestHelper.ExpectedException( - () => blob.UploadFromFileAsync("non_existent.file", FileMode.Open), + () => blob.UploadFromFileAsync("non_existent.file"), "UploadFromFile requires an existing file"); AggregateException e = TestHelper.ExpectedException( @@ -600,6 +650,23 @@ public void CloudPageBlobUploadDownloadFileTask() Assert.IsTrue(e.InnerException is StorageException); Assert.IsFalse(File.Exists("garbage.file")); + byte[] buffer = GetRandomBuffer(100); + using (FileStream systemFile = new FileStream("garbage.file", FileMode.Create, FileAccess.Write)) + { + systemFile.WriteAsync(buffer, 0, buffer.Length); + } + try + { + nullBlob.DownloadToFileAsync("garbage.file", FileMode.CreateNew).Wait(); + Assert.Fail("DownloadToFileAsync should leave an unchanged file behind after failing, depending on the mode."); + } + catch (System.IO.IOException) + { + // Success if test reaches here meaning the expected exception was thrown. + Assert.IsTrue(System.IO.File.Exists("garbage.file")); + System.IO.File.Delete("garbage.file"); + } + e = TestHelper.ExpectedException( () => nullBlob.DownloadToFileAsync("garbage.file", FileMode.Append).Wait(), "DownloadToFile should leave an empty file behind after failing, depending on file mode."); @@ -609,7 +676,7 @@ public void CloudPageBlobUploadDownloadFileTask() } [TestMethod] - [Description("Upload from file to an append blob")] + [Description("Upload from file to an append blob with file cleanup for failure cases")] [TestCategory(ComponentCategory.Blob)] [TestCategory(TestTypeCategory.UnitTest)] [TestCategory(SmokeTestCategory.NonSmoke)] @@ -623,7 +690,7 @@ public void CloudAppendBlobUploadDownloadFileTask() this.DoUploadDownloadFileTask(blob, 4097); TestHelper.ExpectedException( - () => blob.UploadFromFileAsync("non_existent.file", FileMode.Open), + () => blob.UploadFromFileAsync("non_existent.file"), "UploadFromFile requires an existing file"); AggregateException e = TestHelper.ExpectedException( @@ -638,6 +705,23 @@ public void CloudAppendBlobUploadDownloadFileTask() Assert.IsTrue(e.InnerException is StorageException); Assert.IsFalse(File.Exists("garbage.file")); + byte[] buffer = GetRandomBuffer(100); + using (FileStream systemFile = new FileStream("garbage.file", FileMode.Create, FileAccess.Write)) + { + systemFile.WriteAsync(buffer, 0, buffer.Length); + } + try + { + nullBlob.DownloadToFileAsync("garbage.file", FileMode.CreateNew).Wait(); + Assert.Fail("DownloadToFileAsync should leave an unchanged file behind after failing, depending on the mode."); + } + catch (System.IO.IOException) + { + // Success if test reaches here meaning the expected exception was thrown. + Assert.IsTrue(System.IO.File.Exists("garbage.file")); + System.IO.File.Delete("garbage.file"); + } + e = TestHelper.ExpectedException( () => nullBlob.DownloadToFileAsync("garbage.file", FileMode.OpenOrCreate).Wait(), "DownloadToFile should leave an empty file behind after failing depending on file mode."); @@ -660,9 +744,9 @@ private void DoUploadDownloadFileTask(ICloudBlob blob, int fileSize) } OperationContext context = new OperationContext(); - blob.UploadFromFileAsync(inputFileName, FileMode.Open).Wait(); + blob.UploadFromFileAsync(inputFileName).Wait(); - blob.UploadFromFileAsync(inputFileName, FileMode.Open, null, null, context).Wait(); + blob.UploadFromFileAsync(inputFileName, null, null, context).Wait(); Assert.IsNotNull(context.LastResult.ServiceRequestID); TestHelper.ExpectedException( @@ -736,13 +820,13 @@ private void DoUploadDownloadFile(ICloudBlob blob, int fileSize, bool isAsync) using (AutoResetEvent waitHandle = new AutoResetEvent(false)) { OperationContext context = new OperationContext(); - result = blob.BeginUploadFromFile(inputFileName, FileMode.Open, + result = blob.BeginUploadFromFile(inputFileName, ar => waitHandle.Set(), null); waitHandle.WaitOne(); blob.EndUploadFromFile(result); - result = blob.BeginUploadFromFile(inputFileName, FileMode.Open, null, null, context, + result = blob.BeginUploadFromFile(inputFileName, null, null, context, ar => waitHandle.Set(), null); waitHandle.WaitOne(); @@ -795,8 +879,8 @@ private void DoUploadDownloadFile(ICloudBlob blob, int fileSize, bool isAsync) { OperationContext context = new OperationContext(); - blob.UploadFromFile(inputFileName, FileMode.Open); - blob.UploadFromFile(inputFileName, FileMode.Open, null, null, context); + blob.UploadFromFile(inputFileName); + blob.UploadFromFile(inputFileName, null, null, context); Assert.IsNotNull(context.LastResult.ServiceRequestID); TestHelper.ExpectedException( diff --git a/Test/ClassLibraryCommon/Blob/LeaseTests.cs b/Test/ClassLibraryCommon/Blob/LeaseTests.cs index d27424c7e..2cc4d376a 100644 --- a/Test/ClassLibraryCommon/Blob/LeaseTests.cs +++ b/Test/ClassLibraryCommon/Blob/LeaseTests.cs @@ -5368,17 +5368,17 @@ public void ContainerAcquireLeaseSemanticTestsTask() leasedContainer = this.GetContainerReference("leased-container-1"); // make sure we use a new container SetUnleasedState(leasedContainer); - leaseId = leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(15), null /* proposed lease ID */).Result; + leaseId = leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(15)).Result; this.ContainerAcquireRenewLeaseTest(leasedContainer, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20), tolerance); leasedContainer = this.GetContainerReference("leased-container-2"); // make sure we use a new container SetUnleasedState(leasedContainer); - leaseId = leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(60), null /* proposed lease ID */).Result; + leaseId = leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(60)).Result; this.ContainerAcquireRenewLeaseTest(leasedContainer, TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(70), tolerance); leasedContainer = this.GetContainerReference("leased-container-3"); // make sure we use a new container SetUnleasedState(leasedContainer); - leaseId = leasedContainer.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */).Result; + leaseId = leasedContainer.AcquireLeaseAsync(null /* infinite lease */).Result; this.ContainerAcquireRenewLeaseTest(leasedContainer, null /* infinite lease */, TimeSpan.FromSeconds(70), tolerance); leasedContainer = this.GetContainerReference("leased-container-4"); // make sure we use a new container @@ -5927,9 +5927,9 @@ public void ContainerAcquireLeaseStateTestsTask() // Acquire with no proposed ID (non-idempotent) SetUnleasedState(leasedContainer); - leaseId = leasedContainer.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */).Result; + leaseId = leasedContainer.AcquireLeaseAsync(null /* infinite lease */).Result; TestHelper.ExpectedExceptionTask( - leasedContainer.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */), + leasedContainer.AcquireLeaseAsync(null /* infinite lease */), "acquire a lease twice with no proposed lease ID", HttpStatusCode.Conflict, BlobErrorCodeStrings.LeaseAlreadyPresent); @@ -7326,7 +7326,7 @@ public void ContainerLeasedDeleteTestsTask() this.ContainerDeleteExpectLeaseFailureTask(leasedContainer, testAccessCondition, HttpStatusCode.PreconditionFailed, BlobErrorCodeStrings.LeaseNotPresentWithContainerOperation, "delete container using a lease when no lease is held"); // Acquire a lease - string leaseId = leasedContainer.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */).Result; + string leaseId = leasedContainer.AcquireLeaseAsync(null /* lease duration */).Result; // Verify that deletes without a lease do not succeed. testAccessCondition.LeaseId = null; @@ -7532,7 +7532,7 @@ public void ContainerLeasedReadWriteTestsTask() this.ContainerReadWriteExpectLeaseFailureTask(leasedContainer, testAccessCondition, HttpStatusCode.PreconditionFailed, BlobErrorCodeStrings.LeaseNotPresentWithContainerOperation, "read/write container using a lease when no lease is held"); // Acquire a lease - string leaseId = leasedContainer.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */).Result; + string leaseId = leasedContainer.AcquireLeaseAsync(null /* lease duration */).Result; // Verify that reads and writes without a lease succeed. testAccessCondition.LeaseId = null; diff --git a/Test/ClassLibraryCommon/Blob/SASTests.cs b/Test/ClassLibraryCommon/Blob/SASTests.cs index af2acc420..928669009 100644 --- a/Test/ClassLibraryCommon/Blob/SASTests.cs +++ b/Test/ClassLibraryCommon/Blob/SASTests.cs @@ -870,6 +870,31 @@ public void CloudBlobSASSharedProtocolsQueryParam() } } + [TestMethod] + [Description("Perform a SAS request specifying a shared protocol and ensure that everything works properly.")] + [TestCategory(ComponentCategory.Blob)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] + public void CloudBlobSASSharedProtocolsQueryParamInvalid() + { + SharedAccessProtocol? protocol = default(SharedAccessProtocol); + SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy() + { + Permissions = SharedAccessBlobPermissions.Read, + SharedAccessStartTime = DateTimeOffset.UtcNow.AddMinutes(-5), + SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(30), + }; + + CloudBlobContainer container = GetRandomContainerReference(); + CloudBlockBlob blockBlob = container.GetBlockBlobReference("bb"); + + TestHelper.ExpectedException( + () => blockBlob.GetSharedAccessSignature(policy, null /* headers */, null /* stored access policy ID */, protocol, null /* IP address or range */), + "Creating a SAS should throw when using an invalid value for the Protocol enum.", + String.Format(SR.InvalidProtocolsInSAS, protocol)); + } + private static Uri TransformSchemeAndPort(Uri input, string scheme, int port) { UriBuilder builder = new UriBuilder(input); diff --git a/Test/ClassLibraryCommon/File/FileAnalyticsUnitTests.cs b/Test/ClassLibraryCommon/File/FileAnalyticsUnitTests.cs index 3ea16e0d5..d01c6d6ad 100644 --- a/Test/ClassLibraryCommon/File/FileAnalyticsUnitTests.cs +++ b/Test/ClassLibraryCommon/File/FileAnalyticsUnitTests.cs @@ -533,7 +533,7 @@ private void TestCorsRules(CloudFileClient client, IList corsProps) private static FileServiceProperties DefaultServiceProperties() { - FileServiceProperties props = new FileServiceProperties(); + FileServiceProperties props = new FileServiceProperties(new MetricsProperties(), new MetricsProperties(), new CorsProperties()); props.MinuteMetrics.Version = Constants.AnalyticsConstants.MetricsVersionV1; props.HourMetrics.Version = Constants.AnalyticsConstants.MetricsVersionV1; diff --git a/Test/ClassLibraryCommon/File/FileUploadDownloadTest.cs b/Test/ClassLibraryCommon/File/FileUploadDownloadTest.cs index ccdc36d22..3c30e268e 100644 --- a/Test/ClassLibraryCommon/File/FileUploadDownloadTest.cs +++ b/Test/ClassLibraryCommon/File/FileUploadDownloadTest.cs @@ -194,19 +194,30 @@ public void CloudFileUploadDownloadFile() this.DoUploadDownloadFile(file, 4096, false); TestHelper.ExpectedException( - () => file.UploadFromFile("non_existent.file", FileMode.Open), + () => file.UploadFromFile("non_existent.file"), "UploadFromFile requires an existing file"); TestHelper.ExpectedException( () => nullFile.DownloadToFile("garbage.file", FileMode.Create), - "DownloadToFile should not leave an empty file behind after failing."); + "DownloadToFile should leave an unchanged file behind after failing."); Assert.IsFalse(File.Exists("garbage.file")); TestHelper.ExpectedException( () => nullFile.DownloadToFile("garbage.file", FileMode.CreateNew), - "DownloadToFile should not leave an empty file behind after failing."); + "DownloadToFile should leave an unchanged file behind after failing."); Assert.IsFalse(File.Exists("garbage.file")); + byte[] buffer = GetRandomBuffer(100); + using (FileStream systemFile = new FileStream("garbage.file", FileMode.Create, FileAccess.Write)) + { + systemFile.WriteAsync(buffer, 0, buffer.Length); + } + TestHelper.ExpectedException( + () => nullFile.DownloadToFile("garbage.file", FileMode.CreateNew), + "DownloadToFileAsync should leave an unchanged file behind after failing, depending on the mode."); + Assert.IsTrue(System.IO.File.Exists("garbage.file")); + System.IO.File.Delete("garbage.file"); + TestHelper.ExpectedException( () => nullFile.DownloadToFile("garbage.file", FileMode.Append), "DownloadToFile should leave an empty file behind after failing depending on file mode."); @@ -228,7 +239,7 @@ public void CloudFileUploadDownloadFileAPM() this.DoUploadDownloadFile(file, 4096, true); TestHelper.ExpectedException( - () => file.BeginUploadFromFile("non_existent.file", FileMode.Open, null, null), + () => file.BeginUploadFromFile("non_existent.file", null, null), "UploadFromFile requires an existing file"); IAsyncResult result; @@ -282,21 +293,38 @@ public void CloudFileUploadDownloadFileTask() this.DoUploadDownloadFileTask(file, 4096); TestHelper.ExpectedException( - () => file.UploadFromFileAsync("non_existent.file", FileMode.Open), + () => file.UploadFromFileAsync("non_existent.file"), "UploadFromFile requires an existing file"); AggregateException e = TestHelper.ExpectedException( () => nullFile.DownloadToFileAsync("garbage.file", FileMode.Create).Wait(), - "DownloadToFile should not leave an empty file behind after failing."); + "DownloadToFile should leave an unchanged file behind after failing."); Assert.IsTrue(e.InnerException is StorageException); Assert.IsFalse(File.Exists("garbage.file")); e = TestHelper.ExpectedException( () => nullFile.DownloadToFileAsync("garbage.file", FileMode.CreateNew).Wait(), - "DownloadToFile should not leave an empty file behind after failing."); + "DownloadToFile should leave an unchanged file behind after failing."); Assert.IsTrue(e.InnerException is StorageException); Assert.IsFalse(File.Exists("garbage.file")); + byte[] buffer = GetRandomBuffer(100); + using (FileStream systemFile = new FileStream("garbage.file", FileMode.Create, FileAccess.Write)) + { + systemFile.WriteAsync(buffer, 0, buffer.Length); + } + try + { + nullFile.DownloadToFileAsync("garbage.file", FileMode.CreateNew).Wait(); + Assert.Fail("DownloadToFileAsync should leave an unchanged file behind after failing, depending on the mode."); + } + catch (System.IO.IOException) + { + // Success if test reaches here meaning the expected exception was thrown. + Assert.IsTrue(System.IO.File.Exists("garbage.file")); + System.IO.File.Delete("garbage.file"); + } + e = TestHelper.ExpectedException( () => nullFile.DownloadToFileAsync("garbage.file", FileMode.Append).Wait(), "DownloadToFile should leave an empty file behind after failing depending on file mode."); @@ -318,10 +346,10 @@ private void DoUploadDownloadFileTask(CloudFile file, int fileSize) fileStream.Write(buffer, 0, buffer.Length); } - file.UploadFromFileAsync(inputFileName, FileMode.Open).Wait(); + file.UploadFromFileAsync(inputFileName).Wait(); OperationContext context = new OperationContext(); - file.UploadFromFileAsync(inputFileName, FileMode.Open, null, null, context).Wait(); + file.UploadFromFileAsync(inputFileName, null, null, context).Wait(); Assert.IsNotNull(context.LastResult.ServiceRequestID); TestHelper.ExpectedException( @@ -394,14 +422,14 @@ private void DoUploadDownloadFile(CloudFile file, int fileSize, bool isAsync) IAsyncResult result; using (AutoResetEvent waitHandle = new AutoResetEvent(false)) { - result = file.BeginUploadFromFile(inputFileName, FileMode.Open, + result = file.BeginUploadFromFile(inputFileName, ar => waitHandle.Set(), null); waitHandle.WaitOne(); file.EndUploadFromFile(result); OperationContext context = new OperationContext(); - result = file.BeginUploadFromFile(inputFileName, FileMode.Open, null, null, context, + result = file.BeginUploadFromFile(inputFileName, null, null, context, ar => waitHandle.Set(), null); waitHandle.WaitOne(); @@ -452,10 +480,10 @@ private void DoUploadDownloadFile(CloudFile file, int fileSize, bool isAsync) } else { - file.UploadFromFile(inputFileName, FileMode.Open); + file.UploadFromFile(inputFileName); OperationContext context = new OperationContext(); - file.UploadFromFile(inputFileName, FileMode.Open, null, null, context); + file.UploadFromFile(inputFileName, null, null, context); Assert.IsNotNull(context.LastResult.ServiceRequestID); TestHelper.ExpectedException( diff --git a/Test/ClassLibraryCommon/Queue/QueueAnalyticsUnitTests.cs b/Test/ClassLibraryCommon/Queue/QueueAnalyticsUnitTests.cs index 25a6fa831..604f0ede8 100644 --- a/Test/ClassLibraryCommon/Queue/QueueAnalyticsUnitTests.cs +++ b/Test/ClassLibraryCommon/Queue/QueueAnalyticsUnitTests.cs @@ -766,11 +766,7 @@ public void CloudQueueTestAnalyticsOptionalPropertiesSync() client.SetServiceProperties(props); - ServiceProperties newProps = new ServiceProperties(); - - newProps.Logging = null; - newProps.HourMetrics = null; - newProps.MinuteMetrics = null; + ServiceProperties newProps = new ServiceProperties(cors: new CorsProperties()); newProps.Cors.CorsRules.Add( new CorsRule() @@ -829,7 +825,7 @@ private void TestCorsRules(CloudQueueClient client, IList corsProps) private static ServiceProperties DefaultServiceProperties() { - ServiceProperties props = new ServiceProperties(); + ServiceProperties props = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties(), new CorsProperties()); props.Logging.LoggingOperations = LoggingOperations.None; props.Logging.RetentionDays = null; diff --git a/Test/ClassLibraryCommon/Table/CloudTableClientTests.cs b/Test/ClassLibraryCommon/Table/CloudTableClientTests.cs index 121c3e297..60fe5f09c 100644 --- a/Test/ClassLibraryCommon/Table/CloudTableClientTests.cs +++ b/Test/ClassLibraryCommon/Table/CloudTableClientTests.cs @@ -1125,5 +1125,41 @@ public void CloudTableClientMaximumExecutionTimeCheck() Assert.IsInstanceOfType(ex, typeof(ArgumentOutOfRangeException)); } } + + [TestMethod] + [Description("Check for null pk/rk")] + [TestCategory(ComponentCategory.Table)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] + public void CloudTableClientNullPartitionKeyRowKeyCheck() + { + CloudTableClient client = GenerateCloudTableClient(); + var table = client.GetTableReference("newtable"); + table.CreateIfNotExists(); + try + { + TableBatchOperation batch = new TableBatchOperation(); + TableEntity entity = new TableEntity(null, "foo"); + batch.InsertOrMerge(entity); + table.ExecuteBatch(batch); + } + catch (Exception ex) + { + Assert.IsInstanceOfType(ex, typeof(ArgumentNullException)); + } + + try + { + TableBatchOperation batch = new TableBatchOperation(); + TableEntity entity = new TableEntity("foo", null); + batch.InsertOrMerge(entity); + table.ExecuteBatch(batch); + } + catch (Exception ex) + { + Assert.IsInstanceOfType(ex, typeof(ArgumentNullException)); + } + } } } diff --git a/Test/ClassLibraryCommon/Table/SAS/TableSasUnitTests.cs b/Test/ClassLibraryCommon/Table/SAS/TableSasUnitTests.cs index 5a91cbdd2..29a6418b8 100644 --- a/Test/ClassLibraryCommon/Table/SAS/TableSasUnitTests.cs +++ b/Test/ClassLibraryCommon/Table/SAS/TableSasUnitTests.cs @@ -30,7 +30,6 @@ namespace Microsoft.WindowsAzure.Storage.Table { -#pragma warning disable 0618 [TestClass] public class TableSasUnitTests : TableTestBase { @@ -1020,7 +1019,7 @@ public void TableSasInvalidOperations() CloudTableClient sasClient = new CloudTableClient(tableClient.BaseUri, new StorageCredentials(sasString)); // Construct a valid set of service properties to upload. - ServiceProperties properties = new ServiceProperties(); + ServiceProperties properties = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties()); properties.Logging.Version = Constants.AnalyticsConstants.LoggingVersionV1; properties.HourMetrics.Version = Constants.AnalyticsConstants.MetricsVersionV1; properties.Logging.RetentionDays = 9; @@ -1487,5 +1486,4 @@ internal static void AssertPermissionsEqual(TablePermissions permissions1, Table } #endregion } -#pragma warning restore 0618 } diff --git a/Test/ClassLibraryCommon/Table/TableAnalyticsUnitTests.cs b/Test/ClassLibraryCommon/Table/TableAnalyticsUnitTests.cs index c868338c7..a65fd4574 100644 --- a/Test/ClassLibraryCommon/Table/TableAnalyticsUnitTests.cs +++ b/Test/ClassLibraryCommon/Table/TableAnalyticsUnitTests.cs @@ -849,11 +849,7 @@ public void CloudTableTestAnalyticsOptionalPropertiesSync() client.SetServiceProperties(props); - ServiceProperties newProps = new ServiceProperties(); - - newProps.Logging = null; - newProps.HourMetrics = null; - newProps.MinuteMetrics = null; + ServiceProperties newProps = new ServiceProperties(cors: new CorsProperties()); newProps.Cors.CorsRules.Add( new CorsRule() @@ -911,7 +907,7 @@ private void TestCorsRules(CloudTableClient client, IList corsProps) } private static ServiceProperties DefaultServiceProperties() { - ServiceProperties props = new ServiceProperties(); + ServiceProperties props = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties(), new CorsProperties()); props.Logging.LoggingOperations = LoggingOperations.None; props.Logging.RetentionDays = null; diff --git a/Test/ClassLibraryCommon/Table/TableBatchOperationTest.cs b/Test/ClassLibraryCommon/Table/TableBatchOperationTest.cs index b2d6110cd..86d091a80 100644 --- a/Test/ClassLibraryCommon/Table/TableBatchOperationTest.cs +++ b/Test/ClassLibraryCommon/Table/TableBatchOperationTest.cs @@ -352,7 +352,7 @@ private void DoTableBatchInsertFailSync(TablePayloadFormat format) } catch (StorageException) { - TestHelper.ValidateResponse(opContext, 1, (int)HttpStatusCode.Conflict, new string[] { "EntityAlreadyExists" }, "The specified entity already exists"); + TestHelper.ValidateResponse(opContext, 1, (int)HttpStatusCode.Conflict, new string[] { "EntityAlreadyExists" }, "The specified entity already exists.", "The specified entity already exists."); } } @@ -1759,9 +1759,6 @@ public void TableBatchRetrieveWithResolverSync() DoTableBatchRetrieveWithResolverSync(TablePayloadFormat.Json); DoTableBatchRetrieveWithResolverSync(TablePayloadFormat.JsonNoMetadata); DoTableBatchRetrieveWithResolverSync(TablePayloadFormat.JsonFullMetadata); - #pragma warning disable 0618 - DoTableBatchRetrieveWithResolverSync(TablePayloadFormat.AtomPub); - #pragma warning restore 0618 } private void DoTableBatchRetrieveWithResolverSync(TablePayloadFormat format) @@ -2513,42 +2510,6 @@ private void DoTableBatchWithMultipleOperationsOnSameEntityShouldFail(TablePaylo } } - [TestMethod] - [Description("Ensure that a batch with over 100 entities will throw")] - [TestCategory(ComponentCategory.Table)] - [TestCategory(TestTypeCategory.UnitTest)] - [TestCategory(SmokeTestCategory.NonSmoke)] - [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] - public void TableBatchOver100EntitiesShouldThrow() - { - foreach (TablePayloadFormat payloadFormat in Enum.GetValues(typeof(TablePayloadFormat))) - { - DoTableBatchOver100EntitiesShouldThrow(payloadFormat); - } - } - - private void DoTableBatchOver100EntitiesShouldThrow(TablePayloadFormat format) - { - tableClient.DefaultRequestOptions.PayloadFormat = format; - TableBatchOperation batch = new TableBatchOperation(); - string pk = Guid.NewGuid().ToString(); - for (int m = 0; m < 101; m++) - { - batch.Insert(GenerateRandomEntity(pk)); - } - - OperationContext opContext = new OperationContext(); - try - { - currentTable.ExecuteBatch(batch, null, opContext); - Assert.Fail(); - } - catch (StorageException) - { - TestHelper.ValidateResponse(opContext, 1, (int)HttpStatusCode.BadRequest, new string[] { "InvalidInput" }, "One of the request inputs is not valid."); - } - } - [TestMethod] [Description("Ensure that a batch with entity over 1 MB will throw")] [TestCategory(ComponentCategory.Table)] @@ -2862,6 +2823,32 @@ private void DoTableBatchOperationWithRetryHasCorrectNumberOfResults(TablePayloa Assert.AreEqual(batch.Count, results.Count); } + [TestMethod] + [Description("A test to peform batch insert with batch size of 101. Should fail client-side.")] + [TestCategory(ComponentCategory.Table)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] + public void TableBatchTooManyOperations() + { + TableBatchOperation batch = new TableBatchOperation(); + try + { + for (int m = 0; m < 101; m++) + { + batch.Insert(GenerateRandomEntity("testpk"), true); + } + + currentTable.ExecuteBatch(batch); + + Assert.Fail("Batch commands with more than 101 operations should fail."); + } + catch (InvalidOperationException e) + { + Assert.AreEqual(e.Message, SR.BatchExceededMaximumNumberOfOperations); + } + } + #endregion #region Secondary diff --git a/Test/ClassLibraryCommon/Table/TableEntityEncryptionTests.cs b/Test/ClassLibraryCommon/Table/TableEntityEncryptionTests.cs index 792e88453..144c855c5 100644 --- a/Test/ClassLibraryCommon/Table/TableEntityEncryptionTests.cs +++ b/Test/ClassLibraryCommon/Table/TableEntityEncryptionTests.cs @@ -17,7 +17,6 @@ namespace Microsoft.WindowsAzure.Storage.Table { -#pragma warning disable 0618 using Microsoft.Azure.KeyVault; using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.WindowsAzure.Storage.Core; @@ -77,7 +76,6 @@ public void TableOperationInsertDTEEncryption() DoInsertDynamicTableEntityEncryptionSync(TablePayloadFormat.Json); DoInsertDynamicTableEntityEncryptionSync(TablePayloadFormat.JsonNoMetadata); DoInsertDynamicTableEntityEncryptionSync(TablePayloadFormat.JsonFullMetadata); - DoInsertDynamicTableEntityEncryptionSync(TablePayloadFormat.AtomPub); } private void DoInsertDynamicTableEntityEncryptionSync(TablePayloadFormat format) @@ -158,7 +156,6 @@ public void TableOperationInsertPOCOEncryptionWithResolverSync() DoInsertPOCOEntityEncryptionWithResolver(TablePayloadFormat.Json); DoInsertPOCOEntityEncryptionWithResolver(TablePayloadFormat.JsonNoMetadata); DoInsertPOCOEntityEncryptionWithResolver(TablePayloadFormat.JsonFullMetadata); - DoInsertPOCOEntityEncryptionWithResolver(TablePayloadFormat.AtomPub); } private void DoInsertPOCOEntityEncryptionWithResolver(TablePayloadFormat format) @@ -218,7 +215,6 @@ public void TableOperationInsertPOCOEncryptionWithAttributesSync() DoInsertPOCOEntityEncryptionWithAttributes(TablePayloadFormat.Json); DoInsertPOCOEntityEncryptionWithAttributes(TablePayloadFormat.JsonNoMetadata); DoInsertPOCOEntityEncryptionWithAttributes(TablePayloadFormat.JsonFullMetadata); - DoInsertPOCOEntityEncryptionWithAttributes(TablePayloadFormat.AtomPub); } private void DoInsertPOCOEntityEncryptionWithAttributes(TablePayloadFormat format) @@ -265,7 +261,6 @@ public void TableOperationInsertPOCOEncryptionWithAttributesAndResolverSync() DoInsertPOCOEntityEncryptionWithAttributesAndResolver(TablePayloadFormat.Json); DoInsertPOCOEntityEncryptionWithAttributesAndResolver(TablePayloadFormat.JsonNoMetadata); DoInsertPOCOEntityEncryptionWithAttributesAndResolver(TablePayloadFormat.JsonFullMetadata); - DoInsertPOCOEntityEncryptionWithAttributesAndResolver(TablePayloadFormat.AtomPub); } private void DoInsertPOCOEntityEncryptionWithAttributesAndResolver(TablePayloadFormat format) @@ -395,7 +390,6 @@ public void TableQueryPOCOProjectionEncryption() DoTableQueryPOCOProjectionEncryption(TablePayloadFormat.Json, aesKey); DoTableQueryPOCOProjectionEncryption(TablePayloadFormat.JsonNoMetadata, aesKey); DoTableQueryPOCOProjectionEncryption(TablePayloadFormat.JsonFullMetadata, aesKey); - DoTableQueryPOCOProjectionEncryption(TablePayloadFormat.AtomPub, aesKey); } private void DoTableQueryPOCOProjectionEncryption(TablePayloadFormat format, SymmetricKey aesKey) @@ -508,7 +502,6 @@ public void TableQueryDTEProjectionEncryption() DoTableQueryDTEProjectionEncryption(TablePayloadFormat.Json, aesKey); DoTableQueryDTEProjectionEncryption(TablePayloadFormat.JsonNoMetadata, aesKey); DoTableQueryDTEProjectionEncryption(TablePayloadFormat.JsonFullMetadata, aesKey); - DoTableQueryDTEProjectionEncryption(TablePayloadFormat.AtomPub, aesKey); } private void DoTableQueryDTEProjectionEncryption(TablePayloadFormat format, SymmetricKey aesKey) @@ -544,7 +537,6 @@ public void TableOperationReplaceEncryption() DoTableOperationReplaceEncryption(TablePayloadFormat.Json); DoTableOperationReplaceEncryption(TablePayloadFormat.JsonNoMetadata); DoTableOperationReplaceEncryption(TablePayloadFormat.JsonFullMetadata); - DoTableOperationReplaceEncryption(TablePayloadFormat.AtomPub); } private void DoTableOperationReplaceEncryption(TablePayloadFormat format) @@ -667,7 +659,6 @@ public void TableBatchInsertOrReplaceEncryption() DoTableBatchInsertOrReplaceEncryption(TablePayloadFormat.Json); DoTableBatchInsertOrReplaceEncryption(TablePayloadFormat.JsonNoMetadata); DoTableBatchInsertOrReplaceEncryption(TablePayloadFormat.JsonFullMetadata); - DoTableBatchInsertOrReplaceEncryption(TablePayloadFormat.AtomPub); } private void DoTableBatchInsertOrReplaceEncryption(TablePayloadFormat format) @@ -737,7 +728,6 @@ public void TableBatchRetrieveEncryptedEntitySync() DoTableBatchRetrieveEncryptedEntitySync(TablePayloadFormat.Json); DoTableBatchRetrieveEncryptedEntitySync(TablePayloadFormat.JsonNoMetadata); DoTableBatchRetrieveEncryptedEntitySync(TablePayloadFormat.JsonFullMetadata); - DoTableBatchRetrieveEncryptedEntitySync(TablePayloadFormat.AtomPub); } private void DoTableBatchRetrieveEncryptedEntitySync(TablePayloadFormat format) @@ -813,7 +803,6 @@ public void TableOperationValidateEncryption() DoTableOperationValidateEncryption(TablePayloadFormat.Json); DoTableOperationValidateEncryption(TablePayloadFormat.JsonNoMetadata); DoTableOperationValidateEncryption(TablePayloadFormat.JsonFullMetadata); - DoTableOperationValidateEncryption(TablePayloadFormat.AtomPub); } private void DoTableOperationValidateEncryption(TablePayloadFormat format) @@ -1260,5 +1249,4 @@ private static DynamicTableEntity GenerateRandomEntity(string pk) return ent; } } -#pragma warning restore 0618 } diff --git a/Test/ClassLibraryCommon/Table/TableQueryGenericTests.cs b/Test/ClassLibraryCommon/Table/TableQueryGenericTests.cs index 438693d27..38508736a 100644 --- a/Test/ClassLibraryCommon/Table/TableQueryGenericTests.cs +++ b/Test/ClassLibraryCommon/Table/TableQueryGenericTests.cs @@ -17,6 +17,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.WindowsAzure.Storage.Table.Entities; +using Microsoft.WindowsAzure.Storage.Table.Protocol; using System; using System.Collections.Generic; using System.Linq; @@ -25,7 +26,6 @@ namespace Microsoft.WindowsAzure.Storage.Table { -#pragma warning disable 0618 [TestClass] public class TableQueryGenericTests : TableTestBase { @@ -806,26 +806,71 @@ public void TableGenericQueryProjection() { foreach (TablePayloadFormat payloadFormat in Enum.GetValues(typeof(TablePayloadFormat))) { - DoTableGenericQueryProjection(payloadFormat); + DoTableGenericQueryProjection(payloadFormat, false); + DoTableGenericQueryProjection(payloadFormat, true); } } - private void DoTableGenericQueryProjection(TablePayloadFormat format) + private void DoTableGenericQueryProjection(TablePayloadFormat format, bool projectSystemProperties) { tableClient.DefaultRequestOptions.PayloadFormat = format; + tableClient.DefaultRequestOptions.ProjectSystemProperties = projectSystemProperties; + TableQuery query = new TableQuery().Select(new List() { "A", "C" }); foreach (BaseEntity ent in currentTable.ExecuteQuery(query)) { - Assert.IsNotNull(ent.PartitionKey); - Assert.IsNotNull(ent.RowKey); - Assert.IsNotNull(ent.Timestamp); + Assert.AreEqual(ent.A, "a"); + Assert.IsNull(ent.B); + Assert.AreEqual(ent.C, "c"); + Assert.IsNull(ent.D); + Assert.AreEqual(ent.E, 0); + if (tableClient.DefaultRequestOptions.ProjectSystemProperties.HasValue) + { + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.PartitionKey == default(string), "Missing expected " + TableConstants.PartitionKey); + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.RowKey == default(string), "Missing expected " + TableConstants.RowKey); + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.Timestamp == default(DateTimeOffset), "Missing expected " + TableConstants.Timestamp); + } + } + } + + [TestMethod] + [Description("Basic projection test")] + [TestCategory(ComponentCategory.Table)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] + public void TableGenericQueryProjectionSpecifyingSystemProperties() + { + foreach (TablePayloadFormat payloadFormat in Enum.GetValues(typeof(TablePayloadFormat))) + { + DoTableGenericQueryProjectionSpecifyingSystemProperties(payloadFormat, false); + DoTableGenericQueryProjectionSpecifyingSystemProperties(payloadFormat, true); + } + } + + private void DoTableGenericQueryProjectionSpecifyingSystemProperties(TablePayloadFormat format, bool projectSystemProperties) + { + tableClient.DefaultRequestOptions.PayloadFormat = format; + tableClient.DefaultRequestOptions.ProjectSystemProperties = projectSystemProperties; + + TableQuery query = new TableQuery().Select(new List() { "A", "C", TableConstants.PartitionKey, TableConstants.Timestamp }); + + foreach (BaseEntity ent in currentTable.ExecuteQuery(query)) + { Assert.AreEqual(ent.A, "a"); Assert.IsNull(ent.B); Assert.AreEqual(ent.C, "c"); Assert.IsNull(ent.D); Assert.AreEqual(ent.E, 0); + Assert.AreNotEqual(default(string), ent.PartitionKey); + Assert.AreNotEqual(default(DateTimeOffset), ent.Timestamp); + + if (tableClient.DefaultRequestOptions.ProjectSystemProperties.HasValue) + { + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.RowKey == default(string), "Missing expected " + TableConstants.RowKey); + } } } @@ -853,9 +898,7 @@ public void TableGenericQueryProjectionWithNull() table.Execute(TableOperation.Insert(entity)); DoTableGenericQueryProjectionWithSpecialCases(table, TablePayloadFormat.Json, false); - DoTableGenericQueryProjectionWithSpecialCases(table, TablePayloadFormat.AtomPub, false); DoTableGenericQueryProjectionWithSpecialCases(table, TablePayloadFormat.Json, true); - DoTableGenericQueryProjectionWithSpecialCases(table, TablePayloadFormat.AtomPub, true); } finally { @@ -890,9 +933,7 @@ public void TableGenericQueryProjectionWithIncorrectTypes() table.Execute(TableOperation.Insert(entity)); DoTableGenericQueryProjectionWithSpecialCases(table, TablePayloadFormat.Json, false); - DoTableGenericQueryProjectionWithSpecialCases(table, TablePayloadFormat.AtomPub, false); DoTableGenericQueryProjectionWithSpecialCases(table, TablePayloadFormat.Json, true); - DoTableGenericQueryProjectionWithSpecialCases(table, TablePayloadFormat.AtomPub, true); } finally { @@ -1939,5 +1980,4 @@ private static BaseEntity GenerateRandomEntity(string pk) } #endregion } -#pragma warning restore 0618 } diff --git a/Test/ClassLibraryCommon/Table/TableQueryTests.cs b/Test/ClassLibraryCommon/Table/TableQueryTests.cs index 4c7494c07..ff1c77ec0 100644 --- a/Test/ClassLibraryCommon/Table/TableQueryTests.cs +++ b/Test/ClassLibraryCommon/Table/TableQueryTests.cs @@ -17,6 +17,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.WindowsAzure.Storage.Table.Entities; +using Microsoft.WindowsAzure.Storage.Table.Protocol; using System; using System.Collections.Generic; using System.Globalization; @@ -716,25 +717,69 @@ public void TableQueryProjection() { foreach (TablePayloadFormat payloadFormat in Enum.GetValues(typeof(TablePayloadFormat))) { - DoTableQueryProjection(payloadFormat); + DoTableQueryProjection(payloadFormat, false); + DoTableQueryProjection(payloadFormat, true); } } - private void DoTableQueryProjection(TablePayloadFormat format) + private void DoTableQueryProjection(TablePayloadFormat format, bool projectSystemProperties) { tableClient.DefaultRequestOptions.PayloadFormat = format; + tableClient.DefaultRequestOptions.ProjectSystemProperties = projectSystemProperties; + TableQuery query = new TableQuery().Select(new List() { "a", "c" }); foreach (DynamicTableEntity ent in currentTable.ExecuteQuery(query)) { - Assert.IsNotNull(ent.PartitionKey); - Assert.IsNotNull(ent.RowKey); - Assert.IsNotNull(ent.Timestamp); + Assert.AreEqual(ent.Properties["a"].StringValue, "a"); + Assert.IsFalse(ent.Properties.ContainsKey("b")); + Assert.AreEqual(ent.Properties["c"].StringValue, "c"); + Assert.IsFalse(ent.Properties.ContainsKey("d")); + + if (tableClient.DefaultRequestOptions.ProjectSystemProperties.HasValue) + { + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.PartitionKey == default(string), "Missing expected " + TableConstants.PartitionKey); + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.RowKey == default(string), "Missing expected " + TableConstants.RowKey); + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.Timestamp == default(DateTimeOffset), "Missing expected " + TableConstants.Timestamp); + } + } + } + [TestMethod] + [Description("Basic projection test")] + [TestCategory(ComponentCategory.Table)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] + public void TableQueryProjectionSpecifyingSystemProperties() + { + foreach (TablePayloadFormat payloadFormat in Enum.GetValues(typeof(TablePayloadFormat))) + { + DoTableQueryProjectionSpecifyingSystemProperties(payloadFormat, false); + DoTableQueryProjectionSpecifyingSystemProperties(payloadFormat, true); + } + } + + private void DoTableQueryProjectionSpecifyingSystemProperties(TablePayloadFormat format, bool projectSystemProperties) + { + tableClient.DefaultRequestOptions.PayloadFormat = format; + tableClient.DefaultRequestOptions.ProjectSystemProperties = projectSystemProperties; + + TableQuery query = new TableQuery().Select(new List() { "a", "c", TableConstants.PartitionKey, TableConstants.Timestamp }); + + foreach (DynamicTableEntity ent in currentTable.ExecuteQuery(query)) + { Assert.AreEqual(ent.Properties["a"].StringValue, "a"); Assert.IsFalse(ent.Properties.ContainsKey("b")); Assert.AreEqual(ent.Properties["c"].StringValue, "c"); Assert.IsFalse(ent.Properties.ContainsKey("d")); + Assert.AreNotEqual(default(string), ent.PartitionKey); + Assert.AreNotEqual(default(DateTimeOffset), ent.Timestamp); + + if (tableClient.DefaultRequestOptions.ProjectSystemProperties.HasValue) + { + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.RowKey == default(string), "Missing expected " + TableConstants.RowKey); + } } } diff --git a/Test/ClassLibraryCommon/Table/TableQueryableTests.cs b/Test/ClassLibraryCommon/Table/TableQueryableTests.cs index 6b0a2975e..f1ca6ea38 100644 --- a/Test/ClassLibraryCommon/Table/TableQueryableTests.cs +++ b/Test/ClassLibraryCommon/Table/TableQueryableTests.cs @@ -1419,111 +1419,114 @@ public void TableQueryableEnumerateTwice() [TestCategory(SmokeTestCategory.NonSmoke)] [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void TableQueryableProjection() + { + DoTableQueryableProjection(false); + DoTableQueryableProjection(true); + } + + private void DoTableQueryableProjection(bool projectSystemProperties) { OperationContext opContext = new OperationContext(); - var baseQuery = currentTable.CreateQuery().WithContext(opContext); + var baseQuery = + currentTable.CreateQuery() + .WithContext(opContext) + .WithOptions(new TableRequestOptions(tableClient.DefaultRequestOptions) { ProjectSystemProperties = projectSystemProperties }); var pocoRes = (from ent in baseQuery select new ProjectedPOCO() { PartitionKey = ent.PartitionKey, - RowKey = ent.RowKey, Timestamp = ent.Timestamp, a = ent.a, c = ent.c - }); - int count = 0; + }) + .ToList(); // materialize, since we'll want the count later foreach (ProjectedPOCO ent in pocoRes) { - Assert.IsNotNull(ent.PartitionKey); - Assert.IsNotNull(ent.RowKey); - Assert.IsNotNull(ent.Timestamp); - Assert.AreEqual(ent.a, "a"); Assert.IsNull(ent.b); Assert.AreEqual(ent.c, "c"); Assert.IsNull(ent.d); - count++; - } - // Project a single property via Select - var stringRes = (from ent in baseQuery - select ent.b).ToList(); + Assert.AreNotEqual(default(string), ent.PartitionKey, "Missing expected PartitionKey"); + Assert.AreEqual(default(string), ent.RowKey, "Has unexpected RowKey"); + Assert.AreNotEqual(default(DateTimeOffset), ent.Timestamp, "Missing expected Timestamp"); + } - Assert.AreEqual(stringRes.Count, count); + var expectedPocoResultCount = pocoRes.Count(); // Project a single property and modify it via Select - TestHelper.ExpectedException(() => (from ent in complexEntityTable.CreateQuery() + TestHelper.ExpectedException(() => (from ent in complexEntityTable.CreateQuery().WithOptions(new TableRequestOptions(tableClient.DefaultRequestOptions) { ProjectSystemProperties = projectSystemProperties }) where ent.RowKey == "0050" select (ent.Int32 + 1)).Single(), "Specifying any operation after last navigation other than take should fail"); - TestHelper.ExpectedException(() => (from ent in complexEntityTable.CreateQuery() + TestHelper.ExpectedException(() => (from ent in complexEntityTable.CreateQuery().WithOptions(new TableRequestOptions(tableClient.DefaultRequestOptions) { ProjectSystemProperties = projectSystemProperties }) where ent.RowKey.CompareTo("0050") > 0 select ent.Int32).Skip(5).Single(), "Specifying any operation after last navigation other than take should fail"); // TableQuery.Project no resolver - IQueryable projectionResult = (from ent in baseQuery - select TableQuery.Project(ent, "a", "b")); - count = 0; + var projectionResult = (from ent in baseQuery + select TableQuery.Project(ent, "a", "b")) + .ToList(); + foreach (POCOEntity ent in projectionResult) { - Assert.IsNotNull(ent.PartitionKey); - Assert.IsNotNull(ent.RowKey); - Assert.IsNotNull(ent.Timestamp); - Assert.AreEqual(ent.a, "a"); Assert.AreEqual(ent.b, "b"); Assert.IsNull(ent.c); Assert.IsNull(ent.test); - count++; + + Assert.AreNotEqual(projectSystemProperties, ent.PartitionKey == default(string), "Missing expected PartitionKey"); + Assert.AreNotEqual(projectSystemProperties, ent.RowKey == default(string), "Missing expected RowKey"); + Assert.AreNotEqual(projectSystemProperties, ent.Timestamp == default(DateTimeOffset), "Missing expected Timestamp"); } - Assert.AreEqual(stringRes.Count, count); + Assert.AreEqual(expectedPocoResultCount, projectionResult.Count); // TableQuery.Project with resolver - IQueryable resolverRes = (from ent in baseQuery - select TableQuery.Project(ent, "a", "b")).Resolve((pk, rk, ts, props, etag) => props["a"].StringValue); - count = 0; + var resolverRes = (from ent in baseQuery + select TableQuery.Project(ent, "a", "b")) + .Resolve((pk, rk, ts, props, etag) => props["a"].StringValue) + .ToList(); + foreach (string s in resolverRes) { Assert.AreEqual(s, "a"); - count++; } - Assert.AreEqual(stringRes.Count, count); + Assert.AreEqual(expectedPocoResultCount, resolverRes.Count); // Project multiple properties via Select - IEnumerable> result = (from ent in baseQuery - select new Tuple - ( - ent.a, - ent.b - )).ToList(); + var result = (from ent in baseQuery + select new Tuple + ( + ent.a, + ent.b + )) + .ToList(); - count = 0; - foreach (Tuple entTuple in (IEnumerable>)result) + foreach (Tuple entTuple in result) { Assert.AreEqual("a", entTuple.Item1); Assert.AreEqual("b", entTuple.Item2); - count++; } - Assert.AreEqual(1500, count); + Assert.AreEqual(1500, result.Count); // Project with query options - TableQuery queryOptionsResult = (from ent in baseQuery - where (ent.PartitionKey == "tables_batch_1" && ent.RowKey.CompareTo("0050") > 0) - select new ProjectedPOCO() - { - PartitionKey = ent.PartitionKey, - RowKey = ent.RowKey, - Timestamp = ent.Timestamp, - a = ent.a, - c = ent.c - }).AsTableQuery(); + var queryOptionsResult = (from ent in baseQuery + where (ent.PartitionKey == "tables_batch_1" && ent.RowKey.CompareTo("0050") > 0) + select new ProjectedPOCO() + { + PartitionKey = ent.PartitionKey, + RowKey = ent.RowKey, + Timestamp = ent.Timestamp, + a = ent.a, + c = ent.c + }).AsTableQuery() + .ToList(); - count = 0; foreach (ProjectedPOCO ent in queryOptionsResult) { Assert.IsNotNull(ent.PartitionKey); @@ -1534,9 +1537,9 @@ where ent.RowKey.CompareTo("0050") > 0 Assert.IsNull(ent.b); Assert.AreEqual(ent.c, "c"); Assert.IsNull(ent.d); - count++; } - Assert.AreEqual(49, count); + + Assert.AreEqual(49, queryOptionsResult.Count); // Project to an anonymous type var anonymousRes = (from ent in baseQuery @@ -1544,24 +1547,26 @@ where ent.RowKey.CompareTo("0050") > 0 { a = ent.a, b = ent.b - }); - Assert.AreEqual(1500, anonymousRes.ToList().Count); + }) + .ToList(); + + Assert.AreEqual(1500, anonymousRes.Count); // Project with resolver - IQueryable resolverResult = (from ent in baseQuery - select new ProjectedPOCO() - { - a = ent.a, - c = ent.c - }).AsTableQuery().Resolve((pk, rk, ts, props, etag) => props["a"].StringValue); - count = 0; + var resolverResult = (from ent in baseQuery + select new ProjectedPOCO() + { + a = ent.a, + c = ent.c + }).AsTableQuery().Resolve((pk, rk, ts, props, etag) => props["a"].StringValue) + .ToList(); + foreach (string s in resolverResult) { Assert.AreEqual(s, "a"); - count++; } - Assert.AreEqual(stringRes.Count, count); + Assert.AreEqual(expectedPocoResultCount, resolverResult.Count); // Single with entity types ProjectedPOCO singleRes = (from ent in baseQuery @@ -1579,7 +1584,9 @@ where ent.RowKey.CompareTo("0050") > 0 Assert.IsNull(singleRes.b); Assert.AreEqual("c", singleRes.c); Assert.IsNull(singleRes.d); + Assert.AreEqual("tables_batch_1", singleRes.PartitionKey); Assert.AreEqual("0050", singleRes.RowKey); + Assert.AreNotEqual(default(DateTimeOffset), singleRes.Timestamp); // SingleOrDefault ProjectedPOCO singleOrDefaultRes = (from ent in baseQuery @@ -1597,7 +1604,9 @@ where ent.RowKey.CompareTo("0050") > 0 Assert.IsNull(singleOrDefaultRes.b); Assert.AreEqual("c", singleOrDefaultRes.c); Assert.IsNull(singleOrDefaultRes.d); + Assert.AreEqual("tables_batch_1", singleOrDefaultRes.PartitionKey); Assert.AreEqual("0050", singleOrDefaultRes.RowKey); + Assert.AreNotEqual(default(DateTimeOffset), singleOrDefaultRes.Timestamp); // First with entity types ProjectedPOCO firstRes = (from ent in baseQuery @@ -1615,7 +1624,9 @@ where ent.RowKey.CompareTo("0050") > 0 Assert.IsNull(firstRes.b); Assert.AreEqual("c", firstRes.c); Assert.IsNull(firstRes.d); + Assert.AreEqual("tables_batch_1", firstRes.PartitionKey); Assert.AreEqual("0051", firstRes.RowKey); + Assert.AreNotEqual(default(DateTimeOffset), firstRes.Timestamp); // FirstOrDefault with entity types ProjectedPOCO firstOrDefaultRes = (from ent in baseQuery @@ -1633,7 +1644,9 @@ where ent.RowKey.CompareTo("0050") > 0 Assert.IsNull(firstOrDefaultRes.b); Assert.AreEqual("c", firstOrDefaultRes.c); Assert.IsNull(firstOrDefaultRes.d); + Assert.AreEqual("tables_batch_1", firstOrDefaultRes.PartitionKey); Assert.AreEqual("0051", firstOrDefaultRes.RowKey); + Assert.AreNotEqual(default(DateTimeOffset), firstOrDefaultRes.Timestamp); } [TestMethod] diff --git a/Test/Common/TestBase.Common.cs b/Test/Common/TestBase.Common.cs index 97275c6f5..dc7f7ad93 100644 --- a/Test/Common/TestBase.Common.cs +++ b/Test/Common/TestBase.Common.cs @@ -174,16 +174,7 @@ public static CloudQueueClient GenerateCloudQueueClient() [Obsolete("Support for accessing Windows Azure Tables via WCF Data Services is now obsolete. It's recommended that you use the Microsoft.WindowsAzure.Storage.Table namespace for working with tables.")] public static void SetPayloadFormatOnDataServiceContext(TableServiceContext ctx, TablePayloadFormat format, CloudTableClient tableClient) { -#pragma warning disable 0618 - if (format == TablePayloadFormat.AtomPub) -#pragma warning restore 0618 - { - ctx.Format.UseAtom(); - } - else - { - ctx.Format.UseJson(new TableStorageModel(tableClient.Credentials.AccountName)); - } + ctx.Format.UseJson(new TableStorageModel(tableClient.Credentials.AccountName)); } #endif diff --git a/Test/Common/TestHelper.Common.cs b/Test/Common/TestHelper.Common.cs index 08894ecff..9d07c6242 100644 --- a/Test/Common/TestHelper.Common.cs +++ b/Test/Common/TestHelper.Common.cs @@ -43,7 +43,7 @@ public partial class TestHelper /// /// /// - internal static T ExpectedException(Action operation, string operationDescription) + internal static T ExpectedException(Action operation, string operationDescription, string expectedMessage = null) where T : Exception { try @@ -52,6 +52,13 @@ internal static T ExpectedException(Action operation, string operationDescrip } catch (T e) { + if (!string.IsNullOrEmpty(expectedMessage)) + { + if (!expectedMessage.Equals(e.Message, StringComparison.Ordinal)) + { + Assert.Fail("Incorrect message in exception. Expected: {0}, actual: {1}", expectedMessage, e.Message); + } + } return e; } #if ASPNET_K @@ -237,7 +244,7 @@ internal static void AssertBuffersAreEqualUptoIndex(byte[] src, byte[] dst, int } /// - /// Validates if this test supports the currnet target tenant. + /// Validates if this test supports the current target tenant. /// Skips the current test if the target tenant is not supported. /// public static void ValidateIfTestSupportTargetTenant(TenantType supportedTenantTypes) @@ -332,20 +339,26 @@ internal static CloudFile Defiddler(CloudFile file) } } - internal static void ValidateResponse(OperationContext opContext, int expectedAttempts, int expectedStatusCode, string[] allowedErrorCodes, string errorMessageBeginsWith) + internal static void ValidateResponse(OperationContext opContext, int expectedAttempts, int expectedStatusCode, string[] allowedErrorCodes, string errorMessageBeginsWith, string expectedStatusMessageBeginsWith = null) { - ValidateResponse(opContext, expectedAttempts, expectedStatusCode, allowedErrorCodes, new string[] { errorMessageBeginsWith }); + ValidateResponse(opContext, expectedAttempts, expectedStatusCode, allowedErrorCodes, new string[] { errorMessageBeginsWith }, expectedStatusMessageBeginsWith); } - internal static void ValidateResponse(OperationContext opContext, int expectedAttempts, int expectedStatusCode, string[] allowedErrorCodes, string[] errorMessageBeginsWith) + internal static void ValidateResponse(OperationContext opContext, int expectedAttempts, int expectedStatusCode, string[] allowedErrorCodes, string[] errorMessageBeginsWith, string expectedStatusMessageBeginsWith = null) { - ValidateResponse(opContext, expectedAttempts, expectedStatusCode, allowedErrorCodes, errorMessageBeginsWith, true); + ValidateResponse(opContext, expectedAttempts, expectedStatusCode, allowedErrorCodes, errorMessageBeginsWith, true, expectedStatusMessageBeginsWith); } - internal static void ValidateResponse(OperationContext opContext, int expectedAttempts, int expectedStatusCode, string[] allowedErrorCodes, string[] errorMessageBeginsWith, bool stripIndex) + internal static void ValidateResponse(OperationContext opContext, int expectedAttempts, int expectedStatusCode, string[] allowedErrorCodes, string[] errorMessageBeginsWith, bool stripIndex, string expectedStatusMessageBeginsWith = null) { TestHelper.AssertNAttempts(opContext, 1); Assert.AreEqual(opContext.LastResult.HttpStatusCode, expectedStatusCode); + + if (!string.IsNullOrEmpty(expectedStatusMessageBeginsWith)) + { + Assert.IsTrue(opContext.LastResult.HttpStatusMessage.ToString().Contains(expectedStatusMessageBeginsWith)); + } + Assert.IsTrue(allowedErrorCodes.Contains(opContext.LastResult.ExtendedErrorInformation.ErrorCode), "Unexpected Error Code, received " + opContext.LastResult.ExtendedErrorInformation.ErrorCode); if (errorMessageBeginsWith != null) diff --git a/Test/WindowsDesktop/Properties/AssemblyInfo.cs b/Test/WindowsDesktop/Properties/AssemblyInfo.cs index 06f277516..d6aae5590 100644 --- a/Test/WindowsDesktop/Properties/AssemblyInfo.cs +++ b/Test/WindowsDesktop/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("6.2.2.0")] -[assembly: AssemblyFileVersion("6.2.2.0")] +[assembly: AssemblyVersion("7.0.0.0")] +[assembly: AssemblyFileVersion("7.0.0.0")] diff --git a/Test/WindowsDesktop/Table/DataServices/SAS/TableSasUnitTests.cs b/Test/WindowsDesktop/Table/DataServices/SAS/TableSasUnitTests.cs index b24a3cc77..00d3366e1 100644 --- a/Test/WindowsDesktop/Table/DataServices/SAS/TableSasUnitTests.cs +++ b/Test/WindowsDesktop/Table/DataServices/SAS/TableSasUnitTests.cs @@ -1481,7 +1481,7 @@ public void TableSasInvalidOperations() CloudTableClient sasClient = new CloudTableClient(tableClient.BaseUri, new StorageCredentials(sasString)); // Construct a valid set of service properties to upload. - ServiceProperties properties = new ServiceProperties(); + ServiceProperties properties = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties()); properties.Logging.Version = Constants.AnalyticsConstants.LoggingVersionV1; properties.HourMetrics.Version = Constants.AnalyticsConstants.MetricsVersionV1; properties.Logging.RetentionDays = 9; diff --git a/Test/WindowsDesktop/Table/DataServices/TableEntityUnitTests.cs b/Test/WindowsDesktop/Table/DataServices/TableEntityUnitTests.cs index 3c8238a32..f82fe3bc5 100644 --- a/Test/WindowsDesktop/Table/DataServices/TableEntityUnitTests.cs +++ b/Test/WindowsDesktop/Table/DataServices/TableEntityUnitTests.cs @@ -26,7 +26,6 @@ namespace Microsoft.WindowsAzure.Storage.Table.DataServices { -#pragma warning disable 0618 [TestClass] [Obsolete("Support for accessing Windows Azure Tables via WCF Data Services is now obsolete. It's recommended that you use the Microsoft.WindowsAzure.Storage.Table namespace for working with tables.")] public class TableEntityUnitTests : TableTestBase @@ -98,7 +97,6 @@ public void MyTestCleanup() [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void SingleEntityInsert() { - DoSingleEntityInsert(TablePayloadFormat.AtomPub); DoSingleEntityInsert(TablePayloadFormat.Json); } @@ -159,7 +157,6 @@ public void SingleEntityInsertTask() [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void SingleEntityInsertConflict() { - DoSingleEntityInsertConflict(TablePayloadFormat.AtomPub); DoSingleEntityInsertConflict(TablePayloadFormat.Json); } @@ -204,7 +201,6 @@ private void DoSingleEntityInsertConflict(TablePayloadFormat format) [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void SingleEntityInsertOrMerge() { - DoSingleEntityInsertOrMerge(TablePayloadFormat.AtomPub); DoSingleEntityInsertOrMerge(TablePayloadFormat.Json); } @@ -275,7 +271,6 @@ private void DoSingleEntityInsertOrMerge(TablePayloadFormat format) [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void SingleEntityInsertOrReplace() { - DoSingleEntityInsertOrReplace(TablePayloadFormat.AtomPub); DoSingleEntityInsertOrReplace(TablePayloadFormat.Json); } @@ -555,7 +550,6 @@ public void SingleEntityInsertOrReplaceTask() [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void SingleEntityDelete() { - DoSingleEntityDelete(TablePayloadFormat.AtomPub); DoSingleEntityDelete(TablePayloadFormat.Json); } @@ -603,7 +597,6 @@ private void DoSingleEntityDelete(TablePayloadFormat format) [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void SingleEntityInsertDeleteFail() { - DoSingleEntityInsertDeleteFail(TablePayloadFormat.AtomPub); DoSingleEntityInsertDeleteFail(TablePayloadFormat.Json); } @@ -680,7 +673,6 @@ private void DoSingleEntityInsertDeleteFail(TablePayloadFormat format) [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void SingleEntityMerge() { - DoSingleEntityMerge(TablePayloadFormat.AtomPub); DoSingleEntityMerge(TablePayloadFormat.Json); } @@ -729,7 +721,6 @@ private void DoSingleEntityMerge(TablePayloadFormat format) [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void SingleEntityMergeFail() { - DoSingleEntityMergeFail(TablePayloadFormat.AtomPub); DoSingleEntityMergeFail(TablePayloadFormat.Json); } @@ -799,7 +790,6 @@ private void DoSingleEntityMergeFail(TablePayloadFormat format) [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void SingleEntityReplace() { - DoSingleEntityReplace(TablePayloadFormat.AtomPub); DoSingleEntityReplace(TablePayloadFormat.Json); } @@ -848,7 +838,6 @@ private void DoSingleEntityReplace(TablePayloadFormat format) [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void SingleEntityReplaceFail() { - DoSingleEntityReplaceFail(TablePayloadFormat.AtomPub); DoSingleEntityReplaceFail(TablePayloadFormat.Json); } @@ -919,7 +908,6 @@ private void DoSingleEntityReplaceFail(TablePayloadFormat format) [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void BatchInsert() { - DoBatchInsert(TablePayloadFormat.AtomPub); DoBatchInsert(TablePayloadFormat.Json); } @@ -1062,7 +1050,6 @@ public void BatchInsertTask() [TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void SingleEntityInsertEntityOver1MB() { - DoSingleEntityInsertEntityOver1MB(TablePayloadFormat.AtomPub); DoSingleEntityInsertEntityOver1MB(TablePayloadFormat.Json); } @@ -1090,5 +1077,4 @@ private void DoSingleEntityInsertEntityOver1MB(TablePayloadFormat format) } #endregion } -#pragma warning restore 0618 } diff --git a/Test/WindowsDesktop/Table/DataServices/TableServiceQueryUnitTests.cs b/Test/WindowsDesktop/Table/DataServices/TableServiceQueryUnitTests.cs index fdb0094ae..72f6921ff 100644 --- a/Test/WindowsDesktop/Table/DataServices/TableServiceQueryUnitTests.cs +++ b/Test/WindowsDesktop/Table/DataServices/TableServiceQueryUnitTests.cs @@ -26,7 +26,6 @@ namespace Microsoft.WindowsAzure.Storage.Table.DataServices { -#pragma warning disable 0618 /// /// Summary description for TableServiceQueryUnitTests /// @@ -142,7 +141,6 @@ public void TableServiceQueryExecuteSecondary() [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void TableServiceQueryExecuteBasic() { - DoTableServiceQueryExecuteBasic(TablePayloadFormat.AtomPub); DoTableServiceQueryExecuteBasic(TablePayloadFormat.Json); } @@ -168,7 +166,6 @@ private void DoTableServiceQueryExecuteBasic(TablePayloadFormat format) [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void TableServiceQueryExecuteWithTake() { - DoTableServiceQueryExecuteWithTake(TablePayloadFormat.AtomPub); DoTableServiceQueryExecuteWithTake(TablePayloadFormat.Json); } @@ -235,7 +232,6 @@ private void DoTableServiceQueryExecuteWithTake(TablePayloadFormat format) [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void TableServiceQueryExecuteSegmentedBasicSync() { - DoTableServiceQueryExecuteSegmentedBasicSync(TablePayloadFormat.AtomPub); DoTableServiceQueryExecuteSegmentedBasicSync(TablePayloadFormat.Json); } @@ -277,7 +273,6 @@ private void DoTableServiceQueryExecuteSegmentedBasicSync(TablePayloadFormat for [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void TableServiceQueryExecuteSegmentedWithTake() { - DoTableServiceQueryExecuteSegmentedWithTake(TablePayloadFormat.AtomPub); DoTableServiceQueryExecuteSegmentedWithTake(TablePayloadFormat.Json); } @@ -421,7 +416,6 @@ public void TableServiceQueryExecuteSegmentedBasicTask() [TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void TableServiceQueryProjection() { - DoTableServiceQueryProjection(TablePayloadFormat.AtomPub); DoTableServiceQueryProjection(TablePayloadFormat.Json); } @@ -462,7 +456,6 @@ private void DoTableServiceQueryProjection(TablePayloadFormat format) [TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void TableServiceQueryProjectionWithUpdate() { - DoTableServiceQueryProjectionWithUpdate(TablePayloadFormat.AtomPub); DoTableServiceQueryProjectionWithUpdate(TablePayloadFormat.Json); } @@ -509,5 +502,4 @@ private void DoTableServiceQueryProjectionWithUpdate(TablePayloadFormat format) #endregion } -#pragma warning restore 0618 } diff --git a/Test/WindowsPhone/Properties/AssemblyInfo.cs b/Test/WindowsPhone/Properties/AssemblyInfo.cs index dbab0fd42..350a4a6cf 100644 --- a/Test/WindowsPhone/Properties/AssemblyInfo.cs +++ b/Test/WindowsPhone/Properties/AssemblyInfo.cs @@ -32,6 +32,6 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("6.2.2.0")] -[assembly: AssemblyFileVersion("6.2.2.0")] +[assembly: AssemblyVersion("7.0.0.0")] +[assembly: AssemblyFileVersion("7.0.0.0")] [assembly: NeutralResourcesLanguageAttribute("en-US")] diff --git a/Test/WindowsPhone81/Properties/AssemblyInfo.cs b/Test/WindowsPhone81/Properties/AssemblyInfo.cs index e56552259..f9ac1818b 100644 --- a/Test/WindowsPhone81/Properties/AssemblyInfo.cs +++ b/Test/WindowsPhone81/Properties/AssemblyInfo.cs @@ -33,6 +33,6 @@ // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("6.2.2.0")] -[assembly: AssemblyFileVersion("6.2.2.0")] +[assembly: AssemblyVersion("7.0.0.0")] +[assembly: AssemblyFileVersion("7.0.0.0")] [assembly: NeutralResourcesLanguageAttribute("en-US")] diff --git a/Test/WindowsPhoneCommon/Blob/BlobAnalyticsUnitTests.cs b/Test/WindowsPhoneCommon/Blob/BlobAnalyticsUnitTests.cs index 5dacebdcd..63e5cf800 100644 --- a/Test/WindowsPhoneCommon/Blob/BlobAnalyticsUnitTests.cs +++ b/Test/WindowsPhoneCommon/Blob/BlobAnalyticsUnitTests.cs @@ -334,7 +334,7 @@ private void AssertServicePropertiesAreEqual(ServiceProperties propsA, ServicePr private static ServiceProperties DefaultServiceProperties() { - ServiceProperties props = new ServiceProperties(); + ServiceProperties props = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties()); props.Logging.LoggingOperations = LoggingOperations.None; props.Logging.RetentionDays = null; diff --git a/Test/WindowsPhoneCommon/Blob/BlobUploadDownloadTest.cs b/Test/WindowsPhoneCommon/Blob/BlobUploadDownloadTest.cs index fe357194b..b8798d053 100644 --- a/Test/WindowsPhoneCommon/Blob/BlobUploadDownloadTest.cs +++ b/Test/WindowsPhoneCommon/Blob/BlobUploadDownloadTest.cs @@ -168,9 +168,9 @@ private async Task DoUploadDownloadFileAsync(ICloudBlob blob, int fileSize) } OperationContext context = new OperationContext(); - await blob.UploadFromFileAsync(inputFileName, FileMode.Open); + await blob.UploadFromFileAsync(inputFileName); - await blob.UploadFromFileAsync(inputFileName, FileMode.Open, null, null, context); + await blob.UploadFromFileAsync(inputFileName, null, null, context); Assert.IsNotNull(context.LastResult.ServiceRequestID); await TestHelper.ExpectedExceptionAsync( diff --git a/Test/WindowsPhoneCommon/Blob/CloudBlobContainerTest.cs b/Test/WindowsPhoneCommon/Blob/CloudBlobContainerTest.cs index c12e926de..d6a414219 100644 --- a/Test/WindowsPhoneCommon/Blob/CloudBlobContainerTest.cs +++ b/Test/WindowsPhoneCommon/Blob/CloudBlobContainerTest.cs @@ -707,8 +707,6 @@ public async Task CloudBlobContainerGetBlobReferenceFromServerAsync() container.DeleteIfExistsAsync().Wait(); } } - -#pragma warning restore 0618 [TestMethod] [Description("Test conditional access on a container")] diff --git a/Test/WindowsPhoneCommon/Blob/LeaseTests.cs b/Test/WindowsPhoneCommon/Blob/LeaseTests.cs index 5c5c10608..23106d767 100644 --- a/Test/WindowsPhoneCommon/Blob/LeaseTests.cs +++ b/Test/WindowsPhoneCommon/Blob/LeaseTests.cs @@ -394,15 +394,15 @@ public async Task BlobAcquireLeaseSemanticTestsAsync() CloudBlob leasedBlob = this.GetContainerReference("lease-tests").GetBlockBlobReference("LeasedBlob"); await SetAvailableStateAsync(leasedBlob); - leaseId = await leasedBlob.AcquireLeaseAsync(TimeSpan.FromSeconds(15), null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(TimeSpan.FromSeconds(15)); await this.BlobAcquireRenewLeaseTestAsync(leasedBlob, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20), tolerance); await SetAvailableStateAsync(leasedBlob); - leaseId = await leasedBlob.AcquireLeaseAsync(TimeSpan.FromSeconds(60), null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(TimeSpan.FromSeconds(60)); await this.BlobAcquireRenewLeaseTestAsync(leasedBlob, TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(70), tolerance); await SetAvailableStateAsync(leasedBlob); - leaseId = await leasedBlob.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* infinite lease */); await this.BlobAcquireRenewLeaseTestAsync(leasedBlob, null /* infinite lease */, TimeSpan.FromSeconds(70), tolerance); await SetReleasedStateAsync(leasedBlob, null /* infinite lease */); @@ -548,7 +548,7 @@ await TestHelper.ExpectedExceptionAsync( "acquire a lease with 0 duration"); await TestHelper.ExpectedExceptionAsync( - async () => await leasedBlob.AcquireLeaseAsync(TimeSpan.FromSeconds(-1), null /* proposed lease ID */), + async () => await leasedBlob.AcquireLeaseAsync(TimeSpan.FromSeconds(-1)), "acquire a lease with -1 duration"); await TestHelper.ExpectedExceptionAsync( @@ -695,7 +695,7 @@ await TestHelper.ExpectedExceptionAsync( // Acquire with no proposed ID (non-idempotent) await SetAvailableStateAsync(leasedBlob); - leaseId = await leasedBlob.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* infinite lease */); await TestHelper.ExpectedExceptionAsync( async () => await leasedBlob.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */, null, null, operationContext), operationContext, @@ -1394,7 +1394,7 @@ public async Task PageBlobLeasedWriteTestsAsync() await PageBlobWriteExpectLeaseFailureAsync(leasedBlob, testAccessCondition, HttpStatusCode.PreconditionFailed, BlobErrorCodeStrings.LeaseNotPresentWithBlobOperation, "write page blob with a lease when no lease is held"); // Acquire a lease - leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */); // Verify that writes without a lease do not succeed. testAccessCondition.LeaseId = null; @@ -1510,7 +1510,7 @@ public async Task PageBlobLeasedReadTestsAsync() await PageBlobReadExpectLeaseFailureAsync(leasedBlob, testAccessCondition, HttpStatusCode.PreconditionFailed, BlobErrorCodeStrings.LeaseNotPresentWithBlobOperation, "read page blob with a lease when no lease is held"); // Acquire a lease - leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */); // Verify that reads without a lease succeed. testAccessCondition.LeaseId = null; @@ -1590,7 +1590,7 @@ public async Task BlockBlobLeasedWriteTestsAsync() // Acquire a lease testAccessCondition.LeaseId = null; - leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */); // Verify that writes without a lease do not succeed. testAccessCondition.LeaseId = null; @@ -1731,7 +1731,7 @@ public async Task BlockBlobLeasedReadTestsWithoutListAsync() // Acquire a lease testAccessCondition.LeaseId = null; - leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */); // Verify that reads without a lease still succeed. testAccessCondition.LeaseId = null; @@ -1782,7 +1782,7 @@ public async Task BlockBlobLeasedReadTestsWithListAsync() // Acquire a lease testAccessCondition.LeaseId = null; - leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */); // Verify that reads without a lease still succeed. testAccessCondition.LeaseId = null; @@ -1888,7 +1888,7 @@ public async Task BlobLeaseStatusTestAsync() // Check lease status after (infinite) acquire after break await SetTimeBrokenStateAsync(leasedBlob); - await leasedBlob.AcquireLeaseAsync(null /* infinite lease */, null /*proposed lease ID */); + await leasedBlob.AcquireLeaseAsync(null /* infinite lease */); await this.CheckLeaseStatusAsync(leasedBlob, LeaseStatus.Locked, LeaseState.Leased, LeaseDuration.Infinite, "after second acquire lease"); // Check lease status after instant break with infinite lease @@ -1946,17 +1946,17 @@ public async Task ContainerAcquireLeaseSemanticTestsAsync() leasedContainer = this.GetContainerReference("leased-container-1"); // make sure we use a new container await SetUnleasedStateAsync(leasedContainer); - leaseId = await leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(15), null /* proposed lease ID */); + leaseId = await leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(15)); await this.ContainerAcquireRenewLeaseTestAsync(leasedContainer, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20), tolerance); leasedContainer = this.GetContainerReference("leased-container-2"); // make sure we use a new container await SetUnleasedStateAsync(leasedContainer); - leaseId = await leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(60), null /* proposed lease ID */); + leaseId = await leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(60)); await this.ContainerAcquireRenewLeaseTestAsync(leasedContainer, TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(70), tolerance); leasedContainer = this.GetContainerReference("leased-container-3"); // make sure we use a new container await SetUnleasedStateAsync(leasedContainer); - leaseId = await leasedContainer.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */); + leaseId = await leasedContainer.AcquireLeaseAsync(null /* infinite lease */); await this.ContainerAcquireRenewLeaseTestAsync(leasedContainer, null /* infinite lease */, TimeSpan.FromSeconds(70), tolerance); leasedContainer = this.GetContainerReference("leased-container-4"); // make sure we use a new container @@ -2097,11 +2097,11 @@ public async Task ContainerLeaseInvalidInputTestsAsync() await leasedContainer.CreateAsync(); await TestHelper.ExpectedExceptionAsync( - async () => await leasedContainer.AcquireLeaseAsync(TimeSpan.Zero, null /* proposed lease ID */), + async () => await leasedContainer.AcquireLeaseAsync(TimeSpan.Zero), "acquire a lease with 0 duration"); await TestHelper.ExpectedExceptionAsync( - async () => await leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(-1), null /* proposed lease ID */), + async () => await leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(-1)), "acquire a lease with -1 duration"); await TestHelper.ExpectedExceptionAsync( @@ -2250,7 +2250,7 @@ await TestHelper.ExpectedExceptionAsync( // Acquire with no proposed ID (non-idempotent) await SetUnleasedStateAsync(leasedContainer); - leaseId = await leasedContainer.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */); + leaseId = await leasedContainer.AcquireLeaseAsync(null /* infinite lease */); await TestHelper.ExpectedExceptionAsync( async () => await leasedContainer.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */, null, null, operationContext), operationContext, @@ -2704,7 +2704,7 @@ public async Task ContainerLeasedDeleteTestsAsync() await this.ContainerDeleteExpectLeaseFailureAsync(leasedContainer, testAccessCondition, HttpStatusCode.PreconditionFailed, BlobErrorCodeStrings.LeaseNotPresentWithContainerOperation, "delete container using a lease when no lease is held"); // Acquire a lease - string leaseId = await leasedContainer.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + string leaseId = await leasedContainer.AcquireLeaseAsync(null /* lease duration */); // Verify that deletes without a lease do not succeed. testAccessCondition.LeaseId = null; @@ -2767,7 +2767,7 @@ public async Task ContainerLeasedReadWriteTestsAsync() await this.ContainerReadWriteExpectLeaseFailureAsync(leasedContainer, testAccessCondition, HttpStatusCode.PreconditionFailed, BlobErrorCodeStrings.LeaseNotPresentWithContainerOperation, "read/write container using a lease when no lease is held"); // Acquire a lease - string leaseId = await leasedContainer.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + string leaseId = await leasedContainer.AcquireLeaseAsync(null /* lease duration */); // Verify that reads and writes without a lease succeed. testAccessCondition.LeaseId = null; @@ -2896,7 +2896,7 @@ public async Task ContainerLeaseStatusTestAsync() // Check lease status after (infinite) acquire after break await SetTimeBrokenStateAsync(leasedContainer); - await leasedContainer.AcquireLeaseAsync(null /* infinite lease */, null /*proposed lease ID */); + await leasedContainer.AcquireLeaseAsync(null /* infinite lease */); await this.CheckLeaseStatusAsync(leasedContainer, LeaseStatus.Locked, LeaseState.Leased, LeaseDuration.Infinite, "after second acquire lease"); // Check lease status after instant break with infinite lease diff --git a/Test/WindowsPhoneCommon/File/FileUploadDownloadTest.cs b/Test/WindowsPhoneCommon/File/FileUploadDownloadTest.cs index f14c0c08c..3fe330354 100644 --- a/Test/WindowsPhoneCommon/File/FileUploadDownloadTest.cs +++ b/Test/WindowsPhoneCommon/File/FileUploadDownloadTest.cs @@ -135,10 +135,10 @@ private async Task DoUploadDownloadFileAsync(CloudFile file, int fileSize) await fileStream.WriteAsync(buffer, 0, buffer.Length); } - await file.UploadFromFileAsync(inputFileName, FileMode.Open); + await file.UploadFromFileAsync(inputFileName); OperationContext context = new OperationContext(); - await file.UploadFromFileAsync(inputFileName, FileMode.Open, null, null, context); + await file.UploadFromFileAsync(inputFileName, null, null, context); Assert.IsNotNull(context.LastResult.ServiceRequestID); await TestHelper.ExpectedExceptionAsync( diff --git a/Test/WindowsPhoneCommon/Queue/QueueAnalyticsUnitTests.cs b/Test/WindowsPhoneCommon/Queue/QueueAnalyticsUnitTests.cs index 14c611b3f..244012bcb 100644 --- a/Test/WindowsPhoneCommon/Queue/QueueAnalyticsUnitTests.cs +++ b/Test/WindowsPhoneCommon/Queue/QueueAnalyticsUnitTests.cs @@ -324,7 +324,7 @@ private void AssertServicePropertiesAreEqual(ServiceProperties propsA, ServicePr private static ServiceProperties DefaultServiceProperties() { - ServiceProperties props = new ServiceProperties(); + ServiceProperties props = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties()); props.Logging.LoggingOperations = LoggingOperations.None; props.Logging.RetentionDays = null; diff --git a/Test/WindowsPhoneCommon/Table/CloudTableCRUDUnitTaskTests.cs b/Test/WindowsPhoneCommon/Table/CloudTableCRUDUnitTaskTests.cs index 23093c9e8..7b8fda84f 100644 --- a/Test/WindowsPhoneCommon/Table/CloudTableCRUDUnitTaskTests.cs +++ b/Test/WindowsPhoneCommon/Table/CloudTableCRUDUnitTaskTests.cs @@ -22,7 +22,6 @@ namespace Microsoft.WindowsAzure.Storage.Table { -#pragma warning disable 0618 /// /// Summary description for CloudTableCRUDUnitTaskTests /// @@ -91,7 +90,6 @@ public async Task CloudTableCreateAsync() await DoCloudTableCreateAsync(TablePayloadFormat.Json); await DoCloudTableCreateAsync(TablePayloadFormat.JsonNoMetadata); await DoCloudTableCreateAsync(TablePayloadFormat.JsonFullMetadata); - await DoCloudTableCreateAsync(TablePayloadFormat.AtomPub); } private async Task DoCloudTableCreateAsync(TablePayloadFormat format) @@ -124,7 +122,6 @@ public async Task CloudTableCreateAlreadyExistsAsync() await DoCloudTableCreateAlreadyExistsAsync(TablePayloadFormat.Json); await DoCloudTableCreateAlreadyExistsAsync(TablePayloadFormat.JsonNoMetadata); await DoCloudTableCreateAlreadyExistsAsync(TablePayloadFormat.JsonFullMetadata); - await DoCloudTableCreateAlreadyExistsAsync(TablePayloadFormat.AtomPub); } private async Task DoCloudTableCreateAlreadyExistsAsync(TablePayloadFormat format) @@ -171,7 +168,6 @@ public async Task CloudTableCreateIfNotExistsAsync() await DoCloudTableCreateIfNotExistsAsync(TablePayloadFormat.Json); await DoCloudTableCreateIfNotExistsAsync(TablePayloadFormat.JsonNoMetadata); await DoCloudTableCreateIfNotExistsAsync(TablePayloadFormat.JsonFullMetadata); - await DoCloudTableCreateIfNotExistsAsync(TablePayloadFormat.AtomPub); } private async Task DoCloudTableCreateIfNotExistsAsync(TablePayloadFormat format) @@ -208,7 +204,6 @@ public async Task CloudTableDeleteAsync() await DoCloudTableDeleteAsync(TablePayloadFormat.Json); await DoCloudTableDeleteAsync(TablePayloadFormat.JsonNoMetadata); await DoCloudTableDeleteAsync(TablePayloadFormat.JsonFullMetadata); - await DoCloudTableDeleteAsync(TablePayloadFormat.AtomPub); } private async Task DoCloudTableDeleteAsync(TablePayloadFormat format) @@ -243,7 +238,6 @@ public async Task CloudTableDeleteWhenNotExistAsync() await DoCloudTableDeleteWhenNotExistAsync(TablePayloadFormat.Json); await DoCloudTableDeleteWhenNotExistAsync(TablePayloadFormat.JsonNoMetadata); await DoCloudTableDeleteWhenNotExistAsync(TablePayloadFormat.JsonFullMetadata); - await DoCloudTableDeleteWhenNotExistAsync(TablePayloadFormat.AtomPub); } private async Task DoCloudTableDeleteWhenNotExistAsync(TablePayloadFormat format) @@ -288,7 +282,6 @@ public async Task CloudTableDeleteIfExistsAsync() await DoCloudTableDeleteIfExistsAsync(TablePayloadFormat.Json); await DoCloudTableDeleteIfExistsAsync(TablePayloadFormat.JsonNoMetadata); await DoCloudTableDeleteIfExistsAsync(TablePayloadFormat.JsonFullMetadata); - await DoCloudTableDeleteIfExistsAsync(TablePayloadFormat.AtomPub); } private async Task DoCloudTableDeleteIfExistsAsync(TablePayloadFormat format) @@ -327,7 +320,6 @@ public async Task CloudTableExistsAsync() await DoCloudTableExistsAsync(TablePayloadFormat.Json); await DoCloudTableExistsAsync(TablePayloadFormat.JsonNoMetadata); await DoCloudTableExistsAsync(TablePayloadFormat.JsonFullMetadata); - await DoCloudTableExistsAsync(TablePayloadFormat.AtomPub); } private async Task DoCloudTableExistsAsync(TablePayloadFormat format) @@ -352,5 +344,4 @@ private async Task DoCloudTableExistsAsync(TablePayloadFormat format) } #endregion } -#pragma warning restore 0618 } diff --git a/Test/WindowsPhoneCommon/Table/CloudTableClientTaskTest.cs b/Test/WindowsPhoneCommon/Table/CloudTableClientTaskTest.cs index b23a56ac0..e5c529bde 100644 --- a/Test/WindowsPhoneCommon/Table/CloudTableClientTaskTest.cs +++ b/Test/WindowsPhoneCommon/Table/CloudTableClientTaskTest.cs @@ -23,7 +23,6 @@ namespace Microsoft.WindowsAzure.Storage.Table { -#pragma warning disable 0618 [TestClass] public class CloudTableClientTaskTest : TableTestBase { @@ -140,7 +139,6 @@ public async Task ListTablesSegmentedBasicAsync() await DoListTablesSegmentedBasicAsync(TablePayloadFormat.Json); await DoListTablesSegmentedBasicAsync(TablePayloadFormat.JsonNoMetadata); await DoListTablesSegmentedBasicAsync(TablePayloadFormat.JsonFullMetadata); - await DoListTablesSegmentedBasicAsync(TablePayloadFormat.AtomPub); } private async Task DoListTablesSegmentedBasicAsync(TablePayloadFormat format) @@ -196,7 +194,6 @@ public async Task ListTablesSegmentedWithPrefixAsync() await DoListTablesSegmentedWithPrefixAsync(TablePayloadFormat.Json); await DoListTablesSegmentedWithPrefixAsync(TablePayloadFormat.JsonNoMetadata); await DoListTablesSegmentedWithPrefixAsync(TablePayloadFormat.JsonFullMetadata); - await DoListTablesSegmentedWithPrefixAsync(TablePayloadFormat.AtomPub); } private async Task DoListTablesSegmentedWithPrefixAsync(TablePayloadFormat format) @@ -225,5 +222,4 @@ private async Task DoListTablesSegmentedWithPrefixAsync(TablePayloadFormat forma #endregion } -#pragma warning restore 0618 } diff --git a/Test/WindowsPhoneCommon/Table/TableAnalyticsUnitTaskTests.cs b/Test/WindowsPhoneCommon/Table/TableAnalyticsUnitTaskTests.cs index edc48f2eb..45a118b2d 100644 --- a/Test/WindowsPhoneCommon/Table/TableAnalyticsUnitTaskTests.cs +++ b/Test/WindowsPhoneCommon/Table/TableAnalyticsUnitTaskTests.cs @@ -311,7 +311,7 @@ private void AssertServicePropertiesAreEqual(ServiceProperties propsA, ServicePr private static ServiceProperties DefaultServiceProperties() { - ServiceProperties props = new ServiceProperties(); + ServiceProperties props = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties()); props.Logging.LoggingOperations = LoggingOperations.None; props.Logging.RetentionDays = null; diff --git a/Test/WindowsPhoneCommon/Table/TableBatchOperationTaskTest.cs b/Test/WindowsPhoneCommon/Table/TableBatchOperationTaskTest.cs index fc2547f97..b0cd33cc9 100644 --- a/Test/WindowsPhoneCommon/Table/TableBatchOperationTaskTest.cs +++ b/Test/WindowsPhoneCommon/Table/TableBatchOperationTaskTest.cs @@ -27,7 +27,6 @@ namespace Microsoft.WindowsAzure.Storage.Table { -#pragma warning disable 0618 [TestClass] public class TableBatchOperationTaskTest : TableTestBase { @@ -102,7 +101,6 @@ public async Task TableBatchInsertAsync() await DoTableBatchInsertAsync(TablePayloadFormat.Json); await DoTableBatchInsertAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchInsertAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchInsertAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchInsertAsync(TablePayloadFormat format) @@ -152,7 +150,6 @@ public async Task TableBatchInsertFailAsync() await DoTableBatchInsertFailAsync(TablePayloadFormat.Json); await DoTableBatchInsertFailAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchInsertFailAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchInsertFailAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchInsertFailAsync(TablePayloadFormat format) @@ -195,7 +192,6 @@ public async Task TableBatchInsertOrMergeAsync() await DoTableBatchInsertOrMergeAsync(TablePayloadFormat.Json); await DoTableBatchInsertOrMergeAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchInsertOrMergeAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchInsertOrMergeAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchInsertOrMergeAsync(TablePayloadFormat format) @@ -249,7 +245,6 @@ public async Task TableBatchInsertOrReplaceAsync() await DoTableBatchInsertOrReplaceAsync(TablePayloadFormat.Json); await DoTableBatchInsertOrReplaceAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchInsertOrReplaceAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchInsertOrReplaceAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchInsertOrReplaceAsync(TablePayloadFormat format) @@ -299,7 +294,6 @@ public async Task TableBatchDeleteAsync() await DoTableBatchDeleteAsync(TablePayloadFormat.Json); await DoTableBatchDeleteAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchDeleteAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchDeleteAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchDeleteAsync(TablePayloadFormat format) @@ -346,7 +340,6 @@ public async Task TableBatchDeleteFailAsync() await DoTableBatchDeleteFailAsync(TablePayloadFormat.Json); await DoTableBatchDeleteFailAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchDeleteFailAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchDeleteFailAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchDeleteFailAsync(TablePayloadFormat format) @@ -399,7 +392,6 @@ public async Task TableBatchMergeAsync() await DoTableBatchMergeAsync(TablePayloadFormat.Json); await DoTableBatchMergeAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchMergeAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchMergeAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchMergeAsync(TablePayloadFormat format) @@ -440,7 +432,6 @@ public async Task TableBatchMergeFailAsync() await DoTableBatchMergeFailAsync(TablePayloadFormat.Json); await DoTableBatchMergeFailAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchMergeFailAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchMergeFailAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchMergeFailAsync(TablePayloadFormat format) @@ -520,7 +511,6 @@ public async Task TableBatchReplaceAsync() await DoTableBatchReplaceAsync(TablePayloadFormat.Json); await DoTableBatchReplaceAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchReplaceAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchReplaceAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchReplaceAsync(TablePayloadFormat format) @@ -560,7 +550,6 @@ public async Task TableBatchReplaceFailAsync() await DoTableBatchReplaceFailAsync(TablePayloadFormat.Json); await DoTableBatchReplaceFailAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchReplaceFailAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchReplaceFailAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchReplaceFailAsync(TablePayloadFormat format) @@ -637,7 +626,6 @@ public async Task TableBatchAllSupportedOperationsAsync() await DoTableBatchAllSupportedOperationsAsync(TablePayloadFormat.Json); await DoTableBatchAllSupportedOperationsAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchAllSupportedOperationsAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchAllSupportedOperationsAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchAllSupportedOperationsAsync(TablePayloadFormat format) @@ -719,7 +707,6 @@ public async Task TableBatchRetrieveAsync() await DoTableBatchRetrieveAsync(TablePayloadFormat.Json); await DoTableBatchRetrieveAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchRetrieveAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchRetrieveAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchRetrieveAsync(TablePayloadFormat format) @@ -797,7 +784,6 @@ public async Task TableBatchRetrieveWithResolverAsync() await DoTableBatchRetrieveWithResolverAsync(TablePayloadFormat.Json); await DoTableBatchRetrieveWithResolverAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchRetrieveWithResolverAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchRetrieveWithResolverAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchRetrieveWithResolverAsync(TablePayloadFormat format) @@ -849,7 +835,6 @@ public async Task TableBatchOperationsWithEmptyKeysAsync() await DoTableBatchOperationsWithEmptyKeysAsync(TablePayloadFormat.Json); await DoTableBatchOperationsWithEmptyKeysAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchOperationsWithEmptyKeysAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchOperationsWithEmptyKeysAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchOperationsWithEmptyKeysAsync(TablePayloadFormat format) @@ -956,7 +941,6 @@ public async Task TableBatchInsert1Async() await InsertAndDeleteBatchWithNEntities(1, TablePayloadFormat.Json); await InsertAndDeleteBatchWithNEntities(1, TablePayloadFormat.JsonNoMetadata); await InsertAndDeleteBatchWithNEntities(1, TablePayloadFormat.JsonFullMetadata); - await InsertAndDeleteBatchWithNEntities(1, TablePayloadFormat.AtomPub); } [TestMethod] @@ -970,7 +954,6 @@ public async Task TableBatchInsert10Async() await InsertAndDeleteBatchWithNEntities(10, TablePayloadFormat.Json); await InsertAndDeleteBatchWithNEntities(10, TablePayloadFormat.JsonNoMetadata); await InsertAndDeleteBatchWithNEntities(10, TablePayloadFormat.JsonFullMetadata); - await InsertAndDeleteBatchWithNEntities(10, TablePayloadFormat.AtomPub); } @@ -985,7 +968,6 @@ public async Task TableBatchInsert99Async() await InsertAndDeleteBatchWithNEntities(99, TablePayloadFormat.Json); await InsertAndDeleteBatchWithNEntities(99, TablePayloadFormat.JsonNoMetadata); await InsertAndDeleteBatchWithNEntities(99, TablePayloadFormat.JsonFullMetadata); - await InsertAndDeleteBatchWithNEntities(99, TablePayloadFormat.AtomPub); } [TestMethod] @@ -999,7 +981,6 @@ public async Task TableBatchInsert100Async() await InsertAndDeleteBatchWithNEntities(100, TablePayloadFormat.Json); await InsertAndDeleteBatchWithNEntities(100, TablePayloadFormat.JsonNoMetadata); await InsertAndDeleteBatchWithNEntities(100, TablePayloadFormat.JsonFullMetadata); - await InsertAndDeleteBatchWithNEntities(100, TablePayloadFormat.AtomPub); } private async Task InsertAndDeleteBatchWithNEntities(int n, TablePayloadFormat format) @@ -1044,7 +1025,6 @@ public async Task TableBatchInsertOrMerge1Async() await InsertOrMergeBatchWithNEntities(1, TablePayloadFormat.Json); await InsertOrMergeBatchWithNEntities(1, TablePayloadFormat.JsonNoMetadata); await InsertOrMergeBatchWithNEntities(1, TablePayloadFormat.JsonFullMetadata); - await InsertOrMergeBatchWithNEntities(1, TablePayloadFormat.AtomPub); } [TestMethod] @@ -1058,7 +1038,6 @@ public async Task TableBatchInsertOrMerge10Async() await InsertOrMergeBatchWithNEntities(10, TablePayloadFormat.Json); await InsertOrMergeBatchWithNEntities(10, TablePayloadFormat.JsonNoMetadata); await InsertOrMergeBatchWithNEntities(10, TablePayloadFormat.JsonFullMetadata); - await InsertOrMergeBatchWithNEntities(10, TablePayloadFormat.AtomPub); } @@ -1073,7 +1052,6 @@ public async Task TableBatchInsertOrMerge99Async() await InsertOrMergeBatchWithNEntities(99, TablePayloadFormat.Json); await InsertOrMergeBatchWithNEntities(99, TablePayloadFormat.JsonNoMetadata); await InsertOrMergeBatchWithNEntities(99, TablePayloadFormat.JsonFullMetadata); - await InsertOrMergeBatchWithNEntities(99, TablePayloadFormat.AtomPub); } [TestMethod] @@ -1087,7 +1065,6 @@ public async Task TableBatchInsertOrMerge100Async() await InsertOrMergeBatchWithNEntities(100, TablePayloadFormat.Json); await InsertOrMergeBatchWithNEntities(100, TablePayloadFormat.JsonNoMetadata); await InsertOrMergeBatchWithNEntities(100, TablePayloadFormat.JsonFullMetadata); - await InsertOrMergeBatchWithNEntities(100, TablePayloadFormat.AtomPub); } private async Task InsertOrMergeBatchWithNEntities(int n, TablePayloadFormat format) @@ -1289,7 +1266,6 @@ public async Task TableBatchWithMultipleOperationsOnSameEntityShouldFailAsync() await DoTableBatchWithMultipleOperationsOnSameEntityShouldFailAsync(TablePayloadFormat.Json); await DoTableBatchWithMultipleOperationsOnSameEntityShouldFailAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchWithMultipleOperationsOnSameEntityShouldFailAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchWithMultipleOperationsOnSameEntityShouldFailAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchWithMultipleOperationsOnSameEntityShouldFailAsync(TablePayloadFormat format) @@ -1332,7 +1308,6 @@ public async Task TableBatchOver100EntitiesShouldThrowAsync() await DoTableBatchOver100EntitiesShouldThrowAsync(TablePayloadFormat.Json); await DoTableBatchOver100EntitiesShouldThrowAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchOver100EntitiesShouldThrowAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchOver100EntitiesShouldThrowAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchOver100EntitiesShouldThrowAsync(TablePayloadFormat format) @@ -1369,7 +1344,6 @@ public async Task TableBatchEntityOver1MBShouldThrowAsync() await DoTableBatchEntityOver1MBShouldThrowAsync(TablePayloadFormat.Json); await DoTableBatchEntityOver1MBShouldThrowAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchEntityOver1MBShouldThrowAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchEntityOver1MBShouldThrowAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchEntityOver1MBShouldThrowAsync(TablePayloadFormat format) @@ -1585,7 +1559,6 @@ public async Task TableBatchWithPropertyOver255CharsShouldThrow() await DoTableBatchWithPropertyOver255CharsShouldThrow(TablePayloadFormat.Json); await DoTableBatchWithPropertyOver255CharsShouldThrow(TablePayloadFormat.JsonNoMetadata); await DoTableBatchWithPropertyOver255CharsShouldThrow(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchWithPropertyOver255CharsShouldThrow(TablePayloadFormat.AtomPub); } private async Task DoTableBatchWithPropertyOver255CharsShouldThrow(TablePayloadFormat format) @@ -1633,5 +1606,4 @@ private static DynamicTableEntity GenerateRandomEntity(string pk) } #endregion } -#pragma warning restore 0618 } diff --git a/Test/WindowsPhoneCommon/Table/TableOperationUnitTaskTests.cs b/Test/WindowsPhoneCommon/Table/TableOperationUnitTaskTests.cs index bddf7d6d3..bb51dfac5 100644 --- a/Test/WindowsPhoneCommon/Table/TableOperationUnitTaskTests.cs +++ b/Test/WindowsPhoneCommon/Table/TableOperationUnitTaskTests.cs @@ -25,7 +25,6 @@ namespace Microsoft.WindowsAzure.Storage.Table { -#pragma warning disable 0618 [TestClass] public class TableOperationUnitTaskTests : TableTestBase { @@ -101,7 +100,6 @@ public async Task TableOperationInsertAsync() await DoTableOperationInsertAsync(TablePayloadFormat.Json); await DoTableOperationInsertAsync(TablePayloadFormat.JsonNoMetadata); await DoTableOperationInsertAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableOperationInsertAsync(TablePayloadFormat.AtomPub); } private async Task DoTableOperationInsertAsync(TablePayloadFormat format) @@ -139,7 +137,6 @@ public async Task TableOperationInsertWithEchoContentAsync() await DoTableOperationInsertWithEchoContentAsync(TablePayloadFormat.Json); await DoTableOperationInsertWithEchoContentAsync(TablePayloadFormat.JsonNoMetadata); await DoTableOperationInsertWithEchoContentAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableOperationInsertWithEchoContentAsync(TablePayloadFormat.AtomPub); } private async Task DoTableOperationInsertWithEchoContentAsync(TablePayloadFormat format) @@ -172,7 +169,6 @@ public async Task TableOperationInsertConflictAsync() await DoTableOperationInsertConflictAsync(TablePayloadFormat.Json); await DoTableOperationInsertConflictAsync(TablePayloadFormat.JsonNoMetadata); await DoTableOperationInsertConflictAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableOperationInsertConflictAsync(TablePayloadFormat.AtomPub); } private async Task DoTableOperationInsertConflictAsync(TablePayloadFormat format) @@ -215,7 +211,6 @@ public async Task TableOperationInsertOrMerge() await DoTableOperationInsertOrMerge(TablePayloadFormat.Json); await DoTableOperationInsertOrMerge(TablePayloadFormat.JsonNoMetadata); await DoTableOperationInsertOrMerge(TablePayloadFormat.JsonFullMetadata); - await DoTableOperationInsertOrMerge(TablePayloadFormat.AtomPub); } private async Task DoTableOperationInsertOrMerge(TablePayloadFormat format) @@ -263,7 +258,6 @@ public async Task TableOperationInsertOrReplace() await DoTableOperationInsertOrReplace(TablePayloadFormat.Json); await DoTableOperationInsertOrReplace(TablePayloadFormat.JsonNoMetadata); await DoTableOperationInsertOrReplace(TablePayloadFormat.JsonFullMetadata); - await DoTableOperationInsertOrReplace(TablePayloadFormat.AtomPub); } private async Task DoTableOperationInsertOrReplace(TablePayloadFormat format) @@ -308,7 +302,6 @@ public async Task TableOperationDeleteAsync() await DoTableOperationDeleteAsync(TablePayloadFormat.Json); await DoTableOperationDeleteAsync(TablePayloadFormat.JsonNoMetadata); await DoTableOperationDeleteAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableOperationDeleteAsync(TablePayloadFormat.AtomPub); } private async Task DoTableOperationDeleteAsync(TablePayloadFormat format) @@ -344,7 +337,6 @@ public async Task TableOperationDeleteFailAsync() await DoTableOperationDeleteFailAsync(TablePayloadFormat.Json); await DoTableOperationDeleteFailAsync(TablePayloadFormat.JsonNoMetadata); await DoTableOperationDeleteFailAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableOperationDeleteFailAsync(TablePayloadFormat.AtomPub); } private async Task DoTableOperationDeleteFailAsync(TablePayloadFormat format) @@ -410,7 +402,6 @@ public async Task TableOperationMergeAsync() await DoTableOperationMergeAsync(TablePayloadFormat.Json); await DoTableOperationMergeAsync(TablePayloadFormat.JsonNoMetadata); await DoTableOperationMergeAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableOperationMergeAsync(TablePayloadFormat.AtomPub); } private async Task DoTableOperationMergeAsync(TablePayloadFormat format) @@ -448,7 +439,6 @@ public async Task TableOperationMergeFailAsync() await DoTableOperationMergeFailAsync(TablePayloadFormat.Json); await DoTableOperationMergeFailAsync(TablePayloadFormat.JsonNoMetadata); await DoTableOperationMergeFailAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableOperationMergeFailAsync(TablePayloadFormat.AtomPub); } private async Task DoTableOperationMergeFailAsync(TablePayloadFormat format) @@ -520,7 +510,6 @@ public async Task TableOperationReplaceAsync() await DoTableOperationReplaceAsync(TablePayloadFormat.Json); await DoTableOperationReplaceAsync(TablePayloadFormat.JsonNoMetadata); await DoTableOperationReplaceAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableOperationReplaceAsync(TablePayloadFormat.AtomPub); } private async Task DoTableOperationReplaceAsync(TablePayloadFormat format) @@ -557,7 +546,6 @@ public async Task TableOperationReplaceFailAsync() await DoTableOperationReplaceFailAsync(TablePayloadFormat.Json); await DoTableOperationReplaceFailAsync(TablePayloadFormat.JsonNoMetadata); await DoTableOperationReplaceFailAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableOperationReplaceFailAsync(TablePayloadFormat.AtomPub); } private async Task DoTableOperationReplaceFailAsync(TablePayloadFormat format) @@ -628,7 +616,6 @@ public async Task TableBatchRetrieveAsync() await DoTableBatchRetrieveAsync(TablePayloadFormat.Json); await DoTableBatchRetrieveAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchRetrieveAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchRetrieveAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchRetrieveAsync(TablePayloadFormat format) @@ -706,7 +693,6 @@ public async Task TableBatchRetrieveWithResolverAsync() await DoTableBatchRetrieveWithResolverAsync(TablePayloadFormat.Json); await DoTableBatchRetrieveWithResolverAsync(TablePayloadFormat.JsonNoMetadata); await DoTableBatchRetrieveWithResolverAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableBatchRetrieveWithResolverAsync(TablePayloadFormat.AtomPub); } private async Task DoTableBatchRetrieveWithResolverAsync(TablePayloadFormat format) @@ -753,7 +739,6 @@ public async Task TableRetrieveWithIgnoreAttributeWriteAsync() await DoTableRetrieveWithIgnoreAttributeWriteAsync(TablePayloadFormat.Json); await DoTableRetrieveWithIgnoreAttributeWriteAsync(TablePayloadFormat.JsonNoMetadata); await DoTableRetrieveWithIgnoreAttributeWriteAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableRetrieveWithIgnoreAttributeWriteAsync(TablePayloadFormat.AtomPub); } private async Task DoTableRetrieveWithIgnoreAttributeWriteAsync(TablePayloadFormat format) @@ -811,7 +796,6 @@ public async Task TableRetrieveWithIgnoreAttributeReadAsync() await DoTableRetrieveWithIgnoreAttributeReadAsync(TablePayloadFormat.Json); await DoTableRetrieveWithIgnoreAttributeReadAsync(TablePayloadFormat.JsonNoMetadata); await DoTableRetrieveWithIgnoreAttributeReadAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableRetrieveWithIgnoreAttributeReadAsync(TablePayloadFormat.AtomPub); } private async Task DoTableRetrieveWithIgnoreAttributeReadAsync(TablePayloadFormat format) @@ -873,7 +857,6 @@ public async Task TableRetrieveSyncWithIgnoreAttributesAsync() await DoTableRetrieveSyncWithIgnoreAttributesAsync(TablePayloadFormat.Json); await DoTableRetrieveSyncWithIgnoreAttributesAsync(TablePayloadFormat.JsonNoMetadata); await DoTableRetrieveSyncWithIgnoreAttributesAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableRetrieveSyncWithIgnoreAttributesAsync(TablePayloadFormat.AtomPub); } private async Task DoTableRetrieveSyncWithIgnoreAttributesAsync(TablePayloadFormat format) @@ -934,7 +917,6 @@ public async Task TableOperationsWithEmptyKeysAsync() await DoTableOperationsWithEmptyKeysAsync(TablePayloadFormat.Json); await DoTableOperationsWithEmptyKeysAsync(TablePayloadFormat.JsonNoMetadata); await DoTableOperationsWithEmptyKeysAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableOperationsWithEmptyKeysAsync(TablePayloadFormat.AtomPub); } private async Task DoTableOperationsWithEmptyKeysAsync(TablePayloadFormat format) @@ -1109,7 +1091,6 @@ public async Task TableOperationInsertOver1MBAsync() await DoTableOperationInsertOver1MBAsync(TablePayloadFormat.Json); await DoTableOperationInsertOver1MBAsync(TablePayloadFormat.JsonNoMetadata); await DoTableOperationInsertOver1MBAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableOperationInsertOver1MBAsync(TablePayloadFormat.AtomPub); } private async Task DoTableOperationInsertOver1MBAsync(TablePayloadFormat format) @@ -1137,5 +1118,4 @@ private async Task DoTableOperationInsertOver1MBAsync(TablePayloadFormat format) #endregion } -#pragma warning restore 0618 } diff --git a/Test/WindowsPhoneCommon/Table/TableQueryGenericTaskTests.cs b/Test/WindowsPhoneCommon/Table/TableQueryGenericTaskTests.cs index e4a2721b6..c2c9891e9 100644 --- a/Test/WindowsPhoneCommon/Table/TableQueryGenericTaskTests.cs +++ b/Test/WindowsPhoneCommon/Table/TableQueryGenericTaskTests.cs @@ -25,7 +25,6 @@ namespace Microsoft.WindowsAzure.Storage.Table { -#pragma warning disable 0618 [TestClass] public class TableQueryGenericTaskTests : TableTestBase { @@ -114,7 +113,6 @@ public async Task TableGenericQueryBasicAsync() await DoTableGenericQueryBasicAsync(TablePayloadFormat.Json); await DoTableGenericQueryBasicAsync(TablePayloadFormat.JsonNoMetadata); await DoTableGenericQueryBasicAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableGenericQueryBasicAsync(TablePayloadFormat.AtomPub); } private async Task DoTableGenericQueryBasicAsync(TablePayloadFormat format) @@ -143,7 +141,6 @@ public async Task TableGenericQueryWithContinuationAsync() await DoTableGenericQueryWithContinuationAsync(TablePayloadFormat.Json); await DoTableGenericQueryWithContinuationAsync(TablePayloadFormat.JsonNoMetadata); await DoTableGenericQueryWithContinuationAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableGenericQueryWithContinuationAsync(TablePayloadFormat.AtomPub); } private async Task DoTableGenericQueryWithContinuationAsync(TablePayloadFormat format) @@ -188,7 +185,6 @@ public void TableGenericQueryWithFilter() DoTableGenericQueryWithFilter(TablePayloadFormat.Json); DoTableGenericQueryWithFilter(TablePayloadFormat.JsonNoMetadata); DoTableGenericQueryWithFilter(TablePayloadFormat.JsonFullMetadata); - DoTableGenericQueryWithFilter(TablePayloadFormat.AtomPub); } private void DoTableGenericQueryWithFilter(TablePayloadFormat format) @@ -221,7 +217,6 @@ public void TableGenericQueryProjection() DoTableGenericQueryProjection(TablePayloadFormat.Json); DoTableGenericQueryProjection(TablePayloadFormat.JsonNoMetadata); DoTableGenericQueryProjection(TablePayloadFormat.JsonFullMetadata); - DoTableGenericQueryProjection(TablePayloadFormat.AtomPub); } private void DoTableGenericQueryProjection(TablePayloadFormat format) @@ -255,7 +250,6 @@ public void TableGenericWithResolver() DoTableGenericWithResolver(TablePayloadFormat.Json); DoTableGenericWithResolver(TablePayloadFormat.JsonNoMetadata); DoTableGenericWithResolver(TablePayloadFormat.JsonFullMetadata); - DoTableGenericWithResolver(TablePayloadFormat.AtomPub); } private void DoTableGenericWithResolver(TablePayloadFormat format) @@ -301,7 +295,6 @@ public void TableQueryResolverWithDynamic() DoTableQueryResolverWithDynamic(TablePayloadFormat.Json); DoTableQueryResolverWithDynamic(TablePayloadFormat.JsonNoMetadata); DoTableQueryResolverWithDynamic(TablePayloadFormat.JsonFullMetadata); - DoTableQueryResolverWithDynamic(TablePayloadFormat.AtomPub); } private void DoTableQueryResolverWithDynamic(TablePayloadFormat format) @@ -344,7 +337,6 @@ public async Task TableGenericQueryOnSupportedTypesAsync() await DoTableGenericQueryOnSupportedTypesAsync(TablePayloadFormat.Json); await DoTableGenericQueryOnSupportedTypesAsync(TablePayloadFormat.JsonNoMetadata); await DoTableGenericQueryOnSupportedTypesAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableGenericQueryOnSupportedTypesAsync(TablePayloadFormat.AtomPub); } private async Task DoTableGenericQueryOnSupportedTypesAsync(TablePayloadFormat format) @@ -485,7 +477,6 @@ public void TableGenericQueryWithInvalidTakeCount() DoTableGenericQueryWithInvalidTakeCount(TablePayloadFormat.Json); DoTableGenericQueryWithInvalidTakeCount(TablePayloadFormat.JsonNoMetadata); DoTableGenericQueryWithInvalidTakeCount(TablePayloadFormat.JsonFullMetadata); - DoTableGenericQueryWithInvalidTakeCount(TablePayloadFormat.AtomPub); } private void DoTableGenericQueryWithInvalidTakeCount(TablePayloadFormat format) @@ -531,7 +522,6 @@ public async Task TableGenericQueryWithInvalidQuery() await DoTableGenericQueryWithInvalidQuery(TablePayloadFormat.Json); await DoTableGenericQueryWithInvalidQuery(TablePayloadFormat.JsonNoMetadata); await DoTableGenericQueryWithInvalidQuery(TablePayloadFormat.JsonFullMetadata); - await DoTableGenericQueryWithInvalidQuery(TablePayloadFormat.AtomPub); } private async Task DoTableGenericQueryWithInvalidQuery(TablePayloadFormat format) @@ -622,5 +612,4 @@ private static BaseEntity GenerateRandomEntity(string pk) } #endregion } -#pragma warning restore 0618 } diff --git a/Test/WindowsPhoneCommon/Table/TableQueryTaskTests.cs b/Test/WindowsPhoneCommon/Table/TableQueryTaskTests.cs index 418a1e317..8bbef31bb 100644 --- a/Test/WindowsPhoneCommon/Table/TableQueryTaskTests.cs +++ b/Test/WindowsPhoneCommon/Table/TableQueryTaskTests.cs @@ -27,7 +27,6 @@ namespace Microsoft.WindowsAzure.Storage.Table { -#pragma warning disable 0618 [TestClass] public class TableQueryTaskTests : TableTestBase { @@ -117,7 +116,6 @@ public async Task TableQueryBasicAsync() await DoTableQueryBasicAsync(TablePayloadFormat.Json); await DoTableQueryBasicAsync(TablePayloadFormat.JsonNoMetadata); await DoTableQueryBasicAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableQueryBasicAsync(TablePayloadFormat.AtomPub); } private async Task DoTableQueryBasicAsync(TablePayloadFormat format) @@ -145,7 +143,6 @@ public async Task TableQueryWithContinuationAsync() await DoTableQueryWithContinuationAsync(TablePayloadFormat.Json); await DoTableQueryWithContinuationAsync(TablePayloadFormat.JsonNoMetadata); await DoTableQueryWithContinuationAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableQueryWithContinuationAsync(TablePayloadFormat.AtomPub); } private async Task DoTableQueryWithContinuationAsync(TablePayloadFormat format) @@ -190,7 +187,6 @@ public void TableQueryWithFilterAsync() DoTableQueryWithFilterAsync(TablePayloadFormat.Json); DoTableQueryWithFilterAsync(TablePayloadFormat.JsonNoMetadata); DoTableQueryWithFilterAsync(TablePayloadFormat.JsonFullMetadata); - DoTableQueryWithFilterAsync(TablePayloadFormat.AtomPub); } private void DoTableQueryWithFilterAsync(TablePayloadFormat format) @@ -224,7 +220,6 @@ public void TableQueryProjectionAsync() DoTableQueryProjectionAsync(TablePayloadFormat.Json); DoTableQueryProjectionAsync(TablePayloadFormat.JsonNoMetadata); DoTableQueryProjectionAsync(TablePayloadFormat.JsonFullMetadata); - DoTableQueryProjectionAsync(TablePayloadFormat.AtomPub); } private void DoTableQueryProjectionAsync(TablePayloadFormat format) @@ -256,7 +251,6 @@ public async Task TableQueryOnSupportedTypesAsync() await DoTableQueryOnSupportedTypesAsync(TablePayloadFormat.Json); await DoTableQueryOnSupportedTypesAsync(TablePayloadFormat.JsonNoMetadata); await DoTableQueryOnSupportedTypesAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableQueryOnSupportedTypesAsync(TablePayloadFormat.AtomPub); } private async Task DoTableQueryOnSupportedTypesAsync(TablePayloadFormat format) @@ -393,7 +387,6 @@ public async Task TableRegionalQueryOnSupportedTypesAsync() await DoTableRegionalQueryOnSupportedTypesAsync(TablePayloadFormat.Json); await DoTableRegionalQueryOnSupportedTypesAsync(TablePayloadFormat.JsonNoMetadata); await DoTableRegionalQueryOnSupportedTypesAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableRegionalQueryOnSupportedTypesAsync(TablePayloadFormat.AtomPub); } private async Task DoTableRegionalQueryOnSupportedTypesAsync(TablePayloadFormat format) @@ -534,7 +527,6 @@ public async Task TableQueryEmptyValueAsync() await DoTableQueryEmptyValueAsync(TablePayloadFormat.Json); await DoTableQueryEmptyValueAsync(TablePayloadFormat.JsonNoMetadata); await DoTableQueryEmptyValueAsync(TablePayloadFormat.JsonFullMetadata); - await DoTableQueryEmptyValueAsync(TablePayloadFormat.AtomPub); } private async Task DoTableQueryEmptyValueAsync(TablePayloadFormat format) @@ -575,7 +567,6 @@ public void TableQueryWithInvalidTakeCount() DoTableQueryWithInvalidTakeCount(TablePayloadFormat.Json); DoTableQueryWithInvalidTakeCount(TablePayloadFormat.JsonNoMetadata); DoTableQueryWithInvalidTakeCount(TablePayloadFormat.JsonFullMetadata); - DoTableQueryWithInvalidTakeCount(TablePayloadFormat.AtomPub); } private void DoTableQueryWithInvalidTakeCount(TablePayloadFormat format) @@ -621,7 +612,6 @@ public async Task TableQueryWithInvalidQuery() await DoTableQueryWithInvalidQuery(TablePayloadFormat.Json); await DoTableQueryWithInvalidQuery(TablePayloadFormat.JsonNoMetadata); await DoTableQueryWithInvalidQuery(TablePayloadFormat.JsonFullMetadata); - await DoTableQueryWithInvalidQuery(TablePayloadFormat.AtomPub); } private async Task DoTableQueryWithInvalidQuery(TablePayloadFormat format) @@ -681,5 +671,4 @@ private static DynamicTableEntity GenerateRandomEntity(string pk) } #endregion } -#pragma warning restore 0618 } diff --git a/Test/WindowsPhoneRT.Test/Properties/AssemblyInfo.cs b/Test/WindowsPhoneRT.Test/Properties/AssemblyInfo.cs index 29882d7bb..fd7463615 100644 --- a/Test/WindowsPhoneRT.Test/Properties/AssemblyInfo.cs +++ b/Test/WindowsPhoneRT.Test/Properties/AssemblyInfo.cs @@ -24,6 +24,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("6.2.2.0")] -[assembly: AssemblyFileVersion("6.2.2.0")] +[assembly: AssemblyVersion("7.0.0.0")] +[assembly: AssemblyFileVersion("7.0.0.0")] [assembly: ComVisible(false)] \ No newline at end of file diff --git a/Test/WindowsRuntime/AccountSasTests.cs b/Test/WindowsRuntime/AccountSasTests.cs index 5a8b24cc1..a9c57e767 100644 --- a/Test/WindowsRuntime/AccountSasTests.cs +++ b/Test/WindowsRuntime/AccountSasTests.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------------------------- -// +// // Copyright 2013 Microsoft Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,18 +55,19 @@ public void AccountSASPermissions() { // Single-threaded, takes 10 minutes to run // Parallelized, 1 minute. - Task[] tasks = new Task[256 * 4]; //each permission (0x100) times four services. for (int i = 0; i < 0x100; i++) { + Task[] tasks = new Task[4]; //each permission (0x100) times four services. SharedAccessAccountPermissions permissions = (SharedAccessAccountPermissions)i; SharedAccessAccountPolicy policy = GetPolicyWithFullPermissions(); policy.Permissions = permissions; - tasks[i] = this.RunPermissionsTestBlobs(policy); - tasks[256 + i] = this.RunPermissionsTestTables(policy); - tasks[512 + i] = this.RunPermissionsTestQueues(policy); - tasks[768 + i] = this.RunPermissionsTestFiles(policy); + tasks[0] = this.RunPermissionsTestBlobs(policy); + tasks[1] = this.RunPermissionsTestTables(policy); + tasks[2] = this.RunPermissionsTestQueues(policy); + tasks[3] = this.RunPermissionsTestFiles(policy); + Task.WaitAll(tasks); } - Task.WaitAll(tasks); + } [TestMethod] @@ -347,78 +348,6 @@ public async Task AccountSASSignedProtocols() } } - [TestMethod] - [Description("Test account SAS all parameters blob")] - [TestCategory(ComponentCategory.Blob)] - [TestCategory(TestTypeCategory.UnitTest)] - [TestCategory(SmokeTestCategory.NonSmoke)] - [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] - public async Task AccountSASSample() - { - CloudBlobClient blobClient = GenerateCloudBlobClient(); - string containerName = "c" + Guid.NewGuid().ToString("N"); - CloudBlobContainer container = blobClient.GetContainerReference(containerName); - try - { - await container.CreateAsync(); - string blobName = "blob"; - CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName); - byte[] data = new byte[] { 0x1, 0x2, 0x3, 0x4 }; - await blockBlob.UploadFromByteArrayAsync(data, 0, 4); - - SharedAccessAccountPolicy policy = GetPolicyWithFullPermissions(); - HostName invalidIP = new HostName("255.255.255.255"); - policy.IPAddressOrRange = new IPAddressOrRange(invalidIP.ToString()); - - CloudStorageAccount account = new CloudStorageAccount(blobClient.Credentials, false); - string accountSASToken = account.GetSharedAccessSignature(policy); - StorageCredentials accountSAS = new StorageCredentials(accountSASToken); - CloudStorageAccount accountWithSAS = CloudStorageAccount.Create(accountSAS, blobClient.StorageUri, null, null, null); - CloudBlobClient blobClientWithSAS = accountWithSAS.CreateCloudBlobClient(); - CloudBlobContainer containerWithSAS = blobClientWithSAS.GetContainerReference(containerName); - CloudBlockBlob blockblobWithSAS = containerWithSAS.GetBlockBlobReference(blobName); - - byte[] target = new byte[4]; - OperationContext opContext = new OperationContext(); - HostName actualIP = null; - - bool exceptionThrown = false; - try - { - await blockblobWithSAS.DownloadRangeToByteArrayAsync(target, 0, 0, 4, null, null, opContext); - } - catch (WrappedStorageException e) - { - exceptionThrown = true; - XDocument xdocument = XDocument.Parse(e.Message); - string ipString = xdocument.Descendants("SourceIP").First().Value; - actualIP = new HostName(ipString); - Assert.IsNotNull(actualIP); - } - - Assert.IsTrue(exceptionThrown); - - policy.IPAddressOrRange = new IPAddressOrRange(actualIP.ToString()); - accountSASToken = account.GetSharedAccessSignature(policy); - accountSAS = new StorageCredentials(accountSASToken); - accountWithSAS = CloudStorageAccount.Create(accountSAS, blobClient.StorageUri, null, null, null); - blobClientWithSAS = accountWithSAS.CreateCloudBlobClient(); - containerWithSAS = blobClientWithSAS.GetContainerReference(containerName); - blockblobWithSAS = containerWithSAS.GetBlockBlobReference(blobName); - - await blockblobWithSAS.DownloadRangeToByteArrayAsync(target, 0, 0, 4, null, null, null); - for (int i = 0; i < 4; i++) - { - Assert.AreEqual(data[i], target[i]); - } - Assert.IsTrue(blockblobWithSAS.StorageUri.PrimaryUri.Equals(blockBlob.Uri)); - } - finally - { - container.DeleteIfExistsAsync().AsTask().Wait(); - } - } - public async Task RunPermissionsTestBlobs(SharedAccessAccountPolicy policy) { CloudBlobClient blobClient = GenerateCloudBlobClient(); @@ -450,7 +379,7 @@ public async Task RunPermissionsTestBlobs(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await containerWithSAS.CreateAsync(), "Create a container should fail with SAS without Create or Write and Container-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await containerWithSAS.CreateAsync(), "Create a container should fail with SAS without Create or Write and Container-level permissions."); await container.CreateAsync(); } @@ -464,7 +393,7 @@ public async Task RunPermissionsTestBlobs(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => { ContainerResultSegment segment = await blobClientWithSAS.ListContainersSegmentedAsync(container.Name, null); segment.Results.First(); }, "List containers should fail with SAS without List and Service-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => { ContainerResultSegment segment = await blobClientWithSAS.ListContainersSegmentedAsync(container.Name, null); segment.Results.First(); }, "List containers should fail with SAS without List and Service-level permissions."); } string blobName = "blob"; @@ -477,7 +406,7 @@ public async Task RunPermissionsTestBlobs(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await appendBlobWithSAS.CreateOrReplaceAsync(), "Creating an append blob should fail with SAS without Create or Write and Object-level perms."); + await TestHelper.ExpectedExceptionAsync(async () => await appendBlobWithSAS.CreateOrReplaceAsync(), "Creating an append blob should fail with SAS without Create or Write and Object-level perms."); await appendBlob.CreateOrReplaceAsync(); } @@ -487,7 +416,7 @@ public async Task RunPermissionsTestBlobs(SharedAccessAccountPolicy policy) if ((((policy.Permissions & SharedAccessAccountPermissions.Add) == SharedAccessAccountPermissions.Add) || ((policy.Permissions & SharedAccessAccountPermissions.Write) == SharedAccessAccountPermissions.Write)) && ((policy.ResourceTypes & SharedAccessAccountResourceTypes.Object) == SharedAccessAccountResourceTypes.Object)) { - using (IInputStream stream = new MemoryStream(Encoding.UTF8.GetBytes(blobText)).AsInputStream()) + using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(blobText))) { await appendBlobWithSAS.AppendBlockAsync(stream); } @@ -496,9 +425,9 @@ public async Task RunPermissionsTestBlobs(SharedAccessAccountPolicy policy) { using (MemoryStream memStream = new MemoryStream(Encoding.UTF8.GetBytes(blobText))) { - await TestHelper.ExpectedExceptionAsync(async () => await appendBlobWithSAS.AppendBlockAsync(memStream.AsInputStream()), "Append a block to an append blob should fail with SAS without Add or Write and Object-level perms."); + await TestHelper.ExpectedExceptionAsync(async () => await appendBlobWithSAS.AppendBlockAsync(memStream), "Append a block to an append blob should fail with SAS without Add or Write and Object-level perms."); memStream.Seek(0, SeekOrigin.Begin); - await appendBlob.AppendBlockAsync(memStream.AsInputStream()); + await appendBlob.AppendBlockAsync(memStream); } } @@ -511,7 +440,7 @@ public async Task RunPermissionsTestBlobs(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await appendBlobWithSAS.DownloadTextAsync(), "Reading a blob's contents with SAS without Read and Object-level permissions should fail."); + await TestHelper.ExpectedExceptionAsync(async () => await appendBlobWithSAS.DownloadTextAsync(), "Reading a blob's contents with SAS without Read and Object-level permissions should fail."); } if (((policy.Permissions & SharedAccessAccountPermissions.Delete) == SharedAccessAccountPermissions.Delete) && @@ -521,7 +450,7 @@ public async Task RunPermissionsTestBlobs(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await appendBlobWithSAS.DeleteAsync(), "Deleting a blob with SAS without Delete and Object-level perms should fail."); + await TestHelper.ExpectedExceptionAsync(async () => await appendBlobWithSAS.DeleteAsync(), "Deleting a blob with SAS without Delete and Object-level perms should fail."); await appendBlob.DeleteAsync(); } @@ -529,7 +458,7 @@ public async Task RunPermissionsTestBlobs(SharedAccessAccountPolicy policy) } finally { - blobClient.GetContainerReference(containerName).DeleteIfExistsAsync().AsTask().Wait(); + blobClient.GetContainerReference(containerName).DeleteIfExistsAsync().Wait(); } } @@ -568,8 +497,8 @@ public async Task RunPermissionsTestTables(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync( - async () => await tableWithSAS.CreateAsync().AsTask(), + await TestHelper.ExpectedExceptionAsync( + async () => await tableWithSAS.CreateAsync(), "Creating a table with SAS should fail without Add and Container-level permissions."); await table.CreateAsync(); } @@ -582,10 +511,10 @@ await TestHelper.ExpectedExceptionAsync( } else { - await TestHelper.ExpectedExceptionAsync(async () => (await tableClientWithSAS.ListTablesSegmentedAsync(tableName, null)).Results.First(), "Listing tables with SAS should fail without Read and Container-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => (await tableClientWithSAS.ListTablesSegmentedAsync(tableName, null)).Results.First(), "Listing tables with SAS should fail without Read and Container-level permissions."); } - ServiceProperties properties = new ServiceProperties(); + ServiceProperties properties = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties(), new CorsProperties()); properties.Logging = initialProperties.Logging; properties.HourMetrics = initialProperties.HourMetrics; properties.MinuteMetrics = initialProperties.MinuteMetrics; @@ -603,7 +532,7 @@ await TestHelper.ExpectedExceptionAsync( } else { - await TestHelper.ExpectedExceptionAsync(async () => await tableClientWithSAS.SetServicePropertiesAsync(properties), "Setting table service properites should fail with SAS without Write and Service-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await tableClientWithSAS.SetServicePropertiesAsync(properties), "Setting table service properites should fail with SAS without Write and Service-level permissions."); await tableClient.SetServicePropertiesAsync(properties); } Assert.AreEqual(sampleOriginText, rule.AllowedOrigins.First()); @@ -626,7 +555,7 @@ await TestHelper.ExpectedExceptionAsync( } else { - await TestHelper.ExpectedExceptionAsync(async () => await tableWithSAS.ExecuteAsync(TableOperation.Insert(entity1)), "Inserting an entity should fail without Add and Object-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await tableWithSAS.ExecuteAsync(TableOperation.Insert(entity1)), "Inserting an entity should fail without Add and Object-level permissions."); await table.ExecuteAsync(TableOperation.Insert(entity1)); } TableQuery query = new TableQuery().Where(string.Format("(PartitionKey eq '{0}') and (RowKey eq '{1}')", entity1.PartitionKey, entity1.RowKey)); @@ -646,7 +575,7 @@ await TestHelper.ExpectedExceptionAsync( } else { - await TestHelper.ExpectedExceptionAsync(async () => await tableWithSAS.ExecuteAsync(TableOperation.Merge(entity1changed)), "Merging an entity should fail without Update and Object-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await tableWithSAS.ExecuteAsync(TableOperation.Merge(entity1changed)), "Merging an entity should fail without Update and Object-level permissions."); await table.ExecuteAsync(TableOperation.Merge(entity1changed)); } @@ -668,7 +597,7 @@ await TestHelper.ExpectedExceptionAsync( } else { - await TestHelper.ExpectedExceptionAsync(async () => await tableWithSAS.ExecuteAsync(TableOperation.InsertOrMerge(entity2)), "Inserting or merging an entity should fail without Add and Update and Object-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await tableWithSAS.ExecuteAsync(TableOperation.InsertOrMerge(entity2)), "Inserting or merging an entity should fail without Add and Update and Object-level permissions."); await table.ExecuteAsync(TableOperation.InsertOrMerge(entity2)); } query = new TableQuery().Where(string.Format("(PartitionKey eq '{0}') and (RowKey eq '{1}')", entity2.PartitionKey, entity2.RowKey)); @@ -687,7 +616,7 @@ await TestHelper.ExpectedExceptionAsync( } else { - await TestHelper.ExpectedExceptionAsync(async () => await tableWithSAS.ExecuteAsync(TableOperation.InsertOrMerge(entity2changed)), "Inserting or merging an entity should fail without Add and Update and Object-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await tableWithSAS.ExecuteAsync(TableOperation.InsertOrMerge(entity2changed)), "Inserting or merging an entity should fail without Add and Update and Object-level permissions."); await table.ExecuteAsync(TableOperation.InsertOrMerge(entity2changed)); } entity2changed.ETag = "*"; @@ -704,7 +633,7 @@ await TestHelper.ExpectedExceptionAsync( } else { - await TestHelper.ExpectedExceptionAsync(async () => (await tableWithSAS.ExecuteQuerySegmentedAsync(query, null)).ToList(), "Querying tables should fail with SAS without Read and Object-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => (await tableWithSAS.ExecuteQuerySegmentedAsync(query, null)).ToList(), "Querying tables should fail with SAS without Read and Object-level permissions."); } if (((policy.Permissions & SharedAccessAccountPermissions.Delete) == SharedAccessAccountPermissions.Delete) && @@ -714,7 +643,7 @@ await TestHelper.ExpectedExceptionAsync( } else { - await TestHelper.ExpectedExceptionAsync(async () => await tableWithSAS.ExecuteAsync(TableOperation.Delete(entity1)), "Deleting an entity should fail with SAS without Delete and Object-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await tableWithSAS.ExecuteAsync(TableOperation.Delete(entity1)), "Deleting an entity should fail with SAS without Delete and Object-level permissions."); await table.ExecuteAsync(TableOperation.Delete(entity1)); } @@ -723,10 +652,10 @@ await TestHelper.ExpectedExceptionAsync( } finally { - tableClient.GetTableReference(tableName).DeleteIfExistsAsync().AsTask().Wait(); + tableClient.GetTableReference(tableName).DeleteIfExistsAsync().Wait(); if (initialProperties != null) { - tableClient.SetServicePropertiesAsync(initialProperties).AsTask().Wait(); + tableClient.SetServicePropertiesAsync(initialProperties).Wait(); } } } @@ -765,7 +694,7 @@ public async Task RunPermissionsTestQueues(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.CreateAsync(), "Creating a queue with SAS should fail without Add and Container-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.CreateAsync(), "Creating a queue with SAS should fail without Add and Container-level permissions."); await queue.CreateAsync(); } Assert.IsTrue(await queue.ExistsAsync()); @@ -777,7 +706,7 @@ public async Task RunPermissionsTestQueues(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => (await queueClientWithSAS.ListQueuesSegmentedAsync(queueName, null)).Results.First(), "Listing queues with SAS should fail without Read and Service-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => (await queueClientWithSAS.ListQueuesSegmentedAsync(queueName, null)).Results.First(), "Listing queues with SAS should fail without Read and Service-level permissions."); } queueWithSAS.Metadata["metadatakey"] = "metadatavalue"; @@ -790,7 +719,7 @@ public async Task RunPermissionsTestQueues(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.SetMetadataAsync(), "Setting a queue's metadata with SAS should fail without Write and Container-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.SetMetadataAsync(), "Setting a queue's metadata with SAS should fail without Write and Container-level permissions."); } string messageText = "messageText"; @@ -802,7 +731,7 @@ public async Task RunPermissionsTestQueues(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.AddMessageAsync(message), "Adding a queue message should fail with SAS without Add and Object-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.AddMessageAsync(message), "Adding a queue message should fail with SAS without Add and Object-level permissions."); await queue.AddMessageAsync(message); } Assert.AreEqual(messageText, ((await queue.PeekMessageAsync()).AsString)); @@ -814,7 +743,7 @@ public async Task RunPermissionsTestQueues(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.PeekMessageAsync(), "Peeking a queue message should fail with SAS without Read and Object-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.PeekMessageAsync(), "Peeking a queue message should fail with SAS without Read and Object-level permissions."); } CloudQueueMessage messageResult = null; @@ -825,7 +754,7 @@ public async Task RunPermissionsTestQueues(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.GetMessageAsync(), "Getting a message should fail with SAS without Process and Object-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.GetMessageAsync(), "Getting a message should fail with SAS without Process and Object-level permissions."); messageResult = await queue.GetMessageAsync(); } Assert.AreEqual(messageText, messageResult.AsString); @@ -839,7 +768,7 @@ public async Task RunPermissionsTestQueues(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.UpdateMessageAsync(messageResult, TimeSpan.Zero, MessageUpdateFields.Content | MessageUpdateFields.Visibility), "Updating a message should fail with SAS without Update and Object-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.UpdateMessageAsync(messageResult, TimeSpan.Zero, MessageUpdateFields.Content | MessageUpdateFields.Visibility), "Updating a message should fail with SAS without Update and Object-level permissions."); await queue.UpdateMessageAsync(messageResult, TimeSpan.Zero, MessageUpdateFields.Content | MessageUpdateFields.Visibility); } messageResult = await queue.PeekMessageAsync(); @@ -852,12 +781,12 @@ public async Task RunPermissionsTestQueues(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.ClearAsync(), "Clearing messages should fail with SAS without delete and Object-level permissions."); + await TestHelper.ExpectedExceptionAsync(async () => await queueWithSAS.ClearAsync(), "Clearing messages should fail with SAS without delete and Object-level permissions."); } } finally { - queueClient.GetQueueReference(queueName).DeleteIfExistsAsync().AsTask().Wait(); + queueClient.GetQueueReference(queueName).DeleteIfExistsAsync().Wait(); } } public async Task RunPermissionsTestFiles(SharedAccessAccountPolicy policy) @@ -893,7 +822,7 @@ public async Task RunPermissionsTestFiles(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await shareWithSAS.CreateAsync(), "Creating a share with SAS should fail without Create or Write and Container-level perms."); + await TestHelper.ExpectedExceptionAsync(async () => await shareWithSAS.CreateAsync(), "Creating a share with SAS should fail without Create or Write and Container-level perms."); await share.CreateAsync(); } Assert.IsTrue(await share.ExistsAsync()); @@ -905,7 +834,7 @@ public async Task RunPermissionsTestFiles(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => (await fileClientWithSAS.ListSharesSegmentedAsync(shareName, null)).Results.First(), "Listing shared with SAS should fail without List and Service-level perms."); + await TestHelper.ExpectedExceptionAsync(async () => (await fileClientWithSAS.ListSharesSegmentedAsync(shareName, null)).Results.First(), "Listing shared with SAS should fail without List and Service-level perms."); } string filename = "fileName"; @@ -920,7 +849,7 @@ public async Task RunPermissionsTestFiles(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await fileWithSAS.CreateAsync(content.Length), "Creating a file with SAS should fail without Create or Write and Object-level perms."); + await TestHelper.ExpectedExceptionAsync(async () => await fileWithSAS.CreateAsync(content.Length), "Creating a file with SAS should fail without Create or Write and Object-level perms."); await file.CreateAsync(content.Length); } Assert.IsTrue(await file.ExistsAsync()); @@ -930,13 +859,13 @@ public async Task RunPermissionsTestFiles(SharedAccessAccountPolicy policy) if (((policy.Permissions & SharedAccessAccountPermissions.Write) == SharedAccessAccountPermissions.Write) && ((policy.ResourceTypes & SharedAccessAccountResourceTypes.Object) == SharedAccessAccountResourceTypes.Object)) { - await fileWithSAS.WriteRangeAsync(stream.AsInputStream(), 0, null); + await fileWithSAS.WriteRangeAsync(stream, 0, null); } else { - await TestHelper.ExpectedExceptionAsync(async () => await fileWithSAS.WriteRangeAsync(stream.AsInputStream(), 0, null), "Writing a range to a file with SAS should fail without Write and Object-level perms."); + await TestHelper.ExpectedExceptionAsync(async () => await fileWithSAS.WriteRangeAsync(stream, 0, null), "Writing a range to a file with SAS should fail without Write and Object-level perms."); stream.Seek(0, SeekOrigin.Begin); - await file.WriteRangeAsync(stream.AsInputStream(), 0, null); + await file.WriteRangeAsync(stream, 0, null); } } @@ -959,7 +888,7 @@ public async Task RunPermissionsTestFiles(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await fileWithSAS.DownloadRangeToByteArrayAsync(result, 0, 0, content.Length), "Reading a file with SAS should fail without Read and Object-level perms."); + await TestHelper.ExpectedExceptionAsync(async () => await fileWithSAS.DownloadRangeToByteArrayAsync(result, 0, 0, content.Length), "Reading a file with SAS should fail without Read and Object-level perms."); } if (((policy.Permissions & SharedAccessAccountPermissions.Write) == SharedAccessAccountPermissions.Write) && @@ -969,7 +898,7 @@ public async Task RunPermissionsTestFiles(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await fileWithSAS.CreateAsync(2), "Overwriting a file with SAS should fail without Write and Object-level perms."); + await TestHelper.ExpectedExceptionAsync(async () => await fileWithSAS.CreateAsync(2), "Overwriting a file with SAS should fail without Write and Object-level perms."); await file.CreateAsync(2); } @@ -987,7 +916,7 @@ public async Task RunPermissionsTestFiles(SharedAccessAccountPolicy policy) } else { - await TestHelper.ExpectedExceptionAsync(async () => await fileWithSAS.DeleteAsync(), "Deleting a file with SAS should fail without Delete and Object-level perms."); + await TestHelper.ExpectedExceptionAsync(async () => await fileWithSAS.DeleteAsync(), "Deleting a file with SAS should fail without Delete and Object-level perms."); await file.DeleteAsync(); } @@ -995,7 +924,7 @@ public async Task RunPermissionsTestFiles(SharedAccessAccountPolicy policy) } finally { - fileClient.GetShareReference(shareName).DeleteIfExistsAsync().AsTask().Wait(); + fileClient.GetShareReference(shareName).DeleteIfExistsAsync().Wait(); } } @@ -1031,7 +960,7 @@ public async Task RunBlobTest(SharedAccessAccountPolicy policy, int? httpsPort, } finally { - blobClient.GetContainerReference(containerName).DeleteIfExistsAsync().AsTask().Wait(); + blobClient.GetContainerReference(containerName).DeleteIfExistsAsync().Wait(); } } @@ -1075,7 +1004,7 @@ public async Task RunTableTest(SharedAccessAccountPolicy policy, int? httpsPort, } finally { - tableClient.GetTableReference(tableName).DeleteIfExistsAsync().AsTask().Wait(); + tableClient.GetTableReference(tableName).DeleteIfExistsAsync().Wait(); } } @@ -1108,7 +1037,7 @@ public async Task RunQueueTest(SharedAccessAccountPolicy policy, int? httpsPort, } finally { - queueClient.GetQueueReference(queueName).DeleteIfExistsAsync().AsTask().Wait(); + queueClient.GetQueueReference(queueName).DeleteIfExistsAsync().Wait(); } } @@ -1138,7 +1067,7 @@ public async Task RunFileTest(SharedAccessAccountPolicy policy, int? httpsPort, CloudFile fileWithSAS = shareWithSAS.GetRootDirectoryReference().GetFileReference(fileName); byte[] content = new byte[] { 0x1, 0x2, 0x3, 0x4 }; await file.CreateAsync(content.Length); - using (IInputStream stream = new MemoryStream(content).AsInputStream()) + using (MemoryStream stream = new MemoryStream(content)) { await file.WriteRangeAsync(stream, 0, null); } @@ -1152,7 +1081,7 @@ public async Task RunFileTest(SharedAccessAccountPolicy policy, int? httpsPort, } finally { - fileClient.GetShareReference(shareName).DeleteIfExistsAsync().AsTask().Wait(); + fileClient.GetShareReference(shareName).DeleteIfExistsAsync().Wait(); } } @@ -1188,10 +1117,9 @@ private async Task GetMyBlobIPAddressFromService() { await blockblobWithSAS.DownloadRangeToByteArrayAsync(target, 0, 0, 4); } - catch (WrappedStorageException e) + catch (StorageException e) { - XDocument xdocument = XDocument.Parse(e.Message); - actualIP = xdocument.Descendants("SourceIP").First().Value; + actualIP = e.RequestInformation.ExtendedErrorInformation.AdditionalDetails["SourceIP"]; exceptionThrown = true; Assert.IsNotNull(actualIP); } @@ -1201,7 +1129,7 @@ private async Task GetMyBlobIPAddressFromService() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1233,10 +1161,9 @@ private async Task GetMyQueueIPAddressFromService() { await queueWithSAS.GetMessageAsync(); } - catch (WrappedStorageException e) + catch (StorageException e) { - XDocument xdocument = XDocument.Parse(e.Message); - actualIP = xdocument.Descendants("SourceIP").First().Value; + actualIP = e.RequestInformation.ExtendedErrorInformation.AdditionalDetails["SourceIP"]; exceptionThrown = true; Assert.IsNotNull(actualIP); } @@ -1246,7 +1173,7 @@ private async Task GetMyQueueIPAddressFromService() } finally { - queue.DeleteIfExistsAsync().AsTask().Wait(); + queue.DeleteIfExistsAsync().Wait(); } } @@ -1290,12 +1217,9 @@ private async Task GetMyTableIPAddressFromService() TableQuery query = new TableQuery().Where(string.Format("(PartitionKey eq '{0}') and (RowKey eq '{1}')", entity1.PartitionKey, entity1.RowKey)); (await tableWithSAS.ExecuteQuerySegmentedAsync(query, null)).First(); } - catch (WrappedStorageException e) + catch (StorageException e) { - XDocument xdocument = XDocument.Parse(e.Message); - System.Diagnostics.Debug.WriteLine(xdocument.ToString()); - string message = xdocument.Descendants("HttpStatusMessage").First().Value; - string[] parts = message.Split(' '); + string[] parts = e.RequestInformation.HttpStatusMessage.Split(' '); actualIP = parts[parts.Length - 1].Trim('.'); exceptionThrown = true; Assert.IsNotNull(actualIP); @@ -1306,7 +1230,7 @@ private async Task GetMyTableIPAddressFromService() } finally { - table.DeleteIfExistsAsync().AsTask().Wait(); + table.DeleteIfExistsAsync().Wait(); } } @@ -1344,10 +1268,9 @@ private async Task GetMyFileIPAddressFromService() { await fileWithSAS.DownloadRangeToByteArrayAsync(target, 0, 0, 4); } - catch (WrappedStorageException e) + catch (StorageException e) { - XDocument xdocument = XDocument.Parse(e.Message); - actualIP = xdocument.Descendants("SourceIP").First().Value; + actualIP = e.RequestInformation.ExtendedErrorInformation.AdditionalDetails["SourceIP"]; exceptionThrown = true; Assert.IsNotNull(actualIP); } @@ -1357,7 +1280,7 @@ private async Task GetMyFileIPAddressFromService() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -1396,11 +1319,10 @@ private async Task GetMyIPAddressFromService() { await blockblobWithSAS.DownloadRangeToByteArrayAsync(target, 0, 0, 4, null, null, opContext); } - catch (WrappedStorageException e) + catch (StorageException e) { exceptionThrown = true; - XDocument xdocument = XDocument.Parse(e.Message); - actualIP = xdocument.Descendants("SourceIP").First().Value; + actualIP = e.RequestInformation.ExtendedErrorInformation.AdditionalDetails["SourceIP"]; Assert.IsNotNull(actualIP); } @@ -1409,7 +1331,7 @@ private async Task GetMyIPAddressFromService() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } diff --git a/Test/WindowsRuntime/Blob/BlobAnalyticsUnitTests.cs b/Test/WindowsRuntime/Blob/BlobAnalyticsUnitTests.cs index 99509b736..fc17f131d 100644 --- a/Test/WindowsRuntime/Blob/BlobAnalyticsUnitTests.cs +++ b/Test/WindowsRuntime/Blob/BlobAnalyticsUnitTests.cs @@ -78,14 +78,14 @@ public TestContext TestContext public static void MyClassInitialize(TestContext testContext) { client = GenerateCloudBlobClient(); - startProperties = client.GetServicePropertiesAsync().AsTask().Result; + startProperties = client.GetServicePropertiesAsync().Result; } // Use ClassCleanup to run code after all tests in a class have run [ClassCleanup()] public static void MyClassCleanup() { - client.SetServicePropertiesAsync(startProperties).AsTask().Wait(); + client.SetServicePropertiesAsync(startProperties).Wait(); } // @@ -667,7 +667,7 @@ private async Task TestCorsRulesAsync(CloudBlobClient client, OperationContext c private static ServiceProperties DefaultServiceProperties() { - ServiceProperties props = new ServiceProperties(); + ServiceProperties props = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties(), new CorsProperties()); props.Logging.LoggingOperations = LoggingOperations.None; props.Logging.RetentionDays = null; diff --git a/Test/WindowsRuntime/Blob/BlobCancellationUnitTests.cs b/Test/WindowsRuntime/Blob/BlobCancellationUnitTests.cs index c801121d6..31b395b5f 100644 --- a/Test/WindowsRuntime/Blob/BlobCancellationUnitTests.cs +++ b/Test/WindowsRuntime/Blob/BlobCancellationUnitTests.cs @@ -85,21 +85,15 @@ public async Task CloudBlockBlobDownloadToStreamCancelAsync() CloudBlockBlob blob = container.GetBlockBlobReference("blob1"); using (MemoryStream originalBlob = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(originalBlob.AsInputStream()); + await blob.UploadFromStreamAsync(originalBlob); using (MemoryStream downloadedBlob = new MemoryStream()) { OperationContext operationContext = new OperationContext(); -#if ASPNET_K var tokenSource = new CancellationTokenSource(); Task action = blob.DownloadToStreamAsync(downloadedBlob, null, null, operationContext, tokenSource.Token); await Task.Delay(100); tokenSource.Cancel(); -#else - IAsyncAction action = blob.DownloadToStreamAsync(downloadedBlob.AsOutputStream(), null, null, operationContext); - await Task.Delay(100); - action.Cancel(); -#endif try { await action; @@ -116,7 +110,7 @@ public async Task CloudBlockBlobDownloadToStreamCancelAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -140,16 +134,10 @@ public async Task CloudBlockBlobUploadFromStreamCancelAsync() using (ManualResetEvent waitHandle = new ManualResetEvent(false)) { OperationContext operationContext = new OperationContext(); -#if ASPNET_K var tokenSource = new CancellationTokenSource(); Task action = blob.UploadFromStreamAsync(originalBlob, originalBlob.Length, null, null, operationContext, tokenSource.Token); await Task.Delay(1000); //we need a bit longer time in order to put the cancel output exception to operationContext.LastResult tokenSource.Cancel(); -#else - IAsyncAction action = blob.UploadFromStreamAsync(originalBlob.AsInputStream(), null, null, operationContext); - await Task.Delay(100); - action.Cancel(); -#endif try { await action; @@ -166,7 +154,7 @@ public async Task CloudBlockBlobUploadFromStreamCancelAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Blob/BlobReadStreamTest.cs b/Test/WindowsRuntime/Blob/BlobReadStreamTest.cs index 38e52b501..b07a76bcb 100644 --- a/Test/WindowsRuntime/Blob/BlobReadStreamTest.cs +++ b/Test/WindowsRuntime/Blob/BlobReadStreamTest.cs @@ -85,20 +85,20 @@ public async Task BlockBlobReadStreamBasicTestAsync() CloudBlockBlob blob = container.GetBlockBlobReference("blob1"); using (MemoryStream wholeBlob = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(wholeBlob.AsInputStream()); + await blob.UploadFromStreamAsync(wholeBlob); } using (MemoryStream wholeBlob = new MemoryStream(buffer)) { using (var blobStream = await blob.OpenReadAsync()) { - await TestHelper.AssertStreamsAreEqualAsync(wholeBlob.AsInputStream(), blobStream); + await TestHelper.AssertStreamsAreEqualAsync(wholeBlob, blobStream); } } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -119,12 +119,12 @@ public async Task PageBlobReadStreamBasicTestAsync() CloudPageBlob blob = container.GetPageBlobReference("blob1"); using (MemoryStream wholeBlob = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(wholeBlob.AsInputStream()); + await blob.UploadFromStreamAsync(wholeBlob); } using (MemoryStream wholeBlob = new MemoryStream(buffer)) { - using (Stream blobStream = (await blob.OpenReadAsync()).AsStreamForRead()) + using (Stream blobStream = (await blob.OpenReadAsync())) { TestHelper.AssertStreamsAreEqual(wholeBlob, blobStream); } @@ -132,7 +132,7 @@ public async Task PageBlobReadStreamBasicTestAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -155,12 +155,12 @@ public async Task AppendBlobReadStreamBasicTestAsync() using (MemoryStream wholeBlob = new MemoryStream(buffer)) { - await blob.AppendBlockAsync(wholeBlob.AsInputStream()); + await blob.AppendBlockAsync(wholeBlob); } using (MemoryStream wholeBlob = new MemoryStream(buffer)) { - using (Stream blobStream = (await blob.OpenReadAsync()).AsStreamForRead()) + using (Stream blobStream = (await blob.OpenReadAsync())) { TestHelper.AssertStreamsAreEqual(wholeBlob, blobStream); } @@ -168,7 +168,7 @@ public async Task AppendBlobReadStreamBasicTestAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -191,13 +191,13 @@ public async Task BlockBlobReadLockToETagTestAsync() blob.StreamMinimumReadSizeInBytes = outBuffer.Length; using (MemoryStream wholeBlob = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(wholeBlob.AsInputStream()); + await blob.UploadFromStreamAsync(wholeBlob); } OperationContext opContext = new OperationContext(); using (var blobStream = await blob.OpenReadAsync(null, null, opContext)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; await blobStreamForRead.ReadAsync(outBuffer, 0, outBuffer.Length); await blob.SetMetadataAsync(); await TestHelper.ExpectedExceptionAsync( @@ -210,7 +210,7 @@ await TestHelper.ExpectedExceptionAsync( opContext = new OperationContext(); using (var blobStream = await blob.OpenReadAsync(null, null, opContext)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; long length = blobStreamForRead.Length; await blob.SetMetadataAsync(); await TestHelper.ExpectedExceptionAsync( @@ -231,7 +231,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -254,13 +254,13 @@ public async Task PageBlobReadLockToETagTestAsync() blob.StreamMinimumReadSizeInBytes = outBuffer.Length; using (MemoryStream wholeBlob = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(wholeBlob.AsInputStream()); + await blob.UploadFromStreamAsync(wholeBlob); } OperationContext opContext = new OperationContext(); using (var blobStream = await blob.OpenReadAsync(null, null, opContext)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; await blobStreamForRead.ReadAsync(outBuffer, 0, outBuffer.Length); await blob.SetMetadataAsync(); await TestHelper.ExpectedExceptionAsync( @@ -273,7 +273,7 @@ await TestHelper.ExpectedExceptionAsync( opContext = new OperationContext(); using (var blobStream = await blob.OpenReadAsync(null, null, opContext)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; long length = blobStreamForRead.Length; await blob.SetMetadataAsync(); await TestHelper.ExpectedExceptionAsync( @@ -294,7 +294,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -319,13 +319,13 @@ public async Task AppendBlobReadLockToETagTestAsync() blob.StreamMinimumReadSizeInBytes = outBuffer.Length; using (MemoryStream wholeBlob = new MemoryStream(buffer)) { - await blob.AppendBlockAsync(wholeBlob.AsInputStream()); + await blob.AppendBlockAsync(wholeBlob); } OperationContext opContext = new OperationContext(); using (var blobStream = await blob.OpenReadAsync(null, null, opContext)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; await blobStreamForRead.ReadAsync(outBuffer, 0, outBuffer.Length); await blob.SetMetadataAsync(); await TestHelper.ExpectedExceptionAsync( @@ -338,7 +338,7 @@ await TestHelper.ExpectedExceptionAsync( opContext = new OperationContext(); using (var blobStream = await blob.OpenReadAsync(null, null, opContext)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; long length = blobStreamForRead.Length; await blob.SetMetadataAsync(); await TestHelper.ExpectedExceptionAsync( @@ -359,28 +359,25 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } -#if ASPNET_K - private static async Task BlobReadStreamSeekAndCompareAsync(Stream blobStream, byte[] bufferToCompare, ulong offset, uint readSize, uint expectedReadCount) -#else - +#if WINDOWS_RT private static async Task BlobReadStreamSeekAndCompareAsync(IRandomAccessStreamWithContentType blobStream, byte[] bufferToCompare, ulong offset, uint readSize, uint expectedReadCount) +#else + private static async Task BlobReadStreamSeekAndCompareAsync(Stream blobStream, byte[] bufferToCompare, ulong offset, uint readSize, uint expectedReadCount) #endif { byte[] testBuffer = new byte[readSize]; - #if ASPNET_K - int actualReadSize = await blobStream.ReadAsync(testBuffer, 0, (int) readSize); + int actualReadSize = await fileStream.ReadAsync(testBuffer, 0, (int) readSize); Assert.AreEqual(expectedReadCount, actualReadSize); #else IBuffer testBufferAsIBuffer = testBuffer.AsBuffer(); await blobStream.ReadAsync(testBufferAsIBuffer, readSize, InputStreamOptions.None); Assert.AreEqual(expectedReadCount, testBufferAsIBuffer.Length); #endif - long bufferOffset = (long)offset; for (int i = 0; i < expectedReadCount; i++, bufferOffset++) { @@ -390,11 +387,10 @@ private static async Task BlobReadStreamSeekAndCompareAsync(IRandomAccessS return expectedReadCount; } -#if ASPNET_K - private static async Task BlobReadStreamSeekTestAsync(Stream blobStream, long streamReadSize, byte[] bufferToCompare) -#else - +#if WINDOWS_RT private static async Task BlobReadStreamSeekTestAsync(IRandomAccessStreamWithContentType blobStream, long streamReadSize, byte[] bufferToCompare) +#else + private static async Task BlobReadStreamSeekTestAsync(Stream blobStream, long streamReadSize, byte[] bufferToCompare) #endif { int attempts = 1; @@ -471,19 +467,23 @@ public async Task BlockBlobReadStreamSeekTestAsync() blob.StreamMinimumReadSizeInBytes = 2 * 1024 * 1024; using (MemoryStream wholeBlob = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(wholeBlob.AsInputStream()); + await blob.UploadFromStreamAsync(wholeBlob); } OperationContext opContext = new OperationContext(); using (var blobStream = await blob.OpenReadAsync(null, null, opContext)) { +#if WINDOWS_RT + int attempts = await BlobReadStreamSeekTestAsync(blobStream.AsRandomAccessStream(), blob.StreamMinimumReadSizeInBytes, buffer); +#else int attempts = await BlobReadStreamSeekTestAsync(blobStream, blob.StreamMinimumReadSizeInBytes, buffer); +#endif TestHelper.AssertNAttempts(opContext, attempts); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -505,19 +505,23 @@ public async Task PageBlobReadStreamSeekTestAsync() blob.StreamMinimumReadSizeInBytes = 2 * 1024 * 1024; using (MemoryStream wholeBlob = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(wholeBlob.AsInputStream()); + await blob.UploadFromStreamAsync(wholeBlob); } OperationContext opContext = new OperationContext(); using (var blobStream = await blob.OpenReadAsync(null, null, opContext)) { +#if WINDOWS_RT + int attempts = await BlobReadStreamSeekTestAsync(blobStream.AsRandomAccessStream(), blob.StreamMinimumReadSizeInBytes, buffer); +#else int attempts = await BlobReadStreamSeekTestAsync(blobStream, blob.StreamMinimumReadSizeInBytes, buffer); +#endif TestHelper.AssertNAttempts(opContext, attempts); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -541,19 +545,23 @@ public async Task AppendBlobReadStreamSeekTestAsync() blob.StreamMinimumReadSizeInBytes = 2 * 1024 * 1024; using (MemoryStream wholeBlob = new MemoryStream(buffer)) { - await blob.AppendBlockAsync(wholeBlob.AsInputStream()); + await blob.AppendBlockAsync(wholeBlob); } OperationContext opContext = new OperationContext(); using (var blobStream = await blob.OpenReadAsync(null, null, opContext)) { +#if WINDOWS_RT + int attempts = await BlobReadStreamSeekTestAsync(blobStream.AsRandomAccessStream(), blob.StreamMinimumReadSizeInBytes, buffer); +#else int attempts = await BlobReadStreamSeekTestAsync(blobStream, blob.StreamMinimumReadSizeInBytes, buffer); +#endif TestHelper.AssertNAttempts(opContext, attempts); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Blob/BlobStreamTests.cs b/Test/WindowsRuntime/Blob/BlobStreamTests.cs index bed893807..95db124f4 100644 --- a/Test/WindowsRuntime/Blob/BlobStreamTests.cs +++ b/Test/WindowsRuntime/Blob/BlobStreamTests.cs @@ -83,10 +83,10 @@ public async Task BlobSeekTestAsync() CloudPageBlob blob = container.GetPageBlobReference("blob1"); using (MemoryStream srcStream = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(srcStream.AsInputStream(), null, null, null); + await blob.UploadFromStreamAsync(srcStream, null, null, null); using (var blobStream = await blob.OpenReadAsync()) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; blobStreamForRead.Seek(2048, 0); byte[] buff = new byte[100]; int numRead = await blobStreamForRead.ReadAsync(buff, 0, 100); @@ -96,7 +96,7 @@ public async Task BlobSeekTestAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -117,13 +117,13 @@ public async Task BlobOpenWriteTestAsync() CloudPageBlob blob = container.GetPageBlobReference("blob1"); using (var blobStream = await blob.OpenWriteAsync(2048)) { - Stream blobStreamForWrite = blobStream.AsStreamForWrite(); + Stream blobStreamForWrite = blobStream; await blobStreamForWrite.WriteAsync(buffer, 0, 2048); await blobStreamForWrite.FlushAsync(); byte[] testBuffer = new byte[2048]; MemoryStream dstStream = new MemoryStream(testBuffer); - await blob.DownloadRangeToStreamAsync(dstStream.AsOutputStream(), null, null); + await blob.DownloadRangeToStreamAsync(dstStream, null, null); MemoryStream memStream = new MemoryStream(buffer); TestHelper.AssertStreamsAreEqual(memStream, dstStream); @@ -131,7 +131,7 @@ public async Task BlobOpenWriteTestAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -151,8 +151,8 @@ public async Task BlobOpenReadTestAsync() CloudPageBlob blob = container.GetPageBlobReference("blob1"); using (MemoryStream srcStream = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(srcStream.AsInputStream()); - using (Stream dstStreamForRead = (await blob.OpenReadAsync()).AsStreamForRead()) + await blob.UploadFromStreamAsync(srcStream); + using (Stream dstStreamForRead = (await blob.OpenReadAsync())) { TestHelper.AssertStreamsAreEqual(srcStream, dstStreamForRead); } @@ -160,7 +160,7 @@ public async Task BlobOpenReadTestAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -181,21 +181,21 @@ public async Task BlobOpenReadWriteTestAsync() using (var blobStream = await blob.OpenWriteAsync(2048)) { - Stream blobStreamForWrite = blobStream.AsStreamForWrite(); + Stream blobStreamForWrite = blobStream; await blobStreamForWrite.WriteAsync(buffer, 0, 2048); await blobStreamForWrite.FlushAsync(); } using (var dstStream = await blob.OpenReadAsync()) { - Stream dstStreamForRead = dstStream.AsStreamForRead(); + Stream dstStreamForRead = dstStream; MemoryStream memoryStream = new MemoryStream(buffer); TestHelper.AssertStreamsAreEqual(memoryStream, dstStreamForRead); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -217,7 +217,7 @@ public async Task BlobOpenWriteSeekReadTestAsync() MemoryStream memoryStream = new MemoryStream(buffer); using (var blobStream = await blob.OpenWriteAsync(2048)) { - Stream blobStreamForWrite = blobStream.AsStreamForWrite(); + Stream blobStreamForWrite = blobStream; await blobStreamForWrite.WriteAsync(buffer, 0, 2048); Assert.AreEqual(blobStreamForWrite.Position, 2048); @@ -237,13 +237,13 @@ public async Task BlobOpenWriteSeekReadTestAsync() using (var dstStream = await blob.OpenReadAsync()) { - Stream dstStreamForRead = dstStream.AsStreamForRead(); + Stream dstStreamForRead = dstStream; TestHelper.AssertStreamsAreEqual(memoryStream, dstStreamForRead); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -265,7 +265,7 @@ public async Task BlobReadWhenOpenWriteAsync() MemoryStream memoryStream = new MemoryStream(buffer); using (var blobStream = await blob.OpenWriteAsync(2048)) { - Stream blobStreamForWrite = blobStream.AsStreamForWrite(); + Stream blobStreamForWrite = blobStream; await blobStreamForWrite.WriteAsync(buffer, 0, 2048); byte[] testBuffer = new byte[2048]; try @@ -282,7 +282,7 @@ public async Task BlobReadWhenOpenWriteAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -303,12 +303,12 @@ public async Task BlobWriteWhenOpenReadAsync() CloudPageBlob blob = container.GetPageBlobReference("blob1"); using (MemoryStream srcStream = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(srcStream.AsInputStream()); + await blob.UploadFromStreamAsync(srcStream); bool thrown = false; byte[] testBuffer = new byte[2048]; using (var blobStream = await blob.OpenReadAsync()) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; try { await blobStreamForRead.WriteAsync(testBuffer, 0, 2048); @@ -324,7 +324,7 @@ public async Task BlobWriteWhenOpenReadAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Blob/BlobTestBase.cs b/Test/WindowsRuntime/Blob/BlobTestBase.cs index 36def0c0e..d43872463 100644 --- a/Test/WindowsRuntime/Blob/BlobTestBase.cs +++ b/Test/WindowsRuntime/Blob/BlobTestBase.cs @@ -92,17 +92,17 @@ public static async Task UploadTextAsync(CloudBlob blob, string text, Encoding e { CloudAppendBlob blob1 = blob as CloudAppendBlob; await blob1.CreateOrReplaceAsync(); - await blob1.AppendBlockAsync(stream.AsInputStream(), null); + await blob1.AppendBlockAsync(stream, null); } else if (blob.BlobType == BlobType.PageBlob) { CloudPageBlob pageBlob = blob as CloudPageBlob; - await pageBlob.UploadFromStreamAsync(stream.AsInputStream(), accessCondition, options, operationContext); + await pageBlob.UploadFromStreamAsync(stream, accessCondition, options, operationContext); } else { CloudBlockBlob blockBlob = blob as CloudBlockBlob; - await blockBlob.UploadFromStreamAsync(stream.AsInputStream(), accessCondition, options, operationContext); + await blockBlob.UploadFromStreamAsync(stream, accessCondition, options, operationContext); } } } @@ -111,7 +111,7 @@ public static async Task DownloadTextAsync(CloudBlob blob, Encoding enco { using (MemoryStream stream = new MemoryStream()) { - await blob.DownloadToStreamAsync(stream.AsOutputStream(), accessCondition, options, operationContext); + await blob.DownloadToStreamAsync(stream, accessCondition, options, operationContext); byte[] buffer = stream.ToArray(); return encoding.GetString(buffer, 0, buffer.Length); } diff --git a/Test/WindowsRuntime/Blob/BlobUploadDownloadTest.cs b/Test/WindowsRuntime/Blob/BlobUploadDownloadTest.cs index 01c5965e5..39b8da7a2 100644 --- a/Test/WindowsRuntime/Blob/BlobUploadDownloadTest.cs +++ b/Test/WindowsRuntime/Blob/BlobUploadDownloadTest.cs @@ -53,7 +53,7 @@ public void Dispose() public void TestInitialize() { this.testContainer = GetRandomContainerReference(); - this.testContainer.CreateIfNotExistsAsync().AsTask().Wait(); + this.testContainer.CreateIfNotExistsAsync().Wait(); if (TestBase.BlobBufferManager != null) { @@ -67,7 +67,7 @@ public void TestCleanup() #if ASPNET_K this.testContainer.DeleteIfExistsAsync().Wait(); #else - this.testContainer.DeleteIfExistsAsync().AsTask().Wait(); + this.testContainer.DeleteIfExistsAsync().Wait(); #endif if (TestBase.BlobBufferManager != null) { @@ -88,16 +88,16 @@ public async Task PageBlobDownloadToStreamRangeTestAsync() CloudPageBlob blob = this.testContainer.GetPageBlobReference("blob1"); using (MemoryStream wholeBlob = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(wholeBlob.AsInputStream()); + await blob.UploadFromStreamAsync(wholeBlob); byte[] testBuffer = new byte[1024]; MemoryStream blobStream = new MemoryStream(testBuffer); Exception ex = await TestHelper.ExpectedExceptionAsync( - async () => await blob.DownloadRangeToStreamAsync(blobStream.AsOutputStream(), 0, 0), + async () => await blob.DownloadRangeToStreamAsync(blobStream, 0, 0), "Requesting 0 bytes when downloading range should not work"); - Assert.IsInstanceOfType(ex.InnerException.InnerException, typeof(ArgumentOutOfRangeException)); - await blob.DownloadRangeToStreamAsync(blobStream.AsOutputStream(), 0, 1024); + Assert.IsInstanceOfType(ex.InnerException, typeof(ArgumentOutOfRangeException)); + await blob.DownloadRangeToStreamAsync(blobStream, 0, 1024); Assert.AreEqual(blobStream.Position, 1024); TestHelper.AssertStreamsAreEqualAtIndex(blobStream, wholeBlob, 0, 0, 1024); @@ -106,10 +106,10 @@ public async Task PageBlobDownloadToStreamRangeTestAsync() MemoryStream blobStream2 = new MemoryStream(testBuffer); ex = await TestHelper.ExpectedExceptionAsync( - async () => await blob2.DownloadRangeToStreamAsync(blobStream.AsOutputStream(), 1024, 0), + async () => await blob2.DownloadRangeToStreamAsync(blobStream, 1024, 0), "Requesting 0 bytes when downloading range should not work"); - Assert.IsInstanceOfType(ex.InnerException.InnerException, typeof(ArgumentOutOfRangeException)); - await blob2.DownloadRangeToStreamAsync(blobStream2.AsOutputStream(), 1024, 1024); + Assert.IsInstanceOfType(ex.InnerException, typeof(ArgumentOutOfRangeException)); + await blob2.DownloadRangeToStreamAsync(blobStream2, 1024, 1024); TestHelper.AssertStreamsAreEqualAtIndex(blobStream2, wholeBlob, 0, 1024, 1024); @@ -130,10 +130,10 @@ public async Task BlobUploadFromStreamTestAsync() CloudPageBlob blob = this.testContainer.GetPageBlobReference("blob1"); using (MemoryStream srcStream = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(srcStream.AsInputStream()); + await blob.UploadFromStreamAsync(srcStream); byte[] testBuffer = new byte[2048]; MemoryStream dstStream = new MemoryStream(testBuffer); - await blob.DownloadRangeToStreamAsync(dstStream.AsOutputStream(), null, null); + await blob.DownloadRangeToStreamAsync(dstStream, null, null); TestHelper.AssertStreamsAreEqual(srcStream, dstStream); } } @@ -155,14 +155,14 @@ public async Task BlobUploadWithoutMD5ValidationAndStoreBlobContentTestAsync() OperationContext context = new OperationContext(); using (MemoryStream srcStream = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(srcStream.AsInputStream(), null, options, context); + await blob.UploadFromStreamAsync(srcStream, null, options, context); await blob.FetchAttributesAsync(); string md5 = blob.Properties.ContentMD5; blob.Properties.ContentMD5 = "MDAwMDAwMDA="; await blob.SetPropertiesAsync(null, options, context); byte[] testBuffer = new byte[2048]; MemoryStream dstStream = new MemoryStream(testBuffer); - await TestHelper.ExpectedExceptionAsync(async () => await blob.DownloadRangeToStreamAsync(dstStream.AsOutputStream(), null, null, null, options, context), + await TestHelper.ExpectedExceptionAsync(async () => await blob.DownloadRangeToStreamAsync(dstStream, null, null, null, options, context), context, "Try to Download a stream with a corrupted md5 and DisableMD5Validation set to false", HttpStatusCode.OK); @@ -171,7 +171,7 @@ await TestHelper.ExpectedExceptionAsync(async () => await blob.DownloadRangeToSt await blob.SetPropertiesAsync(null, options, context); byte[] testBuffer2 = new byte[2048]; MemoryStream dstStream2 = new MemoryStream(testBuffer2); - await blob.DownloadRangeToStreamAsync(dstStream2.AsOutputStream(), null, null, null, options, context); + await blob.DownloadRangeToStreamAsync(dstStream2, null, null, null, options, context); } } @@ -238,10 +238,10 @@ private async Task DoUploadDownloadFileAsync(ICloudBlob blob, int fileSize) await file.WriteAsync(buffer, 0, buffer.Length); } - await blob.UploadFromFileAsync(inputFileName, FileMode.Open); + await blob.UploadFromFileAsync(inputFileName); OperationContext context = new OperationContext(); - await blob.UploadFromFileAsync(inputFileName, FileMode.Open, null, null, context); + await blob.UploadFromFileAsync(inputFileName, null, null, context); Assert.IsNotNull(context.LastResult.ServiceRequestID); context = new OperationContext(); @@ -458,7 +458,7 @@ private async Task DoDownloadToByteArrayAsyncTest(ICloudBlob blob, int blobSize, using (MemoryStream originalBlob = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(originalBlob.AsInputStream()); + await blob.UploadFromStreamAsync(originalBlob); } if (!isOverload) @@ -661,7 +661,7 @@ private async Task DoDownloadRangeToByteArrayAsyncTest(ICloudBlob blob, int blob using (MemoryStream originalBlob = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(originalBlob.AsInputStream()); + await blob.UploadFromStreamAsync(originalBlob); } if (!isOverload) @@ -698,7 +698,150 @@ private async Task DoDownloadRangeToByteArrayAsyncTest(ICloudBlob blob, int blob } } -#region Negative tests +#if ASPNET_K + [TestMethod] + [Description("Upload from file to a block blob with file cleanup for failure cases")] + [TestCategory(ComponentCategory.Blob)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] + public async Task CloudBlockBlobUploadDownloadFileWithFailures() + { + CloudBlockBlob blob = this.testContainer.GetBlockBlobReference("blob1"); + CloudBlockBlob nullBlob = this.testContainer.GetBlockBlobReference("null"); + await this.DoUploadDownloadFileAsync(blob, 0); + await this.DoUploadDownloadFileAsync(blob, 4096); + await this.DoUploadDownloadFileAsync(blob, 4097); + + await TestHelper.ExpectedExceptionAsync( + async () => await blob.UploadFromFileAsync("non_existentCloudBlockBlobUploadDownloadFileWithFailures.file"), + "UploadFromFileAsync requires an existing file"); + + await TestHelper.ExpectedExceptionAsync( + async () => await nullBlob.DownloadToFileAsync("garbageCloudBlockBlobUploadDownloadFileWithFailures.file", FileMode.Create), + "DownloadToFileAsync should not leave an empty file behind after failing."); + Assert.IsFalse(System.IO.File.Exists("garbageCloudBlockBlobUploadDownloadFileWithFailures.file")); + + await TestHelper.ExpectedExceptionAsync( + async () => await nullBlob.DownloadToFileAsync("garbageCloudBlockBlobUploadDownloadFileWithFailures.file", FileMode.CreateNew), + "DownloadToFileAsync should not leave an empty file behind after failing."); + Assert.IsFalse(System.IO.File.Exists("garbageCloudBlockBlobUploadDownloadFileWithFailures.file")); + + byte[] buffer = GetRandomBuffer(100); + using (FileStream file = new FileStream("garbageCloudBlockBlobUploadDownloadFileWithFailures.file", FileMode.Create, FileAccess.Write)) + { + await file.WriteAsync(buffer, 0, buffer.Length); + } + await TestHelper.ExpectedExceptionAsync( + async () => await nullBlob.DownloadToFileAsync("garbageCloudBlockBlobUploadDownloadFileWithFailures.file", FileMode.CreateNew), + "DownloadToFileAsync should leave an empty file behind after failing, depending on the mode."); + Assert.IsTrue(System.IO.File.Exists("garbageCloudBlockBlobUploadDownloadFileWithFailures.file")); + System.IO.File.Delete("garbageCloudBlockBlobUploadDownloadFileWithFailures.file"); + + await TestHelper.ExpectedExceptionAsync( + async () => await nullBlob.DownloadToFileAsync("garbageCloudBlockBlobUploadDownloadFileWithFailures.file", FileMode.Append), + "DownloadToFileAsync should leave an empty file behind after failing depending on file mode."); + Assert.IsTrue(System.IO.File.Exists("garbageCloudBlockBlobUploadDownloadFileWithFailures.file")); + System.IO.File.Delete("garbageCloudBlockBlobUploadDownloadFileWithFailures.file"); + } + + [TestMethod] + [Description("Upload from file to a page blob with file cleanup for failure cases")] + [TestCategory(ComponentCategory.Blob)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] + public async Task CloudPageBlobUploadDownloadFileWithFailures() + { + CloudPageBlob blob = this.testContainer.GetPageBlobReference("blob1"); + CloudPageBlob nullBlob = this.testContainer.GetPageBlobReference("null"); + await this.DoUploadDownloadFileAsync(blob, 0); + await this.DoUploadDownloadFileAsync(blob, 4096); + + await TestHelper.ExpectedExceptionAsync( + async () => await this.DoUploadDownloadFileAsync(blob, 4097), + "Page blobs must be 512-byte aligned"); + + await TestHelper.ExpectedExceptionAsync( + async () => await blob.UploadFromFileAsync("non_existentCloudPageBlobUploadDownloadFileWithFailures.file"), + "UploadFromFileAsync requires an existing file"); + + await TestHelper.ExpectedExceptionAsync( + async () => await nullBlob.DownloadToFileAsync("garbageCloudPageBlobUploadDownloadFileWithFailures.file", FileMode.Create), + "DownloadToFileAsync should not leave an empty file behind after failing."); + Assert.IsFalse(System.IO.File.Exists("garbageCloudPageBlobUploadDownloadFileWithFailures.file")); + + await TestHelper.ExpectedExceptionAsync( + async () => await nullBlob.DownloadToFileAsync("garbageCloudPageBlobUploadDownloadFileWithFailures.file", FileMode.CreateNew), + "DownloadToFileAsync should not leave an empty file behind after failing."); + Assert.IsFalse(System.IO.File.Exists("garbageCloudPageBlobUploadDownloadFileWithFailures.file")); + + byte[] buffer = GetRandomBuffer(100); + using (FileStream file = new FileStream("garbageCloudPageBlobUploadDownloadFileWithFailures.file", FileMode.Create, FileAccess.Write)) + { + await file.WriteAsync(buffer, 0, buffer.Length); + } + await TestHelper.ExpectedExceptionAsync( + async () => await nullBlob.DownloadToFileAsync("garbageCloudPageBlobUploadDownloadFileWithFailures.file", FileMode.CreateNew), + "DownloadToFileAsync should leave an empty file behind after failing, depending on the mode."); + Assert.IsTrue(System.IO.File.Exists("garbageCloudPageBlobUploadDownloadFileWithFailures.file")); + System.IO.File.Delete("garbageCloudPageBlobUploadDownloadFileWithFailures.file"); + + await TestHelper.ExpectedExceptionAsync( + async () => await nullBlob.DownloadToFileAsync("garbageCloudPageBlobUploadDownloadFileWithFailures.file", FileMode.OpenOrCreate), + "DownloadToFileAsync should leave an empty file behind after failing, depending on file mode."); + Assert.IsTrue(System.IO.File.Exists("garbageCloudPageBlobUploadDownloadFileWithFailures.file")); + System.IO.File.Delete("garbageCloudPageBlobUploadDownloadFileWithFailures.file"); + } + + [TestMethod] + [Description("Upload from file to an append blob with file cleanup for failure cases")] + [TestCategory(ComponentCategory.Blob)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] + public async Task CloudAppendBlobUploadDownloadFileWithFailures() + { + CloudAppendBlob blob = this.testContainer.GetAppendBlobReference("blob1"); + CloudAppendBlob nullBlob = this.testContainer.GetAppendBlobReference("null"); + await this.DoUploadDownloadFileAsync(blob, 0); + await this.DoUploadDownloadFileAsync(blob, 4096); + await this.DoUploadDownloadFileAsync(blob, 4097); + + await TestHelper.ExpectedExceptionAsync( + async () => await blob.UploadFromFileAsync("non_existentCloudAppendBlobUploadDownloadFileWithFailures.file"), + "UploadFromFileAsync requires an existing file"); + + await TestHelper.ExpectedExceptionAsync( + async () => await nullBlob.DownloadToFileAsync("garbageCloudAppendBlobUploadDownloadFileWithFailures.file", FileMode.Create), + "DownloadToFileAsync should not leave an empty file behind after failing."); + Assert.IsFalse(System.IO.File.Exists("garbageCloudAppendBlobUploadDownloadFileWithFailures.file")); + + await TestHelper.ExpectedExceptionAsync( + async () => await nullBlob.DownloadToFileAsync("garbageCloudAppendBlobUploadDownloadFileWithFailures.file", FileMode.CreateNew), + "DownloadToFileAsync should not leave an empty file behind after failing."); + Assert.IsFalse(System.IO.File.Exists("garbageCloudAppendBlobUploadDownloadFileWithFailures.file")); + + byte[] buffer = GetRandomBuffer(100); + using (FileStream file = new FileStream("garbageCloudAppendBlobUploadDownloadFileWithFailures.file", FileMode.Create, FileAccess.Write)) + { + await file.WriteAsync(buffer, 0, buffer.Length); + } + await TestHelper.ExpectedExceptionAsync( + async () => await nullBlob.DownloadToFileAsync("garbageCloudAppendBlobUploadDownloadFileWithFailures.file", FileMode.CreateNew), + "DownloadToFileAsync should leave an empty file behind after failing, depending on the mode."); + Assert.IsTrue(System.IO.File.Exists("garbageCloudAppendBlobUploadDownloadFileWithFailures.file")); + System.IO.File.Delete("garbageCloudAppendBlobUploadDownloadFileWithFailures.file"); + + await TestHelper.ExpectedExceptionAsync( + async () => await nullBlob.DownloadToFileAsync("garbageCloudAppendBlobUploadDownloadFileWithFailures.file", FileMode.Append), + "DownloadToFileAsync should leave an empty file behind after failing depending on file mode."); + Assert.IsTrue(System.IO.File.Exists("garbageCloudAppendBlobUploadDownloadFileWithFailures.file")); + System.IO.File.Delete("garbageCloudAppendBlobUploadDownloadFileWithFailures.file"); + } +#endif + + #region Negative tests [TestMethod] [Description("Single put blob and get blob")] [TestCategory(ComponentCategory.Blob)] @@ -733,19 +876,19 @@ private async Task DoDownloadRangeToByteArrayNegativeTestsAsync(ICloudBlob blob) using (MemoryStream stream = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(stream.AsInputStream()); + await blob.UploadFromStreamAsync(stream); OperationContext context = new OperationContext(); await TestHelper.ExpectedExceptionAsync(async () => await blob.DownloadRangeToByteArrayAsync(resultBuffer, 0, 1024, 1, null, null, context), context, "Try invalid length", HttpStatusCode.RequestedRangeNotSatisfiable); - WrappedStorageException ex = await TestHelper.ExpectedExceptionAsync(async () => await blob.DownloadToByteArrayAsync(resultBuffer, 1024), "Provide invalid offset"); - Assert.IsInstanceOfType(ex.InnerException.InnerException, typeof(NotSupportedException)); - ex = await TestHelper.ExpectedExceptionAsync(async () => await blob.DownloadRangeToByteArrayAsync(resultBuffer, 1023, 0, 2), "Should fail when offset + length required is greater than size of the buffer"); - Assert.IsInstanceOfType(ex.InnerException.InnerException, typeof(NotSupportedException)); - ex = await TestHelper.ExpectedExceptionAsync(async () => await blob.DownloadRangeToByteArrayAsync(resultBuffer, 0, 0, -10), "Fail when a negative length is specified"); - Assert.IsInstanceOfType(ex.InnerException.InnerException, typeof(ArgumentOutOfRangeException)); + StorageException ex = await TestHelper.ExpectedExceptionAsync(async () => await blob.DownloadToByteArrayAsync(resultBuffer, 1024), "Provide invalid offset"); + Assert.IsInstanceOfType(ex.InnerException, typeof(NotSupportedException)); + ex = await TestHelper.ExpectedExceptionAsync(async () => await blob.DownloadRangeToByteArrayAsync(resultBuffer, 1023, 0, 2), "Should fail when offset + length required is greater than size of the buffer"); + Assert.IsInstanceOfType(ex.InnerException, typeof(NotSupportedException)); + ex = await TestHelper.ExpectedExceptionAsync(async () => await blob.DownloadRangeToByteArrayAsync(resultBuffer, 0, 0, -10), "Fail when a negative length is specified"); + Assert.IsInstanceOfType(ex.InnerException, typeof(ArgumentOutOfRangeException)); await TestHelper.ExpectedExceptionAsync(async () => await blob.DownloadRangeToByteArrayAsync(resultBuffer, -10, 0, 20), "Fail if a negative offset is provided"); - ex = await TestHelper.ExpectedExceptionAsync(async () => await blob.DownloadRangeToByteArrayAsync(resultBuffer, 0, -10, 20), "Fail if a negative blob offset is provided"); - Assert.IsInstanceOfType(ex.InnerException.InnerException, typeof(ArgumentOutOfRangeException)); + ex = await TestHelper.ExpectedExceptionAsync(async () => await blob.DownloadRangeToByteArrayAsync(resultBuffer, 0, -10, 20), "Fail if a negative blob offset is provided"); + Assert.IsInstanceOfType(ex.InnerException, typeof(ArgumentOutOfRangeException)); } } #endregion diff --git a/Test/WindowsRuntime/Blob/BlobWriteStreamTest.cs b/Test/WindowsRuntime/Blob/BlobWriteStreamTest.cs index 51dddb160..38eb57599 100644 --- a/Test/WindowsRuntime/Blob/BlobWriteStreamTest.cs +++ b/Test/WindowsRuntime/Blob/BlobWriteStreamTest.cs @@ -130,7 +130,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -282,7 +282,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -385,7 +385,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -488,7 +488,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -523,7 +523,7 @@ public async Task BlockBlobWriteStreamBasicTestAsync() }; using (var writeStream = await blob.OpenWriteAsync(null, options, null)) { - Stream blobStream = writeStream.AsStreamForWrite(); + Stream blobStream = writeStream; for (int i = 0; i < 3; i++) { @@ -555,7 +555,7 @@ public async Task BlockBlobWriteStreamBasicTestAsync() } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -575,7 +575,7 @@ public async Task BlockBlobWriteStreamSeekTestAsync() CloudBlockBlob blob = container.GetBlockBlobReference("blob1"); using (var writeStream = await blob.OpenWriteAsync()) { - Stream blobStream = writeStream.AsStreamForWrite(); + Stream blobStream = writeStream; TestHelper.ExpectedException( () => blobStream.Seek(1, SeekOrigin.Begin), @@ -584,7 +584,7 @@ public async Task BlockBlobWriteStreamSeekTestAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -597,7 +597,7 @@ public async Task BlockBlobWriteStreamSeekTestAsync() public async Task BlockBlobWriteStreamFlushTestAsync() { byte[] buffer = GetRandomBuffer(512 * 1024); - + CloudBlobContainer container = GetRandomContainerReference(); try { @@ -612,7 +612,7 @@ public async Task BlockBlobWriteStreamFlushTestAsync() { for (int i = 0; i < 3; i++) { - await blobStream.WriteAsync(buffer.AsBuffer()); + await blobStream.WriteAsync(buffer, 0, buffer.Length); await wholeBlob.WriteAsync(buffer, 0, buffer.Length); } @@ -626,7 +626,7 @@ public async Task BlockBlobWriteStreamFlushTestAsync() Assert.AreEqual(2, opContext.RequestResults.Count); - await blobStream.WriteAsync(buffer.AsBuffer()); + await blobStream.WriteAsync(buffer, 0, buffer.Length); await wholeBlob.WriteAsync(buffer, 0, buffer.Length); Assert.AreEqual(2, opContext.RequestResults.Count); @@ -640,14 +640,14 @@ public async Task BlockBlobWriteStreamFlushTestAsync() using (MemoryStream downloadedBlob = new MemoryStream()) { - await blob.DownloadToStreamAsync(downloadedBlob.AsOutputStream()); + await blob.DownloadToStreamAsync(downloadedBlob); TestHelper.AssertStreamsAreEqual(wholeBlob, downloadedBlob); } } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -685,7 +685,7 @@ public async Task PageBlobWriteStreamBasicTestAsync() using (var writeStream = await blob.OpenWriteAsync(buffer.Length * 3, null, options, null)) { - Stream blobStream = writeStream.AsStreamForWrite(); + Stream blobStream = writeStream; for (int i = 0; i < 3; i++) { @@ -720,7 +720,7 @@ await TestHelper.ExpectedExceptionAsync( using (var writeStream = await blob.OpenWriteAsync(null)) { - Stream blobStream = writeStream.AsStreamForWrite(); + Stream blobStream = writeStream; blobStream.Seek(buffer.Length / 2, SeekOrigin.Begin); wholeBlob.Seek(buffer.Length / 2, SeekOrigin.Begin); @@ -747,7 +747,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -772,7 +772,7 @@ public async Task PageBlobWriteStreamRandomSeekTestAsync() { using (var writeStream = await blob.OpenWriteAsync(buffer.Length)) { - Stream blobStream = writeStream.AsStreamForWrite(); + Stream blobStream = writeStream; TestHelper.ExpectedException( () => blobStream.Seek(1, SeekOrigin.Begin), "Page blob stream should not allow unaligned seeks"); @@ -802,7 +802,7 @@ public async Task PageBlobWriteStreamRandomSeekTestAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -831,7 +831,7 @@ public async Task PageBlobWriteStreamFlushTestAsync() { for (int i = 0; i < 3; i++) { - await blobStream.WriteAsync(buffer.AsBuffer()); + await blobStream.WriteAsync(buffer, 0, buffer.Length); await wholeBlob.WriteAsync(buffer, 0, buffer.Length); } @@ -850,7 +850,7 @@ public async Task PageBlobWriteStreamFlushTestAsync() Assert.AreEqual(3, opContext.RequestResults.Count); - await blobStream.WriteAsync(buffer.AsBuffer()); + await blobStream.WriteAsync(buffer, 0, buffer.Length); await wholeBlob.WriteAsync(buffer, 0, buffer.Length); Assert.AreEqual(3, opContext.RequestResults.Count); @@ -871,7 +871,7 @@ public async Task PageBlobWriteStreamFlushTestAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -907,7 +907,7 @@ public async Task AppendBlobWriteStreamBasicTestAsync() using (var writeStream = await blob.OpenWriteAsync(true, null, options, null)) { - Stream blobStream = writeStream.AsStreamForWrite(); + Stream blobStream = writeStream; for (int i = 0; i < 3; i++) { @@ -943,7 +943,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -963,7 +963,7 @@ public async Task AppendBlobWriteStreamSeekTestAsync() CloudAppendBlob blob = container.GetAppendBlobReference("blob1"); using (var writeStream = await blob.OpenWriteAsync(true)) { - Stream blobStream = writeStream.AsStreamForWrite(); + Stream blobStream = writeStream; TestHelper.ExpectedException( () => blobStream.Seek(1, SeekOrigin.Begin), @@ -972,7 +972,7 @@ public async Task AppendBlobWriteStreamSeekTestAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1001,7 +1001,7 @@ public async Task AppendBlobWriteStreamFlushTestAsync() { for (int i = 0; i < 3; i++) { - await blobStream.WriteAsync(buffer.AsBuffer()); + await blobStream.WriteAsync(buffer, 0, buffer.Length); await wholeBlob.WriteAsync(buffer, 0, buffer.Length); } @@ -1020,7 +1020,7 @@ public async Task AppendBlobWriteStreamFlushTestAsync() Assert.AreEqual(3, opContext.RequestResults.Count); - await blobStream.WriteAsync(buffer.AsBuffer()); + await blobStream.WriteAsync(buffer, 0, buffer.Length); await wholeBlob.WriteAsync(buffer, 0, buffer.Length); Assert.AreEqual(3, opContext.RequestResults.Count); @@ -1041,7 +1041,7 @@ public async Task AppendBlobWriteStreamFlushTestAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1070,7 +1070,7 @@ public async Task AppendBlobWriteStreamMaxSizeConditionTestAsync() { using (var writeStream = await blob.OpenWriteAsync(true, accessCondition, null, context)) { - Stream blobStream = writeStream.AsStreamForWrite(); + Stream blobStream = writeStream; for (int i = 0; i < 3; i++) { @@ -1090,7 +1090,7 @@ public async Task AppendBlobWriteStreamMaxSizeConditionTestAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Blob/CloudAppendBlobTest.cs b/Test/WindowsRuntime/Blob/CloudAppendBlobTest.cs index 65d7b85fd..86a381137 100644 --- a/Test/WindowsRuntime/Blob/CloudAppendBlobTest.cs +++ b/Test/WindowsRuntime/Blob/CloudAppendBlobTest.cs @@ -93,7 +93,7 @@ public async Task CloudAppendBlobCreateAndDeleteAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -118,7 +118,7 @@ public async Task CloudAppendBlobDeleteIfExistsAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -151,7 +151,7 @@ public async Task CloudAppendBlobExistsAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -195,7 +195,7 @@ public async Task CloudAppendBlobFetchAttributesAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -243,7 +243,7 @@ public async Task CloudAppendBlobSetPropertiesAsync() { DisableContentMD5Validation = true, }; - await blob3.DownloadToStreamAsync(stream.AsOutputStream(), null, options, null); + await blob3.DownloadToStreamAsync(stream, null, options, null); } AssertAreEqual(blob2.Properties, blob3.Properties); @@ -253,7 +253,7 @@ public async Task CloudAppendBlobSetPropertiesAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -277,13 +277,13 @@ public async Task CloudAppendBlobFetchAttributesInvalidTypeAsync() OperationContext operationContext = new OperationContext(); Assert.ThrowsException( - () => blob2.FetchAttributesAsync(null, null, operationContext).AsTask().Wait(), + () => blob2.FetchAttributesAsync(null, null, operationContext).Wait(), "Fetching attributes of an append blob using a block blob reference should fail"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(InvalidOperationException)); } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -311,7 +311,7 @@ public async Task CloudAppendBlobCreateWithMetadataAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -339,19 +339,19 @@ public async Task CloudAppendBlobSetMetadataAsync() blob.Metadata["key1"] = null; Assert.ThrowsException( - () => blob.SetMetadataAsync(null, null, operationContext).AsTask().Wait(), + () => blob.SetMetadataAsync(null, null, operationContext).Wait(), "Metadata keys should have a non-null value"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(ArgumentException)); blob.Metadata["key1"] = ""; Assert.ThrowsException( - () => blob.SetMetadataAsync(null, null, operationContext).AsTask().Wait(), + () => blob.SetMetadataAsync(null, null, operationContext).Wait(), "Metadata keys should have a non-empty value"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(ArgumentException)); blob.Metadata["key1"] = " "; Assert.ThrowsException( - () => blob.SetMetadataAsync(null, null, operationContext).AsTask().Wait(), + () => blob.SetMetadataAsync(null, null, operationContext).Wait(), "Metadata keys should have a non-whitespace only value"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(ArgumentException)); @@ -375,7 +375,7 @@ public async Task CloudAppendBlobSetMetadataAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -396,7 +396,7 @@ public async Task CloudAppendBlobAppendBlockAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -414,12 +414,12 @@ private async Task CloudAppendBlobUploadFromStreamAsync(CloudBlobContainer conta using (MemoryStream sourceStream = new MemoryStream(buffer)) { sourceStream.Seek(startOffset, SeekOrigin.Begin); - await blob.AppendBlockAsync(sourceStream.AsInputStream(), null, accessCondition, null, operationContext); + await blob.AppendBlockAsync(sourceStream, null, accessCondition, null, operationContext); } using (MemoryStream downloadedBlobStream = new MemoryStream()) { - await blob.DownloadToStreamAsync(downloadedBlobStream.AsOutputStream()); + await blob.DownloadToStreamAsync(downloadedBlobStream); TestHelper.AssertStreamsAreEqualAtIndex( originalBlobStream, downloadedBlobStream, @@ -471,7 +471,7 @@ private async Task DoTextUploadDownloadAsync(string text) } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -491,7 +491,7 @@ public async Task CloudAppendBlobSnapshotAsync() MemoryStream originalData = new MemoryStream(GetRandomBuffer(1024)); CloudAppendBlob blob = container.GetAppendBlobReference("blob1"); await blob.CreateOrReplaceAsync(); - await blob.AppendBlockAsync(originalData.AsInputStream(), null); + await blob.AppendBlockAsync(originalData, null); Assert.IsFalse(blob.IsSnapshot); Assert.IsNull(blob.SnapshotTime, "Root blob has SnapshotTime set"); Assert.IsFalse(blob.SnapshotQualifiedUri.Query.Contains("snapshot")); @@ -526,7 +526,7 @@ public async Task CloudAppendBlobSnapshotAsync() await WaitForCopyAsync(snapshotCopy); Assert.AreEqual(CopyStatus.Success, snapshotCopy.CopyState.Status); - using (Stream snapshotStream = (await snapshot1.OpenReadAsync()).AsStreamForRead()) + using (Stream snapshotStream = (await snapshot1.OpenReadAsync())) { snapshotStream.Seek(0, SeekOrigin.End); TestHelper.AssertStreamsAreEqual(originalData, snapshotStream); @@ -534,7 +534,7 @@ public async Task CloudAppendBlobSnapshotAsync() await blob.CreateOrReplaceAsync(); - using (Stream snapshotStream = (await snapshot1.OpenReadAsync()).AsStreamForRead()) + using (Stream snapshotStream = (await snapshot1.OpenReadAsync())) { snapshotStream.Seek(0, SeekOrigin.End); TestHelper.AssertStreamsAreEqual(originalData, snapshotStream); @@ -550,7 +550,7 @@ public async Task CloudAppendBlobSnapshotAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -594,7 +594,7 @@ public async Task CloudAppendBlobSnapshotMetadataAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -708,7 +708,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -731,24 +731,24 @@ public async Task CloudAppendBlobValidateUploadFromStreamAsync() using (MemoryStream memStream = new MemoryStream(buffer)) { - await blob.UploadFromStreamAsync(memStream.AsInputStream()); + await blob.UploadFromStreamAsync(memStream); await blob.FetchAttributesAsync(); Assert.AreEqual(6 * 1024 * 1024, blob.Properties.Length); memStream.Seek(0, SeekOrigin.Begin); - await blob.UploadFromStreamAsync(memStream.AsInputStream()); + await blob.UploadFromStreamAsync(memStream); await blob.FetchAttributesAsync(); Assert.AreEqual(6 * 1024 * 1024, blob.Properties.Length); memStream.Seek(0, SeekOrigin.Begin); - await blob.UploadFromStreamAsync(memStream.AsInputStream(), null /* accessCondition */, null /* options */, null /* operationContext */); + await blob.UploadFromStreamAsync(memStream, null /* accessCondition */, null /* options */, null /* operationContext */); await blob.FetchAttributesAsync(); Assert.AreEqual(6 * 1024 * 1024, blob.Properties.Length); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -773,24 +773,24 @@ public async Task CloudAppendBlobValidateAppendFromStreamAsync() using (MemoryStream memStream = new MemoryStream(buffer)) { - await blob.AppendFromStreamAsync(memStream.AsInputStream()); + await blob.AppendFromStreamAsync(memStream); await blob.FetchAttributesAsync(); Assert.AreEqual(6 * 1024 * 1024, blob.Properties.Length); memStream.Seek(0, SeekOrigin.Begin); - await blob.AppendFromStreamAsync(memStream.AsInputStream()); + await blob.AppendFromStreamAsync(memStream); await blob.FetchAttributesAsync(); Assert.AreEqual(12 * 1024 * 1024, blob.Properties.Length); memStream.Seek(0, SeekOrigin.Begin); - await blob.AppendFromStreamAsync(memStream.AsInputStream(), null /* accessCondition */, null /* options */, null /* operationContext */); + await blob.AppendFromStreamAsync(memStream, null /* accessCondition */, null /* options */, null /* operationContext */); await blob.FetchAttributesAsync(); Assert.AreEqual(18 * 1024 * 1024, blob.Properties.Length); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -815,24 +815,24 @@ public async Task CloudAppendBlobValidateAppendFromStreamWithLengthAsync() using (MemoryStream memStream = new MemoryStream(buffer)) { - await blob.AppendFromStreamAsync(memStream.AsInputStream(), 5 * 1024 * 1024); + await blob.AppendFromStreamAsync(memStream, 5 * 1024 * 1024); await blob.FetchAttributesAsync(); Assert.AreEqual(5 * 1024 * 1024, blob.Properties.Length); memStream.Seek(0, SeekOrigin.Begin); - await blob.AppendFromStreamAsync(memStream.AsInputStream(), 5 * 1024 * 1024); + await blob.AppendFromStreamAsync(memStream, 5 * 1024 * 1024); await blob.FetchAttributesAsync(); Assert.AreEqual(10 * 1024 * 1024, blob.Properties.Length); memStream.Seek(0, SeekOrigin.Begin); - await blob.AppendFromStreamAsync(memStream.AsInputStream(), 5 * 1024 * 1024, null /* accessCondition */, null /* options */, null /* operationContext */); + await blob.AppendFromStreamAsync(memStream, 5 * 1024 * 1024, null /* accessCondition */, null /* options */, null /* operationContext */); await blob.FetchAttributesAsync(); Assert.AreEqual(15 * 1024 * 1024, blob.Properties.Length); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -854,21 +854,21 @@ public async Task CloudAppendBlobVerifyAppendOffsetAsync() CloudAppendBlob blob = container.GetAppendBlobReference("blob1"); await blob.CreateOrReplaceAsync(); - long offset = await blob.AppendBlockAsync(new MemoryStream(buffer).AsInputStream()); + long offset = await blob.AppendBlockAsync(new MemoryStream(buffer)); Assert.AreEqual(0, offset); - offset = await blob.AppendBlockAsync(new MemoryStream(buffer).AsInputStream()); + offset = await blob.AppendBlockAsync(new MemoryStream(buffer)); Assert.AreEqual(2 * 1024 * 1024, offset); - offset = await blob.AppendBlockAsync(new MemoryStream(buffer).AsInputStream()); + offset = await blob.AppendBlockAsync(new MemoryStream(buffer)); Assert.AreEqual(4 * 1024 * 1024, offset); - offset = await blob.AppendBlockAsync(new MemoryStream(buffer).AsInputStream()); + offset = await blob.AppendBlockAsync(new MemoryStream(buffer)); Assert.AreEqual(6 * 1024 * 1024, offset); } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -894,16 +894,16 @@ public async Task CloudAppendBlobAppendOffsetConditionalAccessAsync() using (MemoryStream originalBlob = new MemoryStream(buffer)) { - await blob.AppendBlockAsync(originalBlob.AsInputStream(), null, AccessCondition.GenerateIfAppendPositionEqualCondition(0), null, null); + await blob.AppendBlockAsync(originalBlob, null, AccessCondition.GenerateIfAppendPositionEqualCondition(0), null, null); // Seek and upload the 1MB again originalBlob.Seek(0, SeekOrigin.Begin); - await blob.AppendBlockAsync(originalBlob.AsInputStream(), null, AccessCondition.GenerateIfAppendPositionEqualCondition(1 * 1024 * 1024), null, null); + await blob.AppendBlockAsync(originalBlob, null, AccessCondition.GenerateIfAppendPositionEqualCondition(1 * 1024 * 1024), null, null); // Seek and upload the 1MB again. This time it should throw since the append offset does not match originalBlob.Seek(0, SeekOrigin.Begin); await TestHelper.ExpectedExceptionAsync( - async () => await blob.AppendBlockAsync(originalBlob.AsInputStream(), null, AccessCondition.GenerateIfAppendPositionEqualCondition(1 * 1024 * 1024), null, opContext), + async () => await blob.AppendBlockAsync(originalBlob, null, AccessCondition.GenerateIfAppendPositionEqualCondition(1 * 1024 * 1024), null, opContext), opContext, "IfAppendPositionEqual conditional should throw", HttpStatusCode.PreconditionFailed, @@ -912,7 +912,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -939,28 +939,28 @@ public async Task CloudAppendBlobMaxSizeConditionalAccessAsync() AccessCondition condition = AccessCondition.GenerateIfMaxSizeLessThanOrEqualCondition(2 * 1024 * 1024); using (MemoryStream originalBlob = new MemoryStream(buffer)) { - await blob.AppendBlockAsync(originalBlob.AsInputStream(), null, condition, null, null); + await blob.AppendBlockAsync(originalBlob, null, condition, null, null); // Seek and upload the 1MB again originalBlob.Seek(0, SeekOrigin.Begin); - await blob.AppendBlockAsync(originalBlob.AsInputStream(), null, condition, null, null); + await blob.AppendBlockAsync(originalBlob, null, condition, null, null); // Seek and try to upload the 1MB again. This time it should fail with a Pre-condition failed error. originalBlob.Seek(0, SeekOrigin.Begin); await TestHelper.ExpectedExceptionAsync( - async () => await blob.AppendBlockAsync(originalBlob.AsInputStream(), null, condition, null, opContext), + async () => await blob.AppendBlockAsync(originalBlob, null, condition, null, opContext), opContext, "IfMaxSizeLessThanOrEqual conditional should throw", HttpStatusCode.PreconditionFailed, "MaxBlobSizeConditionNotMet"); originalBlob.Seek(0, SeekOrigin.Begin); - await blob.AppendBlockAsync(originalBlob.AsInputStream(), null, AccessCondition.GenerateIfMaxSizeLessThanOrEqualCondition(3 * 1024 * 1024), null, null); + await blob.AppendBlockAsync(originalBlob, null, AccessCondition.GenerateIfMaxSizeLessThanOrEqualCondition(3 * 1024 * 1024), null, null); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -985,7 +985,7 @@ public async Task CloudAppendBlobMethodsOnBlockBlobAsync() { stream.SetLength(512); await TestHelper.ExpectedExceptionAsync( - async () => await blob.AppendBlockAsync(stream.AsInputStream(), null, null, null, operationContext), + async () => await blob.AppendBlockAsync(stream, null, null, null, operationContext), operationContext, "Append operations should fail on block blobs", HttpStatusCode.Conflict, @@ -994,7 +994,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1025,7 +1025,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1051,7 +1051,7 @@ public async Task CloudPageBlobMethodsOnAppendBlobAsync() { stream.SetLength(512); await TestHelper.ExpectedExceptionAsync( - async () => await blob.WritePagesAsync(stream.AsInputStream(), 0, null, null, null, operationContext), + async () => await blob.WritePagesAsync(stream, 0, null, null, null, operationContext), operationContext, "Page operations should fail on append blobs", HttpStatusCode.Conflict, @@ -1060,7 +1060,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1083,7 +1083,7 @@ public async Task CloudAppendBlobUploadFromStreamAsync() } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -1119,7 +1119,7 @@ public async Task CloudAppendBlobUploadFromStreamLengthAsync() } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -1153,7 +1153,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -1186,18 +1186,18 @@ private async Task CloudAppendBlobUploadFromStreamAsync(CloudBlobContainer conta { if (copyLength.HasValue) { - await blob.UploadFromStreamAsync(sourceStream.AsInputStream(), copyLength.Value, accessCondition, null, null); + await blob.UploadFromStreamAsync(sourceStream, copyLength.Value, accessCondition, null, null); } else { - await blob.UploadFromStreamAsync(sourceStream.AsInputStream(), accessCondition, null, null); + await blob.UploadFromStreamAsync(sourceStream, accessCondition, null, null); } } using (MemoryStream downloadedBlobStream = new MemoryStream()) { - await blob.DownloadToStreamAsync(downloadedBlobStream.AsOutputStream()); + await blob.DownloadToStreamAsync(downloadedBlobStream); Assert.AreEqual(copyLength ?? originalBlobStream.Length, downloadedBlobStream.Length); TestHelper.AssertStreamsAreEqualAtIndex( diff --git a/Test/WindowsRuntime/Blob/CloudBlobClientTest.cs b/Test/WindowsRuntime/Blob/CloudBlobClientTest.cs index c823c87d9..6631bf47f 100644 --- a/Test/WindowsRuntime/Blob/CloudBlobClientTest.cs +++ b/Test/WindowsRuntime/Blob/CloudBlobClientTest.cs @@ -193,7 +193,7 @@ public async Task CloudBlobClientListBlobsSegmentedWithPrefixAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -332,12 +332,12 @@ public async Task CloudBlobClientMaximumExecutionTimeoutAsync() { try { - await blockBlob.UploadFromStreamAsync(ms.AsInputStream()); + await blockBlob.UploadFromStreamAsync(ms); Assert.Fail(); } catch (AggregateException ex) { - Assert.AreEqual("The client could not finish the operation within specified timeout.", RequestResult.TranslateFromExceptionMessage(ex.InnerException.InnerException.Message).ExceptionInfo.Message); + Assert.AreEqual("The client could not finish the operation within specified timeout.", RequestResult.TranslateFromExceptionMessage(ex.InnerException.Message).ExceptionInfo.Message); } catch (TaskCanceledException) { @@ -350,12 +350,12 @@ public async Task CloudBlobClientMaximumExecutionTimeoutAsync() { try { - await pageBlob.UploadFromStreamAsync(ms.AsInputStream()); + await pageBlob.UploadFromStreamAsync(ms); Assert.Fail(); } catch (AggregateException ex) { - Assert.AreEqual("The client could not finish the operation within specified timeout.", RequestResult.TranslateFromExceptionMessage(ex.InnerException.InnerException.Message).ExceptionInfo.Message); + Assert.AreEqual("The client could not finish the operation within specified timeout.", RequestResult.TranslateFromExceptionMessage(ex.InnerException.Message).ExceptionInfo.Message); } catch (TaskCanceledException) { @@ -365,7 +365,7 @@ public async Task CloudBlobClientMaximumExecutionTimeoutAsync() finally { blobClient.DefaultRequestOptions.MaximumExecutionTime = null; - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -398,7 +398,7 @@ public async Task CloudBlobClientMaximumExecutionTimeoutShouldNotBeHonoredForStr DateTime start = DateTime.Now; for (int i = 0; i < 7; i++) { - await bos.WriteAsync(buffer.AsBuffer()); + await bos.WriteAsync(buffer, 0, buffer.Length); } // Sleep to ensure we are over the Max execution time when we do the last write @@ -409,11 +409,11 @@ public async Task CloudBlobClientMaximumExecutionTimeoutShouldNotBeHonoredForStr await Task.Delay(msRemaining); } - await bos.WriteAsync(buffer.AsBuffer()); + await bos.WriteAsync(buffer, 0, buffer.Length); await bos.CommitAsync(); } - using (Stream bis = (await blockBlob.OpenReadAsync()).AsStreamForRead()) + using (Stream bis = (await blockBlob.OpenReadAsync())) { DateTime start = DateTime.Now; int total = 0; @@ -444,7 +444,7 @@ public async Task CloudBlobClientMaximumExecutionTimeoutShouldNotBeHonoredForStr DateTime start = DateTime.Now; for (int i = 0; i < 7; i++) { - await bos.WriteAsync(buffer.AsBuffer()); + await bos.WriteAsync(buffer, 0, buffer.Length); } // Sleep to ensure we are over the Max execution time when we do the last write @@ -455,11 +455,11 @@ public async Task CloudBlobClientMaximumExecutionTimeoutShouldNotBeHonoredForStr await Task.Delay(msRemaining); } - await bos.WriteAsync(buffer.AsBuffer()); + await bos.WriteAsync(buffer, 0, buffer.Length); await bos.CommitAsync(); } - using (Stream bis = (await pageBlob.OpenReadAsync()).AsStreamForRead()) + using (Stream bis = (await pageBlob.OpenReadAsync())) { DateTime start = DateTime.Now; int total = 0; @@ -489,7 +489,7 @@ public async Task CloudBlobClientMaximumExecutionTimeoutShouldNotBeHonoredForStr finally { blobClient.DefaultRequestOptions.MaximumExecutionTime = null; - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } diff --git a/Test/WindowsRuntime/Blob/CloudBlobContainerTest.cs b/Test/WindowsRuntime/Blob/CloudBlobContainerTest.cs index bb36eba29..540c7fa22 100644 --- a/Test/WindowsRuntime/Blob/CloudBlobContainerTest.cs +++ b/Test/WindowsRuntime/Blob/CloudBlobContainerTest.cs @@ -80,6 +80,7 @@ private static async Task TestAccessAsync(BlobContainerPublicAccessType accessTy OperationContext context = new OperationContext(); BlobRequestOptions options = new BlobRequestOptions(); + if (accessType.Equals(BlobContainerPublicAccessType.Container)) { await blob.FetchAttributesAsync(); @@ -158,7 +159,7 @@ public async Task CloudBlobContainerCreateAsync() await container.CreateAsync(); OperationContext operationContext = new OperationContext(); Assert.ThrowsException( - () => container.CreateAsync(null, operationContext).AsTask().Wait(), + () => container.CreateAsync(null, operationContext).Wait(), "Creating already exists container should fail"); Assert.AreEqual((int)HttpStatusCode.Conflict, operationContext.LastResult.HttpStatusCode); await container.DeleteAsync(); @@ -180,7 +181,7 @@ public async Task CloudBlobContainerCreateIfNotExistsAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -222,7 +223,7 @@ public async Task CloudBlobContainerCreateWithContainerAccessTypeAsyncOverload() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -249,7 +250,7 @@ public async Task CloudBlobContainerCreateWithBlobAccessTypeAsyncOverload() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -276,7 +277,7 @@ public async Task CloudBlobContainerCreateWithPrivateAccessTypeAsyncOverload() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -302,7 +303,7 @@ public async Task CloudBlobContainerExistsAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } Assert.IsFalse(await container2.ExistsAsync()); @@ -353,7 +354,7 @@ public async Task CloudBlobContainerSetPermissionsAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -381,7 +382,7 @@ public async Task CloudBlobContainerCreateWithMetadataAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -422,7 +423,7 @@ public async Task CloudBlobContainerSetMetadataAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -451,7 +452,7 @@ public async Task CloudBlobContainerRegionalSetMetadataAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); #if ASPNET_K //CultureInfo.CurrentCulture = currentCulture; #else @@ -484,7 +485,7 @@ public async Task CloudBlobContainerListBlobsAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -521,7 +522,7 @@ public async Task CloudBlobContainerListBlobsSegmentedAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -559,7 +560,7 @@ public async Task CloudBlobContainerListBlobsWithSecondaryUriAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -735,7 +736,7 @@ public async Task CloudBlobContainerGetBlobReferenceFromServerAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -795,7 +796,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Blob/CloudBlobDirectoryTest.cs b/Test/WindowsRuntime/Blob/CloudBlobDirectoryTest.cs index dbb5f3fea..c5f0efce1 100644 --- a/Test/WindowsRuntime/Blob/CloudBlobDirectoryTest.cs +++ b/Test/WindowsRuntime/Blob/CloudBlobDirectoryTest.cs @@ -157,7 +157,7 @@ public async Task CloudBlobDirectoryGetParentAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -257,7 +257,7 @@ public async Task CloudBlobDirectoryFlatListingAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } @@ -287,7 +287,7 @@ public void CloudBlobDirectoryGetSubdirectoryAndTraverseBackToParentAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } @@ -317,7 +317,7 @@ public void CloudBlobDirectoryGetParentOnRootAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } @@ -371,7 +371,7 @@ public async Task CloudBlobDirectoryMultipleDelimitersAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } @@ -413,7 +413,7 @@ public void CloudBlobDirectoryHierarchicalTraversalAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } @@ -442,7 +442,7 @@ public void CloudBlobDirectoryBlobParentValidateAsync() finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } @@ -535,7 +535,7 @@ public void CloudBlobDirectoryDelimitersInARowAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Blob/CloudBlobTest.cs b/Test/WindowsRuntime/Blob/CloudBlobTest.cs index ab6d8c26e..e037b4a79 100644 --- a/Test/WindowsRuntime/Blob/CloudBlobTest.cs +++ b/Test/WindowsRuntime/Blob/CloudBlobTest.cs @@ -57,7 +57,7 @@ internal static async Task CreateForTestAsync(CloudBlockBlob blob, int blockCoun { using (MemoryStream stream = new MemoryStream(buffer)) { - await blob.PutBlockAsync(block, stream.AsInputStream(), null); + await blob.PutBlockAsync(block, stream, null); } } @@ -104,7 +104,7 @@ public async Task CloudBlobSnapshotAsync() MemoryStream originalData = new MemoryStream(GetRandomBuffer(1024)); CloudBlockBlob blockBlob = container.GetBlockBlobReference(BlobName); - await blockBlob.UploadFromStreamAsync(originalData.AsInputStream()); + await blockBlob.UploadFromStreamAsync(originalData); CloudBlob blob = container.GetBlobReference(BlobName); await blob.FetchAttributesAsync(); @@ -142,7 +142,7 @@ public async Task CloudBlobSnapshotAsync() await WaitForCopyAsync(snapshotCopy); Assert.AreEqual(CopyStatus.Success, snapshotCopy.CopyState.Status); - using (Stream snapshotStream = (await snapshot1.OpenReadAsync()).AsStreamForRead()) + using (Stream snapshotStream = (await snapshot1.OpenReadAsync())) { snapshotStream.Seek(0, SeekOrigin.End); TestHelper.AssertStreamsAreEqual(originalData, snapshotStream); @@ -151,7 +151,7 @@ public async Task CloudBlobSnapshotAsync() await blockBlob.PutBlockListAsync(new List()); await blob.FetchAttributesAsync(); - using (Stream snapshotStream = (await snapshot1.OpenReadAsync()).AsStreamForRead()) + using (Stream snapshotStream = (await snapshot1.OpenReadAsync())) { snapshotStream.Seek(0, SeekOrigin.End); TestHelper.AssertStreamsAreEqual(originalData, snapshotStream); @@ -167,7 +167,7 @@ public async Task CloudBlobSnapshotAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -212,7 +212,7 @@ public async Task CloudBlobSnapshotMetadataAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Blob/CloudBlockBlobTest.cs b/Test/WindowsRuntime/Blob/CloudBlockBlobTest.cs index b7233d4e6..54e053968 100644 --- a/Test/WindowsRuntime/Blob/CloudBlockBlobTest.cs +++ b/Test/WindowsRuntime/Blob/CloudBlockBlobTest.cs @@ -62,7 +62,7 @@ internal static async Task CreateForTestAsync(CloudBlockBlob blob, int blockCoun { using (MemoryStream stream = new MemoryStream(buffer)) { - await blob.PutBlockAsync(block, stream.AsInputStream(), null); + await blob.PutBlockAsync(block, stream, null); } } @@ -113,7 +113,7 @@ public async Task CloudBlockBlobCreateAndDeleteAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -138,7 +138,7 @@ public async Task CloudBlockBlobDeleteIfExistsAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -171,7 +171,7 @@ public async Task CloudBlockBlobExistsAsync() } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -218,7 +218,7 @@ public async Task CloudBlockBlobFetchAttributesAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -272,7 +272,7 @@ public async Task CloudBlockBlobSetPropertiesAsync() { DisableContentMD5Validation = true, }; - await blob3.DownloadToStreamAsync(stream.AsOutputStream(), null, options, null); + await blob3.DownloadToStreamAsync(stream, null, options, null); } AssertAreEqual(blob2.Properties, blob3.Properties); @@ -282,7 +282,7 @@ public async Task CloudBlockBlobSetPropertiesAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -306,13 +306,13 @@ public async Task CloudBlockBlobFetchAttributesInvalidTypeAsync() OperationContext operationContext = new OperationContext(); Assert.ThrowsException( - () => blob2.FetchAttributesAsync(null, null, operationContext).AsTask().Wait(), + () => blob2.FetchAttributesAsync(null, null, operationContext).Wait(), "Fetching attributes of a block blob using a page blob reference should fail"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(InvalidOperationException)); } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -340,7 +340,7 @@ public async Task CloudBlockBlobCreateWithMetadataAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -368,19 +368,19 @@ public async Task CloudBlockBlobSetMetadataAsync() blob.Metadata["key1"] = null; Assert.ThrowsException( - () => blob.SetMetadataAsync(null, null, operationContext).AsTask().Wait(), + () => blob.SetMetadataAsync(null, null, operationContext).Wait(), "Metadata keys should have a non-null value"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(ArgumentException)); blob.Metadata["key1"] = ""; Assert.ThrowsException( - () => blob.SetMetadataAsync(null, null, operationContext).AsTask().Wait(), + () => blob.SetMetadataAsync(null, null, operationContext).Wait(), "Metadata keys should have a non-empty value"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(ArgumentException)); blob.Metadata["key1"] = " "; Assert.ThrowsException( - () => blob.SetMetadataAsync(null, null, operationContext).AsTask().Wait(), + () => blob.SetMetadataAsync(null, null, operationContext).Wait(), "Metadata keys should have a non-whitespace only value"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(ArgumentException)); @@ -404,7 +404,7 @@ public async Task CloudBlockBlobSetMetadataAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -432,7 +432,7 @@ public async Task CloudBlockBlobUploadAsync() { using (MemoryStream memoryStream = new MemoryStream(buffer)) { - await blob.PutBlockAsync(block, memoryStream.AsInputStream(), null); + await blob.PutBlockAsync(block, memoryStream, null); } wholeBlob.Write(buffer, 0, buffer.Length); } @@ -440,7 +440,7 @@ public async Task CloudBlockBlobUploadAsync() { using (MemoryStream memoryStream = new MemoryStream(buffer)) { - await blob.PutBlockAsync(block, memoryStream.AsInputStream(), null); + await blob.PutBlockAsync(block, memoryStream, null); } } @@ -457,7 +457,7 @@ public async Task CloudBlockBlobUploadAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -482,7 +482,7 @@ public async Task CloudBlockBlobDownloadBlockListAsync() { using (MemoryStream memoryStream = new MemoryStream(buffer)) { - await blob.PutBlockAsync(block, memoryStream.AsInputStream(), null); + await blob.PutBlockAsync(block, memoryStream, null); } } await blob.PutBlockListAsync(blocks); @@ -491,7 +491,7 @@ public async Task CloudBlockBlobDownloadBlockListAsync() { using (MemoryStream memoryStream = new MemoryStream(buffer)) { - await blob.PutBlockAsync(block, memoryStream.AsInputStream(), null); + await blob.PutBlockAsync(block, memoryStream, null); } } @@ -524,7 +524,7 @@ public async Task CloudBlockBlobDownloadBlockListAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -550,13 +550,13 @@ public async Task CloudBlockBlobUploadFromStreamInvalidOptionsAsync() using (MemoryStream stream = new MemoryStream()) { await TestHelper.ExpectedExceptionAsync( - async () => await blob.UploadFromStreamAsync(stream.AsInputStream(), null, options, null), + async () => await blob.UploadFromStreamAsync(stream, null, options, null), "Single put blob with mismatching MD5 options should fail immediately"); } } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -609,7 +609,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -632,7 +632,7 @@ public async Task CloudBlockBlobUploadFromStreamWithNonSeekableStreamAsync() } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -655,7 +655,7 @@ public async Task CloudBlockBlobUploadFromStreamAsync() } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -691,7 +691,7 @@ public async Task CloudBlockBlobUploadFromStreamLengthSinglePutAsync() } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -727,7 +727,7 @@ public async Task CloudBlockBlobUploadFromStreamLengthAsync() } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -761,7 +761,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -783,7 +783,7 @@ public async Task CloudBlockBlobParallelUploadFromStreamAsync() } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -828,7 +828,7 @@ public async Task CloudBlockBlobParallelUploadFromStreamRequestOptionsAsync() ParallelOperationThreadCount = 2 }; OperationContext context = new OperationContext(); - await blob.UploadFromStreamAsync(sourceStream.AsInputStream(), null /* accessCondition */, options, context); + await blob.UploadFromStreamAsync(sourceStream, null /* accessCondition */, options, context); // Number or requests should be at least 21 since StreamWriteSizeInBytes is 1 MB Assert.IsTrue(context.RequestResults.Count >= 21); @@ -841,7 +841,7 @@ public async Task CloudBlockBlobParallelUploadFromStreamRequestOptionsAsync() ParallelOperationThreadCount = 1 }; context = new OperationContext(); - await blob2.UploadFromStreamAsync(sourceStream.AsInputStream(), null /* accessCondition */, options, context); + await blob2.UploadFromStreamAsync(sourceStream, null /* accessCondition */, options, context); // Number or requests should be at least 21 since StreamWriteSizeInBytes is 1 MB Assert.IsTrue(context.RequestResults.Count >= 21); @@ -854,7 +854,7 @@ public async Task CloudBlockBlobParallelUploadFromStreamRequestOptionsAsync() ParallelOperationThreadCount = 1 }; context = new OperationContext(); - await blob3.UploadFromStreamAsync(sourceStream.AsInputStream(), null /* accessCondition */, options, context); + await blob3.UploadFromStreamAsync(sourceStream, null /* accessCondition */, options, context); // Number or requests should 1, or 2 if there is a retry Assert.IsTrue(context.RequestResults.Count <= 2); @@ -863,7 +863,7 @@ public async Task CloudBlockBlobParallelUploadFromStreamRequestOptionsAsync() } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -914,11 +914,11 @@ private async Task CloudBlockBlobUploadFromStreamAsync(CloudBlobContainer contai }; if (copyLength.HasValue) { - await blob.UploadFromStreamAsync(sourceStream.AsInputStream(), copyLength.Value, accessCondition, options, operationContext); + await blob.UploadFromStreamAsync(sourceStream, copyLength.Value, accessCondition, options, operationContext); } else { - await blob.UploadFromStreamAsync(sourceStream.AsInputStream(), accessCondition, options, operationContext); + await blob.UploadFromStreamAsync(sourceStream, accessCondition, options, operationContext); } } @@ -957,7 +957,7 @@ public async Task CloudBlockBlobSnapshotAsync() MemoryStream originalData = new MemoryStream(GetRandomBuffer(1024)); CloudBlockBlob blob = container.GetBlockBlobReference("blob1"); - await blob.UploadFromStreamAsync(originalData.AsInputStream()); + await blob.UploadFromStreamAsync(originalData); Assert.IsFalse(blob.IsSnapshot); Assert.IsNull(blob.SnapshotTime, "Root blob has SnapshotTime set"); @@ -997,7 +997,7 @@ await TestHelper.ExpectedExceptionAsync( async () => await snapshot1.OpenWriteAsync(), "Trying to write to a blob snapshot should fail"); - using (Stream snapshotStream = (await snapshot1.OpenReadAsync()).AsStreamForRead()) + using (Stream snapshotStream = (await snapshot1.OpenReadAsync())) { snapshotStream.Seek(0, SeekOrigin.End); TestHelper.AssertStreamsAreEqual(originalData, snapshotStream); @@ -1006,7 +1006,7 @@ await TestHelper.ExpectedExceptionAsync( await blob.PutBlockListAsync(new List()); await blob.FetchAttributesAsync(); - using (Stream snapshotStream = (await snapshot1.OpenReadAsync()).AsStreamForRead()) + using (Stream snapshotStream = (await snapshot1.OpenReadAsync())) { snapshotStream.Seek(0, SeekOrigin.End); TestHelper.AssertStreamsAreEqual(originalData, snapshotStream); @@ -1022,7 +1022,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1066,7 +1066,7 @@ public async Task CloudBlockBlobSnapshotMetadataAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1180,7 +1180,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1205,7 +1205,7 @@ public async Task CloudBlockBlobPutBlockBoundariesAsync() using (MemoryStream stream = new MemoryStream(buffer)) { await TestHelper.ExpectedExceptionAsync( - async () => await blob.PutBlockAsync(blockId, stream.AsInputStream(), null, null, null, operationContext), + async () => await blob.PutBlockAsync(blockId, stream, null, null, null, operationContext), operationContext, "Trying to upload a block with zero bytes should fail", HttpStatusCode.BadRequest); @@ -1214,20 +1214,20 @@ await TestHelper.ExpectedExceptionAsync( buffer = new byte[1]; using (MemoryStream stream = new MemoryStream(buffer)) { - await blob.PutBlockAsync(blockId, stream.AsInputStream(), null); + await blob.PutBlockAsync(blockId, stream, null); } buffer = new byte[4 * 1024 * 1024]; using (MemoryStream stream = new MemoryStream(buffer)) { - await blob.PutBlockAsync(blockId, stream.AsInputStream(), null); + await blob.PutBlockAsync(blockId, stream, null); } buffer = new byte[4 * 1024 * 1024 + 1]; using (MemoryStream stream = new MemoryStream(buffer)) { await TestHelper.ExpectedExceptionAsync( - async () => await blob.PutBlockAsync(blockId, stream.AsInputStream(), null, null, null, operationContext), + async () => await blob.PutBlockAsync(blockId, stream, null, null, null, operationContext), operationContext, "Trying to upload a block with more than 4MB should fail", HttpStatusCode.RequestEntityTooLarge); @@ -1235,7 +1235,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1270,21 +1270,21 @@ public async Task CloudBlockBlobPutBlockAsync() using (MemoryStream memoryStream = new MemoryStream(buffer)) { memoryStream.Seek(0, SeekOrigin.Begin); - await blob.PutBlockAsync(blockList[0], memoryStream.AsInputStream(), contentMD5); + await blob.PutBlockAsync(blockList[0], memoryStream, contentMD5); resultingData.Write(buffer, 0, buffer.Length); int offset = buffer.Length - 1024; memoryStream.Seek(offset, SeekOrigin.Begin); OperationContext opContext = new OperationContext(); await TestHelper.ExpectedExceptionAsync( - async () => await blob.PutBlockAsync(blockList[1], memoryStream.AsInputStream(), contentMD5, null, null, opContext), + async () => await blob.PutBlockAsync(blockList[1], memoryStream, contentMD5, null, null, opContext), opContext, "Invalid MD5 should fail with mismatch", HttpStatusCode.BadRequest, "Md5Mismatch"); memoryStream.Seek(offset, SeekOrigin.Begin); - await blob.PutBlockAsync(blockList[1], memoryStream.AsInputStream(), null); + await blob.PutBlockAsync(blockList[1], memoryStream, null); resultingData.Write(buffer, offset, buffer.Length - offset); } @@ -1292,7 +1292,7 @@ await TestHelper.ExpectedExceptionAsync( using (MemoryStream blobData = new MemoryStream()) { - await blob.DownloadToStreamAsync(blobData.AsOutputStream()); + await blob.DownloadToStreamAsync(blobData); Assert.AreEqual(resultingData.Length, blobData.Length); Assert.IsTrue(blobData.ToArray().SequenceEqual(resultingData.ToArray())); } @@ -1300,7 +1300,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1326,7 +1326,7 @@ public async Task CloudBlockBlobMethodsOnPageBlobAsync() using (MemoryStream stream = new MemoryStream(buffer)) { await TestHelper.ExpectedExceptionAsync( - async () => await blob.PutBlockAsync(blockList.First(), stream.AsInputStream(), null, null, null, operationContext), + async () => await blob.PutBlockAsync(blockList.First(), stream, null, null, null, operationContext), operationContext, "Block operations should fail on page blobs", HttpStatusCode.Conflict, @@ -1349,7 +1349,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1375,7 +1375,7 @@ public async Task CloudBlockBlobBlockReorderingAsync() byte[] buffer = Encoding.UTF8.GetBytes(i.ToString()); using (MemoryStream stream = new MemoryStream(buffer)) { - await blob.PutBlockAsync(blockIds[i], stream.AsInputStream(), null); + await blob.PutBlockAsync(blockIds[i], stream, null); } blocks.Add(buffer); } @@ -1396,7 +1396,7 @@ public async Task CloudBlockBlobBlockReorderingAsync() using (MemoryStream stream = new MemoryStream(blocks[9])) { - await blob.PutBlockAsync(originalBlockIds[9], stream.AsInputStream(), null); + await blob.PutBlockAsync(originalBlockIds[9], stream, null); } blockIds.Insert(0, originalBlockIds[9]); await blob.PutBlockListAsync(blockIds); @@ -1404,7 +1404,7 @@ public async Task CloudBlockBlobBlockReorderingAsync() using (MemoryStream stream = new MemoryStream(blocks[0])) { - await blob.PutBlockAsync(originalBlockIds[0], stream.AsInputStream(), null); + await blob.PutBlockAsync(originalBlockIds[0], stream, null); } blockIds.Add(originalBlockIds[0]); await blob.PutBlockListAsync(blockIds); @@ -1412,7 +1412,7 @@ public async Task CloudBlockBlobBlockReorderingAsync() using (MemoryStream stream = new MemoryStream(blocks[4])) { - await blob.PutBlockAsync(originalBlockIds[4], stream.AsInputStream(), null); + await blob.PutBlockAsync(originalBlockIds[4], stream, null); } blockIds.Insert(2, originalBlockIds[4]); await blob.PutBlockListAsync(blockIds); @@ -1424,7 +1424,7 @@ public async Task CloudBlockBlobBlockReorderingAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1448,7 +1448,7 @@ await TestHelper.ExpectedExceptionAsync( using (MemoryStream stream = new MemoryStream()) { - await blob.UploadFromStreamAsync(stream.AsInputStream()); + await blob.UploadFromStreamAsync(stream); } await TestHelper.ExpectedExceptionAsync( @@ -1457,13 +1457,13 @@ await TestHelper.ExpectedExceptionAsync( using (MemoryStream stream = new MemoryStream()) { - await blob.DownloadToStreamAsync(stream.AsOutputStream()); + await blob.DownloadToStreamAsync(stream); Assert.AreEqual(0, stream.Length); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1521,7 +1521,7 @@ public async Task CloudBlockBlobListUncommittedBlobsAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1571,7 +1571,7 @@ private async Task DoTextUploadDownloadAsync(string text, bool checkDifferentEnc } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Blob/CloudPageBlobTest.cs b/Test/WindowsRuntime/Blob/CloudPageBlobTest.cs index 23165dcde..1ab26a075 100644 --- a/Test/WindowsRuntime/Blob/CloudPageBlobTest.cs +++ b/Test/WindowsRuntime/Blob/CloudPageBlobTest.cs @@ -93,7 +93,7 @@ public async Task CloudPageBlobCreateAndDeleteAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -136,7 +136,7 @@ public async Task CloudPageBlobResizeAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -171,48 +171,48 @@ public async Task CloudPageBlobSequenceNumberAsync() await blob.SetSequenceNumberAsync(SequenceNumberAction.Increment, null); Assert.AreEqual(8, blob.Properties.PageBlobSequenceNumber); - WrappedStorageException e = await TestHelper.ExpectedExceptionAsync( + StorageException e = await TestHelper.ExpectedExceptionAsync( async () => await blob.SetSequenceNumberAsync(SequenceNumberAction.Update, null), "SetSequenceNumber with Update should require a value"); - Assert.IsInstanceOfType(e.InnerException.InnerException, typeof(ArgumentNullException)); + Assert.IsInstanceOfType(e.InnerException, typeof(ArgumentNullException)); - e = await TestHelper.ExpectedExceptionAsync( + e = await TestHelper.ExpectedExceptionAsync( async () => await blob.SetSequenceNumberAsync(SequenceNumberAction.Update, -1), "Negative sequence numbers are not supported"); - Assert.IsInstanceOfType(e.InnerException.InnerException, typeof(ArgumentOutOfRangeException)); + Assert.IsInstanceOfType(e.InnerException, typeof(ArgumentOutOfRangeException)); - e = await TestHelper.ExpectedExceptionAsync( + e = await TestHelper.ExpectedExceptionAsync( async () => await blob.SetSequenceNumberAsync(SequenceNumberAction.Max, null), "SetSequenceNumber with Max should require a value"); - Assert.IsInstanceOfType(e.InnerException.InnerException, typeof(ArgumentNullException)); + Assert.IsInstanceOfType(e.InnerException, typeof(ArgumentNullException)); - e = await TestHelper.ExpectedExceptionAsync( + e = await TestHelper.ExpectedExceptionAsync( async () => await blob.SetSequenceNumberAsync(SequenceNumberAction.Increment, 1), "SetSequenceNumber with Increment should require null value"); - Assert.IsInstanceOfType(e.InnerException.InnerException, typeof(ArgumentException)); + Assert.IsInstanceOfType(e.InnerException, typeof(ArgumentException)); using (MemoryStream stream = new MemoryStream(buffer)) { stream.Seek(0, SeekOrigin.Begin); - await blob.WritePagesAsync(stream.AsInputStream(), 0, null, AccessCondition.GenerateIfSequenceNumberEqualCondition(8), null, null); + await blob.WritePagesAsync(stream, 0, null, AccessCondition.GenerateIfSequenceNumberEqualCondition(8), null, null); await blob.ClearPagesAsync(0, stream.Length, AccessCondition.GenerateIfSequenceNumberEqualCondition(8), null, null); stream.Seek(0, SeekOrigin.Begin); - await blob.WritePagesAsync(stream.AsInputStream(), 0, null, AccessCondition.GenerateIfSequenceNumberLessThanOrEqualCondition(8), null, null); + await blob.WritePagesAsync(stream, 0, null, AccessCondition.GenerateIfSequenceNumberLessThanOrEqualCondition(8), null, null); await blob.ClearPagesAsync(0, stream.Length, AccessCondition.GenerateIfSequenceNumberLessThanOrEqualCondition(8), null, null); stream.Seek(0, SeekOrigin.Begin); - await blob.WritePagesAsync(stream.AsInputStream(), 0, null, AccessCondition.GenerateIfSequenceNumberLessThanOrEqualCondition(9), null, null); + await blob.WritePagesAsync(stream, 0, null, AccessCondition.GenerateIfSequenceNumberLessThanOrEqualCondition(9), null, null); await blob.ClearPagesAsync(0, stream.Length, AccessCondition.GenerateIfSequenceNumberLessThanOrEqualCondition(9), null, null); stream.Seek(0, SeekOrigin.Begin); - await blob.WritePagesAsync(stream.AsInputStream(), 0, null, AccessCondition.GenerateIfSequenceNumberLessThanCondition(9), null, null); + await blob.WritePagesAsync(stream, 0, null, AccessCondition.GenerateIfSequenceNumberLessThanCondition(9), null, null); await blob.ClearPagesAsync(0, stream.Length, AccessCondition.GenerateIfSequenceNumberLessThanCondition(9), null, null); stream.Seek(0, SeekOrigin.Begin); OperationContext context = new OperationContext(); await TestHelper.ExpectedExceptionAsync( - async () => await blob.WritePagesAsync(stream.AsInputStream(), 0, null, AccessCondition.GenerateIfSequenceNumberEqualCondition(9), null, context), + async () => await blob.WritePagesAsync(stream, 0, null, AccessCondition.GenerateIfSequenceNumberEqualCondition(9), null, context), context, "Sequence number condition should cause Put Page to fail", HttpStatusCode.PreconditionFailed, @@ -226,7 +226,7 @@ await TestHelper.ExpectedExceptionAsync( stream.Seek(0, SeekOrigin.Begin); await TestHelper.ExpectedExceptionAsync( - async () => await blob.WritePagesAsync(stream.AsInputStream(), 0, null, AccessCondition.GenerateIfSequenceNumberLessThanOrEqualCondition(7), null, context), + async () => await blob.WritePagesAsync(stream, 0, null, AccessCondition.GenerateIfSequenceNumberLessThanOrEqualCondition(7), null, context), context, "Sequence number condition should cause Put Page to fail", HttpStatusCode.PreconditionFailed, @@ -240,7 +240,7 @@ await TestHelper.ExpectedExceptionAsync( stream.Seek(0, SeekOrigin.Begin); await TestHelper.ExpectedExceptionAsync( - async () => await blob.WritePagesAsync(stream.AsInputStream(), 0, null, AccessCondition.GenerateIfSequenceNumberLessThanCondition(8), null, context), + async () => await blob.WritePagesAsync(stream, 0, null, AccessCondition.GenerateIfSequenceNumberLessThanCondition(8), null, context), context, "Sequence number condition should cause Put Page to fail", HttpStatusCode.PreconditionFailed, @@ -253,18 +253,18 @@ await TestHelper.ExpectedExceptionAsync( "SequenceNumberConditionNotMet"); stream.Seek(0, SeekOrigin.Begin); - await blob.UploadFromStreamAsync(stream.AsInputStream(), AccessCondition.GenerateIfSequenceNumberEqualCondition(9), null, null); + await blob.UploadFromStreamAsync(stream, AccessCondition.GenerateIfSequenceNumberEqualCondition(9), null, null); stream.Seek(0, SeekOrigin.Begin); - await blob.UploadFromStreamAsync(stream.AsInputStream(), AccessCondition.GenerateIfSequenceNumberLessThanOrEqualCondition(7), null, null); + await blob.UploadFromStreamAsync(stream, AccessCondition.GenerateIfSequenceNumberLessThanOrEqualCondition(7), null, null); stream.Seek(0, SeekOrigin.Begin); - await blob.UploadFromStreamAsync(stream.AsInputStream(), AccessCondition.GenerateIfSequenceNumberLessThanCondition(8), null, null); + await blob.UploadFromStreamAsync(stream, AccessCondition.GenerateIfSequenceNumberLessThanCondition(8), null, null); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -289,7 +289,7 @@ public async Task CloudPageBlobDeleteIfExistsAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -322,7 +322,7 @@ public async Task CloudPageBlobExistsAsync() } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -371,7 +371,7 @@ public async Task CloudPageBlobFetchAttributesAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -428,7 +428,7 @@ public async Task CloudPageBlobSetPropertiesAsync() DisableContentMD5Validation = true, }; - await blob3.DownloadToStreamAsync(stream.AsOutputStream(), null, options, null); + await blob3.DownloadToStreamAsync(stream, null, options, null); } AssertAreEqual(blob2.Properties, blob3.Properties); @@ -438,7 +438,7 @@ public async Task CloudPageBlobSetPropertiesAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -462,13 +462,13 @@ public async Task CloudPageBlobFetchAttributesInvalidTypeAsync() OperationContext operationContext = new OperationContext(); Assert.ThrowsException( - () => blob2.FetchAttributesAsync(null, null, operationContext).AsTask().Wait(), + () => blob2.FetchAttributesAsync(null, null, operationContext).Wait(), "Fetching attributes of a page blob using a block blob reference should fail"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(InvalidOperationException)); } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -496,7 +496,7 @@ public async Task CloudPageBlobCreateWithMetadataAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -524,19 +524,19 @@ public async Task CloudPageBlobSetMetadataAsync() blob.Metadata["key1"] = null; Assert.ThrowsException( - () => blob.SetMetadataAsync(null, null, operationContext).AsTask().Wait(), + () => blob.SetMetadataAsync(null, null, operationContext).Wait(), "Metadata keys should have a non-null value"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(ArgumentException)); blob.Metadata["key1"] = ""; Assert.ThrowsException( - () => blob.SetMetadataAsync(null, null, operationContext).AsTask().Wait(), + () => blob.SetMetadataAsync(null, null, operationContext).Wait(), "Metadata keys should have a non-empty value"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(ArgumentException)); blob.Metadata["key1"] = " "; Assert.ThrowsException( - () => blob.SetMetadataAsync(null, null, operationContext).AsTask().Wait(), + () => blob.SetMetadataAsync(null, null, operationContext).Wait(), "Metadata keys should have a non-whitespace only value"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(ArgumentException)); @@ -560,7 +560,7 @@ public async Task CloudPageBlobSetMetadataAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -583,12 +583,12 @@ public async Task CloudPageBlobGetPageRangesAsync() using (MemoryStream memoryStream = new MemoryStream(buffer)) { - await blob.WritePagesAsync(memoryStream.AsInputStream(), 512, null); + await blob.WritePagesAsync(memoryStream, 512, null); } using (MemoryStream memoryStream = new MemoryStream(buffer)) { - await blob.WritePagesAsync(memoryStream.AsInputStream(), 3 * 1024, null); + await blob.WritePagesAsync(memoryStream, 3 * 1024, null); } await blob.ClearPagesAsync(1024, 1024); @@ -631,7 +631,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -664,12 +664,12 @@ public async Task CloudPageBlobWritePagesAsync() using (MemoryStream memoryStream = new MemoryStream()) { await TestHelper.ExpectedExceptionAsync( - async () => await blob.WritePagesAsync(memoryStream.AsInputStream(), 0, null), + async () => await blob.WritePagesAsync(memoryStream, 0, null), "Zero-length WritePages should fail"); memoryStream.SetLength(4 * 1024 * 1024 + 1); await TestHelper.ExpectedExceptionAsync( - async () => await blob.WritePagesAsync(memoryStream.AsInputStream(), 0, null), + async () => await blob.WritePagesAsync(memoryStream, 0, null), ">4MB WritePages should fail"); } @@ -679,40 +679,40 @@ await TestHelper.ExpectedExceptionAsync( { OperationContext opContext = new OperationContext(); await TestHelper.ExpectedExceptionAsync( - async () => await blob.WritePagesAsync(memoryStream.AsInputStream(), 512, null, null, null, opContext), + async () => await blob.WritePagesAsync(memoryStream, 512, null, null, null, opContext), opContext, "Writing out-of-range pages should fail", HttpStatusCode.RequestedRangeNotSatisfiable, "InvalidPageRange"); memoryStream.Seek(0, SeekOrigin.Begin); - await blob.WritePagesAsync(memoryStream.AsInputStream(), 0, contentMD5); + await blob.WritePagesAsync(memoryStream, 0, contentMD5); resultingData.Write(buffer, 0, buffer.Length); int offset = buffer.Length - 1024; memoryStream.Seek(offset, SeekOrigin.Begin); await TestHelper.ExpectedExceptionAsync( - async () => await blob.WritePagesAsync(memoryStream.AsInputStream(), 0, contentMD5, null, null, opContext), + async () => await blob.WritePagesAsync(memoryStream, 0, contentMD5, null, null, opContext), opContext, "Invalid MD5 should fail with mismatch", HttpStatusCode.BadRequest, "Md5Mismatch"); memoryStream.Seek(offset, SeekOrigin.Begin); - await blob.WritePagesAsync(memoryStream.AsInputStream(), 0, null); + await blob.WritePagesAsync(memoryStream, 0, null); resultingData.Seek(0, SeekOrigin.Begin); resultingData.Write(buffer, offset, buffer.Length - offset); offset = buffer.Length - 2048; memoryStream.Seek(offset, SeekOrigin.Begin); - await blob.WritePagesAsync(memoryStream.AsInputStream(), 1024, null); + await blob.WritePagesAsync(memoryStream, 1024, null); resultingData.Seek(1024, SeekOrigin.Begin); resultingData.Write(buffer, offset, buffer.Length - offset); } using (MemoryStream blobData = new MemoryStream()) { - await blob.DownloadToStreamAsync(blobData.AsOutputStream()); + await blob.DownloadToStreamAsync(blobData); Assert.AreEqual(resultingData.Length, blobData.Length); Assert.IsTrue(blobData.ToArray().SequenceEqual(resultingData.ToArray())); } @@ -720,7 +720,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -764,7 +764,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -785,7 +785,7 @@ public async Task CloudPageBlobUploadFromStreamAsync() } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -815,7 +815,7 @@ public async Task CloudPageBlobUploadFromStreamLengthAsync() } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -841,7 +841,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteAsync().AsTask().Wait(); + container.DeleteAsync().Wait(); } } @@ -878,11 +878,11 @@ private async Task CloudPageBlobUploadFromStreamAsync(CloudBlobContainer contain }; if (copyLength.HasValue) { - await blob.UploadFromStreamAsync(sourceStream.AsInputStream(), copyLength.Value, accessCondition, options, operationContext); + await blob.UploadFromStreamAsync(sourceStream, copyLength.Value, accessCondition, options, operationContext); } else { - await blob.UploadFromStreamAsync(sourceStream.AsInputStream(), accessCondition, options, operationContext); + await blob.UploadFromStreamAsync(sourceStream, accessCondition, options, operationContext); } } @@ -921,7 +921,7 @@ public async Task CloudPageBlobSnapshotAsync() MemoryStream originalData = new MemoryStream(GetRandomBuffer(1024)); CloudPageBlob blob = container.GetPageBlobReference("blob1"); - await blob.UploadFromStreamAsync(originalData.AsInputStream()); + await blob.UploadFromStreamAsync(originalData); Assert.IsFalse(blob.IsSnapshot); Assert.IsNull(blob.SnapshotTime, "Root blob has SnapshotTime set"); @@ -961,7 +961,7 @@ await TestHelper.ExpectedExceptionAsync( async () => await snapshot1.OpenWriteAsync(1024), "Trying to write to a blob snapshot should fail"); - using (Stream snapshotStream = (await snapshot1.OpenReadAsync()).AsStreamForRead()) + using (Stream snapshotStream = (await snapshot1.OpenReadAsync())) { snapshotStream.Seek(0, SeekOrigin.End); TestHelper.AssertStreamsAreEqual(originalData, snapshotStream); @@ -969,7 +969,7 @@ await TestHelper.ExpectedExceptionAsync( await blob.CreateAsync(1024); - using (Stream snapshotStream = (await snapshot1.OpenReadAsync()).AsStreamForRead()) + using (Stream snapshotStream = (await snapshot1.OpenReadAsync())) { snapshotStream.Seek(0, SeekOrigin.End); TestHelper.AssertStreamsAreEqual(originalData, snapshotStream); @@ -985,7 +985,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1029,7 +1029,7 @@ public async Task CloudPageBlobSnapshotMetadataAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1143,7 +1143,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1168,7 +1168,7 @@ public async Task CloudPageBlobMethodsOnBlockBlobAsync() { stream.SetLength(512); await TestHelper.ExpectedExceptionAsync( - async () => await blob.WritePagesAsync(stream.AsInputStream(), 0, null, null, null, operationContext), + async () => await blob.WritePagesAsync(stream, 0, null, null, null, operationContext), operationContext, "Page operations should fail on block blobs", HttpStatusCode.Conflict, @@ -1191,7 +1191,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1228,7 +1228,7 @@ await TestHelper.ExpectedExceptionAsync( { stream.SetLength(511); await TestHelper.ExpectedExceptionAsync( - async () => await blob.WritePagesAsync(stream.AsInputStream(), 0, null, null, null, operationContext), + async () => await blob.WritePagesAsync(stream, 0, null, null, null, operationContext), "Page operations that are not 512-byte aligned should fail"); } @@ -1236,19 +1236,19 @@ await TestHelper.ExpectedExceptionAsync( { stream.SetLength(513); await TestHelper.ExpectedExceptionAsync( - async () => await blob.WritePagesAsync(stream.AsInputStream(), 0, null, null, null, operationContext), + async () => await blob.WritePagesAsync(stream, 0, null, null, null, operationContext), "Page operations that are not 512-byte aligned should fail"); } using (MemoryStream stream = new MemoryStream()) { stream.SetLength(512); - await blob.WritePagesAsync(stream.AsInputStream(), 0, null); + await blob.WritePagesAsync(stream, 0, null); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -1272,7 +1272,7 @@ await TestHelper.ExpectedExceptionAsync( using (MemoryStream stream = new MemoryStream()) { - await blob.UploadFromStreamAsync(stream.AsInputStream()); + await blob.UploadFromStreamAsync(stream); } await TestHelper.ExpectedExceptionAsync( @@ -1281,13 +1281,13 @@ await TestHelper.ExpectedExceptionAsync( using (MemoryStream stream = new MemoryStream()) { - await blob.DownloadToStreamAsync(stream.AsOutputStream()); + await blob.DownloadToStreamAsync(stream); Assert.AreEqual(0, stream.Length); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Blob/CopyBlobTest.cs b/Test/WindowsRuntime/Blob/CopyBlobTest.cs index b60741a91..1494a0c06 100644 --- a/Test/WindowsRuntime/Blob/CopyBlobTest.cs +++ b/Test/WindowsRuntime/Blob/CopyBlobTest.cs @@ -102,7 +102,7 @@ public async Task CopyBlobUsingUnicodeBlobNameAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -171,7 +171,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -229,7 +229,7 @@ public async Task CloudBlockBlobCopyTestWithMetadataOverrideAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -293,7 +293,7 @@ public async Task CloudBlockBlobCopyFromSnapshotTestAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -362,7 +362,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -420,7 +420,7 @@ public async Task CloudPageBlobCopyTestWithMetadataOverrideAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -484,7 +484,7 @@ public async Task CloudPageBlobCopyFromSnapshotTestAsync() } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Blob/LeaseTests.cs b/Test/WindowsRuntime/Blob/LeaseTests.cs index b406d11b7..537babbd1 100644 --- a/Test/WindowsRuntime/Blob/LeaseTests.cs +++ b/Test/WindowsRuntime/Blob/LeaseTests.cs @@ -413,15 +413,15 @@ public async Task BlobAcquireLeaseSemanticTestsAsync() CloudBlob leasedBlob = this.GetContainerReference("lease-tests").GetBlockBlobReference("LeasedBlob"); await SetAvailableStateAsync(leasedBlob); - leaseId = await leasedBlob.AcquireLeaseAsync(TimeSpan.FromSeconds(15), null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(TimeSpan.FromSeconds(15)); await this.BlobAcquireRenewLeaseTestAsync(leasedBlob, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20), tolerance); await SetAvailableStateAsync(leasedBlob); - leaseId = await leasedBlob.AcquireLeaseAsync(TimeSpan.FromSeconds(60), null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(TimeSpan.FromSeconds(60)); await this.BlobAcquireRenewLeaseTestAsync(leasedBlob, TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(70), tolerance); await SetAvailableStateAsync(leasedBlob); - leaseId = await leasedBlob.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* infinite lease */); await this.BlobAcquireRenewLeaseTestAsync(leasedBlob, null /* infinite lease */, TimeSpan.FromSeconds(70), tolerance); await SetReleasedStateAsync(leasedBlob, null /* infinite lease */); @@ -563,11 +563,11 @@ public async Task BlobLeaseInvalidInputTestsAsync() await CreateBlobAsync(leasedBlob); await TestHelper.ExpectedExceptionAsync( - async () => await leasedBlob.AcquireLeaseAsync(TimeSpan.Zero, null /* proposed lease ID */), + async () => await leasedBlob.AcquireLeaseAsync(TimeSpan.Zero), "acquire a lease with 0 duration"); await TestHelper.ExpectedExceptionAsync( - async () => await leasedBlob.AcquireLeaseAsync(TimeSpan.FromSeconds(-1), null /* proposed lease ID */), + async () => await leasedBlob.AcquireLeaseAsync(TimeSpan.FromSeconds(-1)), "acquire a lease with -1 duration"); await TestHelper.ExpectedExceptionAsync( @@ -714,7 +714,7 @@ await TestHelper.ExpectedExceptionAsync( // Acquire with no proposed ID (non-idempotent) await SetAvailableStateAsync(leasedBlob); - leaseId = await leasedBlob.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* infinite lease */); await TestHelper.ExpectedExceptionAsync( async () => await leasedBlob.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */, null, null, operationContext), operationContext, @@ -1253,7 +1253,7 @@ await TestHelper.ExpectedExceptionAsync( expectedErrorCode); var writeStream = await testBlob.OpenWriteAsync(testAccessCondition, null /* options */, operationContext); - Stream stream = writeStream.AsStreamForWrite(); + Stream stream = writeStream; await TestHelper.ExpectedExceptionAsync( async () => { @@ -1286,7 +1286,7 @@ private async Task BlobWriteExpectLeaseSuccessAsync(CloudBlockBlob testBlob, Clo } var writeStream = await testBlob.OpenWriteAsync(testAccessCondition, null /* options */, null); - Stream stream = writeStream.AsStreamForWrite(); + Stream stream = writeStream; stream.WriteByte(0); await stream.FlushAsync(); @@ -1383,7 +1383,7 @@ private async Task BlobReadExpectLeaseSuccessAsync(CloudBlockBlob testBlob, Acce await DownloadTextAsync(testBlob, Encoding.UTF8, testAccessCondition, null /* options */, null); var readStream = await testBlob.OpenReadAsync(testAccessCondition, null /* options */, null); - Stream stream = readStream.AsStreamForRead(); + Stream stream = readStream; stream.ReadByte(); } @@ -1416,7 +1416,7 @@ public async Task PageBlobLeasedWriteTestsAsync() await PageBlobWriteExpectLeaseFailureAsync(leasedBlob, testAccessCondition, HttpStatusCode.PreconditionFailed, BlobErrorCodeStrings.LeaseNotPresentWithBlobOperation, "write page blob with a lease when no lease is held"); // Acquire a lease - leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */); // Verify that writes without a lease do not succeed. testAccessCondition.LeaseId = null; @@ -1475,7 +1475,7 @@ await TestHelper.ExpectedExceptionAsync( expectedStatusCode, expectedErrorCode); await TestHelper.ExpectedExceptionAsync( - async () => await testBlob.WritePagesAsync(pageStream.AsInputStream(), 512, null, testAccessCondition, null /* options */, operationContext), + async () => await testBlob.WritePagesAsync(pageStream, 512, null, testAccessCondition, null /* options */, operationContext), operationContext, description + " (Write Pages)", expectedStatusCode, @@ -1505,7 +1505,7 @@ private async Task PageBlobWriteExpectSuccessAsync(CloudPageBlob testBlob, Acces Stream pageStream = new MemoryStream(buffer); await testBlob.ClearPagesAsync(512, 512, testAccessCondition, null /* options */, null); - await testBlob.WritePagesAsync(pageStream.AsInputStream(), 512, null, testAccessCondition, null /* options */, null); + await testBlob.WritePagesAsync(pageStream, 512, null, testAccessCondition, null /* options */, null); } [TestMethod] @@ -1532,7 +1532,7 @@ public async Task PageBlobLeasedReadTestsAsync() await PageBlobReadExpectLeaseFailureAsync(leasedBlob, testAccessCondition, HttpStatusCode.PreconditionFailed, BlobErrorCodeStrings.LeaseNotPresentWithBlobOperation, "read page blob with a lease when no lease is held"); // Acquire a lease - leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */); // Verify that reads without a lease succeed. testAccessCondition.LeaseId = null; @@ -1612,7 +1612,7 @@ public async Task BlockBlobLeasedWriteTestsAsync() // Acquire a lease testAccessCondition.LeaseId = null; - leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */); // Verify that writes without a lease do not succeed. testAccessCondition.LeaseId = null; @@ -1708,7 +1708,7 @@ private async Task BlockCreateAsync(CloudBlockBlob testBlob, AccessCondi random.NextBytes(buffer); string blockId = Guid.NewGuid().ToString("N"); Stream blockData = new MemoryStream(buffer); - await testBlob.PutBlockAsync(blockId, blockData.AsInputStream(), null /* content MD5 */, testAccessCondition, null /* options */, operationContext); + await testBlob.PutBlockAsync(blockId, blockData, null /* content MD5 */, testAccessCondition, null /* options */, operationContext); return blockId; } @@ -1753,7 +1753,7 @@ public async Task BlockBlobLeasedReadTestsWithoutListAsync() // Acquire a lease testAccessCondition.LeaseId = null; - leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */); // Verify that reads without a lease still succeed. testAccessCondition.LeaseId = null; @@ -1804,7 +1804,7 @@ public async Task BlockBlobLeasedReadTestsWithListAsync() // Acquire a lease testAccessCondition.LeaseId = null; - leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + leaseId = await leasedBlob.AcquireLeaseAsync(null /* lease duration */); // Verify that reads without a lease still succeed. testAccessCondition.LeaseId = null; @@ -1910,7 +1910,7 @@ public async Task BlobLeaseStatusTestAsync() // Check lease status after (infinite) acquire after break await SetTimeBrokenStateAsync(leasedBlob); - await leasedBlob.AcquireLeaseAsync(null /* infinite lease */, null /*proposed lease ID */); + await leasedBlob.AcquireLeaseAsync(null /* infinite lease */); await this.CheckLeaseStatusAsync(leasedBlob, LeaseStatus.Locked, LeaseState.Leased, LeaseDuration.Infinite, "after second acquire lease"); // Check lease status after instant break with infinite lease @@ -1968,17 +1968,17 @@ public async Task ContainerAcquireLeaseSemanticTestsAsync() leasedContainer = this.GetContainerReference("leased-container-1"); // make sure we use a new container await SetUnleasedStateAsync(leasedContainer); - leaseId = await leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(15), null /* proposed lease ID */); + leaseId = await leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(15)); await this.ContainerAcquireRenewLeaseTestAsync(leasedContainer, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20), tolerance); leasedContainer = this.GetContainerReference("leased-container-2"); // make sure we use a new container await SetUnleasedStateAsync(leasedContainer); - leaseId = await leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(60), null /* proposed lease ID */); + leaseId = await leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(60)); await this.ContainerAcquireRenewLeaseTestAsync(leasedContainer, TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(70), tolerance); leasedContainer = this.GetContainerReference("leased-container-3"); // make sure we use a new container await SetUnleasedStateAsync(leasedContainer); - leaseId = await leasedContainer.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */); + leaseId = await leasedContainer.AcquireLeaseAsync(null /* infinite lease */); await this.ContainerAcquireRenewLeaseTestAsync(leasedContainer, null /* infinite lease */, TimeSpan.FromSeconds(70), tolerance); leasedContainer = this.GetContainerReference("leased-container-4"); // make sure we use a new container @@ -2119,11 +2119,11 @@ public async Task ContainerLeaseInvalidInputTestsAsync() await leasedContainer.CreateAsync(); await TestHelper.ExpectedExceptionAsync( - async () => await leasedContainer.AcquireLeaseAsync(TimeSpan.Zero, null /* proposed lease ID */), + async () => await leasedContainer.AcquireLeaseAsync(TimeSpan.Zero), "acquire a lease with 0 duration"); await TestHelper.ExpectedExceptionAsync( - async () => await leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(-1), null /* proposed lease ID */), + async () => await leasedContainer.AcquireLeaseAsync(TimeSpan.FromSeconds(-1)), "acquire a lease with -1 duration"); await TestHelper.ExpectedExceptionAsync( @@ -2272,7 +2272,7 @@ await TestHelper.ExpectedExceptionAsync( // Acquire with no proposed ID (non-idempotent) await SetUnleasedStateAsync(leasedContainer); - leaseId = await leasedContainer.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */); + leaseId = await leasedContainer.AcquireLeaseAsync(null /* infinite lease */); await TestHelper.ExpectedExceptionAsync( async () => await leasedContainer.AcquireLeaseAsync(null /* infinite lease */, null /* proposed lease ID */, null, null, operationContext), operationContext, @@ -2726,7 +2726,7 @@ public async Task ContainerLeasedDeleteTestsAsync() await this.ContainerDeleteExpectLeaseFailureAsync(leasedContainer, testAccessCondition, HttpStatusCode.PreconditionFailed, BlobErrorCodeStrings.LeaseNotPresentWithContainerOperation, "delete container using a lease when no lease is held"); // Acquire a lease - string leaseId = await leasedContainer.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + string leaseId = await leasedContainer.AcquireLeaseAsync(null /* lease duration */); // Verify that deletes without a lease do not succeed. testAccessCondition.LeaseId = null; @@ -2789,7 +2789,7 @@ public async Task ContainerLeasedReadWriteTestsAsync() await this.ContainerReadWriteExpectLeaseFailureAsync(leasedContainer, testAccessCondition, HttpStatusCode.PreconditionFailed, BlobErrorCodeStrings.LeaseNotPresentWithContainerOperation, "read/write container using a lease when no lease is held"); // Acquire a lease - string leaseId = await leasedContainer.AcquireLeaseAsync(null /* lease duration */, null /* proposed lease ID */); + string leaseId = await leasedContainer.AcquireLeaseAsync(null /* lease duration */); // Verify that reads and writes without a lease succeed. testAccessCondition.LeaseId = null; @@ -2918,7 +2918,7 @@ public async Task ContainerLeaseStatusTestAsync() // Check lease status after (infinite) acquire after break await SetTimeBrokenStateAsync(leasedContainer); - await leasedContainer.AcquireLeaseAsync(null /* infinite lease */, null /*proposed lease ID */); + await leasedContainer.AcquireLeaseAsync(null /* infinite lease */); await this.CheckLeaseStatusAsync(leasedContainer, LeaseStatus.Locked, LeaseState.Leased, LeaseDuration.Infinite, "after second acquire lease"); // Check lease status after instant break with infinite lease diff --git a/Test/WindowsRuntime/Blob/MD5FlagsTest.cs b/Test/WindowsRuntime/Blob/MD5FlagsTest.cs index 3685b5249..93d54c5fa 100644 --- a/Test/WindowsRuntime/Blob/MD5FlagsTest.cs +++ b/Test/WindowsRuntime/Blob/MD5FlagsTest.cs @@ -55,7 +55,7 @@ public async Task StoreBlobContentMD5TestAsync() CloudBlockBlob blob1 = container.GetBlockBlobReference("blob1"); using (Stream stream = new NonSeekableMemoryStream()) { - await blob1.UploadFromStreamAsync(stream.AsInputStream(), null, optionsWithMD5, null); + await blob1.UploadFromStreamAsync(stream, null, optionsWithMD5, null); } await blob1.FetchAttributesAsync(); Assert.IsNotNull(blob1.Properties.ContentMD5); @@ -63,7 +63,7 @@ public async Task StoreBlobContentMD5TestAsync() blob1 = container.GetBlockBlobReference("blob2"); using (Stream stream = new NonSeekableMemoryStream()) { - await blob1.UploadFromStreamAsync(stream.AsInputStream(), null, optionsWithNoMD5, null); + await blob1.UploadFromStreamAsync(stream, null, optionsWithNoMD5, null); } await blob1.FetchAttributesAsync(); Assert.IsNull(blob1.Properties.ContentMD5); @@ -71,7 +71,7 @@ public async Task StoreBlobContentMD5TestAsync() blob1 = container.GetBlockBlobReference("blob3"); using (Stream stream = new NonSeekableMemoryStream()) { - await blob1.UploadFromStreamAsync(stream.AsInputStream()); + await blob1.UploadFromStreamAsync(stream); } await blob1.FetchAttributesAsync(); Assert.IsNotNull(blob1.Properties.ContentMD5); @@ -80,7 +80,7 @@ public async Task StoreBlobContentMD5TestAsync() blob2 = container.GetPageBlobReference("blob4"); using (Stream stream = new MemoryStream()) { - await blob2.UploadFromStreamAsync(stream.AsInputStream(), null, optionsWithMD5, null); + await blob2.UploadFromStreamAsync(stream, null, optionsWithMD5, null); } await blob2.FetchAttributesAsync(); Assert.IsNotNull(blob2.Properties.ContentMD5); @@ -88,7 +88,7 @@ public async Task StoreBlobContentMD5TestAsync() blob2 = container.GetPageBlobReference("blob5"); using (Stream stream = new MemoryStream()) { - await blob2.UploadFromStreamAsync(stream.AsInputStream(), null, optionsWithNoMD5, null); + await blob2.UploadFromStreamAsync(stream, null, optionsWithNoMD5, null); } await blob2.FetchAttributesAsync(); Assert.IsNull(blob2.Properties.ContentMD5); @@ -96,14 +96,14 @@ public async Task StoreBlobContentMD5TestAsync() blob2 = container.GetPageBlobReference("blob6"); using (Stream stream = new MemoryStream()) { - await blob2.UploadFromStreamAsync(stream.AsInputStream()); + await blob2.UploadFromStreamAsync(stream); } await blob2.FetchAttributesAsync(); Assert.IsNull(blob2.Properties.ContentMD5); } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } @@ -138,17 +138,17 @@ public async Task DisableContentMD5ValidationTestAsync() CloudBlockBlob blockBlob = container.GetBlockBlobReference("blob1"); using (Stream stream = new NonSeekableMemoryStream(buffer)) { - await blockBlob.UploadFromStreamAsync(stream.AsInputStream(), null, optionsWithMD5, null); + await blockBlob.UploadFromStreamAsync(stream, null, optionsWithMD5, null); } using (Stream stream = new MemoryStream()) { - await blockBlob.DownloadToStreamAsync(stream.AsOutputStream(), null, optionsWithMD5, null); - await blockBlob.DownloadToStreamAsync(stream.AsOutputStream(), null, optionsWithNoMD5, null); + await blockBlob.DownloadToStreamAsync(stream, null, optionsWithMD5, null); + await blockBlob.DownloadToStreamAsync(stream, null, optionsWithNoMD5, null); using (var blobStream = await blockBlob.OpenReadAsync(null, optionsWithMD5, null)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; int read; do { @@ -159,7 +159,7 @@ public async Task DisableContentMD5ValidationTestAsync() using (var blobStream = await blockBlob.OpenReadAsync(null, optionsWithNoMD5, null)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; int read; do { @@ -173,15 +173,15 @@ public async Task DisableContentMD5ValidationTestAsync() OperationContext opContext = new OperationContext(); await TestHelper.ExpectedExceptionAsync( - async () => await blockBlob.DownloadToStreamAsync(stream.AsOutputStream(), null, optionsWithMD5, opContext), + async () => await blockBlob.DownloadToStreamAsync(stream, null, optionsWithMD5, opContext), opContext, "Downloading a blob with invalid MD5 should fail", HttpStatusCode.OK); - await blockBlob.DownloadToStreamAsync(stream.AsOutputStream(), null, optionsWithNoMD5, null); + await blockBlob.DownloadToStreamAsync(stream, null, optionsWithNoMD5, null); using (var blobStream = await blockBlob.OpenReadAsync(null, optionsWithMD5, null)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; TestHelper.ExpectedException( () => { @@ -197,7 +197,7 @@ await TestHelper.ExpectedExceptionAsync( using (var blobStream = await blockBlob.OpenReadAsync(null, optionsWithNoMD5, null)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; int read; do { @@ -210,17 +210,17 @@ await TestHelper.ExpectedExceptionAsync( CloudPageBlob pageBlob = container.GetPageBlobReference("blob2"); using (Stream stream = new MemoryStream(buffer)) { - await pageBlob.UploadFromStreamAsync(stream.AsInputStream(), null, optionsWithMD5, null); + await pageBlob.UploadFromStreamAsync(stream, null, optionsWithMD5, null); } using (Stream stream = new MemoryStream()) { - await pageBlob.DownloadToStreamAsync(stream.AsOutputStream(), null, optionsWithMD5, null); - await pageBlob.DownloadToStreamAsync(stream.AsOutputStream(), null, optionsWithNoMD5, null); + await pageBlob.DownloadToStreamAsync(stream, null, optionsWithMD5, null); + await pageBlob.DownloadToStreamAsync(stream, null, optionsWithNoMD5, null); using (var blobStream = await pageBlob.OpenReadAsync(null, optionsWithMD5, null)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; int read; do { @@ -231,7 +231,7 @@ await TestHelper.ExpectedExceptionAsync( using (var blobStream = await pageBlob.OpenReadAsync(null, optionsWithNoMD5, null)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; int read; do { @@ -245,16 +245,16 @@ await TestHelper.ExpectedExceptionAsync( OperationContext opContext = new OperationContext(); await TestHelper.ExpectedExceptionAsync( - async () => await pageBlob.DownloadToStreamAsync(stream.AsOutputStream(), null, optionsWithMD5, opContext), + async () => await pageBlob.DownloadToStreamAsync(stream, null, optionsWithMD5, opContext), opContext, "Downloading a blob with invalid MD5 should fail", HttpStatusCode.OK); - await pageBlob.DownloadToStreamAsync(stream.AsOutputStream(), null, optionsWithNoMD5, null); + await pageBlob.DownloadToStreamAsync(stream, null, optionsWithNoMD5, null); using (var blobStream = await pageBlob.OpenReadAsync(null, optionsWithMD5, null)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; TestHelper.ExpectedException( () => { @@ -270,7 +270,7 @@ await TestHelper.ExpectedExceptionAsync( using (var blobStream = await pageBlob.OpenReadAsync(null, optionsWithNoMD5, null)) { - Stream blobStreamForRead = blobStream.AsStreamForRead(); + Stream blobStreamForRead = blobStream; int read; do { @@ -282,7 +282,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Blob/MemoryOutputStream.cs b/Test/WindowsRuntime/Blob/MemoryOutputStream.cs index 80433cbe9..103e67358 100644 --- a/Test/WindowsRuntime/Blob/MemoryOutputStream.cs +++ b/Test/WindowsRuntime/Blob/MemoryOutputStream.cs @@ -23,7 +23,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob { -#if ASPNET_K + internal sealed class MemoryOutputStream : MemoryStream { public MemoryStream UnderlyingStream { @@ -33,43 +33,4 @@ public MemoryStream UnderlyingStream { } } } -#else - internal sealed class MemoryOutputStream : IOutputStream - { - private IOutputStream outputStream; - - public MemoryStream UnderlyingStream { get; private set; } - - public MemoryOutputStream() - { - this.UnderlyingStream = new MemoryStream(); - this.outputStream = this.UnderlyingStream.AsOutputStream(); - } - - public IAsyncOperation FlushAsync() - { - return this.outputStream.FlushAsync(); - } - - public IAsyncOperationWithProgress WriteAsync(IBuffer buffer) - { - return this.outputStream.WriteAsync(buffer); - } - - public void Dispose() - { - if (this.outputStream != null) - { - this.outputStream.Dispose(); - this.outputStream = null; - } - - if (this.UnderlyingStream != null) - { - this.UnderlyingStream.Dispose(); - this.UnderlyingStream = null; - } - } - } -#endif } diff --git a/Test/WindowsRuntime/Blob/SASTests.cs b/Test/WindowsRuntime/Blob/SASTests.cs index 286f08e83..a199e6a4c 100644 --- a/Test/WindowsRuntime/Blob/SASTests.cs +++ b/Test/WindowsRuntime/Blob/SASTests.cs @@ -17,6 +17,7 @@ using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.WindowsAzure.Storage.Auth; +using Microsoft.WindowsAzure.Storage.Core; using System; using System.Net; using System.Text; @@ -48,7 +49,7 @@ public void Dispose() public void TestInitialize() { this.testContainer = GetRandomContainerReference(); - this.testContainer.CreateAsync().AsTask().Wait(); + this.testContainer.CreateAsync().Wait(); if (TestBase.BlobBufferManager != null) { @@ -59,7 +60,7 @@ public void TestInitialize() [TestCleanup] public void TestCleanup() { - this.testContainer.DeleteAsync().AsTask().Wait(); + this.testContainer.DeleteAsync().Wait(); this.testContainer = null; if (TestBase.BlobBufferManager != null) { @@ -67,7 +68,7 @@ public void TestCleanup() } } - private static async Task TestAccessAsync(string sasToken, SharedAccessBlobPermissions permissions, SharedAccessBlobHeaders headers, CloudBlobContainer container, CloudBlob blob) + private static async Task TestAccessAsync(string sasToken, SharedAccessBlobPermissions permissions, SharedAccessBlobHeaders headers, CloudBlobContainer container, CloudBlob blob, HttpStatusCode setBlobMetadataWhileSasExpectedStatusCode = HttpStatusCode.Forbidden, HttpStatusCode deleteBlobWhileSasExpectedStatusCode = HttpStatusCode.Forbidden, HttpStatusCode listBlobWhileSasExpectedStatusCode = HttpStatusCode.Forbidden) { OperationContext operationContext = new OperationContext(); StorageCredentials credentials = string.IsNullOrEmpty(sasToken) ? @@ -110,7 +111,7 @@ await TestHelper.ExpectedExceptionAsync( async () => await container.ListBlobsSegmentedAsync(null, true, BlobListingDetails.None, null, null, null, operationContext), operationContext, "List blobs while SAS does not allow for listing", - HttpStatusCode.Forbidden); + listBlobWhileSasExpectedStatusCode); } } @@ -166,7 +167,7 @@ await TestHelper.ExpectedExceptionAsync( async () => await blob.SetMetadataAsync(null, null, operationContext), operationContext, "Set blob metadata while SAS does not allow for writing", - HttpStatusCode.Forbidden); + setBlobMetadataWhileSasExpectedStatusCode); } if ((permissions & SharedAccessBlobPermissions.Delete) == SharedAccessBlobPermissions.Delete) @@ -179,7 +180,7 @@ await TestHelper.ExpectedExceptionAsync( async () => await blob.DeleteAsync(DeleteSnapshotsOption.None, null, null, operationContext), operationContext, "Delete blob while SAS does not allow for deleting", - HttpStatusCode.Forbidden); + deleteBlobWhileSasExpectedStatusCode); } } @@ -295,14 +296,14 @@ public async Task CloudBlobContainerPublicAccessAsync() permissions.PublicAccess = BlobContainerPublicAccessType.Container; await this.testContainer.SetPermissionsAsync(permissions); await Task.Delay(30 * 1000); - await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.List | SharedAccessBlobPermissions.Read, null, this.testContainer, testBlockBlob); - await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.List | SharedAccessBlobPermissions.Read, null, this.testContainer, testPageBlob); + await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.List | SharedAccessBlobPermissions.Read, null, this.testContainer, testBlockBlob, setBlobMetadataWhileSasExpectedStatusCode: HttpStatusCode.NotFound, deleteBlobWhileSasExpectedStatusCode: HttpStatusCode.NotFound); + await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.List | SharedAccessBlobPermissions.Read, null, this.testContainer, testPageBlob, setBlobMetadataWhileSasExpectedStatusCode: HttpStatusCode.NotFound, deleteBlobWhileSasExpectedStatusCode: HttpStatusCode.NotFound); permissions.PublicAccess = BlobContainerPublicAccessType.Blob; await this.testContainer.SetPermissionsAsync(permissions); await Task.Delay(30 * 1000); - await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.Read, null, this.testContainer, testBlockBlob); - await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.Read, null, this.testContainer, testPageBlob); + await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.Read, null, this.testContainer, testBlockBlob, setBlobMetadataWhileSasExpectedStatusCode: HttpStatusCode.NotFound, deleteBlobWhileSasExpectedStatusCode: HttpStatusCode.NotFound, listBlobWhileSasExpectedStatusCode: HttpStatusCode.NotFound); + await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.Read, null, this.testContainer, testPageBlob, setBlobMetadataWhileSasExpectedStatusCode: HttpStatusCode.NotFound, deleteBlobWhileSasExpectedStatusCode: HttpStatusCode.NotFound, listBlobWhileSasExpectedStatusCode: HttpStatusCode.NotFound); } [TestMethod] @@ -390,5 +391,30 @@ public async Task CloudPageBlobSASHeadersAsync() await TestBlobSASAsync(testBlob, permissions, headers); } } + + [TestMethod] + [Description("Perform a SAS request specifying a shared protocol and ensure that everything works properly.")] + [TestCategory(ComponentCategory.Blob)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] + public void CloudBlobSASSharedProtocolsQueryParamInvalid() + { + SharedAccessProtocol? protocol = default(SharedAccessProtocol); + SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy() + { + Permissions = SharedAccessBlobPermissions.Read, + SharedAccessStartTime = DateTimeOffset.UtcNow.AddMinutes(-5), + SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(30), + }; + + CloudBlobContainer container = GetRandomContainerReference(); + CloudBlockBlob blockBlob = container.GetBlockBlobReference("bb"); + + TestHelper.ExpectedException( + () => blockBlob.GetSharedAccessSignature(policy, null /* headers */, null /* stored access policy ID */, protocol, null /* IP address or range */), + "Creating a SAS should throw when using an invalid value for the Protocol enum.", + String.Format(SR.InvalidProtocolsInSAS, protocol)); + } } } diff --git a/Test/WindowsRuntime/Core/LoggingTests.cs b/Test/WindowsRuntime/Core/LoggingTests.cs index 7073c652d..2def0eaf9 100644 --- a/Test/WindowsRuntime/Core/LoggingTests.cs +++ b/Test/WindowsRuntime/Core/LoggingTests.cs @@ -101,7 +101,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Core/MultiBufferMemoryStreamTests.cs b/Test/WindowsRuntime/Core/MultiBufferMemoryStreamTests.cs index bf7cdf2e2..d94fb1d36 100644 --- a/Test/WindowsRuntime/Core/MultiBufferMemoryStreamTests.cs +++ b/Test/WindowsRuntime/Core/MultiBufferMemoryStreamTests.cs @@ -98,14 +98,14 @@ public async Task EnsureMultiBufferMemoryStreamIsNotClosedAsync() originalBlob.Write(buffer, 0, buffer.Length); originalBlob.Seek(0, SeekOrigin.Begin); - await blob.PutBlockAsync(Convert.ToBase64String(Guid.NewGuid().ToByteArray()), originalBlob.AsInputStream(), null); + await blob.PutBlockAsync(Convert.ToBase64String(Guid.NewGuid().ToByteArray()), originalBlob, null); Assert.IsTrue(originalBlob.CanSeek); } } finally { - container.DeleteIfExistsAsync().AsTask().Wait(); + container.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Core/RetryPoliciesTests.cs b/Test/WindowsRuntime/Core/RetryPoliciesTests.cs index b6fcd179a..83a9d3d0a 100644 --- a/Test/WindowsRuntime/Core/RetryPoliciesTests.cs +++ b/Test/WindowsRuntime/Core/RetryPoliciesTests.cs @@ -45,11 +45,7 @@ public async Task RetryDelayShouldBeCancellableAsync() CloudBlobClient blobClient = GenerateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("test" + DateTime.UtcNow.Ticks.ToString()); CancellationTokenSource token = new CancellationTokenSource(); -#if ASPNET_K Task task = container.FetchAttributesAsync(null, options, context, token.Token); -#else - Task task = container.FetchAttributesAsync(null, options, context).AsTask(token.Token); -#endif await responseTask.Task; await Task.Delay(10 * 1000); diff --git a/Test/WindowsRuntime/Core/SecondaryTests.cs b/Test/WindowsRuntime/Core/SecondaryTests.cs index 286a04a3d..f9b3f7a55 100644 --- a/Test/WindowsRuntime/Core/SecondaryTests.cs +++ b/Test/WindowsRuntime/Core/SecondaryTests.cs @@ -54,19 +54,19 @@ public async Task LocationModeWithMissingUriAsync() Exception e = await TestHelper.ExpectedExceptionAsync( async () => await container.FetchAttributesAsync(null, options, null), "Request should fail when an URI is not provided for the target location"); - Assert.IsInstanceOfType(e.InnerException.InnerException, typeof(InvalidOperationException)); + Assert.IsInstanceOfType(e.InnerException, typeof(InvalidOperationException)); options.LocationMode = LocationMode.SecondaryThenPrimary; e = await TestHelper.ExpectedExceptionAsync( async () => await container.FetchAttributesAsync(null, options, null), "Request should fail when an URI is not provided for the target location"); - Assert.IsInstanceOfType(e.InnerException.InnerException, typeof(InvalidOperationException)); + Assert.IsInstanceOfType(e.InnerException, typeof(InvalidOperationException)); options.LocationMode = LocationMode.PrimaryThenSecondary; e = await TestHelper.ExpectedExceptionAsync( async () => await container.FetchAttributesAsync(null, options, null), "Request should fail when an URI is not provided for the target location"); - Assert.IsInstanceOfType(e.InnerException.InnerException, typeof(InvalidOperationException)); + Assert.IsInstanceOfType(e.InnerException, typeof(InvalidOperationException)); } [TestMethod] diff --git a/Test/WindowsRuntime/File/CloudFileClientTest.cs b/Test/WindowsRuntime/File/CloudFileClientTest.cs index bf970b94e..66e0a2a95 100644 --- a/Test/WindowsRuntime/File/CloudFileClientTest.cs +++ b/Test/WindowsRuntime/File/CloudFileClientTest.cs @@ -256,12 +256,12 @@ public async Task CloudFileClientMaximumExecutionTimeoutAsync() { try { - await file.UploadFromStreamAsync(ms.AsInputStream()); + await file.UploadFromStreamAsync(ms); Assert.Fail(); } catch (AggregateException ex) { - Assert.AreEqual("The client could not finish the operation within specified timeout.", RequestResult.TranslateFromExceptionMessage(ex.InnerException.InnerException.Message).ExceptionInfo.Message); + Assert.AreEqual("The client could not finish the operation within specified timeout.", RequestResult.TranslateFromExceptionMessage(ex.InnerException.Message).ExceptionInfo.Message); } catch (TaskCanceledException) { @@ -271,7 +271,7 @@ public async Task CloudFileClientMaximumExecutionTimeoutAsync() finally { fileClient.DefaultRequestOptions.MaximumExecutionTime = null; - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -298,7 +298,7 @@ public async Task CloudFileClientMaximumExecutionTimeoutShouldNotBeHonoredForStr using (var fileStream = await file.OpenWriteAsync(8 * 1024 * 1024)) { - Stream fos = fileStream.AsStreamForWrite(); + Stream fos = fileStream; DateTime start = DateTime.Now; for (int i = 0; i < 7; i++) @@ -320,7 +320,7 @@ public async Task CloudFileClientMaximumExecutionTimeoutShouldNotBeHonoredForStr using (var fileStream = await file.OpenReadAsync()) { - Stream fis = fileStream.AsStreamForRead(); + Stream fis = fileStream; DateTime start = DateTime.Now; int total = 0; @@ -349,7 +349,7 @@ public async Task CloudFileClientMaximumExecutionTimeoutShouldNotBeHonoredForStr finally { fileClient.DefaultRequestOptions.MaximumExecutionTime = null; - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } diff --git a/Test/WindowsRuntime/File/CloudFileDirectoryTest.cs b/Test/WindowsRuntime/File/CloudFileDirectoryTest.cs index ee140e7c7..088a12501 100644 --- a/Test/WindowsRuntime/File/CloudFileDirectoryTest.cs +++ b/Test/WindowsRuntime/File/CloudFileDirectoryTest.cs @@ -124,7 +124,7 @@ public async Task CloudFileDirectoryCreateAndDeleteAsync() } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } @@ -149,7 +149,7 @@ public async Task CloudFileDirectoryCreateIfNotExistsAsync() } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } @@ -203,7 +203,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -228,7 +228,7 @@ public async Task CloudFileDirectoryDeleteIfExistsAsync() } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } @@ -286,7 +286,7 @@ public async Task CloudFileDirectoryListFilesAndDirectoriesAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -324,7 +324,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } @@ -410,7 +410,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } */ @@ -450,7 +450,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } @@ -483,7 +483,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } @@ -527,7 +527,7 @@ public async Task CloudFileDirectoryGetParentAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } diff --git a/Test/WindowsRuntime/File/CloudFileServiceTest.cs b/Test/WindowsRuntime/File/CloudFileServiceTest.cs index 37d5868c7..1ba7d2192 100644 --- a/Test/WindowsRuntime/File/CloudFileServiceTest.cs +++ b/Test/WindowsRuntime/File/CloudFileServiceTest.cs @@ -115,7 +115,7 @@ public async Task CloudFileTestAnalyticsRoundTripAsync() private static FileServiceProperties DefaultServiceProperties() { - FileServiceProperties props = new FileServiceProperties(); + FileServiceProperties props = new FileServiceProperties(new MetricsProperties(), new MetricsProperties(), new CorsProperties()); props.HourMetrics.MetricsLevel = MetricsLevel.None; props.HourMetrics.RetentionDays = null; diff --git a/Test/WindowsRuntime/File/CloudFileShareTest.cs b/Test/WindowsRuntime/File/CloudFileShareTest.cs index eebc68c55..b2f5068b8 100644 --- a/Test/WindowsRuntime/File/CloudFileShareTest.cs +++ b/Test/WindowsRuntime/File/CloudFileShareTest.cs @@ -105,13 +105,13 @@ public async Task CloudFileShareCreateAsync() { OperationContext operationContext = new OperationContext(); Assert.ThrowsException( - () => share.CreateAsync(null, operationContext).AsTask().Wait(), + () => share.CreateAsync(null, operationContext).Wait(), "Creating already exists share should fail"); Assert.AreEqual((int)HttpStatusCode.Conflict, operationContext.LastResult.HttpStatusCode); } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } @@ -131,7 +131,7 @@ public async Task CloudFileShareCreateIfNotExistsAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -172,7 +172,7 @@ public async Task CloudFileShareExistsAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } Assert.IsFalse(await share2.ExistsAsync()); @@ -202,7 +202,7 @@ public async Task CloudFileShareCreateWithMetadataAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -243,7 +243,7 @@ public async Task CloudFileShareSetMetadataAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -277,7 +277,7 @@ public async Task CloudFileShareRegionalSetMetadataAsync() #else ApplicationLanguages.PrimaryLanguageOverride = currentPrimaryLanguage; #endif - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -306,7 +306,7 @@ public async Task CloudFileShareListFilesAndDirectoriesAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -344,7 +344,7 @@ public async Task CloudFileShareListFilesAndDirectoriesSegmentedAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -390,7 +390,7 @@ public async Task CloudFileShareSetPermissionsAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -437,7 +437,7 @@ public async Task CloudFileShareSetPermissionsOverloadAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -485,7 +485,7 @@ public async Task CloudFileShareClearPermissionsAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -538,7 +538,7 @@ public async Task CloudFileShareCopyPermissionsAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -613,7 +613,7 @@ public async Task CloudFileShareRemovePermissionsAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -676,7 +676,7 @@ public async Task CloudFileShareTryGetValuePermissions() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -730,7 +730,7 @@ public async Task CloudFileShareGetEnumeratorPermissionsAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -783,7 +783,7 @@ public async Task CloudFileShareGetValuesPermissionsAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -875,7 +875,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } */ diff --git a/Test/WindowsRuntime/File/CloudFileTest.cs b/Test/WindowsRuntime/File/CloudFileTest.cs index 2ecaf01c6..cf99887d5 100644 --- a/Test/WindowsRuntime/File/CloudFileTest.cs +++ b/Test/WindowsRuntime/File/CloudFileTest.cs @@ -93,7 +93,7 @@ public async Task CloudFileCreateAndDeleteAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -136,7 +136,7 @@ public async Task CloudFileResizeAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -161,7 +161,7 @@ public async Task CloudFileDeleteIfExistsAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -194,7 +194,7 @@ public async Task CloudFileExistsAsync() } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } @@ -237,7 +237,7 @@ public async Task CloudFileFetchAttributesAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -289,7 +289,7 @@ public async Task CloudFileSetPropertiesAsync() { DisableContentMD5Validation = true, }; - await file3.DownloadToStreamAsync(stream.AsOutputStream(), null, options, null); + await file3.DownloadToStreamAsync(stream, null, options, null); } AssertAreEqual(file2.Properties, file3.Properties); @@ -300,7 +300,7 @@ public async Task CloudFileSetPropertiesAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -328,7 +328,7 @@ public async Task CloudFileCreateWithMetadataAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -356,13 +356,13 @@ public async Task CloudFileSetMetadataAsync() file.Metadata["key1"] = null; Assert.ThrowsException( - () => file.SetMetadataAsync(null, null, operationContext).AsTask().Wait(), + () => file.SetMetadataAsync(null, null, operationContext).Wait(), "Metadata keys should have a non-null value"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(ArgumentException)); file.Metadata["key1"] = ""; Assert.ThrowsException( - () => file.SetMetadataAsync(null, null, operationContext).AsTask().Wait(), + () => file.SetMetadataAsync(null, null, operationContext).Wait(), "Metadata keys should have a non-empty value"); Assert.IsInstanceOfType(operationContext.LastResult.Exception.InnerException, typeof(ArgumentException)); @@ -381,7 +381,7 @@ public async Task CloudFileSetMetadataAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -404,12 +404,12 @@ public async Task CloudFileListRangesAsync() using (MemoryStream memoryStream = new MemoryStream(buffer)) { - await file.WriteRangeAsync(memoryStream.AsInputStream(), 512, null); + await file.WriteRangeAsync(memoryStream, 512, null); } using (MemoryStream memoryStream = new MemoryStream(buffer)) { - await file.WriteRangeAsync(memoryStream.AsInputStream(), 3 * 1024, null); + await file.WriteRangeAsync(memoryStream, 3 * 1024, null); } await file.ClearRangeAsync(1024, 1024); @@ -452,7 +452,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -485,7 +485,7 @@ public async Task CloudFileWriteRangeAsync() using (MemoryStream memoryStream = new MemoryStream()) { await TestHelper.ExpectedExceptionAsync( - async () => await file.WriteRangeAsync(memoryStream.AsInputStream(), 0, null), + async () => await file.WriteRangeAsync(memoryStream, 0, null), "Zero-length WriteRange should fail"); } @@ -495,40 +495,40 @@ await TestHelper.ExpectedExceptionAsync( { OperationContext opContext = new OperationContext(); await TestHelper.ExpectedExceptionAsync( - async () => await file.WriteRangeAsync(memoryStream.AsInputStream(), 512, null, null, null, opContext), + async () => await file.WriteRangeAsync(memoryStream, 512, null, null, null, opContext), opContext, "Writing out-of-range ranges should fail", HttpStatusCode.RequestedRangeNotSatisfiable, "InvalidRange"); memoryStream.Seek(0, SeekOrigin.Begin); - await file.WriteRangeAsync(memoryStream.AsInputStream(), 0, contentMD5); + await file.WriteRangeAsync(memoryStream, 0, contentMD5); resultingData.Write(buffer, 0, buffer.Length); int offset = buffer.Length - 1024; memoryStream.Seek(offset, SeekOrigin.Begin); await TestHelper.ExpectedExceptionAsync( - async () => await file.WriteRangeAsync(memoryStream.AsInputStream(), 0, contentMD5, null, null, opContext), + async () => await file.WriteRangeAsync(memoryStream, 0, contentMD5, null, null, opContext), opContext, "Invalid MD5 should fail with mismatch", HttpStatusCode.BadRequest, "Md5Mismatch"); memoryStream.Seek(offset, SeekOrigin.Begin); - await file.WriteRangeAsync(memoryStream.AsInputStream(), 0, null); + await file.WriteRangeAsync(memoryStream, 0, null); resultingData.Seek(0, SeekOrigin.Begin); resultingData.Write(buffer, offset, buffer.Length - offset); offset = buffer.Length - 2048; memoryStream.Seek(offset, SeekOrigin.Begin); - await file.WriteRangeAsync(memoryStream.AsInputStream(), 1024, null); + await file.WriteRangeAsync(memoryStream, 1024, null); resultingData.Seek(1024, SeekOrigin.Begin); resultingData.Write(buffer, offset, buffer.Length - offset); } using (MemoryStream fileData = new MemoryStream()) { - await file.DownloadToStreamAsync(fileData.AsOutputStream()); + await file.DownloadToStreamAsync(fileData); Assert.AreEqual(resultingData.Length, fileData.Length); Assert.IsTrue(fileData.ToArray().SequenceEqual(resultingData.ToArray())); @@ -537,7 +537,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -582,7 +582,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } */ @@ -604,7 +604,7 @@ public async Task CloudFileUploadFromStreamAsync() } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } @@ -634,7 +634,7 @@ public async Task CloudFileUploadFromStreamLengthAsync() } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } @@ -660,7 +660,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } @@ -692,11 +692,11 @@ private async Task CloudFileUploadFromStreamAsync(CloudFileShare share, int size }; if (copyLength.HasValue) { - await file.UploadFromStreamAsync(sourceStream.AsInputStream(), copyLength.Value, accessCondition, options, operationContext); + await file.UploadFromStreamAsync(sourceStream, copyLength.Value, accessCondition, options, operationContext); } else { - await file.UploadFromStreamAsync(sourceStream.AsInputStream(), accessCondition, options, operationContext); + await file.UploadFromStreamAsync(sourceStream, accessCondition, options, operationContext); } } @@ -705,7 +705,7 @@ private async Task CloudFileUploadFromStreamAsync(CloudFileShare share, int size using (MemoryStream downloadedFileStream = new MemoryStream()) { - await file.DownloadToStreamAsync(downloadedFileStream.AsOutputStream()); + await file.DownloadToStreamAsync(downloadedFileStream); Assert.AreEqual(copyLength ?? originalFileStream.Length, downloadedFileStream.Length); TestHelper.AssertStreamsAreEqualAtIndex( originalFileStream, @@ -828,7 +828,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } */ @@ -855,24 +855,24 @@ public async Task CloudFileAlignmentAsync() using (MemoryStream stream = new MemoryStream()) { stream.SetLength(511); - await file.WriteRangeAsync(stream.AsInputStream(), 0, null); + await file.WriteRangeAsync(stream, 0, null); } using (MemoryStream stream = new MemoryStream()) { stream.SetLength(512); - await file.WriteRangeAsync(stream.AsInputStream(), 0, null); + await file.WriteRangeAsync(stream, 0, null); } using (MemoryStream stream = new MemoryStream()) { stream.SetLength(513); - await file.WriteRangeAsync(stream.AsInputStream(), 0, null); + await file.WriteRangeAsync(stream, 0, null); } } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -896,7 +896,7 @@ await TestHelper.ExpectedExceptionAsync( using (MemoryStream stream = new MemoryStream()) { - await file.UploadFromStreamAsync(stream.AsInputStream()); + await file.UploadFromStreamAsync(stream); } await TestHelper.ExpectedExceptionAsync( @@ -905,13 +905,13 @@ await TestHelper.ExpectedExceptionAsync( using (MemoryStream stream = new MemoryStream()) { - await file.DownloadToStreamAsync(stream.AsOutputStream()); + await file.DownloadToStreamAsync(stream); Assert.AreEqual(0, stream.Length); } } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/File/CopyFileTest.cs b/Test/WindowsRuntime/File/CopyFileTest.cs index 4778ad55a..a71b0835e 100644 --- a/Test/WindowsRuntime/File/CopyFileTest.cs +++ b/Test/WindowsRuntime/File/CopyFileTest.cs @@ -115,7 +115,7 @@ public async Task CopyFileUsingUnicodeFileNameAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -227,7 +227,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -318,7 +318,7 @@ public async Task CloudFileCopyTestWithMetadataOverrideAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/File/FileMD5FlagsTest.cs b/Test/WindowsRuntime/File/FileMD5FlagsTest.cs index db8371190..93487621b 100644 --- a/Test/WindowsRuntime/File/FileMD5FlagsTest.cs +++ b/Test/WindowsRuntime/File/FileMD5FlagsTest.cs @@ -55,7 +55,7 @@ public async Task FileStoreContentMD5TestAsync() CloudFile file = share.GetRootDirectoryReference().GetFileReference("file4"); using (Stream stream = new MemoryStream()) { - await file.UploadFromStreamAsync(stream.AsInputStream(), null, optionsWithMD5, null); + await file.UploadFromStreamAsync(stream, null, optionsWithMD5, null); } await file.FetchAttributesAsync(); Assert.IsNotNull(file.Properties.ContentMD5); @@ -63,7 +63,7 @@ public async Task FileStoreContentMD5TestAsync() file = share.GetRootDirectoryReference().GetFileReference("file5"); using (Stream stream = new MemoryStream()) { - await file.UploadFromStreamAsync(stream.AsInputStream(), null, optionsWithNoMD5, null); + await file.UploadFromStreamAsync(stream, null, optionsWithNoMD5, null); } await file.FetchAttributesAsync(); Assert.IsNull(file.Properties.ContentMD5); @@ -71,14 +71,14 @@ public async Task FileStoreContentMD5TestAsync() file = share.GetRootDirectoryReference().GetFileReference("file6"); using (Stream stream = new MemoryStream()) { - await file.UploadFromStreamAsync(stream.AsInputStream()); + await file.UploadFromStreamAsync(stream); } await file.FetchAttributesAsync(); Assert.IsNull(file.Properties.ContentMD5); } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -113,17 +113,17 @@ public async Task FileDisableContentMD5ValidationTestAsync() CloudFile file = share.GetRootDirectoryReference().GetFileReference("file2"); using (Stream stream = new MemoryStream(buffer)) { - await file.UploadFromStreamAsync(stream.AsInputStream(), null, optionsWithMD5, null); + await file.UploadFromStreamAsync(stream, null, optionsWithMD5, null); } using (Stream stream = new MemoryStream()) { - await file.DownloadToStreamAsync(stream.AsOutputStream(), null, optionsWithMD5, null); - await file.DownloadToStreamAsync(stream.AsOutputStream(), null, optionsWithNoMD5, null); + await file.DownloadToStreamAsync(stream, null, optionsWithMD5, null); + await file.DownloadToStreamAsync(stream, null, optionsWithNoMD5, null); using (var fileStream = await file.OpenReadAsync(null, optionsWithMD5, null)) { - Stream fileStreamForRead = fileStream.AsStreamForRead(); + Stream fileStreamForRead = fileStream; int read; do { @@ -134,7 +134,7 @@ public async Task FileDisableContentMD5ValidationTestAsync() using (var fileStream = await file.OpenReadAsync(null, optionsWithNoMD5, null)) { - Stream fileStreamForRead = fileStream.AsStreamForRead(); + Stream fileStreamForRead = fileStream; int read; do { @@ -148,15 +148,15 @@ public async Task FileDisableContentMD5ValidationTestAsync() OperationContext opContext = new OperationContext(); await TestHelper.ExpectedExceptionAsync( - async () => await file.DownloadToStreamAsync(stream.AsOutputStream(), null, optionsWithMD5, opContext), + async () => await file.DownloadToStreamAsync(stream, null, optionsWithMD5, opContext), opContext, "Downloading a file with invalid MD5 should fail", HttpStatusCode.OK); - await file.DownloadToStreamAsync(stream.AsOutputStream(), null, optionsWithNoMD5, null); + await file.DownloadToStreamAsync(stream, null, optionsWithNoMD5, null); using (var fileStream = await file.OpenReadAsync(null, optionsWithMD5, null)) { - Stream fileStreamForRead = fileStream.AsStreamForRead(); + Stream fileStreamForRead = fileStream; TestHelper.ExpectedException( () => { @@ -172,7 +172,7 @@ await TestHelper.ExpectedExceptionAsync( using (var fileStream = await file.OpenReadAsync(null, optionsWithNoMD5, null)) { - Stream fileStreamForRead = fileStream.AsStreamForRead(); + Stream fileStreamForRead = fileStream; int read; do { @@ -184,7 +184,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/File/FileReadStreamTest.cs b/Test/WindowsRuntime/File/FileReadStreamTest.cs index 6017ee2b2..552826065 100644 --- a/Test/WindowsRuntime/File/FileReadStreamTest.cs +++ b/Test/WindowsRuntime/File/FileReadStreamTest.cs @@ -48,13 +48,13 @@ public async Task FileReadStreamBasicTestAsync() CloudFile file = share.GetRootDirectoryReference().GetFileReference("file1"); using (MemoryStream wholeFile = new MemoryStream(buffer)) { - await file.UploadFromStreamAsync(wholeFile.AsInputStream()); + await file.UploadFromStreamAsync(wholeFile); } using (MemoryStream wholeFile = new MemoryStream(buffer)) { var readStream = await file.OpenReadAsync(); - using (Stream fileStream = readStream.AsStreamForRead()) + using (Stream fileStream = readStream) { TestHelper.AssertStreamsAreEqual(wholeFile, fileStream); } @@ -62,7 +62,7 @@ public async Task FileReadStreamBasicTestAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -85,13 +85,13 @@ public async Task FileReadLockToETagTestAsync() file.StreamMinimumReadSizeInBytes = outBuffer.Length; using (MemoryStream wholeFile = new MemoryStream(buffer)) { - await file.UploadFromStreamAsync(wholeFile.AsInputStream()); + await file.UploadFromStreamAsync(wholeFile); } OperationContext opContext = new OperationContext(); using (var fileStream = await file.OpenReadAsync(null, null, opContext)) { - Stream fileStreamForRead = fileStream.AsStreamForRead(); + Stream fileStreamForRead = fileStream; await fileStreamForRead.ReadAsync(outBuffer, 0, outBuffer.Length); await file.SetMetadataAsync(); await ExpectedExceptionAsync( @@ -104,7 +104,7 @@ await ExpectedExceptionAsync( opContext = new OperationContext(); using (var fileStream = await file.OpenReadAsync(null, null, opContext)) { - Stream fileStreamForRead = fileStream.AsStreamForRead(); + Stream fileStreamForRead = fileStream; long length = fileStreamForRead.Length; await file.SetMetadataAsync(); await ExpectedExceptionAsync( @@ -127,7 +127,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -170,16 +170,17 @@ private static async Task ExpectedExceptionAsync(Func operation, Operation Assert.Fail("No exception received while expecting {0}: {1}", expectedStatusCode, operationDescription); } -#if ASPNET_K - private static async Task FileReadStreamSeekAndCompareAsync(Stream fileStream, byte[] bufferToCompare, ulong offset, uint readSize, uint expectedReadCount) -#else +#if WINDOWS_RT private static async Task FileReadStreamSeekAndCompareAsync(IRandomAccessStreamWithContentType fileStream, byte[] bufferToCompare, ulong offset, uint readSize, uint expectedReadCount) +#else + private static async Task FileReadStreamSeekAndCompareAsync(Stream fileStream, byte[] bufferToCompare, ulong offset, uint readSize, uint expectedReadCount) #endif { + byte[] testBuffer = new byte[readSize]; #if ASPNET_K - int actualReadSize = await fileStream.ReadAsync(testBuffer, 0, (int)readSize); + int actualReadSize = await fileStream.ReadAsync(testBuffer, 0, (int) readSize); Assert.AreEqual(expectedReadCount, actualReadSize); #else IBuffer testBufferAsIBuffer = testBuffer.AsBuffer(); @@ -196,10 +197,10 @@ private static async Task FileReadStreamSeekAndCompareAsync(IRandomAccessS return expectedReadCount; } -#if ASPNET_K - private static async Task FileReadStreamSeekTestAsync(Stream fileStream, long streamReadSize, byte[] bufferToCompare) -#else +#if WINDOWS_RT private static async Task FileReadStreamSeekTestAsync(IRandomAccessStreamWithContentType fileStream, long streamReadSize, byte[] bufferToCompare) +#else + private static async Task FileReadStreamSeekTestAsync(Stream fileStream, long streamReadSize, byte[] bufferToCompare) #endif { int attempts = 1; @@ -234,7 +235,7 @@ private static async Task FileReadStreamSeekTestAsync(IRandomAccessStreamWi Assert.AreEqual(position, fileStream.Position); position = (ulong)(streamReadSize + 4096 - 512); fileStream.Seek(position); -#if ASPNET_K +#if ASPNET_K //don't know why adding these two line will pass, but this this the same as the desktop test Assert.AreEqual(position, fileStream.Position); position += await FileReadStreamSeekAndCompareAsync(fileStream, bufferToCompare, position, 1024, 512); @@ -276,19 +277,23 @@ public async Task FileReadStreamSeekTestAsync() file.StreamMinimumReadSizeInBytes = 2 * 1024 * 1024; using (MemoryStream wholeFile = new MemoryStream(buffer)) { - await file.UploadFromStreamAsync(wholeFile.AsInputStream()); + await file.UploadFromStreamAsync(wholeFile); } OperationContext opContext = new OperationContext(); using (var fileStream = await file.OpenReadAsync(null, null, opContext)) { +#if ASPNET_K int attempts = await FileReadStreamSeekTestAsync(fileStream, file.StreamMinimumReadSizeInBytes, buffer); +#else + int attempts = await FileReadStreamSeekTestAsync(fileStream.AsRandomAccessStream(), file.StreamMinimumReadSizeInBytes, buffer); +#endif TestHelper.AssertNAttempts(opContext, attempts); } } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/File/FileSASTests.cs b/Test/WindowsRuntime/File/FileSASTests.cs index d4c4e33bd..2c7b2aab5 100644 --- a/Test/WindowsRuntime/File/FileSASTests.cs +++ b/Test/WindowsRuntime/File/FileSASTests.cs @@ -55,7 +55,7 @@ public void Dispose() public void MyTestInitialize() { this.testShare = GetRandomShareReference(); - this.testShare.CreateAsync().AsTask().Wait(); + this.testShare.CreateAsync().Wait(); if (TestBase.FileBufferManager != null) { @@ -66,7 +66,7 @@ public void MyTestInitialize() [TestCleanup] public void MyTestCleanup() { - this.testShare.DeleteAsync().AsTask().Wait(); + this.testShare.DeleteAsync().Wait(); this.testShare = null; if (TestBase.FileBufferManager != null) { @@ -478,7 +478,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } diff --git a/Test/WindowsRuntime/File/FileStreamTests.cs b/Test/WindowsRuntime/File/FileStreamTests.cs index 2b50f430a..9b5056f08 100644 --- a/Test/WindowsRuntime/File/FileStreamTests.cs +++ b/Test/WindowsRuntime/File/FileStreamTests.cs @@ -45,10 +45,10 @@ public async Task FileSeekTestAsync() CloudFile file = share.GetRootDirectoryReference().GetFileReference("file1"); using (MemoryStream srcStream = new MemoryStream(buffer)) { - await file.UploadFromStreamAsync(srcStream.AsInputStream(), null, null, null); + await file.UploadFromStreamAsync(srcStream, null, null, null); using (var fileStream = await file.OpenReadAsync()) { - Stream fileStreamForRead = fileStream.AsStreamForRead(); + Stream fileStreamForRead = fileStream; fileStreamForRead.Seek(2048, 0); byte[] buff = new byte[100]; int numRead = await fileStreamForRead.ReadAsync(buff, 0, 100); @@ -58,7 +58,7 @@ public async Task FileSeekTestAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -79,13 +79,13 @@ public async Task FileOpenWriteTestAsync() CloudFile file = share.GetRootDirectoryReference().GetFileReference("file1"); using (var fileStream = await file.OpenWriteAsync(2048)) { - Stream fileStreamForWrite = fileStream.AsStreamForWrite(); + Stream fileStreamForWrite = fileStream; await fileStreamForWrite.WriteAsync(buffer, 0, 2048); await fileStreamForWrite.FlushAsync(); byte[] testBuffer = new byte[2048]; MemoryStream dstStream = new MemoryStream(testBuffer); - await file.DownloadRangeToStreamAsync(dstStream.AsOutputStream(), null, null); + await file.DownloadRangeToStreamAsync(dstStream, null, null); MemoryStream memStream = new MemoryStream(buffer); TestHelper.AssertStreamsAreEqual(memStream, dstStream); @@ -93,7 +93,7 @@ public async Task FileOpenWriteTestAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -113,10 +113,10 @@ public async Task FileOpenReadTestAsync() CloudFile file = share.GetRootDirectoryReference().GetFileReference("file1"); using (MemoryStream srcStream = new MemoryStream(buffer)) { - await file.UploadFromStreamAsync(srcStream.AsInputStream()); + await file.UploadFromStreamAsync(srcStream); var dstStream = await file.OpenReadAsync(); - using (Stream dstStreamForRead = dstStream.AsStreamForRead()) + using (Stream dstStreamForRead = dstStream) { TestHelper.AssertStreamsAreEqual(srcStream, dstStreamForRead); } @@ -124,7 +124,7 @@ public async Task FileOpenReadTestAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -145,21 +145,21 @@ public async Task FileOpenReadWriteTestAsync() using (var fileStream = await file.OpenWriteAsync(2048)) { - Stream fileStreamForWrite = fileStream.AsStreamForWrite(); + Stream fileStreamForWrite = fileStream; await fileStreamForWrite.WriteAsync(buffer, 0, 2048); await fileStreamForWrite.FlushAsync(); } using (var dstStream = await file.OpenReadAsync()) { - Stream dstStreamForRead = dstStream.AsStreamForRead(); + Stream dstStreamForRead = dstStream; MemoryStream memoryStream = new MemoryStream(buffer); TestHelper.AssertStreamsAreEqual(memoryStream, dstStreamForRead); } } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -181,7 +181,7 @@ public async Task FileOpenWriteSeekReadTestAsync() MemoryStream memoryStream = new MemoryStream(buffer); using (var fileStream = await file.OpenWriteAsync(2048)) { - Stream fileStreamForWrite = fileStream.AsStreamForWrite(); + Stream fileStreamForWrite = fileStream; await fileStreamForWrite.WriteAsync(buffer, 0, 2048); Assert.AreEqual(fileStreamForWrite.Position, 2048); @@ -201,13 +201,13 @@ public async Task FileOpenWriteSeekReadTestAsync() using (var dstStream = await file.OpenReadAsync()) { - Stream dstStreamForRead = dstStream.AsStreamForRead(); + Stream dstStreamForRead = dstStream; TestHelper.AssertStreamsAreEqual(memoryStream, dstStreamForRead); } } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -229,7 +229,7 @@ public async Task FileReadWhenOpenWriteAsync() MemoryStream memoryStream = new MemoryStream(buffer); using (var fileStream = await file.OpenWriteAsync(2048)) { - Stream fileStreamForWrite = fileStream.AsStreamForWrite(); + Stream fileStreamForWrite = fileStream; await fileStreamForWrite.WriteAsync(buffer, 0, 2048); byte[] testBuffer = new byte[2048]; try @@ -246,7 +246,7 @@ public async Task FileReadWhenOpenWriteAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -267,12 +267,12 @@ public async Task FileWriteWhenOpenReadAsync() CloudFile file = share.GetRootDirectoryReference().GetFileReference("file1"); using (MemoryStream srcStream = new MemoryStream(buffer)) { - await file.UploadFromStreamAsync(srcStream.AsInputStream()); + await file.UploadFromStreamAsync(srcStream); bool thrown = false; byte[] testBuffer = new byte[2048]; using (var fileStream = await file.OpenReadAsync()) { - Stream fileStreamForRead = fileStream.AsStreamForRead(); + Stream fileStreamForRead = fileStream; try { await fileStreamForRead.WriteAsync(testBuffer, 0, 2048); @@ -288,7 +288,7 @@ public async Task FileWriteWhenOpenReadAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/File/FileTestBase.cs b/Test/WindowsRuntime/File/FileTestBase.cs index c28346b3b..aa7e1b0c7 100644 --- a/Test/WindowsRuntime/File/FileTestBase.cs +++ b/Test/WindowsRuntime/File/FileTestBase.cs @@ -73,7 +73,7 @@ public static async Task UploadTextAsync(CloudFile file, string text, Encoding e stream.Write(textAsBytes, 0, textAsBytes.Length); stream.Seek(0, SeekOrigin.Begin); file.ServiceClient.DefaultRequestOptions.ParallelOperationThreadCount = 2; - await file.UploadFromStreamAsync(stream.AsInputStream(), accessCondition, options, operationContext); + await file.UploadFromStreamAsync(stream, accessCondition, options, operationContext); } } @@ -81,7 +81,7 @@ public static async Task DownloadTextAsync(CloudFile file, Encoding enco { using (MemoryStream stream = new MemoryStream()) { - await file.DownloadToStreamAsync(stream.AsOutputStream(), accessCondition, options, operationContext); + await file.DownloadToStreamAsync(stream, accessCondition, options, operationContext); return encoding.GetString(stream.ToArray(), 0, (int)stream.Length); } } diff --git a/Test/WindowsRuntime/File/FileUploadDownloadTest.cs b/Test/WindowsRuntime/File/FileUploadDownloadTest.cs index 270bff0f0..d6bf5909f 100644 --- a/Test/WindowsRuntime/File/FileUploadDownloadTest.cs +++ b/Test/WindowsRuntime/File/FileUploadDownloadTest.cs @@ -52,13 +52,13 @@ public void Dispose() public void TestInitialize() { this.testShare = GetRandomShareReference(); - this.testShare.CreateIfNotExistsAsync().AsTask().Wait(); + this.testShare.CreateIfNotExistsAsync().Wait(); } [TestCleanup] public void TestCleanup() { - this.testShare.DeleteIfExistsAsync().AsTask().Wait(); + this.testShare.DeleteIfExistsAsync().Wait(); } [TestMethod] @@ -78,25 +78,25 @@ public async Task FileDownloadToStreamRangeTestAsync() CloudFile file = share.GetRootDirectoryReference().GetFileReference("file1"); using (MemoryStream wholeFile = new MemoryStream(buffer)) { - await file.UploadFromStreamAsync(wholeFile.AsInputStream()); + await file.UploadFromStreamAsync(wholeFile); byte[] testBuffer = new byte[1024]; MemoryStream fileStream = new MemoryStream(testBuffer); Exception ex = await TestHelper.ExpectedExceptionAsync( - async () => await file.DownloadRangeToStreamAsync(fileStream.AsOutputStream(), 0, 0), + async () => await file.DownloadRangeToStreamAsync(fileStream, 0, 0), "Requesting 0 bytes when downloading range should not work"); - Assert.IsInstanceOfType(ex.InnerException.InnerException, typeof(ArgumentOutOfRangeException)); - await file.DownloadRangeToStreamAsync(fileStream.AsOutputStream(), 0, 1024); + Assert.IsInstanceOfType(ex.InnerException, typeof(ArgumentOutOfRangeException)); + await file.DownloadRangeToStreamAsync(fileStream, 0, 1024); Assert.AreEqual(fileStream.Position, 1024); TestHelper.AssertStreamsAreEqualAtIndex(fileStream, wholeFile, 0, 0, 1024); CloudFile file2 = share.GetRootDirectoryReference().GetFileReference("file1"); MemoryStream fileStream2 = new MemoryStream(testBuffer); ex = await TestHelper.ExpectedExceptionAsync( - async () => await file2.DownloadRangeToStreamAsync(fileStream.AsOutputStream(), 1024, 0), + async () => await file2.DownloadRangeToStreamAsync(fileStream, 1024, 0), "Requesting 0 bytes when downloading range should not work"); - Assert.IsInstanceOfType(ex.InnerException.InnerException, typeof(ArgumentOutOfRangeException)); - await file2.DownloadRangeToStreamAsync(fileStream2.AsOutputStream(), 1024, 1024); + Assert.IsInstanceOfType(ex.InnerException, typeof(ArgumentOutOfRangeException)); + await file2.DownloadRangeToStreamAsync(fileStream2, 1024, 1024); TestHelper.AssertStreamsAreEqualAtIndex(fileStream2, wholeFile, 0, 1024, 1024); AssertAreEqual(file, file2); @@ -104,7 +104,7 @@ public async Task FileDownloadToStreamRangeTestAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -125,16 +125,16 @@ public async Task FileUploadFromStreamTestAsync() CloudFile file = share.GetRootDirectoryReference().GetFileReference("file1"); using (MemoryStream srcStream = new MemoryStream(buffer)) { - await file.UploadFromStreamAsync(srcStream.AsInputStream()); + await file.UploadFromStreamAsync(srcStream); byte[] testBuffer = new byte[2048]; MemoryStream dstStream = new MemoryStream(testBuffer); - await file.DownloadRangeToStreamAsync(dstStream.AsOutputStream(), null, null); + await file.DownloadRangeToStreamAsync(dstStream, null, null); TestHelper.AssertStreamsAreEqual(srcStream, dstStream); } } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -159,14 +159,14 @@ public async Task FileUploadWithoutMD5ValidationAndStoreFileContentTestAsync() OperationContext context = new OperationContext(); using (MemoryStream srcStream = new MemoryStream(buffer)) { - await file.UploadFromStreamAsync(srcStream.AsInputStream(), null, options, context); + await file.UploadFromStreamAsync(srcStream, null, options, context); await file.FetchAttributesAsync(); string md5 = file.Properties.ContentMD5; file.Properties.ContentMD5 = "MDAwMDAwMDA="; await file.SetPropertiesAsync(null, options, context); byte[] testBuffer = new byte[2048]; MemoryStream dstStream = new MemoryStream(testBuffer); - await TestHelper.ExpectedExceptionAsync(async () => await file.DownloadRangeToStreamAsync(dstStream.AsOutputStream(), null, null, null, options, context), + await TestHelper.ExpectedExceptionAsync(async () => await file.DownloadRangeToStreamAsync(dstStream, null, null, null, options, context), context, "Try to Download a stream with a corrupted md5 and DisableMD5Validation set to false", HttpStatusCode.OK); @@ -175,12 +175,12 @@ await TestHelper.ExpectedExceptionAsync(async () => await file.DownloadRangeToSt await file.SetPropertiesAsync(null, options, context); byte[] testBuffer2 = new byte[2048]; MemoryStream dstStream2 = new MemoryStream(testBuffer2); - await file.DownloadRangeToStreamAsync(dstStream2.AsOutputStream(), null, null, null, options, context); + await file.DownloadRangeToStreamAsync(dstStream2, null, null, null, options, context); } } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -215,10 +215,10 @@ private async Task DoUploadDownloadFileAsync(CloudFile file, int fileSize) await localFile.WriteAsync(buffer, 0, buffer.Length); } - await file.UploadFromFileAsync(inputFileName, FileMode.Open); + await file.UploadFromFileAsync(inputFileName); OperationContext context = new OperationContext(); - await file.UploadFromFileAsync(inputFileName, FileMode.Open, null, null, context); + await file.UploadFromFileAsync(inputFileName, null, null, context); Assert.IsNotNull(context.LastResult.ServiceRequestID); context = new OperationContext(); @@ -344,12 +344,12 @@ private async Task DoDownloadToByteArrayAsyncTest(CloudFile file, int fileSize, { if (!isOverload) { - await file.UploadFromStreamAsync(originalFile.AsInputStream()); + await file.UploadFromStreamAsync(originalFile); downloadLength = await file.DownloadToByteArrayAsync(resultBuffer, bufferOffset); } else { - await file.UploadFromStreamAsync(originalFile.AsInputStream()); + await file.UploadFromStreamAsync(originalFile); OperationContext context = new OperationContext(); downloadLength = await file.DownloadToByteArrayAsync(resultBuffer, bufferOffset, null, null, context); } @@ -447,12 +447,12 @@ private async Task DoDownloadRangeToByteArrayAsyncTest(CloudFile file, int fileS { if (!isOverload) { - await file.UploadFromStreamAsync(originalFile.AsInputStream()); + await file.UploadFromStreamAsync(originalFile); downloadLength = await file.DownloadRangeToByteArrayAsync(resultBuffer, bufferOffset, fileOffset, length); } else { - await file.UploadFromStreamAsync(originalFile.AsInputStream()); + await file.UploadFromStreamAsync(originalFile); OperationContext context = new OperationContext(); downloadLength = await file.DownloadRangeToByteArrayAsync(resultBuffer, bufferOffset, fileOffset, length, null, null, context); } @@ -482,7 +482,54 @@ private async Task DoDownloadRangeToByteArrayAsyncTest(CloudFile file, int fileS } } -#region Negative tests +#if ASPNET_K + [TestMethod] + [Description("Upload from file to a file with file cleanup for failure cases")] + [TestCategory(ComponentCategory.File)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] + public async Task CloudFileUploadDownloadFileAsyncWithFailures() + { + CloudFile file = this.testShare.GetRootDirectoryReference().GetFileReference("file1"); + CloudFile nullFile = this.testShare.GetRootDirectoryReference().GetFileReference("null"); + await this.DoUploadDownloadFileAsync(file, 0); + await this.DoUploadDownloadFileAsync(file, 4096); + + await TestHelper.ExpectedExceptionAsync( + async () => await file.UploadFromFileAsync("non_existentCloudFileUploadDownloadFileAsyncWithFailures.file"), + "UploadFromFile requires an existing file"); + + await TestHelper.ExpectedExceptionAsync( + async () => await nullFile.DownloadToFileAsync("garbageCloudFileUploadDownloadFileAsyncWithFailures.file", FileMode.Create), + "DownloadToFile should not leave an empty file behind after failing."); + Assert.IsFalse(System.IO.File.Exists("garbageCloudFileUploadDownloadFileAsyncWithFailures.file")); + + await TestHelper.ExpectedExceptionAsync( + async () => await nullFile.DownloadToFileAsync("garbageCloudFileUploadDownloadFileAsyncWithFailures.file", FileMode.CreateNew), + "DownloadToFile should not leave an empty file behind after failing."); + Assert.IsFalse(System.IO.File.Exists("garbageCloudFileUploadDownloadFileAsyncWithFailures.file")); + + byte[] buffer = GetRandomBuffer(100); + using (FileStream systemFile = new FileStream("garbageCloudFileUploadDownloadFileAsyncWithFailures.file", FileMode.Create, FileAccess.Write)) + { + systemFile.Write(buffer, 0, buffer.Length); + } + await TestHelper.ExpectedExceptionAsync( + async () => await nullFile.DownloadToFileAsync("garbageCloudFileUploadDownloadFileAsyncWithFailures.file", FileMode.CreateNew), + "DownloadToFileAsync should leave an empty file behind after failing, depending on the mode."); + Assert.IsTrue(System.IO.File.Exists("garbageCloudFileUploadDownloadFileAsyncWithFailures.file")); + System.IO.File.Delete("garbageCloudFileUploadDownloadFileAsyncWithFailures.file"); + + await TestHelper.ExpectedExceptionAsync( + async () => await nullFile.DownloadToFileAsync("garbageCloudFileUploadDownloadFileAsyncWithFailures.file", FileMode.Append), + "DownloadToFile should leave an empty file behind after failing depending on file mode."); + Assert.IsTrue(System.IO.File.Exists("garbageCloudFileUploadDownloadFileAsyncWithFailures.file")); + System.IO.File.Delete("garbageCloudFileUploadDownloadFileAsyncWithFailures.file"); + } +#endif + + #region Negative tests [TestMethod] // [Description("Single put file and get file")] [TestCategory(ComponentCategory.File)] @@ -504,19 +551,19 @@ private async Task DoDownloadRangeToByteArrayNegativeTestsAsync(CloudFile file) using (MemoryStream stream = new MemoryStream(buffer)) { - await file.UploadFromStreamAsync(stream.AsInputStream()); + await file.UploadFromStreamAsync(stream); OperationContext context = new OperationContext(); await TestHelper.ExpectedExceptionAsync(async () => await file.DownloadRangeToByteArrayAsync(resultBuffer, 0, 1024, 1, null, null, context), context, "Try invalid length", HttpStatusCode.RequestedRangeNotSatisfiable); - WrappedStorageException ex = await TestHelper.ExpectedExceptionAsync(async () => await file.DownloadToByteArrayAsync(resultBuffer, 1024), "Provide invalid offset"); - Assert.IsInstanceOfType(ex.InnerException.InnerException, typeof(NotSupportedException)); - ex = await TestHelper.ExpectedExceptionAsync(async () => await file.DownloadRangeToByteArrayAsync(resultBuffer, 1023, 0, 2), "Should fail when offset + length required is greater than size of the buffer"); - Assert.IsInstanceOfType(ex.InnerException.InnerException, typeof(NotSupportedException)); - ex = await TestHelper.ExpectedExceptionAsync(async () => await file.DownloadRangeToByteArrayAsync(resultBuffer, 0, 0, -10), "Fail when a negative length is specified"); - Assert.IsInstanceOfType(ex.InnerException.InnerException, typeof(ArgumentOutOfRangeException)); + StorageException ex = await TestHelper.ExpectedExceptionAsync(async () => await file.DownloadToByteArrayAsync(resultBuffer, 1024), "Provide invalid offset"); + Assert.IsInstanceOfType(ex.InnerException, typeof(NotSupportedException)); + ex = await TestHelper.ExpectedExceptionAsync(async () => await file.DownloadRangeToByteArrayAsync(resultBuffer, 1023, 0, 2), "Should fail when offset + length required is greater than size of the buffer"); + Assert.IsInstanceOfType(ex.InnerException, typeof(NotSupportedException)); + ex = await TestHelper.ExpectedExceptionAsync(async () => await file.DownloadRangeToByteArrayAsync(resultBuffer, 0, 0, -10), "Fail when a negative length is specified"); + Assert.IsInstanceOfType(ex.InnerException, typeof(ArgumentOutOfRangeException)); await TestHelper.ExpectedExceptionAsync(async () => await file.DownloadRangeToByteArrayAsync(resultBuffer, -10, 0, 20), "Fail if a negative offset is provided"); - ex = await TestHelper.ExpectedExceptionAsync(async () => await file.DownloadRangeToByteArrayAsync(resultBuffer, 0, -10, 20), "Fail if a negative file offset is provided"); - Assert.IsInstanceOfType(ex.InnerException.InnerException, typeof(ArgumentOutOfRangeException)); + ex = await TestHelper.ExpectedExceptionAsync(async () => await file.DownloadRangeToByteArrayAsync(resultBuffer, 0, -10, 20), "Fail if a negative file offset is provided"); + Assert.IsInstanceOfType(ex.InnerException, typeof(ArgumentOutOfRangeException)); } } #endregion diff --git a/Test/WindowsRuntime/File/FileWriteStreamTest.cs b/Test/WindowsRuntime/File/FileWriteStreamTest.cs index 8b8501a99..941227959 100644 --- a/Test/WindowsRuntime/File/FileWriteStreamTest.cs +++ b/Test/WindowsRuntime/File/FileWriteStreamTest.cs @@ -70,7 +70,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } @@ -174,7 +174,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } */ @@ -212,7 +212,7 @@ public async Task FileWriteStreamBasicTestAsync() }; using (var writeStream = await file.OpenWriteAsync(buffer.Length * 3, null, options, null)) { - Stream fileStream = writeStream.AsStreamForWrite(); + Stream fileStream = writeStream; for (int i = 0; i < 3; i++) { @@ -247,7 +247,7 @@ await TestHelper.ExpectedExceptionAsync( using (var writeStream = await file.OpenWriteAsync(null)) { - Stream fileStream = writeStream.AsStreamForWrite(); + Stream fileStream = writeStream; fileStream.Seek(buffer.Length / 2, SeekOrigin.Begin); wholeFile.Seek(buffer.Length / 2, SeekOrigin.Begin); @@ -274,7 +274,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - share.DeleteAsync().AsTask().Wait(); + share.DeleteAsync().Wait(); } } @@ -299,7 +299,7 @@ public async Task FileWriteStreamRandomSeekTestAsync() { using (var writeStream = await file.OpenWriteAsync(buffer.Length)) { - Stream fileStream = writeStream.AsStreamForWrite(); + Stream fileStream = writeStream; await fileStream.WriteAsync(buffer, 0, buffer.Length); await wholeFile.WriteAsync(buffer, 0, buffer.Length); Random random = new Random(); @@ -326,7 +326,7 @@ public async Task FileWriteStreamRandomSeekTestAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } @@ -355,7 +355,7 @@ public async Task FileWriteStreamFlushTestAsync() { for (int i = 0; i < 3; i++) { - await fileStream.WriteAsync(buffer.AsBuffer()); + await fileStream.WriteAsync(buffer, 0, buffer.Length); await wholeFile.WriteAsync(buffer, 0, buffer.Length); } @@ -374,7 +374,7 @@ public async Task FileWriteStreamFlushTestAsync() Assert.AreEqual(3, opContext.RequestResults.Count); - await fileStream.WriteAsync(buffer.AsBuffer()); + await fileStream.WriteAsync(buffer, 0, buffer.Length); await wholeFile.WriteAsync(buffer, 0, buffer.Length); Assert.AreEqual(3, opContext.RequestResults.Count); @@ -395,7 +395,7 @@ public async Task FileWriteStreamFlushTestAsync() } finally { - share.DeleteIfExistsAsync().AsTask().Wait(); + share.DeleteIfExistsAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Microsoft.WindowsAzure.StorageRT.Test.csproj b/Test/WindowsRuntime/Microsoft.WindowsAzure.StorageRT.Test.csproj index a1582262b..abedd1ba8 100644 --- a/Test/WindowsRuntime/Microsoft.WindowsAzure.StorageRT.Test.csproj +++ b/Test/WindowsRuntime/Microsoft.WindowsAzure.StorageRT.Test.csproj @@ -88,13 +88,11 @@ - - @@ -113,7 +111,6 @@ - @@ -158,12 +155,12 @@ - + TestConfigurations.xml Always Designer - - + + diff --git a/Test/WindowsRuntime/Properties/AssemblyInfo.cs b/Test/WindowsRuntime/Properties/AssemblyInfo.cs index f90e66740..656e8a61a 100644 --- a/Test/WindowsRuntime/Properties/AssemblyInfo.cs +++ b/Test/WindowsRuntime/Properties/AssemblyInfo.cs @@ -24,6 +24,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("6.2.2.0")] -[assembly: AssemblyFileVersion("6.2.2.0")] +[assembly: AssemblyVersion("7.0.0.0")] +[assembly: AssemblyFileVersion("7.0.0.0")] [assembly: ComVisible(false)] diff --git a/Test/WindowsRuntime/Queue/CloudQueueMessageTest.cs b/Test/WindowsRuntime/Queue/CloudQueueMessageTest.cs index 5cf637f59..63c86cb5c 100644 --- a/Test/WindowsRuntime/Queue/CloudQueueMessageTest.cs +++ b/Test/WindowsRuntime/Queue/CloudQueueMessageTest.cs @@ -95,7 +95,7 @@ public async Task CloudQueueCreateMessageAsync() } finally { - queue.DeleteIfExistsAsync().AsTask().Wait(); + queue.DeleteIfExistsAsync().Wait(); } } @@ -147,7 +147,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - queue.DeleteIfExistsAsync().AsTask().Wait(); + queue.DeleteIfExistsAsync().Wait(); } } diff --git a/Test/WindowsRuntime/Queue/CloudQueueTest.cs b/Test/WindowsRuntime/Queue/CloudQueueTest.cs index da2fb8dab..460d334c4 100644 --- a/Test/WindowsRuntime/Queue/CloudQueueTest.cs +++ b/Test/WindowsRuntime/Queue/CloudQueueTest.cs @@ -106,7 +106,7 @@ public async Task CloudQueueCreateIfNotExistsAsync() } finally { - queue.DeleteIfExistsAsync().AsTask().Wait(); + queue.DeleteIfExistsAsync().Wait(); } } @@ -317,7 +317,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - queue.DeleteIfExistsAsync().AsTask().Wait(); + queue.DeleteIfExistsAsync().Wait(); } } @@ -382,7 +382,7 @@ public async Task QueueRegionalSASTestAsync() #else ApplicationLanguages.PrimaryLanguageOverride = currentPrimaryLanguage; #endif - queue.DeleteAsync().AsTask().Wait(); + queue.DeleteAsync().Wait(); } } } diff --git a/Test/WindowsRuntime/Queue/QueueAnalyticsUnitTests.cs b/Test/WindowsRuntime/Queue/QueueAnalyticsUnitTests.cs index 54ffacb23..70b76f5ee 100644 --- a/Test/WindowsRuntime/Queue/QueueAnalyticsUnitTests.cs +++ b/Test/WindowsRuntime/Queue/QueueAnalyticsUnitTests.cs @@ -78,7 +78,7 @@ public TestContext TestContext public static void MyClassInitialize(TestContext testContext) { client = GenerateCloudQueueClient(); - startProperties = client.GetServicePropertiesAsync().AsTask().Result; + startProperties = client.GetServicePropertiesAsync().Result; } // Use ClassCleanup to run code after all tests in a class have run @@ -88,7 +88,7 @@ public static void MyClassCleanup() #if ASPNET_K client.SetServicePropertiesAsync(startProperties).Wait(); #else - client.SetServicePropertiesAsync(startProperties).AsTask().Wait(); + client.SetServicePropertiesAsync(startProperties).Wait(); #endif } @@ -670,7 +670,7 @@ private async Task TestCorsRulesAsync(CloudQueueClient client, OperationContext private static ServiceProperties DefaultServiceProperties() { - ServiceProperties props = new ServiceProperties(); + ServiceProperties props = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties(), new CorsProperties()); props.Logging.LoggingOperations = LoggingOperations.None; props.Logging.RetentionDays = null; diff --git a/Test/WindowsRuntime/Table/CloudTableCRUDUnitTests.cs b/Test/WindowsRuntime/Table/CloudTableCRUDUnitTests.cs index a490ab637..ac39e9d49 100644 --- a/Test/WindowsRuntime/Table/CloudTableCRUDUnitTests.cs +++ b/Test/WindowsRuntime/Table/CloudTableCRUDUnitTests.cs @@ -137,7 +137,7 @@ private async Task DoCloudTableCreateAsync(TablePayloadFormat payloadFormat) } finally { - tableRef.DeleteIfExistsAsync().AsTask().Wait(); + tableRef.DeleteIfExistsAsync().Wait(); } } @@ -178,7 +178,7 @@ private async Task DoCloudTableCreateAlreadyExistsAsync(TablePayloadFormat paylo } finally { - tableRef.DeleteIfExistsAsync().AsTask().Wait(); + tableRef.DeleteIfExistsAsync().Wait(); } } @@ -214,7 +214,7 @@ private async Task DoCloudTableCreateIfNotExistsAsync(TablePayloadFormat payload } finally { - tableRef.DeleteIfExistsAsync().AsTask().Wait(); + tableRef.DeleteIfExistsAsync().Wait(); } } @@ -251,7 +251,7 @@ private async Task DoCloudTableDeleteAsync(TablePayloadFormat payloadFormat) } finally { - tableRef.DeleteIfExistsAsync().AsTask().Wait(); + tableRef.DeleteIfExistsAsync().Wait(); } } @@ -291,7 +291,7 @@ private async Task DoCloudTableDeleteWhenNotExistAsync(TablePayloadFormat payloa } finally { - tableRef.DeleteIfExistsAsync().AsTask().Wait(); + tableRef.DeleteIfExistsAsync().Wait(); } } @@ -329,7 +329,7 @@ private async Task DoCloudTableDeleteIfExistsAsync(TablePayloadFormat payloadFor } finally { - tableRef.DeleteIfExistsAsync().AsTask().Wait(); + tableRef.DeleteIfExistsAsync().Wait(); } } @@ -366,7 +366,7 @@ private async Task DoCloudTableExistsAsync(TablePayloadFormat payloadFormat) } finally { - tableRef.DeleteIfExistsAsync().AsTask().Wait(); + tableRef.DeleteIfExistsAsync().Wait(); } } diff --git a/Test/WindowsRuntime/Table/CloudTableClientTest.cs b/Test/WindowsRuntime/Table/CloudTableClientTest.cs index 0b3156bb7..663dc18d0 100644 --- a/Test/WindowsRuntime/Table/CloudTableClientTest.cs +++ b/Test/WindowsRuntime/Table/CloudTableClientTest.cs @@ -83,7 +83,7 @@ public static void MyClassInitialize(TestContext testContext) for (int m = 0; m < 20; m++) { CloudTable tableRef = tableClient.GetTableReference(GenerateRandomTableName()); - tableRef.CreateIfNotExistsAsync().AsTask().Wait(); + tableRef.CreateIfNotExistsAsync().Wait(); createdTables.Add(tableRef); } @@ -92,7 +92,7 @@ public static void MyClassInitialize(TestContext testContext) for (int m = 0; m < 20; m++) { CloudTable tableRef = tableClient.GetTableReference(prefixTablesPrefix + m.ToString()); - tableRef.CreateIfNotExistsAsync().AsTask().Wait(); + tableRef.CreateIfNotExistsAsync().Wait(); createdTables.Add(tableRef); } } @@ -107,7 +107,7 @@ public static void MyClassCleanup() { try { - t.DeleteIfExistsAsync().AsTask().Wait(); + t.DeleteIfExistsAsync().Wait(); } catch (Exception) { diff --git a/Test/WindowsRuntime/Table/SAS/TableSasFunctionalTests.cs b/Test/WindowsRuntime/Table/SAS/TableSasFunctionalTests.cs index 422bfc003..af3e7037b 100644 --- a/Test/WindowsRuntime/Table/SAS/TableSasFunctionalTests.cs +++ b/Test/WindowsRuntime/Table/SAS/TableSasFunctionalTests.cs @@ -196,7 +196,7 @@ public async Task TableGetSetPermissionTestAsync() } finally { - table.DeleteIfExistsAsync().AsTask().Wait(); + table.DeleteIfExistsAsync().Wait(); } } diff --git a/Test/WindowsRuntime/Table/SAS/TableSasUnitTests.cs b/Test/WindowsRuntime/Table/SAS/TableSasUnitTests.cs index a7c796e05..d756f9796 100644 --- a/Test/WindowsRuntime/Table/SAS/TableSasUnitTests.cs +++ b/Test/WindowsRuntime/Table/SAS/TableSasUnitTests.cs @@ -167,7 +167,7 @@ public async Task TableSASConstructorsAsync() } finally { - table.DeleteIfExistsAsync().AsTask().Wait(); + table.DeleteIfExistsAsync().Wait(); } } @@ -212,7 +212,7 @@ public async Task TableSetGetPermissionsAsync() } finally { - table.DeleteIfExistsAsync().AsTask().Wait(); + table.DeleteIfExistsAsync().Wait(); } } @@ -285,7 +285,7 @@ public async Task TableSASNullAccessPolicyAsync() } finally { - table.DeleteIfExistsAsync().AsTask().Wait(); + table.DeleteIfExistsAsync().Wait(); } } @@ -471,7 +471,7 @@ internal async Task TestTableSasWithRange( } finally { - table.DeleteIfExistsAsync().AsTask().Wait(); + table.DeleteIfExistsAsync().Wait(); } } @@ -499,7 +499,7 @@ private async Task TestPointQuery( Action queryDelegate = (tableEntity, ctx) => { - Task retrieveTask = testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.Retrieve(tableEntity.PartitionKey, tableEntity.RowKey), null, ctx).AsTask(); + Task retrieveTask = testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.Retrieve(tableEntity.PartitionKey, tableEntity.RowKey), null, ctx); retrieveTask.Wait(); if (expectSuccess) @@ -553,7 +553,7 @@ private async Task TestUpdateMerge( // Merge entity tableEntity.A = "10"; tableEntity.ETag = "*"; - testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.Merge(tableEntity), null, ctx).AsTask().Wait(); + testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.Merge(tableEntity), null, ctx).Wait(); }; bool expectSuccess = (accessPermissions & SharedAccessTablePermissions.Update) != 0; @@ -597,7 +597,7 @@ private async Task TestUpdateReplace( // replace entity tableEntity.A = "20"; tableEntity.ETag = "*"; - testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.Replace(tableEntity), null, ctx).AsTask().Wait(); + testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.Replace(tableEntity), null, ctx).Wait(); }; bool expectSuccess = (accessPermissions & SharedAccessTablePermissions.Update) != 0; @@ -640,7 +640,7 @@ private async Task TestAdd( { // insert entity tableEntity.A = "10"; - testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.Insert(tableEntity), null, ctx).AsTask().Wait(); + testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.Insert(tableEntity), null, ctx).Wait(); }; bool expectSuccess = (accessPermissions & SharedAccessTablePermissions.Add) != 0; @@ -684,7 +684,7 @@ private async Task TestDelete( // delete entity tableEntity.A = "10"; tableEntity.ETag = "*"; - testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.Delete(tableEntity), null, ctx).AsTask().Wait(); + testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.Delete(tableEntity), null, ctx).Wait(); }; bool expectSuccess = (accessPermissions & SharedAccessTablePermissions.Delete) != 0; @@ -727,7 +727,7 @@ private async Task TestUpsertMerge( { // insert or merge entity tableEntity.A = "10"; - testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.InsertOrMerge(tableEntity), null, ctx).AsTask().Wait(); + testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.InsertOrMerge(tableEntity), null, ctx).Wait(); }; SharedAccessTablePermissions upsertPermissions = (SharedAccessTablePermissions.Update | SharedAccessTablePermissions.Add); @@ -771,7 +771,7 @@ private async Task TestUpsertReplace( { // insert or replace entity tableEntity.A = "10"; - testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.InsertOrReplace(tableEntity), null, ctx).AsTask().Wait(); + testClient.GetTableReference(tableName).ExecuteAsync(TableOperation.InsertOrReplace(tableEntity), null, ctx).Wait(); }; SharedAccessTablePermissions upsertPermissions = (SharedAccessTablePermissions.Update | SharedAccessTablePermissions.Add); @@ -999,7 +999,7 @@ public async Task TableSasInvalidOperations() CloudTableClient sasClient = new CloudTableClient(tableClient.BaseUri, new StorageCredentials(sasString)); // Construct a valid set of service properties to upload. - ServiceProperties properties = new ServiceProperties(); + ServiceProperties properties = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties()); properties.Logging.Version = "1.0"; properties.HourMetrics.Version = "1.0"; properties.Logging.RetentionDays = 9; @@ -1009,25 +1009,25 @@ public async Task TableSasInvalidOperations() // Test invalid client operations // BUGBUG: ListTables hides the exception. We should fix this // TestHelpers.ExpectedException(() => sasClient.ListTablesSegmented(), "List tables with SAS", HttpStatusCode.NotFound); - TestHelper.ExpectedException((ctx) => sasClient.GetServicePropertiesAsync().AsTask().Wait(), "Get service properties with SAS", (int)HttpStatusCode.NotFound); - TestHelper.ExpectedException((ctx) => sasClient.SetServicePropertiesAsync(properties).AsTask().Wait(), "Set service properties with SAS", (int)HttpStatusCode.NotFound); + TestHelper.ExpectedException((ctx) => sasClient.GetServicePropertiesAsync().Wait(), "Get service properties with SAS", (int)HttpStatusCode.NotFound); + TestHelper.ExpectedException((ctx) => sasClient.SetServicePropertiesAsync(properties).Wait(), "Set service properties with SAS", (int)HttpStatusCode.NotFound); CloudTable sasTable = sasClient.GetTableReference(table.Name); // Verify that creation fails with SAS - TestHelper.ExpectedException((ctx) => sasTable.CreateAsync(null, ctx).AsTask().Wait(), "Create a table with SAS", (int)HttpStatusCode.NotFound); + TestHelper.ExpectedException((ctx) => sasTable.CreateAsync(null, ctx).Wait(), "Create a table with SAS", (int)HttpStatusCode.NotFound); // Create the table. await table.CreateAsync(); // Test invalid table operations - TestHelper.ExpectedException((ctx) => sasTable.DeleteAsync(null, ctx).AsTask().Wait(), "Delete a table with SAS", (int)HttpStatusCode.NotFound); - TestHelper.ExpectedException((ctx) => sasTable.GetPermissionsAsync(null, ctx).AsTask().Wait(), "Get ACL with SAS", (int)HttpStatusCode.NotFound); - TestHelper.ExpectedException((ctx) => sasTable.SetPermissionsAsync(new TablePermissions(), null, ctx).AsTask().Wait(), "Set ACL with SAS", (int)HttpStatusCode.NotFound); + TestHelper.ExpectedException((ctx) => sasTable.DeleteAsync(null, ctx).Wait(), "Delete a table with SAS", (int)HttpStatusCode.NotFound); + TestHelper.ExpectedException((ctx) => sasTable.GetPermissionsAsync(null, ctx).Wait(), "Get ACL with SAS", (int)HttpStatusCode.NotFound); + TestHelper.ExpectedException((ctx) => sasTable.SetPermissionsAsync(new TablePermissions(), null, ctx).Wait(), "Set ACL with SAS", (int)HttpStatusCode.NotFound); } finally { - table.DeleteIfExistsAsync().AsTask().Wait(); + table.DeleteIfExistsAsync().Wait(); } } @@ -1088,7 +1088,7 @@ await TestHelper.ExpectedExceptionAsync( } finally { - table.DeleteIfExistsAsync().AsTask().Wait(); + table.DeleteIfExistsAsync().Wait(); } } #endregion @@ -1134,7 +1134,7 @@ public async Task TableSasUriTestAsync() } finally { - table.DeleteIfExistsAsync().AsTask().Wait(); + table.DeleteIfExistsAsync().Wait(); } } #endregion diff --git a/Test/WindowsRuntime/Table/TableAnalyticsUnitTests.cs b/Test/WindowsRuntime/Table/TableAnalyticsUnitTests.cs index d54fcad0a..47727c811 100644 --- a/Test/WindowsRuntime/Table/TableAnalyticsUnitTests.cs +++ b/Test/WindowsRuntime/Table/TableAnalyticsUnitTests.cs @@ -79,14 +79,14 @@ public TestContext TestContext public static void MyClassInitialize(TestContext testContext) { client = GenerateCloudTableClient(); - startProperties = client.GetServicePropertiesAsync().AsTask().Result; + startProperties = client.GetServicePropertiesAsync().Result; } // Use ClassCleanup to run code after all tests in a class have run [ClassCleanup()] public static void MyClassCleanup() { - client.SetServicePropertiesAsync(startProperties).AsTask().Wait(); + client.SetServicePropertiesAsync(startProperties).Wait(); } // @@ -667,7 +667,7 @@ private async Task TestCorsRulesAsync(CloudTableClient client, OperationContext private static ServiceProperties DefaultServiceProperties() { - ServiceProperties props = new ServiceProperties(); + ServiceProperties props = new ServiceProperties(new LoggingProperties(), new MetricsProperties(), new MetricsProperties(), new CorsProperties()); props.Logging.LoggingOperations = LoggingOperations.None; props.Logging.RetentionDays = null; diff --git a/Test/WindowsRuntime/Table/TableBatchOperationTest.cs b/Test/WindowsRuntime/Table/TableBatchOperationTest.cs index 11055bcae..3d6c0879d 100644 --- a/Test/WindowsRuntime/Table/TableBatchOperationTest.cs +++ b/Test/WindowsRuntime/Table/TableBatchOperationTest.cs @@ -88,7 +88,7 @@ public void MyTestInitialize() { tableClient = GenerateCloudTableClient(); currentTable = tableClient.GetTableReference(GenerateRandomTableName()); - currentTable.CreateIfNotExistsAsync().AsTask().Wait(); + currentTable.CreateIfNotExistsAsync().Wait(); if (TestBase.TableBufferManager != null) { @@ -101,7 +101,7 @@ public void MyTestInitialize() [TestCleanup()] public void MyTestCleanup() { - currentTable.DeleteIfExistsAsync().AsTask().Wait(); + currentTable.DeleteIfExistsAsync().Wait(); if (TestBase.TableBufferManager != null) { Assert.AreEqual(0, TestBase.TableBufferManager.OutstandingBufferCount); @@ -183,7 +183,6 @@ private async Task DoTableBatchInsertFailAsync(TablePayloadFormat format) // add entity await currentTable.ExecuteAsync(TableOperation.Insert(ent)); - TableBatchOperation batch = new TableBatchOperation(); batch.Insert(ent); @@ -195,7 +194,7 @@ private async Task DoTableBatchInsertFailAsync(TablePayloadFormat format) } catch (Exception) { - TestHelper.ValidateResponse(opContext, 1, (int)HttpStatusCode.Conflict, new string[] { "EntityAlreadyExists" }, "The specified entity already exists"); + TestHelper.ValidateResponse(opContext, 1, (int)HttpStatusCode.Conflict, new string[] { "EntityAlreadyExists" }, "The specified entity already exists", "The specified entity already exists"); } } #endregion @@ -1190,47 +1189,47 @@ private async Task DoTableBatchOnSecondaryAsync(TablePayloadFormat format) Exception e = await TestHelper.ExpectedExceptionAsync( async () => await table.ExecuteBatchAsync(batch, options, context), "Batch operations other than retrieve should not be sent to secondary"); - Assert.AreEqual(SR.PrimaryOnlyCommand, RequestResult.TranslateFromExceptionMessage(e.Message).ExceptionInfo.Message); + Assert.AreEqual(SR.PrimaryOnlyCommand, e.Message); batch = new TableBatchOperation(); batch.InsertOrMerge(new DynamicTableEntity("PartitionKey", "RowKey")); - e = await TestHelper.ExpectedExceptionAsync( + e = await TestHelper.ExpectedExceptionAsync( async () => await table.ExecuteBatchAsync(batch, options, null), "Batch operations other than retrieve should not be sent to secondary"); - Assert.AreEqual(SR.PrimaryOnlyCommand, RequestResult.TranslateFromExceptionMessage(e.Message).ExceptionInfo.Message); + Assert.AreEqual(SR.PrimaryOnlyCommand, e.Message); batch = new TableBatchOperation(); batch.InsertOrReplace(new DynamicTableEntity("PartitionKey", "RowKey")); - e = await TestHelper.ExpectedExceptionAsync( + e = await TestHelper.ExpectedExceptionAsync( async () => await table.ExecuteBatchAsync(batch, options, null), "Batch operations other than retrieve should not be sent to secondary"); - Assert.AreEqual(SR.PrimaryOnlyCommand, RequestResult.TranslateFromExceptionMessage(e.Message).ExceptionInfo.Message); + Assert.AreEqual(SR.PrimaryOnlyCommand, e.Message); batch = new TableBatchOperation(); batch.Merge(new DynamicTableEntity("PartitionKey", "RowKey") { ETag = "*" }); - e = await TestHelper.ExpectedExceptionAsync( + e = await TestHelper.ExpectedExceptionAsync( async () => await table.ExecuteBatchAsync(batch, options, null), "Batch operations other than retrieve should not be sent to secondary"); - Assert.AreEqual(SR.PrimaryOnlyCommand, RequestResult.TranslateFromExceptionMessage(e.Message).ExceptionInfo.Message); + Assert.AreEqual(SR.PrimaryOnlyCommand, e.Message); batch = new TableBatchOperation(); batch.Replace(new DynamicTableEntity("PartitionKey", "RowKey") { ETag = "*" }); - e = await TestHelper.ExpectedExceptionAsync( + e = await TestHelper.ExpectedExceptionAsync( async () => await table.ExecuteBatchAsync(batch, options, null), "Batch operations other than retrieve should not be sent to secondary"); - Assert.AreEqual(SR.PrimaryOnlyCommand, RequestResult.TranslateFromExceptionMessage(e.Message).ExceptionInfo.Message); + Assert.AreEqual(SR.PrimaryOnlyCommand, e.Message); batch = new TableBatchOperation(); batch.Delete(new DynamicTableEntity("PartitionKey", "RowKey") { ETag = "*" }); - e = await TestHelper.ExpectedExceptionAsync( + e = await TestHelper.ExpectedExceptionAsync( async () => await table.ExecuteBatchAsync(batch, options, null), "Batch operations other than retrieve should not be sent to secondary"); - Assert.AreEqual(SR.PrimaryOnlyCommand, RequestResult.TranslateFromExceptionMessage(e.Message).ExceptionInfo.Message); + Assert.AreEqual(SR.PrimaryOnlyCommand, e.Message); } #endregion #region Boundary Conditions @@ -1320,7 +1319,7 @@ private async Task DoTableBatchWithMultipleOperationsOnSameEntityShouldFailAsync ITableEntity first = GenerateRandomEntity(pk); batch.Insert(first); - for (int m = 0; m < 99; m++) + for (int m = 0; m < 98; m++) { batch.Insert(GenerateRandomEntity(pk)); } @@ -1340,42 +1339,6 @@ private async Task DoTableBatchWithMultipleOperationsOnSameEntityShouldFailAsync } } - [TestMethod] - [Description("Ensure that a batch with over 100 entities will throw")] - [TestCategory(ComponentCategory.Table)] - [TestCategory(TestTypeCategory.UnitTest)] - [TestCategory(SmokeTestCategory.NonSmoke)] - [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] - public async Task TableBatchOver100EntitiesShouldThrowAsync() - { - foreach (TablePayloadFormat payloadFormat in Enum.GetValues(typeof(TablePayloadFormat))) - { - await DoTableBatchOver100EntitiesShouldThrowAsync(payloadFormat); - } - } - - private async Task DoTableBatchOver100EntitiesShouldThrowAsync(TablePayloadFormat format) - { - tableClient.DefaultRequestOptions.PayloadFormat = format; - TableBatchOperation batch = new TableBatchOperation(); - string pk = Guid.NewGuid().ToString(); - for (int m = 0; m < 101; m++) - { - batch.Insert(GenerateRandomEntity(pk)); - } - - OperationContext opContext = new OperationContext(); - try - { - await currentTable.ExecuteBatchAsync(batch, null, opContext); - Assert.Fail(); - } - catch (Exception) - { - TestHelper.ValidateResponse(opContext, 1, (int)HttpStatusCode.BadRequest, new string[] { "InvalidInput" }, "One of the request inputs is not valid."); - } - } - [TestMethod] [Description("Ensure that a batch with entity over 1 MB will throw")] [TestCategory(ComponentCategory.Table)] @@ -1545,6 +1508,32 @@ await TestHelper.ExpectedExceptionAsync( "Empty batch operation should fail"); } + [TestMethod] + [Description("A test to peform batch insert with batch size of 101. Should fail client-side.")] + [TestCategory(ComponentCategory.Table)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] + public async Task TableBatchTooManyOperationsAsync() + { + TableBatchOperation batch = new TableBatchOperation(); + try + { + for (int m = 0; m < 101; m++) + { + batch.Insert(GenerateRandomEntity("testpk"), true); + } + + await currentTable.ExecuteBatchAsync(batch); + + Assert.Fail("Batch commands with more than 101 operations should fail."); + } + catch (InvalidOperationException e) + { + Assert.AreEqual(e.Message, SR.BatchExceededMaximumNumberOfOperations); + } + } + [TestMethod] [Description("Ensure that a given batch only allows entities with the same partitionkey")] [TestCategory(ComponentCategory.Table)] diff --git a/Test/WindowsRuntime/Table/TableEntitySerializationTests.cs b/Test/WindowsRuntime/Table/TableEntitySerializationTests.cs index 613392086..c81afbd99 100644 --- a/Test/WindowsRuntime/Table/TableEntitySerializationTests.cs +++ b/Test/WindowsRuntime/Table/TableEntitySerializationTests.cs @@ -88,7 +88,7 @@ public void MyTestInitialize() { CloudTableClient tableClient = GenerateCloudTableClient(); currentTable = tableClient.GetTableReference(GenerateRandomTableName()); - currentTable.CreateIfNotExistsAsync().AsTask().Wait(); + currentTable.CreateIfNotExistsAsync().Wait(); if (TestBase.TableBufferManager != null) { @@ -101,7 +101,7 @@ public void MyTestInitialize() [TestCleanup()] public void MyTestCleanup() { - currentTable.DeleteIfExistsAsync().AsTask().Wait(); + currentTable.DeleteIfExistsAsync().Wait(); if (TestBase.TableBufferManager != null) { diff --git a/Test/WindowsRuntime/Table/TableEscapingTests.cs b/Test/WindowsRuntime/Table/TableEscapingTests.cs index 743e8f3d2..7af7e8a36 100644 --- a/Test/WindowsRuntime/Table/TableEscapingTests.cs +++ b/Test/WindowsRuntime/Table/TableEscapingTests.cs @@ -83,7 +83,7 @@ public void MyTestInitialize() { CloudTableClient tableClient = GenerateCloudTableClient(); currentTable = tableClient.GetTableReference(GenerateRandomTableName()); - currentTable.CreateIfNotExistsAsync().AsTask().Wait(); + currentTable.CreateIfNotExistsAsync().Wait(); if (TestBase.TableBufferManager != null) { @@ -96,7 +96,7 @@ public void MyTestInitialize() [TestCleanup()] public void MyTestCleanup() { - currentTable.DeleteIfExistsAsync().AsTask().Wait(); + currentTable.DeleteIfExistsAsync().Wait(); if (TestBase.TableBufferManager != null) { diff --git a/Test/WindowsRuntime/Table/TableOperationUnitTests.cs b/Test/WindowsRuntime/Table/TableOperationUnitTests.cs index b60a7294b..33b8c44f7 100644 --- a/Test/WindowsRuntime/Table/TableOperationUnitTests.cs +++ b/Test/WindowsRuntime/Table/TableOperationUnitTests.cs @@ -86,7 +86,7 @@ public void MyTestInitialize() { tableClient = GenerateCloudTableClient(); currentTable = tableClient.GetTableReference(GenerateRandomTableName()); - currentTable.CreateIfNotExistsAsync().AsTask().Wait(); + currentTable.CreateIfNotExistsAsync().Wait(); if (TestBase.TableBufferManager != null) { @@ -99,7 +99,7 @@ public void MyTestInitialize() [TestCleanup()] public void MyTestCleanup() { - currentTable.DeleteIfExistsAsync().AsTask().Wait(); + currentTable.DeleteIfExistsAsync().Wait(); if (TestBase.TableBufferManager != null) { diff --git a/Test/WindowsRuntime/Table/TableQueryGenericTests.cs b/Test/WindowsRuntime/Table/TableQueryGenericTests.cs index 753fabe15..f88e8e37d 100644 --- a/Test/WindowsRuntime/Table/TableQueryGenericTests.cs +++ b/Test/WindowsRuntime/Table/TableQueryGenericTests.cs @@ -17,6 +17,7 @@ using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.WindowsAzure.Storage.Table.Entities; +using Microsoft.WindowsAzure.Storage.Table.Protocol; using System; using System.Collections.Generic; using System.Linq; @@ -82,7 +83,7 @@ public static void MyClassInitialize(TestContext testContext) { tableClient = GenerateCloudTableClient(); currentTable = tableClient.GetTableReference(GenerateRandomTableName()); - currentTable.CreateIfNotExistsAsync().AsTask().Wait(); + currentTable.CreateIfNotExistsAsync().Wait(); for (int i = 0; i < 15; i++) { @@ -95,7 +96,7 @@ public static void MyClassInitialize(TestContext testContext) batch.Insert(ent); } - currentTable.ExecuteBatchAsync(batch).AsTask().Wait(); + currentTable.ExecuteBatchAsync(batch).Wait(); } } // @@ -103,7 +104,7 @@ public static void MyClassInitialize(TestContext testContext) [ClassCleanup()] public static void MyClassCleanup() { - currentTable.DeleteIfExistsAsync().AsTask().Wait(); + currentTable.DeleteIfExistsAsync().Wait(); } // @@ -235,18 +236,63 @@ public void TableGenericQueryWithFilter() [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] public void TableGenericQueryProjection() { + DoTableGenericQueryProjection(false); + DoTableGenericQueryProjection(true); + } + + private void DoTableGenericQueryProjection(bool projectSystemProperties) + { + tableClient.DefaultRequestOptions.ProjectSystemProperties = projectSystemProperties; + TableQuery query = new TableQuery().Select(new List() { "A", "C" }); foreach (BaseEntity ent in ExecuteQuery(currentTable, query)) { - Assert.IsNotNull(ent.PartitionKey); - Assert.IsNotNull(ent.RowKey); - Assert.IsNotNull(ent.Timestamp); + Assert.AreEqual(ent.A, "a"); + Assert.IsNull(ent.B); + Assert.AreEqual(ent.C, "c"); + Assert.IsNull(ent.D); + + if (tableClient.DefaultRequestOptions.ProjectSystemProperties.HasValue) + { + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.PartitionKey == default(string), "Missing expected " + TableConstants.PartitionKey); + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.RowKey == default(string), "Missing expected " + TableConstants.RowKey); + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.Timestamp == default(DateTimeOffset), "Missing expected " + TableConstants.Timestamp); + } + } + } + [TestMethod] + [Description("Basic projection test")] + [TestCategory(ComponentCategory.Table)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] + public void TableGenericQueryProjectionSpecifyingSystemProperties() + { + DoTableGenericQueryProjectionSpecifyingSystemProperties(false); + DoTableGenericQueryProjectionSpecifyingSystemProperties(true); + } + + private void DoTableGenericQueryProjectionSpecifyingSystemProperties(bool projectSystemProperties) + { + tableClient.DefaultRequestOptions.ProjectSystemProperties = projectSystemProperties; + + TableQuery query = new TableQuery().Select(new List() { "A", "C", TableConstants.PartitionKey, TableConstants.Timestamp }); + + foreach (BaseEntity ent in ExecuteQuery(currentTable, query)) + { Assert.AreEqual(ent.A, "a"); Assert.IsNull(ent.B); Assert.AreEqual(ent.C, "c"); Assert.IsNull(ent.D); + Assert.AreNotEqual(default(string), ent.PartitionKey); + Assert.AreNotEqual(default(DateTimeOffset), ent.Timestamp); + + if (tableClient.DefaultRequestOptions.ProjectSystemProperties.HasValue) + { + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.RowKey == default(string), "Missing expected " + TableConstants.RowKey); + } } } @@ -440,7 +486,7 @@ private async Task DoTableGenericQueryOnSupportedTypesAsync(TablePayloadFormat f } finally { - table.DeleteIfExistsAsync().AsTask().Wait(); + table.DeleteIfExistsAsync().Wait(); } } @@ -528,7 +574,7 @@ private async Task DoTableGenericQueryWithInvalidQueryAsync(TablePayloadFormat f while (currSeg == null || currSeg.ContinuationToken != null) { - Task> task = Task.Run(() => table.ExecuteQuerySegmentedAsync(query, currSeg != null ? currSeg.ContinuationToken : null).AsTask()); + Task> task = Task.Run(() => table.ExecuteQuerySegmentedAsync(query, currSeg != null ? currSeg.ContinuationToken : null)); task.Wait(); currSeg = task.Result; retList.AddRange(currSeg.Results); @@ -545,7 +591,7 @@ private static List ExecuteQueryWithResolver(CloudTable table, while (currSeg == null || currSeg.ContinuationToken != null) { - Task> task = Task.Run(() => table.ExecuteQuerySegmentedAsync(query, resolver, currSeg != null ? currSeg.ContinuationToken : null).AsTask()); + Task> task = Task.Run(() => table.ExecuteQuerySegmentedAsync(query, resolver, currSeg != null ? currSeg.ContinuationToken : null)); task.Wait(); currSeg = task.Result; retList.AddRange(currSeg.Results); @@ -563,7 +609,7 @@ private static List ExecuteQueryWithResolver(CloudTable table, while (currSeg == null || currSeg.ContinuationToken != null) { - Task> task = Task.Run(() => table.ExecuteQuerySegmentedAsync(query, resolver, currSeg != null ? currSeg.ContinuationToken : null).AsTask()); + Task> task = Task.Run(() => table.ExecuteQuerySegmentedAsync(query, resolver, currSeg != null ? currSeg.ContinuationToken : null)); task.Wait(); currSeg = task.Result; retList.AddRange(currSeg.Results); diff --git a/Test/WindowsRuntime/Table/TableQueryTests.cs b/Test/WindowsRuntime/Table/TableQueryTests.cs index ecf3fdd97..669740740 100644 --- a/Test/WindowsRuntime/Table/TableQueryTests.cs +++ b/Test/WindowsRuntime/Table/TableQueryTests.cs @@ -22,6 +22,7 @@ using System.Linq; using System.Net; using System.Threading.Tasks; +using Microsoft.WindowsAzure.Storage.Table.Protocol; #if ASPNET_K using System.Globalization; @@ -89,7 +90,7 @@ public static void MyClassInitialize(TestContext testContext) { tableClient = GenerateCloudTableClient(); currentTable = tableClient.GetTableReference(GenerateRandomTableName()); - currentTable.CreateIfNotExistsAsync().AsTask().Wait(); + currentTable.CreateIfNotExistsAsync().Wait(); for (int i = 0; i < 15; i++) { @@ -102,7 +103,7 @@ public static void MyClassInitialize(TestContext testContext) batch.Insert(ent); } - currentTable.ExecuteBatchAsync(batch).AsTask().Wait(); + currentTable.ExecuteBatchAsync(batch).Wait(); } } // @@ -110,7 +111,7 @@ public static void MyClassInitialize(TestContext testContext) [ClassCleanup()] public static void MyClassCleanup() { - currentTable.DeleteIfExistsAsync().AsTask().Wait(); + currentTable.DeleteIfExistsAsync().Wait(); } // @@ -255,25 +256,69 @@ public void TableQueryProjectionAsync() { foreach (TablePayloadFormat payloadFormat in Enum.GetValues(typeof(TablePayloadFormat))) { - DoTableQueryProjectionAsync(payloadFormat); + DoTableQueryProjectionAsync(payloadFormat, false); + DoTableQueryProjectionAsync(payloadFormat, true); } } - private void DoTableQueryProjectionAsync(TablePayloadFormat format) + private void DoTableQueryProjectionAsync(TablePayloadFormat format, bool projectSystemProperties) { tableClient.DefaultRequestOptions.PayloadFormat = format; + tableClient.DefaultRequestOptions.ProjectSystemProperties = projectSystemProperties; + TableQuery query = new TableQuery().Select(new List() { "a", "c" }); foreach (DynamicTableEntity ent in ExecuteQuery(currentTable, query)) { - Assert.IsNotNull(ent.PartitionKey); - Assert.IsNotNull(ent.RowKey); - Assert.IsNotNull(ent.Timestamp); + Assert.AreEqual(ent.Properties["a"].StringValue, "a"); + Assert.IsFalse(ent.Properties.ContainsKey("b")); + Assert.AreEqual(ent.Properties["c"].StringValue, "c"); + Assert.IsFalse(ent.Properties.ContainsKey("d")); + + if (tableClient.DefaultRequestOptions.ProjectSystemProperties.HasValue) + { + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.PartitionKey == default(string), "Missing expected " + TableConstants.PartitionKey); + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.RowKey == default(string), "Missing expected " + TableConstants.RowKey); + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.Timestamp == default(DateTimeOffset), "Missing expected " + TableConstants.Timestamp); + } + } + } + [TestMethod] + [Description("Basic projection test")] + [TestCategory(ComponentCategory.Table)] + [TestCategory(TestTypeCategory.UnitTest)] + [TestCategory(SmokeTestCategory.NonSmoke)] + [TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)] + public void TableQueryProjectionAsyncSpecifyingSystemProperties() + { + foreach (TablePayloadFormat payloadFormat in Enum.GetValues(typeof(TablePayloadFormat))) + { + DoTableQueryProjectionAsyncSpecifyingSystemProperties(payloadFormat, false); + DoTableQueryProjectionAsyncSpecifyingSystemProperties(payloadFormat, true); + } + } + + private void DoTableQueryProjectionAsyncSpecifyingSystemProperties(TablePayloadFormat format, bool projectSystemProperties) + { + tableClient.DefaultRequestOptions.PayloadFormat = format; + tableClient.DefaultRequestOptions.ProjectSystemProperties = projectSystemProperties; + + TableQuery query = new TableQuery().Select(new List() { "a", "c", TableConstants.PartitionKey, TableConstants.Timestamp }); + + foreach (DynamicTableEntity ent in ExecuteQuery(currentTable, query)) + { Assert.AreEqual(ent.Properties["a"].StringValue, "a"); Assert.IsFalse(ent.Properties.ContainsKey("b")); Assert.AreEqual(ent.Properties["c"].StringValue, "c"); Assert.IsFalse(ent.Properties.ContainsKey("d")); + Assert.AreNotEqual(default(string), ent.PartitionKey); + Assert.AreNotEqual(default(DateTimeOffset), ent.Timestamp); + + if (tableClient.DefaultRequestOptions.ProjectSystemProperties.HasValue) + { + Assert.AreNotEqual(tableClient.DefaultRequestOptions.ProjectSystemProperties.Value, ent.RowKey == default(string), "Missing expected " + TableConstants.RowKey); + } } } @@ -408,7 +453,7 @@ private async Task DoTableQueryOnSupportedTypesAsync(TablePayloadFormat format) } finally { - table.DeleteIfExistsAsync().AsTask().Wait(); + table.DeleteIfExistsAsync().Wait(); } } @@ -555,7 +600,7 @@ private async Task DoTableRegionalQueryOnSupportedTypesAsync(TablePayloadFormat #else ApplicationLanguages.PrimaryLanguageOverride = currentPrimaryLanguage; #endif - table.DeleteIfExistsAsync().AsTask().Wait(); + table.DeleteIfExistsAsync().Wait(); } } @@ -686,7 +731,7 @@ private static List ExecuteQuery(CloudTable table, TableQuer while (currSeg == null || currSeg.ContinuationToken != null) { - Task task = Task.Run(() => table.ExecuteQuerySegmentedAsync(query, currSeg != null ? currSeg.ContinuationToken : null).AsTask()); + Task task = Task.Run(() => table.ExecuteQuerySegmentedAsync(query, currSeg != null ? currSeg.ContinuationToken : null)); task.Wait(); currSeg = task.Result; retList.AddRange(currSeg.Results); diff --git a/Test/WindowsRuntime/TestBase.cs b/Test/WindowsRuntime/TestBase.cs index a410edae5..a28179fc7 100644 --- a/Test/WindowsRuntime/TestBase.cs +++ b/Test/WindowsRuntime/TestBase.cs @@ -17,10 +17,12 @@ using Microsoft.WindowsAzure.Storage.Auth; using System; +using System.IO; using System.Xml.Linq; using Windows.ApplicationModel; using Windows.Data.Xml.Dom; using Windows.Storage; +using Windows.Storage.Streams; namespace Microsoft.WindowsAzure.Storage { @@ -44,4 +46,99 @@ static TestBase() } } } + +#if WINDOWS_RT + public static class MicrosoftStreamExtensions + { + public static IRandomAccessStreamWithContentType AsRandomAccessStream(this Stream stream) + { + return new RandomStream(stream); + } + + } + + class RandomStream : IRandomAccessStreamWithContentType + { + Stream internstream; + + public RandomStream(Stream underlyingstream) + { + internstream = underlyingstream; + } + + public IInputStream GetInputStreamAt(ulong position) + { + internstream.Position = (long)position; + return internstream.AsInputStream(); + } + + public IOutputStream GetOutputStreamAt(ulong position) + { + internstream.Position = (long)position; + return internstream.AsOutputStream(); + } + + public ulong Size + { + get + { + return (ulong)internstream.Length; + } + set + { + internstream.SetLength((long)value); + } + } + + public bool CanRead + { + get { return this.internstream.CanRead; } + } + + public bool CanWrite + { + get { return this.internstream.CanWrite; } + } + + public IRandomAccessStream CloneStream() + { + throw new NotSupportedException(); + } + + public ulong Position + { + get { return (ulong)this.internstream.Position; } + } + + public void Seek(ulong position) + { + this.internstream.Seek((long)position, SeekOrigin.Begin); + } + + public void Dispose() + { + this.internstream.Dispose(); + } + + public Windows.Foundation.IAsyncOperationWithProgress ReadAsync(IBuffer buffer, uint count, InputStreamOptions options) + { + return this.GetInputStreamAt(this.Position).ReadAsync(buffer, count, options); + } + + public Windows.Foundation.IAsyncOperation FlushAsync() + { + return this.GetOutputStreamAt(this.Position).FlushAsync(); + } + + public Windows.Foundation.IAsyncOperationWithProgress WriteAsync(IBuffer buffer) + { + return this.GetOutputStreamAt(this.Position).WriteAsync(buffer); + } + + public string ContentType + { + get { throw new NotImplementedException(); } + } + } +#endif } diff --git a/Test/WindowsRuntime/TestHelper.cs b/Test/WindowsRuntime/TestHelper.cs index 00870adb9..67af489ae 100644 --- a/Test/WindowsRuntime/TestHelper.cs +++ b/Test/WindowsRuntime/TestHelper.cs @@ -26,6 +26,7 @@ namespace Microsoft.WindowsAzure.Storage { public partial class TestHelper { + /// /// Compares the streams from the current position to the end. /// @@ -55,6 +56,32 @@ internal static async Task AssertStreamsAreEqualAsync(IInputStream src, IInputSt while (srcRead > 0); } + /// + /// Compares the streams from the current position to the end. + /// + internal static async Task AssertStreamsAreEqualAsync(Stream src, Stream dst) + { + byte[] srcBuffer = new byte[64 * 1024]; + int srcRead; + + byte[] dstBuffer = new byte[64 * 1024]; + int dstRead; + + do + { + srcRead = await src.ReadAsync(srcBuffer, 0, srcBuffer.Length); + dstRead = await dst.ReadAsync(dstBuffer, 0, dstBuffer.Length); + + Assert.AreEqual(srcRead, dstRead); + + for (int i = 0; i < srcRead; i++) + { + Assert.AreEqual(srcBuffer[i], dstBuffer[i]); + } + } + while (srcRead > 0); + } + /// /// Runs a given operation that is expected to throw an exception. /// diff --git a/changelog.txt b/changelog.txt index d4d6b8401..28429a6c8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,33 @@ +Changes in 7.0.0 : + +- All: Support for 2015-07-08 REST version. Please see our REST API documentation and blogs for information about the related added features. If you are using the Storage Emulator, please update to Emulator version 4.3. +- All (WinRT): All apis now return Task objects instead of IAsync* objects. Please see our blog post for more info. +- All: Ensure disposal of CancellationTokenSource in StreamExtensions.WriteToAsync. +- All: Virtualized all service call APIs and unsealed their classes. +- All: Updated the UserAgent string to match the Azure Storage standard. +- All: Windows Runtime no longer uses WrappedStorageExceptions or HResults. Catch StorageException and check HTTP status code instead. +- All: Changed use of HttpClient in Windows Runtime from instance-per-request to singleton instance shared across all requests. +- All: SetServiceProperties APIs no longer instantiates Logging, HourMetrics, MinuteMetrics, or Cors instance variables. New LoggingProperties, MetricsProperties, and CorsProperties objects will need to be set for those variables before they can be assigned. +- All: LoggingProperties and MetricsProperties Version now defaults to "1.0" or Constants.AnalyticsConstants.MetricsVersionV1 or LoggingVersionV1. +- All: Removed deprecated SharedKeyLiteAuthenticationHandler, use SharedKeyAuthenticationHandler instead. +- All: Removed deprecated request options setters on the *Client class object in favor of setting request options on Client's DefaultRequestOptions object. +- All: When creating a SAS token with a non-null SharedAccessProtocol, only valid enum values are permitted. All other values will now throw an ArgumentException. +- All: Fixed a bug that caused the PCL to not work correctly when only targeting Win8. +- Blobs: Removed deprecated (Begin/End)StartCopyFromBlob(Async) APIs in favor of using (Begin/End)StartCopy(Async) APIs. +- Blobs: Removed deprecated GetSubdirectoryReference API in favor of GetDirectoryReference. +- Blobs: Removed FileMode parameter for UploadFromFile* and AppendFromFile* APIs since there is only 1 valid option (FileMode.Open). +- Blobs: When downloading blob to local file fails, file created for download will be cleaned up. +- Blobs: proposedLeaseId for minimum AcquireLease API overloads defaults to null. +- Blobs/Files: Fixed bug in DownloadToFile APIs where existing files could be deleted if users call API with Create or CreateNew FileModes. +- Tables: Removed deprecated AtomPub payloadFormat support. +- Tables: Fixed a bug in table batch operations where storage exceptions resulted in operation contexts with incorrect HttpStatusMessage. +- Tables: Batching validation was added for batch sizes exceeding 100 operations. +- Tables: Batching validation was added for null partition keys and row keys. +- Tables: Removed deprecated overloads for Table.Retrieve APIs. +- Tables: Add ProjectSystemProperties to TableRequestOptions to allow opt-out on system properties (PartitionKey, RowKey, Timestamp). +- Files: When downloading file to local system file fails, file created for download will be cleaned up. +- Queues: Removed deprecated EndBeginClear API in favor of EndClear. + Changes since 6.2.2-preview : - All: TestConfigurations.xml has been deleted and added to the .gitignore file to keep users from accidentally leaking their credentials. To continue running tests, simply add the same file back after you get the latest code.