diff --git a/.gitignore b/.gitignore
index 228eee069009a..19e4afec5199b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -109,8 +109,7 @@ Backup*/
UpgradeLog*.XML
# NuGet
-/microsoft-azure-api/Services/Storage/Test/Unit/RT/AppPackages/
-libraries/packages
+packages
# Mac development
.DS_Store
diff --git a/libraries/.nuget/NuGet.Config b/.nuget/NuGet.Config
similarity index 100%
rename from libraries/.nuget/NuGet.Config
rename to .nuget/NuGet.Config
diff --git a/libraries/.nuget/NuGet.exe b/.nuget/NuGet.exe
similarity index 100%
rename from libraries/.nuget/NuGet.exe
rename to .nuget/NuGet.exe
diff --git a/libraries/.nuget/NuGet.targets b/.nuget/NuGet.targets
similarity index 100%
rename from libraries/.nuget/NuGet.targets
rename to .nuget/NuGet.targets
diff --git a/README.md b/README.md
index c67a76ce42133..fbd3882707803 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,9 @@ complete SDK, please see the [Windows Azure .NET Developer Center](http://www.wi
# Features
- Storage
+
+ > Available in the separate [Storage repository](https://github.com/WindowsAzure/azure-storage-net/)
+
- Tables
- Create/Delete Tables
- Query/Create/Read/Update/Delete Entities
@@ -18,6 +21,7 @@ complete SDK, please see the [Windows Azure .NET Developer Center](http://www.wi
- Create/Delete Queues
- Insert/Peek Queue Messages
- Advanced Queue Operations
+
- Management Libraries (Preview)
- Compute
- Infrastructure
@@ -68,61 +72,29 @@ We gladly accept community contributions.
For general suggestions about Windows Azure please use our [UserVoice forum](http://www.mygreatwindowsazureidea.com/forums/34192-windows-azure-feature-voting).
-# Storage Client Library for .NET 4, Windows 8, and Windows Phone 8 (2.1.0.0)
+# Storage Client Library
-The Storage Client Library ships with the Windows Azure SDK for .NET and also on NuGet. You'll find the latest version and hotfixes on NuGet via the `WindowsAzure.Storage` package. You can [read about the 2.1 release on the storage team blog post](http://blogs.msdn.com/b/windowsazurestorage/archive/2013/09/07/announcing-storage-client-library-2-1-rtm.aspx).
+To use storage services (blog, table, queue), the storage client library provides rich APIs for interacting with the storage service.
-Please note that Windows 8 and Windows Phone 8 libraries are CTP (Community
-Technology Preview) releases.
+The Storage Client Library ships with the Windows Azure SDK for .NET and also on NuGet. You'll find the latest version and hotfixes on NuGet via the `WindowsAzure.Storage` package.
-## Download & Install
-
-### Via Git
+## Storage source code
-To get the source code of the SDK via git just type:
+### v3.0+
-```bash
-git clone git://github.com/WindowsAzure/azure-sdk-for-net.git
-cd azure-sdk-for-net
-```
+With the release of the 3.0.0 storage client library, you can find the latest storage library (and associated issues) in the separate repo [azure-storage-net](http://github.com/WindowsAzure/azure-storage-net/).
-### Via NuGet
+### v2.0.1.4
-To get the binaries of this library as distributed by Microsoft, ready for use
-within your project you can also have them installed by the .NET package manager [NuGet](http://www.nuget.org/).
+The latest version of the v2.1.x storage client library is available in the azure-sdk-for-net repo under the [`v2.1.0.4` tag](https://github.com/WindowsAzure/azure-sdk-for-net/releases/tag/v2.1.0.4).
-`Install-Package WindowsAzure.Storage`
+## NuGet package install
-## Dependencies
+The storage client libaries are delivered via NuGet officially by Microsoft, ready for use within your project. They are installed with the [NuGet package manager](http://www.nuget.org/) which is built into Visual Studio 2013; for earlier releases of Visual Studio, NuGet is a quick and easy extension to install.
-### OData
-
-This version depends on three libraries (collectively referred to as ODataLib), which are resolved through the ODataLib (version 5.2.0) packages available through NuGet and not the WCF Data Services installer which currently contains 5.0.0 versions.
-
-The ODataLib libraries can be downloaded directly or referenced by your code project through NuGet.
-
-The specific ODataLib packages are:
-
-- [Microsoft.Data.OData](http://nuget.org/packages/Microsoft.Data.OData/)
-- [Microsoft.Data.Edm](http://nuget.org/packages/Microsoft.Data.Edm/)
-- [System.Spatial](http://nuget.org/packages/System.Spatial)
-
-### Test Dependencies
-
-FiddlerCore is required by:
-
-- Test\Unit\FaultInjection\HttpMangler
-- Test\Unit\FaultInjection\XStoreMangler
-- Test\Unit\DotNet40
-
-This dependency is not included and must be downloaded from [http://www.fiddler2.com/Fiddler/Core/](http://www.fiddler2.com/Fiddler/Core/).
-
-Once installed:
-
-- Copy `FiddlerCore.dll` `\azure-sdk-for-net\microsoft-azure-api\Services\Storage\Test\Unit\FaultInjection\Dependencies\DotNet2`
-- Copy `FiddlerCore4.dll` to `azure-sdk-for-net\microsoft-azure-api\Services\Storage\Test\Unit\FaultInjection\Dependencies\DotNet4`
+`Install-Package WindowsAzure.Storage`
-## Code Samples
+## Storage code samples
> Note:
> How-Tos focused around accomplishing specific tasks are available on the [Windows Azure .NET Developer Center](http://www.windowsazure.com/en-us/develop/net/).
diff --git a/libraries/Settings.SourceAnalysis b/Settings.SourceAnalysis
similarity index 100%
rename from libraries/Settings.SourceAnalysis
rename to Settings.SourceAnalysis
diff --git a/libraries/WindowsAzureLibraries.sln b/WindowsAzureLibraries.sln
similarity index 99%
rename from libraries/WindowsAzureLibraries.sln
rename to WindowsAzureLibraries.sln
index 032c9eff379ea..67767d2c8ecc5 100644
--- a/libraries/WindowsAzureLibraries.sln
+++ b/WindowsAzureLibraries.sln
@@ -61,6 +61,7 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlManagement", "src\SqlManagement\SqlManagement.csproj", "{74CEEF0C-D9DB-412E-B6AD-F63020C0AC72}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StoreManagement", "src\StoreManagement\StoreManagement.csproj", "{E9119999-B156-4CE1-A83E-F7778992739B}"
+EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Tracing.Etw", "src\Common.Tracing.Etw\Common.Tracing.Etw.csproj", "{50B0A8CE-D290-4EB7-8C6C-16EAAB75225E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Tracing.Test", "src\Common.Tracing.Test\Common.Tracing.Test.csproj", "{B2FAA0E6-2643-4011-8CFE-BA28BDFFC7E7}"
diff --git a/libraries/WindowsAzureLibraries.vsmdi b/WindowsAzureLibraries.vsmdi
similarity index 100%
rename from libraries/WindowsAzureLibraries.vsmdi
rename to WindowsAzureLibraries.vsmdi
diff --git a/libraries/libraries.msbuild b/libraries.msbuild
similarity index 97%
rename from libraries/libraries.msbuild
rename to libraries.msbuild
index dfb73344f53f3..5088e9091845d 100644
--- a/libraries/libraries.msbuild
+++ b/libraries.msbuild
@@ -65,9 +65,9 @@
-
-
-
+
+
+
-
diff --git a/libraries/libraries.testsettings b/libraries.testsettings
similarity index 100%
rename from libraries/libraries.testsettings
rename to libraries.testsettings
diff --git a/microsoft-azure-api/Services/Storage/.gitattributes b/microsoft-azure-api/Services/Storage/.gitattributes
deleted file mode 100644
index 1e11d3235cef3..0000000000000
--- a/microsoft-azure-api/Services/Storage/.gitattributes
+++ /dev/null
@@ -1,3 +0,0 @@
-*.cs eol=crlf
-*.csproj eol=crlf
-*.sln eol=crlf
diff --git a/microsoft-azure-api/Services/Storage/CustomDictionary.xml b/microsoft-azure-api/Services/Storage/CustomDictionary.xml
deleted file mode 100644
index bfb660f6c5669..0000000000000
--- a/microsoft-azure-api/Services/Storage/CustomDictionary.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-
-
-
- Auth
- api
- sas
- dest
- Acl
- Md
- Eq
- Canonicalizer
- Async
- orderby
- IBufferManager
- DynamicTableEntity
- GetDefaultBufferSize
- ITableEntity
- EndRead
- TableQuery
- EndFlush
- EntityProperty
- ExecuteQuery
- CloudTable
- CreateQuery
- TableQuery
- EndFlush
- EntityProperty
- ExecuteQuery
- CloudTable
- CreateQuery
- Etag
- OData
-
-
- Tablequery
- Entityproperty
- Executequery
- Cloudtable
- Createquery
- Endflush
- Beginflush
- Endread
- Numberless
-
-
- etag
- Etag
-
-
-
\ No newline at end of file
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/AccessCondition.cs b/microsoft-azure-api/Services/Storage/Lib/Common/AccessCondition.cs
deleted file mode 100644
index 0ee742c1c5d46..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/AccessCondition.cs
+++ /dev/null
@@ -1,269 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- using System;
- using System.Diagnostics.CodeAnalysis;
-
- ///
- /// Represents a set of access conditions to be used for operations against the storage services.
- ///
- public sealed class AccessCondition
- {
- ///
- /// Time for IfModifiedSince.
- ///
- private DateTimeOffset? ifModifiedSinceDateTime;
-
- ///
- /// Time for IfUnmodifiedSince.
- ///
- private DateTimeOffset? ifNotModifiedSinceDateTime;
-
- ///
- /// Gets or sets an ETag value that must match the ETag of the specified resource.
- ///
- /// A string containing an ETag value, or "*" to match any ETag. If null, no condition exists.
- public string IfMatchETag
- {
- get;
- set;
- }
-
- ///
- /// Gets or sets an ETag value that must not match the ETag of the specified resource.
- ///
- /// A string containing an ETag value, or "*" to match any ETag. If null, no condition exists.
- public string IfNoneMatchETag
- {
- get;
- set;
- }
-
- ///
- /// Gets or sets a time that must be before the last modification of a resource.
- ///
- /// A DateTimeOffset in UTC, or null if no condition exists.
- public DateTimeOffset? IfModifiedSinceTime
- {
- get
- {
- return this.ifModifiedSinceDateTime;
- }
-
- set
- {
- this.ifModifiedSinceDateTime = value.HasValue ? value.Value.ToUniversalTime() : value;
- }
- }
-
- ///
- /// Gets or sets a time that must not be before the last modification of a resource.
- ///
- /// A DateTimeOffset in UTC, or null if no condition exists.
- public DateTimeOffset? IfNotModifiedSinceTime
- {
- get
- {
- return this.ifNotModifiedSinceDateTime;
- }
-
- set
- {
- this.ifNotModifiedSinceDateTime = value.HasValue ? value.Value.ToUniversalTime() : value;
- }
- }
-
- ///
- /// Gets or sets a sequence number that the current sequence number of a page blob must be less than or equal to in order for the operation to proceed.
- ///
- /// A sequence number, or null if no condition exists.
- /// This condition only applies to page blobs.
- public long? IfSequenceNumberLessThanOrEqual
- {
- get;
- set;
- }
-
- ///
- /// Gets or sets a sequence number that the current sequence number of a page blob must be less than in order for the operation to proceed.
- ///
- /// A sequence number, or null if no condition exists.
- /// This condition only applies to page blobs.
- public long? IfSequenceNumberLessThan
- {
- get;
- set;
- }
-
- ///
- /// Gets or sets a sequence number that the current sequence number of a page blob must be equal to in order for the operation to proceed.
- ///
- /// A sequence number, or null if no condition exists.
- /// This condition only applies to page blobs.
- public long? IfSequenceNumberEqual
- {
- get;
- set;
- }
-
- ///
- /// Gets or sets a lease ID that must match the lease on a resource.
- ///
- /// A lease ID, or null if no condition exists.
- public string LeaseId
- {
- get;
- set;
- }
-
- ///
- /// Determines whether the access condition is one of the four conditional headers.
- ///
- /// true if the access condition is a conditional header; otherwise, false.
- internal bool IsConditional
- {
- get
- {
- return !string.IsNullOrEmpty(this.IfMatchETag) ||
- !string.IsNullOrEmpty(this.IfNoneMatchETag) ||
- this.IfModifiedSinceTime.HasValue ||
- this.IfNotModifiedSinceTime.HasValue;
- }
- }
-
- ///
- /// Constructs an empty access condition.
- ///
- /// An empty access condition.
- public static AccessCondition GenerateEmptyCondition()
- {
- return new AccessCondition();
- }
-
- ///
- /// Constructs an access condition such that an operation will be performed only if the resource's ETag value
- /// matches the specified ETag value.
- ///
- /// The ETag value that must be matched.
- /// An AccessCondition object that represents the If-Match condition.
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "etag", Justification = "Reviewed: etag can be used for identifier names.")]
- public static AccessCondition GenerateIfMatchCondition(string etag)
- {
- return new AccessCondition { IfMatchETag = etag };
- }
-
- ///
- /// Constructs an access condition such that an operation will be performed only if the resource has been
- /// modified since the specified time.
- ///
- /// The time since which the resource must have been modified in order for the operation to proceed.
- /// An AccessCondition object that represents the If-Modified-Since condition.
- public static AccessCondition GenerateIfModifiedSinceCondition(DateTimeOffset modifiedTime)
- {
- return new AccessCondition { IfModifiedSinceTime = modifiedTime };
- }
-
- ///
- /// Constructs an access condition such that an operation will be performed only if the resource's ETag value
- /// does not match the specified ETag value.
- ///
- /// The ETag value that must be matched, or "*".
- /// An AccessCondition object that represents the If-None-Match condition.
- ///
- /// If "*" is specified as the parameter then this condition requires that the resource does not exist.
- ///
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "etag", Justification = "Reviewed: etag can be used for identifier names.")]
- public static AccessCondition GenerateIfNoneMatchCondition(string etag)
- {
- return new AccessCondition { IfNoneMatchETag = etag };
- }
-
- ///
- /// Constructs an access condition such that an operation will be performed only if the resource has not been
- /// modified since the specified time.
- ///
- /// The time since which the resource must not have been modified in order for the operation to proceed.
- /// An AccessCondition object that represents the If-Unmodified-Since condition.
- public static AccessCondition GenerateIfNotModifiedSinceCondition(DateTimeOffset modifiedTime)
- {
- return new AccessCondition { IfNotModifiedSinceTime = modifiedTime };
- }
-
- ///
- /// Constructs an access condition such that an operation will be performed only if resource's current sequence
- /// number is less than or equal to the specified value.
- ///
- /// The value that the current sequence number of the resource must be less than or equal to.
- /// An AccessCondition object that represents the If-Sequence-Number-LE condition.
- public static AccessCondition GenerateIfSequenceNumberLessThanOrEqualCondition(long sequenceNumber)
- {
- return new AccessCondition { IfSequenceNumberLessThanOrEqual = sequenceNumber };
- }
-
- ///
- /// Constructs an access condition such that an operation will be performed only if resource's current sequence
- /// number is less than the specified value.
- ///
- /// The value that the current sequence number of the resource must be less than.
- /// An AccessCondition object that represents the If-Sequence-Number-LT condition.
- public static AccessCondition GenerateIfSequenceNumberLessThanCondition(long sequenceNumber)
- {
- return new AccessCondition { IfSequenceNumberLessThan = sequenceNumber };
- }
-
- ///
- /// Constructs an access condition such that an operation will be performed only if resource's current sequence
- /// number is equal to the specified value.
- ///
- /// The value that the current sequence number of the resource must be equal to.
- /// An AccessCondition object that represents the If-Sequence-Number-EQ condition.
- public static AccessCondition GenerateIfSequenceNumberEqualCondition(long sequenceNumber)
- {
- return new AccessCondition { IfSequenceNumberEqual = sequenceNumber };
- }
-
- ///
- /// Constructs an access condition such that an operation will be performed only if the lease ID on the
- /// resource matches the specified lease ID.
- ///
- /// The lease ID that must match the lease ID of the resource.
- /// An AccessCondition object that represents the lease condition.
- public static AccessCondition GenerateLeaseCondition(string leaseId)
- {
- return new AccessCondition { LeaseId = leaseId };
- }
-
- ///
- /// Constructs an access condition such that an operation will be performed only if the resource's ETag value
- /// matches the specified ETag value and the lease ID on the resource matches the lease ID specified in
- /// the given access condition.
- ///
- /// An AccessCondition object that represents the lease condition.
- /// The ETag value that must be matched.
- /// An AccessCondition object that represents the If-Match and the lease conditions.
- internal static AccessCondition CloneConditionWithETag(AccessCondition accessCondition, string etag)
- {
- return new AccessCondition
- {
- IfMatchETag = etag,
- LeaseId = accessCondition != null ? accessCondition.LeaseId : null,
- };
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Auth/StorageAccountKey.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Auth/StorageAccountKey.cs
deleted file mode 100644
index a300392ab8672..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Auth/StorageAccountKey.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- internal struct StorageAccountKey
- {
- internal string KeyName;
- internal byte[] KeyValue;
-
- public StorageAccountKey(string keyName, byte[] keyValue)
- {
- this.KeyName = keyName;
- this.KeyValue = keyValue;
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Auth/StorageCredentials.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Auth/StorageCredentials.cs
deleted file mode 100644
index a79314f6029e1..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Auth/StorageCredentials.cs
+++ /dev/null
@@ -1,351 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- using Microsoft.WindowsAzure.Storage.Core;
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
-
- ///
- /// Represents a set of credentials used to authenticate access to a Windows Azure storage account.
- ///
- public sealed class StorageCredentials
- {
- private UriQueryBuilder queryBuilder;
-
- ///
- /// Gets the associated shared access signature token for the credentials.
- ///
- /// The shared access signature token.
- [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "SAS", Justification = "Back compatibility.")]
- public string SASToken { get; private set; }
-
- ///
- /// Gets the associated account name for the credentials.
- ///
- /// The account name.
- public string AccountName { get; private set; }
-
- ///
- /// Gets the associated key name for the credentials.
- ///
- /// The key name.
- public string KeyName
- {
- get
- {
- return this.Key.KeyName;
- }
- }
-
- internal StorageAccountKey Key { get; private set; }
-
- ///
- /// Gets a value indicating whether the credentials are for anonymous access.
- ///
- /// true if the credentials are for anonymous access; otherwise, false.
- public bool IsAnonymous
- {
- get
- {
- return (this.SASToken == null) && (this.AccountName == null);
- }
- }
-
- ///
- /// Gets a value indicating whether the credentials are a shared access signature token.
- ///
- /// true if the credentials are a shared access signature token; otherwise, false.
- [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "SAS", Justification = "Back compatibility.")]
- public bool IsSAS
- {
- get
- {
- return (this.SASToken != null) && (this.AccountName == null);
- }
- }
-
- ///
- /// Gets a value indicating whether the credentials are a shared key.
- ///
- /// true if the credentials are a shared key; otherwise, false.
- public bool IsSharedKey
- {
- get
- {
- return (this.SASToken == null) && (this.AccountName != null);
- }
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public StorageCredentials()
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified account name and key value.
- ///
- /// A string that represents the name of the storage account.
- /// A string that represents the Base64-encoded account access key.
- public StorageCredentials(string accountName, string keyValue)
- : this(accountName, keyValue, null)
- {
- }
-
-#if WINDOWS_DESKTOP
- ///
- /// Initializes a new instance of the class with the specified account name and key value.
- ///
- /// A string that represents the name of the storage account.
- /// An array of bytes that represent the account access key.
- public StorageCredentials(string accountName, byte[] keyValue)
- : this(accountName, keyValue, null)
- {
- }
-#endif
-
- ///
- /// Initializes a new instance of the class with the specified account name, key value, and key name.
- ///
- /// A string that represents the name of the storage account.
- /// A string that represents the Base64-encoded account access key.
- /// A string that represents the name of the key.
- public StorageCredentials(string accountName, string keyValue, string keyName)
- {
- if (string.IsNullOrEmpty(accountName))
- {
- throw new ArgumentNullException("accountName");
- }
-
- this.AccountName = accountName;
- this.UpdateKey(keyValue, keyName);
- }
-
-#if WINDOWS_DESKTOP
- ///
- /// Initializes a new instance of the class with the specified account name, key value, and key name.
- ///
- /// A string that represents the name of the storage account.
- /// An array of bytes that represent the account access key.
- /// A string that represents the name of the key.
- public StorageCredentials(string accountName, byte[] keyValue, string keyName)
- {
- if (string.IsNullOrEmpty(accountName))
- {
- throw new ArgumentNullException("accountName");
- }
-
- this.AccountName = accountName;
- this.UpdateKey(keyValue, keyName);
- }
-#endif
-
- ///
- /// Initializes a new instance of the class with the specified shared access signature token.
- ///
- /// A string representing the shared access signature token.
- public StorageCredentials(string sasToken)
- {
- if (string.IsNullOrEmpty(sasToken))
- {
- throw new ArgumentNullException("sasToken");
- }
-
- this.SASToken = sasToken;
- this.UpdateQueryBuilder();
- }
-
- ///
- /// Updates the key value for the credentials.
- ///
- /// The key value, as a Base64-encoded string, to update.
- public void UpdateKey(string keyValue)
- {
- this.UpdateKey(keyValue, null);
- }
-
-#if WINDOWS_DESKTOP
- ///
- /// Updates the key value for the credentials.
- ///
- /// The key value, as an array of bytes, to update.
- public void UpdateKey(byte[] keyValue)
- {
- this.UpdateKey(keyValue, null);
- }
-#endif
-
- ///
- /// Updates the key value and key name for the credentials.
- ///
- /// The key value, as a Base64-encoded string, to update.
- /// The key name to update.
- public void UpdateKey(string keyValue, string keyName)
- {
- if (!this.IsSharedKey)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotUpdateKeyWithoutAccountKeyCreds);
- throw new InvalidOperationException(errorMessage);
- }
-
- if (keyValue == null)
- {
- throw new ArgumentNullException("keyValue");
- }
-
- this.Key = new StorageAccountKey(keyName, Convert.FromBase64String(keyValue));
- }
-
-#if WINDOWS_DESKTOP
- ///
- /// Updates the key value and key name for the credentials.
- ///
- /// The key value, as an array of bytes, to update.
- /// The key name to update.
- public void UpdateKey(byte[] keyValue, string keyName)
- {
- if (!this.IsSharedKey)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotUpdateKeyWithoutAccountKeyCreds);
- throw new InvalidOperationException(errorMessage);
- }
-
- if (keyValue == null)
- {
- throw new ArgumentNullException("keyValue");
- }
-
- this.Key = new StorageAccountKey(keyName, keyValue);
- }
-#endif
-
- ///
- /// Updates the shared access signature (SAS) token value for storage credentials created with a shared access signature.
- ///
- /// A string that specifies the SAS token value to update.
- [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "SAS", Justification = "Back compatibility.")]
- public void UpdateSASToken(string sasToken)
- {
- if (!this.IsSAS)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotUpdateSasWithoutSasCreds);
- throw new InvalidOperationException(errorMessage);
- }
-
- if (string.IsNullOrEmpty(sasToken))
- {
- throw new ArgumentNullException("sasToken");
- }
-
- this.SASToken = sasToken;
- this.UpdateQueryBuilder();
- }
-
- ///
- /// Returns the account key for the credentials.
- ///
- /// An array of bytes that contains the key.
- public byte[] ExportKey()
- {
- return (byte[])this.Key.KeyValue.Clone();
- }
-
- ///
- /// Transforms a resource URI into a shared access signature URI, by appending a shared access token.
- ///
- /// A object that represents the resource URI to be transformed.
- /// A object that represents the signature, including the resource URI and the shared access token.
- public Uri TransformUri(Uri resourceUri)
- {
- if (this.IsSAS)
- {
- return this.queryBuilder.AddToUri(resourceUri);
- }
- else
- {
- return resourceUri;
- }
- }
-
- ///
- /// Exports the value of the account access key to a Base64-encoded string.
- ///
- /// The account access key.
- public string ExportBase64EncodedKey()
- {
- StorageAccountKey localKey = this.Key;
- return (localKey.KeyValue == null) ? null : Convert.ToBase64String(localKey.KeyValue);
- }
-
- internal string ToString(bool exportSecrets)
- {
- if (this.IsSharedKey)
- {
- return string.Format(
- CultureInfo.InvariantCulture,
- "{0}={1};{2}={3}",
- CloudStorageAccount.AccountNameSettingString,
- this.AccountName,
- CloudStorageAccount.AccountKeySettingString,
- exportSecrets ? this.ExportBase64EncodedKey() : "[key hidden]");
- }
-
- if (this.IsSAS)
- {
- return string.Format(CultureInfo.InvariantCulture, "{0}={1}", CloudStorageAccount.SharedAccessSignatureSettingString, exportSecrets ? this.SASToken : "[signature hidden]");
- }
-
- return string.Empty;
- }
-
- ///
- /// Determines whether an other object is equal to this one by comparing their SAS tokens, account names, key names, and key values.
- ///
- /// The object to compare to this one.
- /// true if the two objects are equal; otherwise, false.
- public bool Equals(StorageCredentials other)
- {
- if (other == null)
- {
- return false;
- }
- else
- {
- 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());
- }
- }
-
- private void UpdateQueryBuilder()
- {
- this.queryBuilder = new UriQueryBuilder();
- IDictionary parameters = HttpWebUtility.ParseQueryString(this.SASToken);
- foreach (KeyValuePair parameter in parameters)
- {
- this.queryBuilder.Add(parameter.Key, parameter.Value);
- }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/AuthenticationScheme.cs b/microsoft-azure-api/Services/Storage/Lib/Common/AuthenticationScheme.cs
deleted file mode 100644
index b0986d838d8e0..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/AuthenticationScheme.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Specifies the authentication scheme used to sign HTTP requests.
- ///
- public enum AuthenticationScheme
- {
- ///
- /// Signs HTTP requests using the Shared Key Lite authentication scheme.
- ///
- SharedKeyLite,
-
- ///
- /// Signs HTTP requests using the Shared Key authentication scheme.
- ///
- SharedKey
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobAttributes.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobAttributes.cs
deleted file mode 100644
index 93826ba0bd62a..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobAttributes.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 Microsoft.WindowsAzure.Storage.Core;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
-
- internal sealed class BlobAttributes
- {
- internal BlobAttributes()
- {
- this.Properties = new BlobProperties();
- this.Metadata = new Dictionary();
- }
-
- ///
- /// Gets the blob's system properties.
- ///
- /// The blob's properties.
- public BlobProperties Properties { get; internal set; }
-
- ///
- /// Gets the user-defined metadata for the blob.
- ///
- /// The blob's metadata, as a collection of name-value pairs.
- public IDictionary Metadata { get; internal set; }
-
- ///
- /// Gets the blob's URI.
- ///
- /// The absolute URI to the blob.
- public Uri Uri { get; internal set; }
-
- ///
- /// Gets the date and time that the blob snapshot was taken, if this blob is a snapshot.
- ///
- /// The blob's snapshot time if the blob is a snapshot; otherwise, null.
- ///
- /// If the blob is not a snapshot, the value of this property is null.
- ///
- public DateTimeOffset? SnapshotTime { get; internal set; }
-
- ///
- /// Gets the state of the most recent or pending copy operation.
- ///
- /// A object containing the copy state, or null if no copy blob state exists for this blob.
- public CopyState CopyState { get; internal set; }
-
- ///
- /// Verifies that the blob is not a snapshot.
- ///
- internal void AssertNoSnapshot()
- {
- if (this.SnapshotTime.HasValue)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotModifySnapshot);
- throw new InvalidOperationException(errorMessage);
- }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobContainerPermissions.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobContainerPermissions.cs
deleted file mode 100644
index 6aeb65d847e37..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobContainerPermissions.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Represents the permissions for a container.
- ///
- public sealed class BlobContainerPermissions
- {
- ///
- /// Initializes a new instance of the class.
- ///
- public BlobContainerPermissions()
- {
- this.PublicAccess = BlobContainerPublicAccessType.Off;
- this.SharedAccessPolicies = new SharedAccessBlobPolicies();
- }
-
- ///
- /// Gets or sets the public access setting for the container.
- ///
- /// The public access setting for the container.
- public BlobContainerPublicAccessType PublicAccess { get; set; }
-
- ///
- /// Gets the set of shared access policies for the container.
- ///
- /// The set of shared access policies for the container.
- public SharedAccessBlobPolicies SharedAccessPolicies { get; private set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobContainerProperties.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobContainerProperties.cs
deleted file mode 100644
index d4f9d35c64e3b..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobContainerProperties.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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;
-
- ///
- /// Represents the system properties for a container.
- ///
- public sealed class BlobContainerProperties
- {
- ///
- /// Gets the ETag value for the container.
- ///
- /// The container's quoted ETag value.
- public string ETag { get; internal set; }
-
- ///
- /// Gets the container's last-modified time.
- ///
- /// The container's last-modified time.
- public DateTimeOffset? LastModified { get; internal set; }
-
- ///
- /// Gets the container's lease status.
- ///
- /// A object that indicates the container's lease status.
- public LeaseStatus LeaseStatus { get; internal set; }
-
- ///
- /// Gets the container's lease state.
- ///
- /// A object that indicates the container's lease state.
- public LeaseState LeaseState { get; internal set; }
-
- ///
- /// Gets the container's lease duration.
- ///
- /// A object that indicates the container's lease duration.
- public LeaseDuration LeaseDuration { get; internal set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobContainerPublicAccessType.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobContainerPublicAccessType.cs
deleted file mode 100644
index 86b5053a8886b..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobContainerPublicAccessType.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Specifies the level of public access that is allowed on the container.
- ///
- public enum BlobContainerPublicAccessType
- {
- ///
- /// No public access. Only the account owner can read resources in this container.
- ///
- Off,
-
- ///
- /// Container-level public access. Anonymous clients can read container and blob data.
- ///
- Container,
-
- ///
- /// Blob-level public access. Anonymous clients can read blob data within this container, but not container data.
- ///
- Blob
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobContinuationToken.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobContinuationToken.cs
deleted file mode 100644
index 9f3646234e430..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobContinuationToken.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 Microsoft.WindowsAzure.Storage;
- using Microsoft.WindowsAzure.Storage.Core;
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
- using System.Xml;
- using System.Xml.Schema;
- using System.Xml.Serialization;
-
- ///
- /// Represents a continuation token for listing operations.
- ///
- /// continuation tokens are used in methods that return a object, such as .
- [SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1001:CommasMustBeSpacedCorrectly", Justification = "Reviewed.")]
- public sealed class BlobContinuationToken : IContinuationToken
-#if WINDOWS_DESKTOP
- , IXmlSerializable
-#endif
- {
- ///
- /// Gets or sets the next marker for continuing results for enumeration operations.
- ///
- /// The next marker.
- public string NextMarker { get; set; }
-
-#if WINDOWS_DESKTOP
- ///
- /// Gets an XML representation of an object.
- ///
- ///
- /// An that describes the XML representation of the object that is produced by the method and consumed by the method.
- ///
- public XmlSchema GetSchema()
- {
- return null;
- }
-
- ///
- /// Generates a serializable continuation token from its XML representation.
- ///
- /// The stream from which the continuation token is deserialized.
- public void ReadXml(XmlReader reader)
- {
- CommonUtility.AssertNotNull("reader", reader);
-
- reader.MoveToContent();
-
- if (reader.IsEmptyElement)
- {
- reader.Skip();
- }
- else
- {
- reader.ReadStartElement();
- while (reader.IsStartElement())
- {
- if (reader.IsEmptyElement)
- {
- reader.Skip();
- }
- else
- {
- switch (reader.Name)
- {
- case Constants.ContinuationConstants.VersionElement:
- string version = reader.ReadElementContentAsString();
- if (version != Constants.ContinuationConstants.CurrentVersion)
- {
- throw new XmlException(string.Format(CultureInfo.InvariantCulture, SR.UnexpectedElement, version));
- }
-
- break;
-
- case Constants.ContinuationConstants.NextMarkerElement:
- this.NextMarker = reader.ReadElementContentAsString();
- break;
-
- case Constants.ContinuationConstants.TypeElement:
- string continuationType = reader.ReadElementContentAsString();
- if (Constants.ContinuationConstants.BlobType != continuationType)
- {
- throw new XmlException(SR.UnexpectedContinuationType);
- }
-
- break;
-
- default:
- throw new XmlException(string.Format(CultureInfo.InvariantCulture, SR.UnexpectedElement, reader.Name));
- }
- }
- }
-
- reader.ReadEndElement();
- }
- }
-
- ///
- /// Converts a serializable continuation token into its XML representation.
- ///
- /// The stream to which the continuation token is serialized.
- public void WriteXml(XmlWriter writer)
- {
- CommonUtility.AssertNotNull("writer", writer);
-
- writer.WriteStartElement(Constants.ContinuationConstants.ContinuationTopElement);
-
- writer.WriteElementString(Constants.ContinuationConstants.VersionElement, Constants.ContinuationConstants.CurrentVersion);
-
- writer.WriteElementString(Constants.ContinuationConstants.TypeElement, Constants.ContinuationConstants.BlobType);
-
- if (this.NextMarker != null)
- {
- writer.WriteElementString(Constants.ContinuationConstants.NextMarkerElement, this.NextMarker);
- }
-
- writer.WriteEndElement(); // End ContinuationToken
- }
-#endif
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobListingDetails.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobListingDetails.cs
deleted file mode 100644
index 59f53965a241f..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobListingDetails.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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;
-
- ///
- /// Specifies which items to include when listing a set of blobs.
- ///
- [Flags]
- public enum BlobListingDetails
- {
- ///
- /// List only committed blobs, and do not return blob metadata.
- ///
- None = 0x0,
-
- ///
- /// List committed blobs and blob snapshots.
- ///
- Snapshots = 0x1,
-
- ///
- /// Retrieve blob metadata for each blob returned in the listing.
- ///
- Metadata = 0x2,
-
- ///
- /// List committed and uncommitted blobs.
- ///
- UncommittedBlobs = 0x4,
-
- ///
- /// Include copy properties in the listing.
- ///
- Copy = 0x8,
-
- ///
- /// List all available committed blobs, uncommitted blobs, and snapshots, and return all metadata and copy status for those blobs.
- ///
- All = 0xF
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobProperties.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobProperties.cs
deleted file mode 100644
index bdcf3d9330cf0..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobProperties.cs
+++ /dev/null
@@ -1,144 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 Microsoft.WindowsAzure.Storage.Core.Util;
- using System;
-
- ///
- /// Represents the system properties for a blob.
- ///
- public sealed class BlobProperties
- {
- ///
- /// Initializes a new instance of the class.
- ///
- public BlobProperties()
- {
- this.Length = -1;
- }
-
- ///
- /// Initializes a new instance of the class based on an existing instance.
- ///
- /// The set of properties to clone.
- /// Lease-related properties will not be cloned, because a lease associated with the base blob is not copied to the snapshot.
- public BlobProperties(BlobProperties other)
- {
- CommonUtility.AssertNotNull("other", other);
-
- this.BlobType = other.BlobType;
- this.ContentType = other.ContentType;
- this.ContentEncoding = other.ContentEncoding;
- this.ContentLanguage = other.ContentLanguage;
- this.CacheControl = other.CacheControl;
- this.ContentMD5 = other.ContentMD5;
- this.Length = other.Length;
- this.ETag = other.ETag;
- this.LastModified = other.LastModified;
- this.PageBlobSequenceNumber = other.PageBlobSequenceNumber;
- }
-
- ///
- /// Gets or sets the cache-control value stored for the blob.
- ///
- /// The blob's cache-control value.
- public string CacheControl { get; set; }
-
- ///
- /// Gets or sets the content-encoding value stored for the blob.
- ///
- /// The blob's content-encoding value.
- ///
- /// If this property has not been set for the blob, it returns null.
- ///
- public string ContentEncoding { get; set; }
-
- ///
- /// Gets or sets the content-language value stored for the blob.
- ///
- /// The blob's content-language value.
- ///
- /// If this property has not been set for the blob, it returns null.
- ///
- public string ContentLanguage { get; set; }
-
- ///
- /// Gets the size of the blob, in bytes.
- ///
- /// The blob's size in bytes.
- public long Length { get; internal set; }
-
- ///
- /// Gets or sets the content-MD5 value stored for the blob.
- ///
- /// The blob's content-MD5 hash.
- public string ContentMD5 { get; set; }
-
- ///
- /// Gets or sets the content-type value stored for the blob.
- ///
- /// The blob's content-type value.
- ///
- /// If this property has not been set for the blob, it returns null.
- ///
- public string ContentType { get; set; }
-
- ///
- /// Gets the blob's ETag value.
- ///
- /// The blob's ETag value.
- public string ETag { get; internal set; }
-
- ///
- /// Gets the the last-modified time for the blob, expressed as a UTC value.
- ///
- /// The blob's last-modified time, in UTC format.
- public DateTimeOffset? LastModified { get; internal set; }
-
- ///
- /// Gets the type of the blob.
- ///
- /// A object that indicates the type of the blob.
- public BlobType BlobType { get; internal set; }
-
- ///
- /// Gets the blob's lease status.
- ///
- /// A object that indicates the blob's lease status.
- public LeaseStatus LeaseStatus { get; internal set; }
-
- ///
- /// Gets the blob's lease state.
- ///
- /// A object that indicates the blob's lease state.
- public LeaseState LeaseState { get; internal set; }
-
- ///
- /// Gets the blob's lease duration.
- ///
- /// A object that indicates the blob's lease duration.
- public LeaseDuration LeaseDuration { get; internal set; }
-
- ///
- /// If the blob is a page blob, gets the blob's current sequence number.
- ///
- /// The blob's current sequence number.
- public long? PageBlobSequenceNumber { get; internal set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobReadStreamBase.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobReadStreamBase.cs
deleted file mode 100644
index 23bbab9f826d9..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobReadStreamBase.cs
+++ /dev/null
@@ -1,299 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 Microsoft.WindowsAzure.Storage.Core;
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
- using System.IO;
-
- [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed.")]
- internal abstract class BlobReadStreamBase : Stream
- {
- protected ICloudBlob blob;
- protected BlobProperties blobProperties;
- protected long currentOffset;
- protected MemoryStream internalBuffer;
- protected int streamMinimumReadSizeInBytes;
- protected AccessCondition accessCondition;
- protected BlobRequestOptions options;
- protected OperationContext operationContext;
- protected MD5Wrapper blobMD5;
- protected volatile Exception lastException;
-
- ///
- /// Initializes a new instance of the BlobReadStreamBase class.
- ///
- /// Blob reference to read from
- /// An object that represents the access conditions for the blob. If null, no condition is used.
- /// An object that specifies additional options for the request.
- /// An object for tracking the current operation.
- protected BlobReadStreamBase(ICloudBlob blob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
- {
- if (options.UseTransactionalMD5.Value)
- {
- CommonUtility.AssertInBounds("StreamMinimumReadSizeInBytes", blob.StreamMinimumReadSizeInBytes, 1, Constants.MaxRangeGetContentMD5Size);
- }
-
- this.blob = blob;
- this.blobProperties = new BlobProperties(blob.Properties);
- this.currentOffset = 0;
- this.streamMinimumReadSizeInBytes = this.blob.StreamMinimumReadSizeInBytes;
- this.internalBuffer = new MemoryStream(this.streamMinimumReadSizeInBytes);
- this.accessCondition = accessCondition;
- this.options = options;
- this.operationContext = operationContext;
- this.blobMD5 = (this.options.DisableContentMD5Validation.Value || string.IsNullOrEmpty(this.blobProperties.ContentMD5)) ? null : new MD5Wrapper();
- this.lastException = null;
- }
-
- ///
- /// Gets a value indicating whether the current stream supports reading.
- ///
- public override bool CanRead
- {
- get
- {
- return true;
- }
- }
-
- ///
- /// Gets a value indicating whether the current stream supports seeking.
- ///
- public override bool CanSeek
- {
- get
- {
- return true;
- }
- }
-
- ///
- /// Gets a value indicating whether the current stream supports writing.
- ///
- public override bool CanWrite
- {
- get
- {
- return false;
- }
- }
-
- ///
- /// Gets or sets the position within the current stream.
- ///
- public override long Position
- {
- get
- {
- return this.currentOffset;
- }
-
- set
- {
- this.Seek(value, SeekOrigin.Begin);
- }
- }
-
- ///
- /// Gets the length in bytes of the stream.
- ///
- /// The length in bytes of the stream.
- public override long Length
- {
- get
- {
- return this.blobProperties.Length;
- }
- }
-
- ///
- /// Sets the position within the current stream.
- ///
- /// A byte offset relative to the origin parameter.
- /// A value of type SeekOrigin indicating the reference
- /// point used to obtain the new position.
- /// The new position within the current stream.
- /// Seeking in a BlobReadStream disables MD5 validation.
- public override long Seek(long offset, SeekOrigin origin)
- {
- if (this.lastException != null)
- {
- throw this.lastException;
- }
-
- long newOffset;
- switch (origin)
- {
- case SeekOrigin.Begin:
- newOffset = offset;
- break;
-
- case SeekOrigin.Current:
- newOffset = this.currentOffset + offset;
- break;
-
- case SeekOrigin.End:
- newOffset = this.Length + offset;
- break;
-
- default:
- CommonUtility.ArgumentOutOfRange("origin", origin);
- throw new ArgumentOutOfRangeException("origin");
- }
-
- CommonUtility.AssertInBounds("offset", newOffset, 0, this.Length);
-
- if (newOffset != this.currentOffset)
- {
- long bufferOffset = this.internalBuffer.Position + (newOffset - this.currentOffset);
- if ((bufferOffset >= 0) && (bufferOffset < this.internalBuffer.Length))
- {
- this.internalBuffer.Position = bufferOffset;
- }
- else
- {
- this.internalBuffer.SetLength(0);
- }
-
- this.blobMD5 = null;
- this.currentOffset = newOffset;
- }
-
- return this.currentOffset;
- }
-
- ///
- /// This operation is not supported in BlobReadStreamBase.
- ///
- /// Not used.
- public override void SetLength(long value)
- {
- throw new NotSupportedException();
- }
-
- ///
- /// This operation is not supported in BlobReadStreamBase.
- ///
- /// Not used.
- /// Not used.
- /// Not used.
- public override void Write(byte[] buffer, int offset, int count)
- {
- throw new NotSupportedException();
- }
-
- ///
- /// This operation is a no-op in BlobReadStreamBase.
- ///
- public override void Flush()
- {
- }
-
- ///
- /// Read as much as we can from the internal buffer
- ///
- /// The buffer to read the data into.
- /// The byte offset in buffer at which to begin writing
- /// data read from the stream.
- /// The maximum number of bytes to read.
- /// Number of bytes read from the stream.
- protected int ConsumeBuffer(byte[] buffer, int offset, int count)
- {
- int readCount = this.internalBuffer.Read(buffer, offset, count);
- this.currentOffset += readCount;
- this.VerifyBlobMD5(buffer, offset, readCount);
- return readCount;
- }
-
- ///
- /// Calculates the number of bytes to read from the blob.
- ///
- /// Number of bytes to read.
- protected int GetReadSize()
- {
- if (this.currentOffset < this.Length)
- {
- return (int)Math.Min(this.streamMinimumReadSizeInBytes, this.Length - this.currentOffset);
- }
- else
- {
- return 0;
- }
- }
-
- ///
- /// Updates the blob MD5 with newly downloaded content.
- ///
- /// The buffer to read the data from.
- /// The byte offset in buffer at which to begin reading data.
- /// The maximum number of bytes to read.
- protected void VerifyBlobMD5(byte[] buffer, int offset, int count)
- {
- if ((this.blobMD5 != null) && (this.lastException == null) && (count > 0))
- {
- this.blobMD5.UpdateHash(buffer, offset, count);
-
- if ((this.currentOffset == this.Length) &&
- !string.IsNullOrEmpty(this.blobProperties.ContentMD5))
- {
- string computedMD5 = this.blobMD5.ComputeHash();
- this.blobMD5.Dispose();
- this.blobMD5 = null;
-
- if (!computedMD5.Equals(this.blobProperties.ContentMD5))
- {
- this.lastException = new IOException(string.Format(
- CultureInfo.InvariantCulture,
- SR.BlobDataCorrupted,
- this.blobProperties.ContentMD5,
- computedMD5));
- }
- }
- }
- }
-
- ///
- /// Releases the blob resources used by the Stream.
- ///
- /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (this.blobMD5 != null)
- {
- this.blobMD5.Dispose();
- this.blobMD5 = null;
- }
-
- if (this.internalBuffer != null)
- {
- this.internalBuffer.Dispose();
- this.internalBuffer = null;
- }
- }
-
- base.Dispose(disposing);
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobRequestOptions.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobRequestOptions.cs
deleted file mode 100644
index 283e27810fe2a..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobRequestOptions.cs
+++ /dev/null
@@ -1,189 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 Microsoft.WindowsAzure.Storage;
- using Microsoft.WindowsAzure.Storage.Core;
- using Microsoft.WindowsAzure.Storage.RetryPolicies;
- using System;
-
- ///
- /// Represents a set of timeout and retry policy options that may be specified for a request against the Blob service.
- ///
- public sealed class BlobRequestOptions : IRequestOptions
- {
- ///
- /// Initializes a new instance of the class.
- ///
- public BlobRequestOptions()
- {
- }
-
- ///
- /// Clones an instance of BlobRequestOptions so that we can apply defaults.
- ///
- /// BlobRequestOptions instance to be cloned.
- internal BlobRequestOptions(BlobRequestOptions other)
- : this()
- {
- if (other != null)
- {
- this.RetryPolicy = other.RetryPolicy;
- this.ServerTimeout = other.ServerTimeout;
- this.MaximumExecutionTime = other.MaximumExecutionTime;
- this.OperationExpiryTime = other.OperationExpiryTime;
- this.UseTransactionalMD5 = other.UseTransactionalMD5;
- this.StoreBlobContentMD5 = other.StoreBlobContentMD5;
- this.DisableContentMD5Validation = other.DisableContentMD5Validation;
- }
- }
-
- internal static BlobRequestOptions ApplyDefaults(BlobRequestOptions options, BlobType blobType, CloudBlobClient serviceClient, bool applyExpiry = true)
- {
- BlobRequestOptions modifiedOptions = new BlobRequestOptions(options);
-
- modifiedOptions.RetryPolicy = modifiedOptions.RetryPolicy ?? serviceClient.RetryPolicy;
- modifiedOptions.ServerTimeout = modifiedOptions.ServerTimeout ?? serviceClient.ServerTimeout;
- modifiedOptions.MaximumExecutionTime = modifiedOptions.MaximumExecutionTime ?? serviceClient.MaximumExecutionTime;
-
- if (applyExpiry && !modifiedOptions.OperationExpiryTime.HasValue && modifiedOptions.MaximumExecutionTime.HasValue)
- {
- modifiedOptions.OperationExpiryTime = DateTime.Now + modifiedOptions.MaximumExecutionTime.Value;
- }
-
-#if WINDOWS_PHONE
- modifiedOptions.DisableContentMD5Validation = true;
- modifiedOptions.StoreBlobContentMD5 = false;
- modifiedOptions.UseTransactionalMD5 = false;
-#else
- modifiedOptions.DisableContentMD5Validation = modifiedOptions.DisableContentMD5Validation ?? false;
- modifiedOptions.StoreBlobContentMD5 = modifiedOptions.StoreBlobContentMD5 ?? (blobType == BlobType.BlockBlob);
- modifiedOptions.UseTransactionalMD5 = modifiedOptions.UseTransactionalMD5 ?? false;
-#endif
-
- return modifiedOptions;
- }
-
- ///
- /// Gets or sets the absolute expiry time across all potential retries for the request.
- ///
- internal DateTime? OperationExpiryTime { get; set; }
-
- ///
- /// Gets or sets the retry policy.
- ///
- /// The retry policy.
- public IRetryPolicy RetryPolicy { get; set; }
-
- ///
- /// Gets or sets the server timeout interval for the request.
- ///
- /// The server timeout interval for the request.
- public TimeSpan? ServerTimeout { get; set; }
-
- ///
- /// Gets or sets the maximum execution time across all potential retries for the request.
- ///
- /// A representing the maximum execution time for retries for the request.
- public TimeSpan? MaximumExecutionTime { get; set; }
-
- ///
- /// Gets or sets a value to calculate and send/validate content MD5 for transactions.
- ///
- /// Use true to calculate and send/validate content MD5 for transactions; otherwise, false.
-#if WINDOWS_PHONE
- /// This property is not supported for Windows Phone.
-#endif
- public bool? UseTransactionalMD5
- {
- get
- {
- return this.useTransactionalMD5;
- }
-
- set
- {
-#if WINDOWS_PHONE
- if (value.HasValue && value.Value)
- {
- throw new NotSupportedException(SR.WindowsPhoneDoesNotSupportMD5);
- }
-#endif
- this.useTransactionalMD5 = value;
- }
- }
-
- private bool? useTransactionalMD5;
-
- ///
- /// Gets or sets a value to indicate that an MD5 hash will be calculated and stored when uploading a blob.
- ///
- /// Use true to calculate and store an MD5 hash when uploading a blob; otherwise, false.
-#if WINDOWS_PHONE
- /// This property is not supported for Windows Phone.
-#endif
- public bool? StoreBlobContentMD5
- {
- get
- {
- return this.storeBlobContentMD5;
- }
-
- set
- {
-#if WINDOWS_PHONE
- if (value.HasValue && value.Value)
- {
- throw new NotSupportedException(SR.WindowsPhoneDoesNotSupportMD5);
- }
-#endif
- this.storeBlobContentMD5 = value;
- }
- }
-
- private bool? storeBlobContentMD5;
-
- ///
- /// Gets or sets a value to indicate that MD5 validation will be disabled when downloading blobs.
- ///
- /// Use true to disable MD5 validation; false to enable MD5 validation.
-#if WINDOWS_PHONE
- /// This property is not supported for Windows Phone.
-#endif
- public bool? DisableContentMD5Validation
- {
- get
- {
- return this.disableContentMD5Validation;
- }
-
- set
- {
-#if WINDOWS_PHONE
- if (value.HasValue && !value.Value)
- {
- throw new NotSupportedException(SR.WindowsPhoneDoesNotSupportMD5);
- }
-#endif
- this.disableContentMD5Validation = value;
- }
- }
-
- private bool? disableContentMD5Validation;
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobResultSegment.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobResultSegment.cs
deleted file mode 100644
index 4b53c179c9eed..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobResultSegment.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Collections.Generic;
-
- ///
- /// Represents a segment of results, with continuation information for pagination scenarios.
- ///
- public sealed class BlobResultSegment
- {
- internal BlobResultSegment(IEnumerable blobs, BlobContinuationToken continuationToken)
- {
- this.Results = blobs;
- this.ContinuationToken = continuationToken;
- }
-
- ///
- /// Gets an enumerable collection of results.
- ///
- /// An enumerable collection of results.
- public IEnumerable Results { get; private set; }
-
- ///
- /// Gets the continuation token used to retrieve the next segment of results. Returns null if there are no more results.
- ///
- /// The continuation token.
- public BlobContinuationToken ContinuationToken { get; private set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobType.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobType.cs
deleted file mode 100644
index 1804a0081bdac..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobType.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// The type of a blob.
- ///
- public enum BlobType
- {
- ///
- /// Not specified.
- ///
- Unspecified,
-
- ///
- /// A page blob.
- ///
- PageBlob,
-
- ///
- /// A block blob.
- ///
- BlockBlob,
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobWriteStreamBase.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobWriteStreamBase.cs
deleted file mode 100644
index 59c568375903e..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlobWriteStreamBase.cs
+++ /dev/null
@@ -1,316 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 Microsoft.WindowsAzure.Storage.Core;
- 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;
- using System.IO;
- using System.Text;
-
- [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;
- protected long pageBlobSize;
- protected bool newPageBlob;
- protected long currentOffset;
- protected long currentPageOffset;
- protected int streamWriteSizeInBytes;
- protected MultiBufferMemoryStream internalBuffer;
- protected List blockList;
- protected string blockIdPrefix;
- protected AccessCondition accessCondition;
- protected BlobRequestOptions options;
- protected OperationContext operationContext;
- protected CounterEvent noPendingWritesEvent;
- protected MD5Wrapper blobMD5;
- protected MD5Wrapper blockMD5;
- protected AsyncSemaphore parallelOperationSemaphore;
- protected volatile Exception lastException;
- protected volatile bool committed;
- protected bool disposed;
-
- ///
- /// Initializes a new instance of the BlobWriteStreamBase class.
- ///
- /// The service client.
- /// An object that represents the access conditions for the blob. If null, no condition is used.
- /// An object that specifies additional options for the request.
- /// An object for tracking the current operation.
- private BlobWriteStreamBase(CloudBlobClient serviceClient, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
- : base()
- {
- this.internalBuffer = new MultiBufferMemoryStream(serviceClient.BufferManager);
- this.currentOffset = 0;
- this.accessCondition = accessCondition;
- this.options = options;
- this.operationContext = operationContext;
- this.noPendingWritesEvent = new CounterEvent();
- this.blobMD5 = this.options.StoreBlobContentMD5.Value ? new MD5Wrapper() : null;
- this.blockMD5 = this.options.UseTransactionalMD5.Value ? new MD5Wrapper() : null;
- this.parallelOperationSemaphore = new AsyncSemaphore(serviceClient.ParallelOperationThreadCount);
- this.lastException = null;
- this.committed = false;
- this.disposed = false;
- }
-
- ///
- /// Initializes a new instance of the BlobWriteStreamBase class for a block blob.
- ///
- /// Blob reference to write to.
- /// An object that represents the access conditions for the blob. If null, no condition is used.
- /// An object that specifies additional options for the request.
- /// An object for tracking the current operation.
- protected BlobWriteStreamBase(CloudBlockBlob blockBlob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
- : this(blockBlob.ServiceClient, accessCondition, options, operationContext)
- {
- this.blockBlob = blockBlob;
- this.blockList = new List();
- this.blockIdPrefix = Guid.NewGuid().ToString("N") + "-";
- this.streamWriteSizeInBytes = blockBlob.StreamWriteSizeInBytes;
- }
-
- ///
- /// Initializes a new instance of the BlobWriteStreamBase class for a page blob.
- ///
- /// Blob reference to write to.
- /// Size of the page blob.
- /// Use true if the page blob is newly created, false otherwise.
- /// An object that represents the access conditions for the blob. If null, no condition is used.
- /// An object that specifies additional options for the request.
- /// An object for tracking the current operation.
- protected BlobWriteStreamBase(CloudPageBlob pageBlob, long pageBlobSize, bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
- : this(pageBlob.ServiceClient, accessCondition, options, operationContext)
- {
- this.currentPageOffset = 0;
- this.pageBlob = pageBlob;
- this.pageBlobSize = pageBlobSize;
- this.streamWriteSizeInBytes = pageBlob.StreamWriteSizeInBytes;
- this.newPageBlob = createNew;
- }
-
- protected ICloudBlob Blob
- {
- get
- {
- if (this.blockBlob != null)
- {
- return this.blockBlob;
- }
- else
- {
- return this.pageBlob;
- }
- }
- }
-
- ///
- /// Gets a value indicating whether the current stream supports reading.
- ///
- public override bool CanRead
- {
- get
- {
- return false;
- }
- }
-
- ///
- /// Gets a value indicating whether the current stream supports seeking.
- ///
- public override bool CanSeek
- {
- get
- {
- return this.pageBlob != null;
- }
- }
-
- ///
- /// Gets a value indicating whether the current stream supports writing.
- ///
- public override bool CanWrite
- {
- get
- {
- return true;
- }
- }
-
- ///
- /// Gets the length in bytes of the stream.
- ///
- public override long Length
- {
- get
- {
- if (this.pageBlob != null)
- {
- return this.pageBlobSize;
- }
- else
- {
- throw new NotSupportedException();
- }
- }
- }
-
- ///
- /// Gets or sets the position within the current stream.
- ///
- public override long Position
- {
- get
- {
- return this.currentOffset;
- }
-
- set
- {
- this.Seek(value, SeekOrigin.Begin);
- }
- }
-
- ///
- /// This operation is not supported in BlobWriteStreamBase.
- ///
- /// Not used.
- /// Not used.
- /// Not used.
- public override int Read(byte[] buffer, int offset, int count)
- {
- throw new NotSupportedException();
- }
-
- ///
- /// Calculates the new position within the current stream for a Seek operation.
- ///
- /// A byte offset relative to the origin parameter.
- /// A value of type SeekOrigin indicating the reference
- /// point used to obtain the new position.
- /// The new position within the current stream.
- protected long GetNewOffset(long offset, SeekOrigin origin)
- {
- if (!this.CanSeek)
- {
- throw new NotSupportedException();
- }
-
- if (this.lastException != null)
- {
- throw this.lastException;
- }
-
- long newOffset;
- switch (origin)
- {
- case SeekOrigin.Begin:
- newOffset = offset;
- break;
-
- case SeekOrigin.Current:
- newOffset = this.currentOffset + offset;
- break;
-
- case SeekOrigin.End:
- newOffset = this.Length + offset;
- break;
-
- default:
- CommonUtility.ArgumentOutOfRange("origin", origin);
- throw new ArgumentOutOfRangeException("origin");
- }
-
- CommonUtility.AssertInBounds("offset", newOffset, 0, this.Length);
-
- if ((newOffset % Constants.PageSize) != 0)
- {
- CommonUtility.ArgumentOutOfRange("offset", offset);
- }
-
- return newOffset;
- }
-
- ///
- /// This operation is not supported in BlobWriteStreamBase.
- ///
- /// Not used.
- public override void SetLength(long value)
- {
- throw new NotSupportedException();
- }
-
- ///
- /// Generates a new block ID to be used for PutBlock.
- ///
- /// Base64 encoded block ID
- protected string GetCurrentBlockId()
- {
- string blockIdSuffix = this.blockList.Count.ToString("D6", CultureInfo.InvariantCulture);
- byte[] blockIdInBytes = Encoding.UTF8.GetBytes(this.blockIdPrefix + blockIdSuffix);
- return Convert.ToBase64String(blockIdInBytes);
- }
-
- ///
- /// Releases the blob resources used by the Stream.
- ///
- /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (this.blobMD5 != null)
- {
- this.blobMD5.Dispose();
- this.blobMD5 = null;
- }
-
- if (this.blockMD5 != null)
- {
- this.blockMD5.Dispose();
- this.blockMD5 = null;
- }
-
- if (this.internalBuffer != null)
- {
- this.internalBuffer.Dispose();
- this.internalBuffer = null;
- }
-
- if (this.noPendingWritesEvent != null)
- {
- this.noPendingWritesEvent.Dispose();
- this.noPendingWritesEvent = null;
- }
- }
-
- base.Dispose(disposing);
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlockListingFilter.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlockListingFilter.cs
deleted file mode 100644
index 7c9bf566d0eea..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlockListingFilter.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Indicates whether to list only committed blocks, only uncommitted blocks, or all blocks.
- ///
- public enum BlockListingFilter
- {
- ///
- /// Committed blocks.
- ///
- Committed,
-
- ///
- /// Uncommitted blocks.
- ///
- Uncommitted,
-
- ///
- /// Both committed and uncommitted blocks.
- ///
- All
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlockSearchMode.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlockSearchMode.cs
deleted file mode 100644
index 35ba6a78f39d3..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/BlockSearchMode.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Indicates which block lists should be searched to find a specified block.
- ///
- public enum BlockSearchMode
- {
- ///
- /// Search the committed block list only.
- ///
- Committed,
-
- ///
- /// Search the uncommitted block list only.
- ///
- Uncommitted,
-
- ///
- /// Search the uncommitted block list first, and if the block is not found there, search
- /// the committed block list.
- ///
- Latest
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudBlobClient.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudBlobClient.Common.cs
deleted file mode 100644
index 6f8f3ac5ad233..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudBlobClient.Common.cs
+++ /dev/null
@@ -1,334 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 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;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
-
- ///
- /// 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
- {
- ///
- /// Constant for the max value of ParallelOperationThreadCount.
- ///
- private const int MaxParallelOperationThreadCount = 64;
-
- ///
- /// Stores the default delimiter.
- ///
- private string defaultDelimiter;
-
- ///
- /// Stores the parallelism factor.
- ///
- private int parallelismFactor = 1;
-
- ///
- /// Default is 32 MB.
- ///
- private long singleBlobUploadThresholdInBytes = Constants.MaxSingleUploadBlobSize / 2;
-
- ///
- /// The default server and client timeout interval.
- ///
- private TimeSpan? timeout;
-
- ///
- /// Max execution time across all potential retries.
- ///
- private TimeSpan? maximumExecutionTime;
-
- private AuthenticationScheme authenticationScheme;
-
- ///
- /// Initializes a new instance of the class using the specified Blob service endpoint
- /// and anonymous credentials.
- ///
- /// The Blob service endpoint to use to create the client.
- public CloudBlobClient(Uri baseUri)
- : this(baseUri, null /* credentials */)
- {
- }
-
- ///
- /// Initializes a new instance of the class using the specified Blob service endpoint
- /// and account credentials.
- ///
- /// The Blob service endpoint to use to create the client.
- /// The account credentials.
- public CloudBlobClient(Uri baseUri, StorageCredentials credentials)
- : this(null /* usePathStyleUris */, baseUri, credentials)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// True to use path style Uris.
- /// The Blob service endpoint to use to create the client.
- /// The account credentials.
- internal CloudBlobClient(bool? usePathStyleUris, Uri baseUri, StorageCredentials credentials)
- {
- CommonUtility.AssertNotNull("baseUri", baseUri);
-
- if (credentials == null)
- {
- credentials = new StorageCredentials();
- }
-
- if (baseUri == null)
- {
- throw new ArgumentNullException("baseUri");
- }
-
- if (!baseUri.IsAbsoluteUri)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.RelativeAddressNotPermitted, baseUri.ToString());
- throw new ArgumentException(errorMessage, "baseUri");
- }
-
- this.BaseUri = baseUri;
- this.Credentials = credentials;
- this.RetryPolicy = new ExponentialRetry();
- this.ServerTimeout = Constants.DefaultServerSideTimeout;
- this.DefaultDelimiter = NavigationHelper.Slash;
- this.AuthenticationScheme = AuthenticationScheme.SharedKey;
-
- if (usePathStyleUris.HasValue)
- {
- this.UsePathStyleUris = usePathStyleUris.Value;
- }
- else
- {
- // Automatically decide whether to use host style uri or path style uri
- this.UsePathStyleUris = CommonUtility.UsePathStyleAddressing(this.BaseUri);
- }
- }
-
- ///
- /// Gets or sets a buffer manager that implements the interface,
- /// specifying a buffer pool for use with operations against the Blob service client.
- ///
- public IBufferManager BufferManager { get; set; }
-
- ///
- /// Gets the account credentials used to create the Blob service client.
- ///
- /// The account credentials.
- public StorageCredentials Credentials { get; private set; }
-
- ///
- /// Gets the base URI for the Blob service client.
- ///
- /// The base URI used to construct the Blob service client.
- public Uri BaseUri { get; private set; }
-
- ///
- /// Gets or sets the default retry policy for requests made via the Blob service client.
- ///
- /// The retry policy.
- public IRetryPolicy RetryPolicy { get; set; }
-
- ///
- /// Gets or sets the default server and client timeout for requests made via the Blob service client.
- ///
- /// The server and client timeout interval.
- public TimeSpan? ServerTimeout
- {
- get
- {
- return this.timeout;
- }
-
- set
- {
- if (value.HasValue)
- {
- CommonUtility.CheckTimeoutBounds(value.Value);
- }
-
- this.timeout = value;
- }
- }
-
- ///
- /// Gets or sets the maximum execution time across all potential retries.
- ///
- /// The maximum execution time across all potential retries.
- public TimeSpan? MaximumExecutionTime
- {
- get
- {
- return this.maximumExecutionTime;
- }
-
- set
- {
- if (value.HasValue)
- {
- CommonUtility.CheckTimeoutBounds(value.Value);
- }
-
- this.maximumExecutionTime = value;
- }
- }
-
- ///
- /// Gets or sets the default delimiter that may be used to create a virtual directory structure of blobs.
- ///
- /// The default delimiter.
- public string DefaultDelimiter
- {
- get
- {
- return this.defaultDelimiter;
- }
-
- set
- {
- CommonUtility.AssertNotNullOrEmpty("DefaultDelimiter", value);
- this.defaultDelimiter = value;
- }
- }
-
- ///
- /// Gets or sets the maximum size of a blob in bytes that may be uploaded as a single blob.
- ///
- /// The maximum size of a blob, in bytes, that may be uploaded as a single blob,
- /// ranging from between 1 and 64 MB inclusive.
- public long SingleBlobUploadThresholdInBytes
- {
- get
- {
- return this.singleBlobUploadThresholdInBytes;
- }
-
- set
- {
- CommonUtility.AssertInBounds("SingleBlobUploadThresholdInBytes", value, 1 * Constants.MB, Constants.MaxSingleUploadBlobSize);
- this.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.
- ///
- /// The number of parallel operations that may proceed.
- public int ParallelOperationThreadCount
- {
- get
- {
- return this.parallelismFactor;
- }
-
- set
- {
- CommonUtility.AssertInBounds("UploadParallelActiveTasks", value, 1, MaxParallelOperationThreadCount);
- this.parallelismFactor = value;
- }
- }
-
- ///
- /// Gets a value indicating whether the service client is used with Path style or Host style.
- ///
- /// Is true if use path style uris; otherwise, false.
- internal bool UsePathStyleUris { get; private set; }
-
- ///
- /// Returns a reference to the root container for this service client.
- ///
- /// A reference to the root container.
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Reviewed")]
- public CloudBlobContainer GetRootContainerReference()
- {
- return new CloudBlobContainer(NavigationHelper.RootContainerName, this);
- }
-
- ///
- /// Returns a reference to a object with the specified name.
- ///
- /// The name of the container, or an absolute URI to the container.
- /// A reference to a container.
- public CloudBlobContainer GetContainerReference(string containerName)
- {
- CommonUtility.AssertNotNullOrEmpty("containerName", containerName);
- return new CloudBlobContainer(containerName, this);
- }
-
- private ICanonicalizer GetCanonicalizer()
- {
- if (this.AuthenticationScheme == AuthenticationScheme.SharedKeyLite)
- {
- return SharedKeyLiteCanonicalizer.Instance;
- }
-
- return SharedKeyCanonicalizer.Instance;
- }
-
- ///
- /// Parses the user prefix.
- ///
- /// The prefix.
- /// Name of the container.
- /// The listing prefix.
- private static void ParseUserPrefix(string prefix, out string containerName, out string listingPrefix)
- {
- containerName = null;
- listingPrefix = null;
-
- string[] prefixParts = prefix.Split(NavigationHelper.SlashAsSplitOptions, 2, StringSplitOptions.None);
- if (prefixParts.Length == 1)
- {
- // No slash in prefix
- // Case abc => container = $root, prefix=abc; Listing with prefix at root
- listingPrefix = prefixParts[0];
- }
- else
- {
- // Case "/abc" => container=$root, prefix=abc; Listing with prefix at root
- // Case "abc/" => container=abc, no prefix; Listing all under a container
- // Case "abc/def" => container = abc, prefix = def; Listing with prefix under a container
- // Case "/" => container=$root, no prefix; Listing all under root
- containerName = prefixParts[0];
- listingPrefix = prefixParts[1];
- }
-
- if (string.IsNullOrEmpty(containerName))
- {
- containerName = NavigationHelper.RootContainerName;
- }
-
- if (string.IsNullOrEmpty(listingPrefix))
- {
- listingPrefix = null;
- }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudBlobContainer.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudBlobContainer.Common.cs
deleted file mode 100644
index 49dd2821c5714..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudBlobContainer.Common.cs
+++ /dev/null
@@ -1,240 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 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;
- using System.Globalization;
-
- ///
- /// Represents a container in the Windows Azure Blob service.
- ///
- public sealed partial class CloudBlobContainer
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The absolute URI to the container.
- public CloudBlobContainer(Uri containerAddress)
- : this(containerAddress, null /* credentials */)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The absolute URI to the container.
- /// The account credentials.
- public CloudBlobContainer(Uri containerAddress, StorageCredentials credentials)
- {
- this.ParseQueryAndVerify(containerAddress, credentials);
- this.Metadata = new Dictionary();
- this.Properties = new BlobContainerProperties();
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The container name.
- /// A client object that specifies the endpoint for the Blob service.
- internal CloudBlobContainer(string containerName, CloudBlobClient serviceClient)
- : this(new BlobContainerProperties(), new Dictionary(), containerName, serviceClient)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The properties.
- /// The metadata.
- /// The container name.
- /// The client to be used.
- internal CloudBlobContainer(BlobContainerProperties properties, IDictionary metadata, string containerName, CloudBlobClient serviceClient)
- {
- this.Uri = NavigationHelper.AppendPathToUri(serviceClient.BaseUri, containerName);
- this.ServiceClient = serviceClient;
- this.Name = containerName;
- this.Metadata = metadata;
- this.Properties = properties;
- }
-
- ///
- /// Gets the service client for the container.
- ///
- /// A client object that specifies the endpoint for the Blob service.
- public CloudBlobClient ServiceClient { get; private set; }
-
- ///
- /// Gets the container's URI.
- ///
- /// The absolute URI to the container.
- public Uri Uri { get; private set; }
-
- ///
- /// Gets the name of the container.
- ///
- /// The container's name.
- public string Name { get; private set; }
-
- ///
- /// Gets the container's metadata.
- ///
- /// The container's metadata.
- public IDictionary Metadata { get; private set; }
-
- ///
- /// Gets the container's system properties.
- ///
- /// The container's properties.
- public BlobContainerProperties Properties { get; private set; }
-
- ///
- /// Parse URI for SAS (Shared Access Signature) information.
- ///
- /// The complete Uri.
- /// The credentials to use.
- private void ParseQueryAndVerify(Uri address, StorageCredentials credentials)
- {
- StorageCredentials parsedCredentials;
- DateTimeOffset? parsedSnapshot;
- this.Uri = NavigationHelper.ParseBlobQueryAndVerify(address, out parsedCredentials, out parsedSnapshot);
-
- if ((parsedCredentials != null) && (credentials != null) && !parsedCredentials.Equals(credentials))
- {
- string error = string.Format(CultureInfo.CurrentCulture, SR.MultipleCredentialsProvided);
- throw new ArgumentException(error);
- }
-
- this.ServiceClient = new CloudBlobClient(NavigationHelper.GetServiceClientBaseAddress(this.Uri, null /* usePathStyleUris */), credentials ?? parsedCredentials);
- this.Name = NavigationHelper.GetContainerNameFromContainerAddress(this.Uri, this.ServiceClient.UsePathStyleUris);
- }
-
- ///
- /// Returns the canonical name for shared access.
- ///
- /// The canonical name.
- private string GetSharedAccessCanonicalName()
- {
- if (this.ServiceClient.UsePathStyleUris)
- {
- return this.Uri.AbsolutePath;
- }
- else
- {
- return NavigationHelper.GetCanonicalPathFromCreds(this.ServiceClient.Credentials, this.Uri.AbsolutePath);
- }
- }
-
- ///
- /// Returns a shared access signature for the container.
- ///
- /// The access policy for the shared access signature.
- /// A shared access signature, as a URI query string.
- /// The query string returned includes the leading question mark.
- public string GetSharedAccessSignature(SharedAccessBlobPolicy policy)
- {
- return this.GetSharedAccessSignature(policy, null /* groupPolicyIdentifier */);
- }
-
- ///
- /// Returns a shared access signature for the container.
- ///
- /// The access policy for the shared access signature.
- /// A container-level access policy.
- /// A shared access signature, as a URI query string.
- /// The query string returned includes the leading question mark.
- public string GetSharedAccessSignature(SharedAccessBlobPolicy policy, string groupPolicyIdentifier)
- {
- if (!this.ServiceClient.Credentials.IsSharedKey)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotCreateSASWithoutAccountKey);
- throw new InvalidOperationException(errorMessage);
- }
-
- string resourceName = this.GetSharedAccessCanonicalName();
- StorageAccountKey accountKey = this.ServiceClient.Credentials.Key;
- string signature = SharedAccessSignatureHelper.GetSharedAccessSignatureHashImpl(policy, groupPolicyIdentifier, resourceName, accountKey.KeyValue);
- string accountKeyName = accountKey.KeyName;
-
- // Future resource type changes from "c" => "container"
- UriQueryBuilder builder = SharedAccessSignatureHelper.GetSharedAccessSignatureImpl(policy, groupPolicyIdentifier, "c", signature, accountKeyName);
-
- return builder.ToString();
- }
-
- ///
- /// Gets a reference to a page blob in this container.
- ///
- /// The name of the blob.
- /// A reference to a page blob.
- public CloudPageBlob GetPageBlobReference(string blobName)
- {
- return this.GetPageBlobReference(blobName, null /* snapshotTime */);
- }
-
- ///
- /// Returns a reference to a page blob in this virtual directory.
- ///
- /// The name of the page blob.
- /// The snapshot timestamp, if the blob is a snapshot.
- /// A reference to a page blob.
- public CloudPageBlob GetPageBlobReference(string blobName, DateTimeOffset? snapshotTime)
- {
- CommonUtility.AssertNotNullOrEmpty("blobName", blobName);
- return new CloudPageBlob(blobName, snapshotTime, this);
- }
-
- ///
- /// Gets a reference to a block blob in this container.
- ///
- /// The name of the blob.
- /// A reference to a block blob.
- public CloudBlockBlob GetBlockBlobReference(string blobName)
- {
- return this.GetBlockBlobReference(blobName, null /* snapshotTime */);
- }
-
- ///
- /// Gets a reference to a block blob in this container.
- ///
- /// The name of the blob.
- /// The snapshot timestamp, if the blob is a snapshot.
- /// A reference to a block blob.
- public CloudBlockBlob GetBlockBlobReference(string blobName, DateTimeOffset? snapshotTime)
- {
- CommonUtility.AssertNotNullOrEmpty("blobName", blobName);
- return new CloudBlockBlob(blobName, snapshotTime, this);
- }
-
- ///
- /// Gets a reference to a virtual blob directory beneath this container.
- ///
- /// The name of the virtual blob directory.
- /// A reference to a virtual blob directory.
- public CloudBlobDirectory GetDirectoryReference(string relativeAddress)
- {
- CommonUtility.AssertNotNullOrEmpty("relativeAddress", relativeAddress);
- Uri blobDirectoryUri = NavigationHelper.AppendPathToUri(this.Uri, relativeAddress);
- return new CloudBlobDirectory(blobDirectoryUri.AbsoluteUri, this);
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudBlobDirectory.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudBlobDirectory.Common.cs
deleted file mode 100644
index acb1128be4e68..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudBlobDirectory.Common.cs
+++ /dev/null
@@ -1,194 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 Microsoft.WindowsAzure.Storage.Core.Util;
- using System;
-
- ///
- /// Represents a virtual directory of blobs on the client which emulates a hierarchical data store by using delimiter characters.
- ///
- /// 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 : IListBlobItem
- {
- ///
- /// Stores the parent directory.
- ///
- private CloudBlobDirectory parent;
-
- ///
- /// Stores the prefix this directory represents.
- ///
- private string prefix;
-
- ///
- /// Initializes a new instance of the class given an address and a client.
- ///
- /// The blob directory's address.
- /// The container for the virtual directory.
- internal CloudBlobDirectory(string absolutePath, CloudBlobContainer container)
- {
- CommonUtility.AssertNotNullOrEmpty("absolutePath", absolutePath);
- CommonUtility.AssertNotNull("container", container);
-
- this.ServiceClient = container.ServiceClient;
- this.Container = container;
-
- string delimiter = Uri.EscapeUriString(this.ServiceClient.DefaultDelimiter);
- if (!absolutePath.EndsWith(delimiter, StringComparison.Ordinal))
- {
- absolutePath = absolutePath + delimiter;
- }
-
- this.Uri = NavigationHelper.AppendPathToUri(this.ServiceClient.BaseUri, absolutePath);
- }
-
- ///
- /// Gets the service client for the virtual directory.
- ///
- /// A client object that specifies the endpoint for the Windows Azure Blob service.
- public CloudBlobClient ServiceClient { get; private set; }
-
- ///
- /// Gets the URI that identifies the virtual directory.
- ///
- /// The URI to the virtual directory.
- public Uri Uri { get; private set; }
-
- ///
- /// Gets the container for the virtual directory.
- ///
- /// The container for the virtual directory.
- public CloudBlobContainer Container { get; private set; }
-
- ///
- /// Gets the parent directory for the virtual directory.
- ///
- /// The virtual directory's parent directory.
- public CloudBlobDirectory Parent
- {
- get
- {
- if (this.parent == null)
- {
- Uri parentUri = NavigationHelper.GetParentAddress(
- this.Uri,
- this.ServiceClient.DefaultDelimiter,
- this.ServiceClient.UsePathStyleUris);
-
- if (parentUri != null)
- {
- this.parent = new CloudBlobDirectory(
- parentUri.AbsoluteUri,
- this.Container);
- }
- }
-
- return this.parent;
- }
- }
-
- ///
- /// Gets the prefix.
- ///
- /// The prefix.
- public string Prefix
- {
- get
- {
- if (this.prefix == null)
- {
- this.InitializePrefix();
- }
-
- return this.prefix;
- }
- }
-
- ///
- /// Gets a reference to a page blob in this virtual directory.
- ///
- /// The name of the blob.
- /// A reference to a page blob.
- public CloudPageBlob GetPageBlobReference(string blobName)
- {
- return this.GetPageBlobReference(blobName, null /* snapshotTime */);
- }
-
- ///
- /// Returns a reference to a page blob in this virtual directory.
- ///
- /// The name of the page blob.
- /// The snapshot timestamp, if the blob is a snapshot.
- /// A reference to a page blob.
- public CloudPageBlob GetPageBlobReference(string blobName, DateTimeOffset? snapshotTime)
- {
- CommonUtility.AssertNotNullOrEmpty("blobName", blobName);
-
- Uri blobUri = NavigationHelper.AppendPathToUri(this.Uri, blobName, this.ServiceClient.DefaultDelimiter);
- return new CloudPageBlob(blobUri, snapshotTime, this.ServiceClient.Credentials);
- }
-
- ///
- /// Gets a reference to a block blob in this virtual directory.
- ///
- /// The name of the blob.
- /// A reference to a block blob.
- public CloudBlockBlob GetBlockBlobReference(string blobName)
- {
- return this.GetBlockBlobReference(blobName, null /* snapshotTime */);
- }
-
- ///
- /// Gets a reference to a block blob in this virtual directory.
- ///
- /// The name of the blob.
- /// The snapshot timestamp, if the blob is a snapshot.
- /// A reference to a block blob.
- public CloudBlockBlob GetBlockBlobReference(string blobName, DateTimeOffset? snapshotTime)
- {
- CommonUtility.AssertNotNullOrEmpty("blobName", blobName);
-
- Uri blobUri = NavigationHelper.AppendPathToUri(this.Uri, blobName, this.ServiceClient.DefaultDelimiter);
- return new CloudBlockBlob(blobUri, snapshotTime, this.ServiceClient.Credentials);
- }
-
- ///
- /// Returns a virtual subdirectory within this virtual directory.
- ///
- /// The name of the virtual subdirectory.
- /// A object representing the virtual subdirectory.
- public CloudBlobDirectory GetSubdirectoryReference(string itemName)
- {
- CommonUtility.AssertNotNull("itemName", itemName);
- Uri subdirectoryUri = NavigationHelper.AppendPathToUri(this.Uri, itemName, this.ServiceClient.DefaultDelimiter);
- return new CloudBlobDirectory(subdirectoryUri.AbsoluteUri, this.Container);
- }
-
- ///
- /// Initializes the prefix.
- ///
- private void InitializePrefix()
- {
- // Need to add the trailing slash or MakeRelativeUri will return the containerName again
- Uri parentUri = new Uri(this.Container.Uri + NavigationHelper.Slash);
-
- this.prefix = Uri.UnescapeDataString(parentUri.MakeRelativeUri(this.Uri).OriginalString);
- }
- }
-}
\ No newline at end of file
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudBlockBlob.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudBlockBlob.Common.cs
deleted file mode 100644
index c34d3c4541f1f..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudBlockBlob.Common.cs
+++ /dev/null
@@ -1,438 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 Microsoft.WindowsAzure.Storage.Auth;
- using Microsoft.WindowsAzure.Storage.Blob.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.Collections.Generic;
- using System.Globalization;
-
- ///
- /// Represents a blob that is uploaded as a set of blocks.
- ///
- public sealed partial class CloudBlockBlob : ICloudBlob
- {
- ///
- /// Default is 4 MB.
- ///
- private int streamWriteSizeInBytes = Constants.DefaultWriteBlockSizeBytes;
-
- ///
- /// Default is 4 MB.
- ///
- private int streamMinimumReadSizeInBytes = Constants.DefaultWriteBlockSizeBytes;
-
- ///
- /// Initializes a new instance of the class using an absolute URI to the blob.
- ///
- /// The absolute URI to the blob.
- public CloudBlockBlob(Uri blobAbsoluteUri)
- : this(blobAbsoluteUri, null /* credentials */)
- {
- }
-
- ///
- /// Initializes a new instance of the class using an absolute URI to the blob.
- ///
- /// The absolute URI to the blob.
- /// The account credentials.
- public CloudBlockBlob(Uri blobAbsoluteUri, StorageCredentials credentials)
- : this(blobAbsoluteUri, null /* snapshotTime */, credentials)
- {
- }
-
- ///
- /// Initializes a new instance of the class using an absolute URI to the blob.
- ///
- /// The absolute URI to the blob.
- /// The snapshot timestamp, if the blob is a snapshot.
- /// The account credentials.
- public CloudBlockBlob(Uri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials)
- {
- this.attributes = new BlobAttributes();
- this.SnapshotTime = snapshotTime;
- this.ParseQueryAndVerify(blobAbsoluteUri, credentials);
- this.Properties.BlobType = BlobType.BlockBlob;
- }
-
- ///
- /// Initializes a new instance of the class using the specified blob name and
- /// the parent container reference.
- /// If snapshotTime is not null, the blob instance represents a Snapshot.
- ///
- /// Name of the blob.
- /// Snapshot time in case the blob is a snapshot.
- /// The reference to the parent container.
- internal CloudBlockBlob(string blobName, DateTimeOffset? snapshotTime, CloudBlobContainer container)
- {
- CommonUtility.AssertNotNullOrEmpty("blobName", blobName);
- CommonUtility.AssertNotNull("container", container);
-
- this.attributes = new BlobAttributes();
- this.Uri = NavigationHelper.AppendPathToUri(container.Uri, blobName);
- this.Name = blobName;
- this.ServiceClient = container.ServiceClient;
- this.container = container;
- this.SnapshotTime = snapshotTime;
- this.Properties.BlobType = BlobType.BlockBlob;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The attributes.
- /// The service client.
- internal CloudBlockBlob(BlobAttributes attributes, CloudBlobClient serviceClient)
- {
- this.attributes = attributes;
- this.ServiceClient = serviceClient;
-
- this.ParseQueryAndVerify(this.Uri, this.ServiceClient.Credentials);
- this.Properties.BlobType = BlobType.BlockBlob;
- }
-
- ///
- /// Stores the that contains this blob.
- ///
- private CloudBlobContainer container;
-
- ///
- /// Stores the blob's parent .
- ///
- private CloudBlobDirectory parent;
-
- ///
- /// Stores the blob's attributes.
- ///
- private readonly BlobAttributes attributes;
-
- ///
- /// Gets the object that represents the Blob service.
- ///
- /// A client object that specifies the Blob service endpoint.
- public CloudBlobClient ServiceClient { get; private set; }
-
- ///
- /// Gets or sets the block size for writing to a block blob.
- ///
- /// The size of a block, in bytes, ranging from between 16 KB and 4 MB inclusive.
- public int StreamWriteSizeInBytes
- {
- get
- {
- return this.streamWriteSizeInBytes;
- }
-
- set
- {
- CommonUtility.AssertInBounds("StreamWriteSizeInBytes", value, 16 * Constants.KB, Constants.MaxBlockSize);
- this.streamWriteSizeInBytes = value;
- }
- }
-
- ///
- /// Gets or sets the minimum number of bytes to buffer when reading from a blob stream.
- ///
- /// The minimum number of bytes to buffer, being at least 16KB.
- public int StreamMinimumReadSizeInBytes
- {
- get
- {
- return this.streamMinimumReadSizeInBytes;
- }
-
- set
- {
- CommonUtility.AssertInBounds("StreamMinimumReadSizeInBytes", value, 16 * Constants.KB);
- this.streamMinimumReadSizeInBytes = value;
- }
- }
-
- ///
- /// Gets the blob's system properties.
- ///
- /// The blob's properties.
- public BlobProperties Properties
- {
- get
- {
- return this.attributes.Properties;
- }
- }
-
- ///
- /// Gets the user-defined metadata for the blob.
- ///
- /// The blob's metadata, as a collection of name-value pairs.
- public IDictionary Metadata
- {
- get
- {
- return this.attributes.Metadata;
- }
- }
-
- ///
- /// Gets the blob's URI.
- ///
- /// The absolute URI to the blob.
- public Uri Uri
- {
- get
- {
- return this.attributes.Uri;
- }
-
- private set
- {
- this.attributes.Uri = value;
- }
- }
-
- ///
- /// Gets the date and time that the blob snapshot was taken, if this blob is a snapshot.
- ///
- /// The blob's snapshot time, if the blob is a snapshot. If the blob is not a snapshot, the value of this property is null.
- public DateTimeOffset? SnapshotTime
- {
- get
- {
- return this.attributes.SnapshotTime;
- }
-
- private set
- {
- this.attributes.SnapshotTime = value;
- }
- }
-
- ///
- /// Gets a value indicating whether this blob is a snapshot.
- ///
- /// true if this blob is a snapshot; otherwise, false.
- public bool IsSnapshot
- {
- get
- {
- return this.SnapshotTime.HasValue;
- }
- }
-
- ///
- /// Gets the qualified URI to this blob if it is a snapshot.
- ///
- /// The qualified URI to the blob if the blob is a snapshot; otherwise, returns the absolute URI to the blob.
- public Uri SnapshotQualifiedUri
- {
- get
- {
- if (this.SnapshotTime.HasValue)
- {
- UriQueryBuilder builder = new UriQueryBuilder();
- builder.Add("snapshot", BlobRequest.ConvertDateTimeToSnapshotString(this.SnapshotTime.Value));
- return builder.AddToUri(this.Uri);
- }
- else
- {
- return this.Uri;
- }
- }
- }
-
- ///
- /// Gets the state of the most recent or pending copy operation.
- ///
- /// A object containing the copy state, or null if no copy blob state exists for this blob.
- public CopyState CopyState
- {
- get
- {
- return this.attributes.CopyState;
- }
- }
-
- ///
- /// Gets the type of the blob.
- ///
- /// The type of the blob.
- public BlobType BlobType
- {
- get
- {
- return BlobType.BlockBlob;
- }
- }
-
- ///
- /// Gets the blob's name.
- ///
- /// The blob's name.
- public string Name { get; private set; }
-
- ///
- /// Gets a object representing the blob's container.
- ///
- /// The blob's container.
- public CloudBlobContainer Container
- {
- get
- {
- if (this.container == null)
- {
- this.container = this.ServiceClient.GetContainerReference(
- NavigationHelper.GetContainerName(this.Uri, this.ServiceClient.UsePathStyleUris));
- }
-
- return this.container;
- }
- }
-
- ///
- /// Gets the object representing the
- /// virtual parent directory for the blob.
- ///
- /// The blob's virtual parent directory.
- public CloudBlobDirectory Parent
- {
- get
- {
- if (this.parent == null)
- {
- Uri parentUri = NavigationHelper.GetParentAddress(
- this.Uri,
- this.ServiceClient.DefaultDelimiter,
- this.ServiceClient.UsePathStyleUris);
-
- if (parentUri != null)
- {
- this.parent = new CloudBlobDirectory(
- parentUri.AbsoluteUri,
- this.Container);
- }
- }
-
- return this.parent;
- }
- }
-
- ///
- /// Returns a shared access signature for the blob.
- ///
- /// The access policy for the shared access signature.
- /// A shared access signature, as a URI query string.
- /// The query string returned includes the leading question mark.
- public string GetSharedAccessSignature(SharedAccessBlobPolicy policy)
- {
- return this.GetSharedAccessSignature(policy, null /* groupPolicyIdentifier */);
- }
-
- ///
- /// Returns a shared access signature for the blob.
- ///
- /// The access policy for the shared access signature.
- /// A stored access policy.
- /// A shared access signature, as a URI query string.
- /// The query string returned includes the leading question mark.
- public string GetSharedAccessSignature(SharedAccessBlobPolicy policy, string groupPolicyIdentifier)
- {
- if (!this.ServiceClient.Credentials.IsSharedKey)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotCreateSASWithoutAccountKey);
- throw new InvalidOperationException(errorMessage);
- }
-
- if (this.SnapshotTime != null)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotCreateSASForSnapshot);
- throw new NotSupportedException(errorMessage);
- }
-
- string resourceName = this.GetCanonicalName(true);
- StorageAccountKey accountKey = this.ServiceClient.Credentials.Key;
- string signature = SharedAccessSignatureHelper.GetSharedAccessSignatureHashImpl(policy, groupPolicyIdentifier, resourceName, accountKey.KeyValue);
-
- // Future resource type changes from "c" => "container"
- UriQueryBuilder builder = SharedAccessSignatureHelper.GetSharedAccessSignatureImpl(policy, groupPolicyIdentifier, "b", signature, accountKey.KeyName);
-
- return builder.ToString();
- }
-
- ///
- /// Gets the canonical name of the blob, formatted as /<account-name>/<container-name>/<blob-name>.
- /// If ignoreSnapshotTime is false and this blob is a snapshot, the canonical name is augmented with a
- /// query of the form ?snapshot=<snapshot-time>.
- /// This is used by both Shared Access and Copy blob operations.
- ///
- /// Indicates if the snapshot time is ignored.
- /// The canonical name of the blob.
- private string GetCanonicalName(bool ignoreSnapshotTime)
- {
- string accountName = this.ServiceClient.Credentials.AccountName;
- string containerName = this.Container.Name;
-
- // Replace \ with / for uri compatibility when running under .net 4.5.
- string blobName = this.Name.Replace('\\', '/');
-
- string canonicalName = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}/{2}", accountName, containerName, blobName);
-
- if (!ignoreSnapshotTime && this.SnapshotTime != null)
- {
- canonicalName += "?snapshot=" + BlobRequest.ConvertDateTimeToSnapshotString(this.SnapshotTime.Value);
- }
-
- return canonicalName;
- }
-
- ///
- /// Parse URI for SAS (Shared Access Signature) and snapshot information.
- ///
- /// The complete Uri.
- /// The credentials to use.
- private void ParseQueryAndVerify(Uri address, StorageCredentials credentials)
- {
- StorageCredentials parsedCredentials;
- DateTimeOffset? parsedSnapshot;
- this.Uri = NavigationHelper.ParseBlobQueryAndVerify(address, out parsedCredentials, out parsedSnapshot);
-
- if ((parsedCredentials != null) && (credentials != null) && !parsedCredentials.Equals(credentials))
- {
- string error = string.Format(CultureInfo.CurrentCulture, SR.MultipleCredentialsProvided);
- throw new ArgumentException(error);
- }
-
- if (parsedSnapshot.HasValue && this.SnapshotTime.HasValue && !parsedSnapshot.Value.Equals(this.SnapshotTime.Value))
- {
- string error = string.Format(CultureInfo.CurrentCulture, SR.MultipleSnapshotTimesProvided, parsedSnapshot, this.SnapshotTime);
- throw new ArgumentException(error);
- }
-
- if (parsedSnapshot.HasValue)
- {
- this.SnapshotTime = parsedSnapshot;
- }
-
- this.ServiceClient = new CloudBlobClient(NavigationHelper.GetServiceClientBaseAddress(this.Uri, null /* usePathStyleUris */), credentials ?? parsedCredentials);
- this.Name = NavigationHelper.GetBlobName(this.Uri, this.ServiceClient.UsePathStyleUris);
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudPageBlob.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudPageBlob.Common.cs
deleted file mode 100644
index 5fa37bc485757..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CloudPageBlob.Common.cs
+++ /dev/null
@@ -1,438 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 Microsoft.WindowsAzure.Storage.Auth;
- using Microsoft.WindowsAzure.Storage.Blob.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.Collections.Generic;
- using System.Globalization;
-
- ///
- /// Represents a Windows Azure page blob.
- ///
- public sealed partial class CloudPageBlob : ICloudBlob
- {
- ///
- /// Default is 4 MB.
- ///
- private int streamWriteSizeInBytes = Constants.DefaultWriteBlockSizeBytes;
-
- ///
- /// Default is 4 MB.
- ///
- private int streamMinimumReadSizeInBytes = Constants.DefaultWriteBlockSizeBytes;
-
- ///
- /// Initializes a new instance of the class using an absolute URI to the blob.
- ///
- /// The absolute URI to the blob.
- public CloudPageBlob(Uri blobAbsoluteUri)
- : this(blobAbsoluteUri, null /* credentials */)
- {
- }
-
- ///
- /// Initializes a new instance of the class using an absolute URI to the blob.
- ///
- /// The absolute URI to the blob.
- /// The account credentials.
- public CloudPageBlob(Uri blobAbsoluteUri, StorageCredentials credentials)
- : this(blobAbsoluteUri, null /* snapshotTime */, credentials)
- {
- }
-
- ///
- /// Initializes a new instance of the class using an absolute URI to the blob.
- ///
- /// The absolute URI to the blob.
- /// The snapshot timestamp, if the blob is a snapshot.
- /// The account credentials.
- public CloudPageBlob(Uri blobAbsoluteUri, DateTimeOffset? snapshotTime, StorageCredentials credentials)
- {
- this.attributes = new BlobAttributes();
- this.SnapshotTime = snapshotTime;
- this.ParseQueryAndVerify(blobAbsoluteUri, credentials);
- this.Properties.BlobType = BlobType.PageBlob;
- }
-
- ///
- /// Initializes a new instance of the class using the specified blob name and
- /// the parent container reference.
- /// If snapshotTime is not null, the blob instance represents a Snapshot.
- ///
- /// Name of the blob.
- /// Snapshot time in case the blob is a snapshot.
- /// The reference to the parent container.
- internal CloudPageBlob(string blobName, DateTimeOffset? snapshotTime, CloudBlobContainer container)
- {
- CommonUtility.AssertNotNullOrEmpty("blobName", blobName);
- CommonUtility.AssertNotNull("container", container);
-
- this.attributes = new BlobAttributes();
- this.Uri = NavigationHelper.AppendPathToUri(container.Uri, blobName);
- this.Name = blobName;
- this.ServiceClient = container.ServiceClient;
- this.container = container;
- this.SnapshotTime = snapshotTime;
- this.Properties.BlobType = BlobType.PageBlob;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The attributes.
- /// The service client.
- internal CloudPageBlob(BlobAttributes attributes, CloudBlobClient serviceClient)
- {
- this.attributes = attributes;
- this.ServiceClient = serviceClient;
-
- this.ParseQueryAndVerify(this.Uri, this.ServiceClient.Credentials);
- this.Properties.BlobType = BlobType.PageBlob;
- }
-
- ///
- /// Stores the that contains this blob.
- ///
- private CloudBlobContainer container;
-
- ///
- /// Stores the blob's parent .
- ///
- private CloudBlobDirectory parent;
-
- ///
- /// Stores the blob's attributes.
- ///
- private readonly BlobAttributes attributes;
-
- ///
- /// Gets the object that represents the Blob service.
- ///
- /// A client object that specifies the Blob service endpoint.
- public CloudBlobClient ServiceClient { get; private set; }
-
- ///
- /// Gets or sets the number of bytes to buffer when writing to a page blob stream.
- ///
- /// The number of bytes to buffer, ranging from between 512 bytes and 4 MB inclusive.
- public int StreamWriteSizeInBytes
- {
- get
- {
- return this.streamWriteSizeInBytes;
- }
-
- set
- {
- CommonUtility.AssertInBounds("StreamWriteSizeInBytes", value, Constants.PageSize, Constants.MaxBlockSize);
- this.streamWriteSizeInBytes = value;
- }
- }
-
- ///
- /// Gets or sets the minimum number of bytes to buffer when reading from a blob stream.
- ///
- /// The minimum number of bytes to buffer, being at least 16KB.
- public int StreamMinimumReadSizeInBytes
- {
- get
- {
- return this.streamMinimumReadSizeInBytes;
- }
-
- set
- {
- CommonUtility.AssertInBounds("StreamMinimumReadSizeInBytes", value, 16 * Constants.KB);
- this.streamMinimumReadSizeInBytes = value;
- }
- }
-
- ///
- /// Gets the blob's system properties.
- ///
- /// The blob's properties.
- public BlobProperties Properties
- {
- get
- {
- return this.attributes.Properties;
- }
- }
-
- ///
- /// Gets the user-defined metadata for the blob.
- ///
- /// The blob's metadata, as a collection of name-value pairs.
- public IDictionary Metadata
- {
- get
- {
- return this.attributes.Metadata;
- }
- }
-
- ///
- /// Gets the blob's URI.
- ///
- /// The absolute URI to the blob.
- public Uri Uri
- {
- get
- {
- return this.attributes.Uri;
- }
-
- private set
- {
- this.attributes.Uri = value;
- }
- }
-
- ///
- /// Gets the date and time that the blob snapshot was taken, if this blob is a snapshot.
- ///
- /// The blob's snapshot time, if the blob is a snapshot. If the blob is not a snapshot, the value of this property is null.
- public DateTimeOffset? SnapshotTime
- {
- get
- {
- return this.attributes.SnapshotTime;
- }
-
- private set
- {
- this.attributes.SnapshotTime = value;
- }
- }
-
- ///
- /// Gets a value indicating whether this blob is a snapshot.
- ///
- /// true if this blob is a snapshot; otherwise, false.
- public bool IsSnapshot
- {
- get
- {
- return this.SnapshotTime.HasValue;
- }
- }
-
- ///
- /// Gets the qualified URI to this blob if it is a snapshot.
- ///
- /// The qualified URI to the blob if the blob is a snapshot; otherwise, returns the absolute URI to the blob.
- public Uri SnapshotQualifiedUri
- {
- get
- {
- if (this.SnapshotTime.HasValue)
- {
- UriQueryBuilder builder = new UriQueryBuilder();
- builder.Add("snapshot", BlobRequest.ConvertDateTimeToSnapshotString(this.SnapshotTime.Value));
- return builder.AddToUri(this.Uri);
- }
- else
- {
- return this.Uri;
- }
- }
- }
-
- ///
- /// Gets the state of the most recent or pending copy operation.
- ///
- /// A object containing the copy state, or null if no copy blob state exists for this blob.
- public CopyState CopyState
- {
- get
- {
- return this.attributes.CopyState;
- }
- }
-
- ///
- /// Gets the type of the blob.
- ///
- /// The type of the blob.
- public BlobType BlobType
- {
- get
- {
- return BlobType.PageBlob;
- }
- }
-
- ///
- /// Gets the blob's name.
- ///
- /// The blob's name.
- public string Name { get; private set; }
-
- ///
- /// Gets a object representing the blob's container.
- ///
- /// The blob's container.
- public CloudBlobContainer Container
- {
- get
- {
- if (this.container == null)
- {
- this.container = this.ServiceClient.GetContainerReference(
- NavigationHelper.GetContainerName(this.Uri, this.ServiceClient.UsePathStyleUris));
- }
-
- return this.container;
- }
- }
-
- ///
- /// Gets the object representing the
- /// virtual parent directory for the blob.
- ///
- /// The blob's virtual parent directory.
- public CloudBlobDirectory Parent
- {
- get
- {
- if (this.parent == null)
- {
- Uri parentUri = NavigationHelper.GetParentAddress(
- this.Uri,
- this.ServiceClient.DefaultDelimiter,
- this.ServiceClient.UsePathStyleUris);
-
- if (parentUri != null)
- {
- this.parent = new CloudBlobDirectory(
- parentUri.AbsoluteUri,
- this.Container);
- }
- }
-
- return this.parent;
- }
- }
-
- ///
- /// Returns a shared access signature for the blob.
- ///
- /// The access policy for the shared access signature.
- /// A shared access signature, as a URI query string.
- /// The query string returned includes the leading question mark.
- public string GetSharedAccessSignature(SharedAccessBlobPolicy policy)
- {
- return this.GetSharedAccessSignature(policy, null /* groupPolicyIdentifier */);
- }
-
- ///
- /// Returns a shared access signature for the blob.
- ///
- /// The access policy for the shared access signature.
- /// A stored access policy.
- /// A shared access signature, as a URI query string.
- /// The query string returned includes the leading question mark.
- public string GetSharedAccessSignature(SharedAccessBlobPolicy policy, string groupPolicyIdentifier)
- {
- if (!this.ServiceClient.Credentials.IsSharedKey)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotCreateSASWithoutAccountKey);
- throw new InvalidOperationException(errorMessage);
- }
-
- if (this.SnapshotTime != null)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotCreateSASForSnapshot);
- throw new NotSupportedException(errorMessage);
- }
-
- string resourceName = this.GetCanonicalName(true);
- StorageAccountKey accountKey = this.ServiceClient.Credentials.Key;
- string signature = SharedAccessSignatureHelper.GetSharedAccessSignatureHashImpl(policy, groupPolicyIdentifier, resourceName, accountKey.KeyValue);
-
- // Future resource type changes from "c" => "container"
- UriQueryBuilder builder = SharedAccessSignatureHelper.GetSharedAccessSignatureImpl(policy, groupPolicyIdentifier, "b", signature, accountKey.KeyName);
-
- return builder.ToString();
- }
-
- ///
- /// Gets the canonical name of the blob, formatted as /<account-name>/<container-name>/<blob-name>.
- /// If ignoreSnapshotTime is false and this blob is a snapshot, the canonical name is augmented with a
- /// query of the form ?snapshot=<snapshot-time>.
- /// This is used by both Shared Access and Copy blob operations.
- ///
- /// Indicates if the snapshot time is ignored.
- /// The canonical name of the blob.
- private string GetCanonicalName(bool ignoreSnapshotTime)
- {
- string accountName = this.ServiceClient.Credentials.AccountName;
- string containerName = this.Container.Name;
-
- // Replace \ with / for uri compatibility when running under .net 4.5.
- string blobName = this.Name.Replace('\\', '/');
-
- string canonicalName = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}/{2}", accountName, containerName, blobName);
-
- if (!ignoreSnapshotTime && this.SnapshotTime != null)
- {
- canonicalName += "?snapshot=" + BlobRequest.ConvertDateTimeToSnapshotString(this.SnapshotTime.Value);
- }
-
- return canonicalName;
- }
-
- ///
- /// Parse URI for SAS (Shared Access Signature) and snapshot information.
- ///
- /// The complete Uri.
- /// The credentials to use.
- private void ParseQueryAndVerify(Uri address, StorageCredentials credentials)
- {
- StorageCredentials parsedCredentials;
- DateTimeOffset? parsedSnapshot;
- this.Uri = NavigationHelper.ParseBlobQueryAndVerify(address, out parsedCredentials, out parsedSnapshot);
-
- if ((parsedCredentials != null) && (credentials != null) && !parsedCredentials.Equals(credentials))
- {
- string error = string.Format(CultureInfo.CurrentCulture, SR.MultipleCredentialsProvided);
- throw new ArgumentException(error);
- }
-
- if (parsedSnapshot.HasValue && this.SnapshotTime.HasValue && !parsedSnapshot.Value.Equals(this.SnapshotTime.Value))
- {
- string error = string.Format(CultureInfo.CurrentCulture, SR.MultipleSnapshotTimesProvided, parsedSnapshot, this.SnapshotTime);
- throw new ArgumentException(error);
- }
-
- if (parsedSnapshot.HasValue)
- {
- this.SnapshotTime = parsedSnapshot;
- }
-
- this.ServiceClient = new CloudBlobClient(NavigationHelper.GetServiceClientBaseAddress(this.Uri, null /* usePathStyleUris */), credentials ?? parsedCredentials);
- this.Name = NavigationHelper.GetBlobName(this.Uri, this.ServiceClient.UsePathStyleUris);
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/ContainerListingDetails.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/ContainerListingDetails.cs
deleted file mode 100644
index d29b727b8c7ed..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/ContainerListingDetails.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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;
-
- ///
- /// Specifies which details to include when listing the containers in this storage account.
- ///
- [Flags]
- public enum ContainerListingDetails
- {
- ///
- /// No additional details.
- ///
- None = 0x0,
-
- ///
- /// Retrieve container metadata.
- ///
- Metadata = 0x1,
-
- ///
- /// Retrieve all available details.
- ///
- All = 0x1
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/ContainerResultSegment.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/ContainerResultSegment.cs
deleted file mode 100644
index f2cda2b4a81bb..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/ContainerResultSegment.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Collections.Generic;
-
- ///
- /// Represents a segment of results and contains continuation and pagination information.
- ///
- public sealed class ContainerResultSegment
- {
- internal ContainerResultSegment(IEnumerable containers, BlobContinuationToken continuationToken)
- {
- this.Results = containers;
- this.ContinuationToken = continuationToken;
- }
-
- ///
- /// Gets an enumerable collection of results.
- ///
- /// An enumerable collection of results.
- public IEnumerable Results { get; private set; }
-
- ///
- /// Gets the continuation token used to retrieve the next segment of results.
- ///
- /// The continuation token.
- public BlobContinuationToken ContinuationToken { get; private set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CopyState.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CopyState.cs
deleted file mode 100644
index 65c4a5956411f..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CopyState.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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;
-
- ///
- /// Represents the attributes of a copy operation.
- ///
- public sealed class CopyState
- {
- ///
- /// Gets the ID of the copy operation.
- ///
- /// A copy ID string.
- public string CopyId
- {
- get;
- internal set;
- }
-
- ///
- /// Gets the time the copy operation completed, and indicates whether completion was due to a successful copy, the cancelling of the operation, or a failure.
- ///
- /// A containing the completion time, or null if the operation has not completed.
- public DateTimeOffset? CompletionTime
- {
- get;
- internal set;
- }
-
- ///
- /// Gets the status of the copy operation.
- ///
- /// A enumeration indicating the status of the operation.
- public CopyStatus Status
- {
- get;
- internal set;
- }
-
- ///
- /// Gets the source URI of a copy operation.
- ///
- /// A indicating the source of a copy operation, or null.
- public Uri Source
- {
- get;
- internal set;
- }
-
- ///
- /// Gets the number of bytes copied in the operation so far.
- ///
- /// The number of bytes copied in the operation so far, or null.
- public long? BytesCopied
- {
- get;
- internal set;
- }
-
- ///
- /// Gets the total number of bytes in the source of the copy.
- ///
- /// The number of bytes in the source, or null.
- public long? TotalBytes
- {
- get;
- internal set;
- }
-
- ///
- /// Gets the description of the current status, if any.
- ///
- /// A status description string, or null.
- public string StatusDescription
- {
- get;
- internal set;
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CopyStatus.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CopyStatus.cs
deleted file mode 100644
index 8f2dac2c76e53..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/CopyStatus.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Represents the status of a copy blob operation.
- ///
- public enum CopyStatus
- {
- ///
- /// The copy status is invalid.
- ///
- Invalid,
-
- ///
- /// The copy operation is pending.
- ///
- Pending,
-
- ///
- /// The copy operation succeeded.
- ///
- Success,
-
- ///
- /// The copy operation has been aborted.
- ///
- Aborted,
-
- ///
- /// The copy operation encountered an error.
- ///
- Failed
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/DeleteSnapshotsOption.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/DeleteSnapshotsOption.cs
deleted file mode 100644
index 9050c481eb448..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/DeleteSnapshotsOption.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// The set of options describing delete operation.
- ///
- public enum DeleteSnapshotsOption
- {
- ///
- /// Delete blobs but not snapshots.
- ///
- None,
-
- ///
- /// Delete the blob and its snapshots.
- ///
- IncludeSnapshots,
-
- ///
- /// Delete the blob's snapshots only.
- ///
- DeleteSnapshotsOnly
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/ICloudBlob.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/ICloudBlob.Common.cs
deleted file mode 100644
index fd55df14a5251..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/ICloudBlob.Common.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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;
-
- ///
- /// An interface required for Windows Azure blob types. The and classes implement the interface.
- ///
- public partial interface ICloudBlob : IListBlobItem
- {
- ///
- /// Gets the blob item's name.
- ///
- /// The blob item's name.
- string Name { get; }
-
- ///
- /// Gets the object that represents the Blob service.
- ///
- /// A client object that specifies the Blob service endpoint.
- CloudBlobClient ServiceClient { get; }
-
- ///
- /// Gets or sets the number of bytes to buffer when writing to a page blob stream or
- /// the block size for writing to a block blob.
- ///
- /// The number of bytes to buffer or the size of a block, in bytes.
- int StreamWriteSizeInBytes { get; set; }
-
- ///
- /// Gets or sets the minimum number of bytes to buffer when reading from a blob stream.
- ///
- /// The minimum number of bytes to buffer.
- int StreamMinimumReadSizeInBytes { get; set; }
-
- ///
- /// Gets the blob's system properties.
- ///
- /// The blob's properties.
- BlobProperties Properties { get; }
-
- ///
- /// Gets the user-defined metadata for the blob.
- ///
- /// The blob's metadata, as a collection of name-value pairs.
- IDictionary Metadata { get; }
-
- ///
- /// Gets the date and time that the blob snapshot was taken, if this blob is a snapshot.
- ///
- /// The blob's snapshot time if the blob is a snapshot; otherwise, null.
- ///
- /// If the blob is not a snapshot, the value of this property is null.
- ///
- DateTimeOffset? SnapshotTime { get; }
-
- ///
- /// Gets a value indicating whether this blob is a snapshot.
- ///
- /// true if this blob is a snapshot; otherwise, false.
- bool IsSnapshot { get; }
-
- ///
- /// Gets the snapshot qualified URI to this blob.
- ///
- /// The blob's snapshot qualified URI if the blob is a snapshot; otherwise the absolute URI to the blob.
- Uri SnapshotQualifiedUri { get; }
-
- ///
- /// Gets the state of the most recent or pending copy operation.
- ///
- /// A object containing the copy state, or null if no copy blob state exists for this blob.
- CopyState CopyState { get; }
-
- ///
- /// Gets the type of the blob.
- ///
- /// The type of the blob.
- BlobType BlobType { get; }
-
- ///
- /// Returns a shared access signature for the blob.
- ///
- /// The access policy for the shared access signature.
- /// A shared access signature, as a URI query string.
- /// The query string returned includes the leading question mark.
- string GetSharedAccessSignature(SharedAccessBlobPolicy policy);
-
- ///
- /// Returns a shared access signature for the blob.
- ///
- /// The access policy for the shared access signature.
- /// A container-level access policy.
- /// A shared access signature, as a URI query string.
- /// The query string returned includes the leading question mark.
- string GetSharedAccessSignature(SharedAccessBlobPolicy policy, string groupPolicyIdentifier);
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/IListBlobItem.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/IListBlobItem.cs
deleted file mode 100644
index d76d4219037da..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/IListBlobItem.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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;
-
- ///
- /// Represents an item that may be returned by a blob listing operation.
- ///
- public interface IListBlobItem
- {
- ///
- /// Gets the URI to the blob item.
- ///
- /// The blob item's URI.
- Uri Uri { get; }
-
- ///
- /// Gets the blob item's parent virtual directory.
- ///
- /// The blob item's parent virtual directory.
- CloudBlobDirectory Parent { get; }
-
- ///
- /// Gets the blob item's container.
- ///
- /// The blob item's container.
- CloudBlobContainer Container { get; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/LeaseAction.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/LeaseAction.cs
deleted file mode 100644
index 2e46db1697eeb..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/LeaseAction.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Describes actions that can be performed on a lease.
- ///
- public enum LeaseAction
- {
- ///
- /// Acquire the lease.
- ///
- Acquire,
-
- ///
- /// Renew the lease.
- ///
- Renew,
-
- ///
- /// Release the lease.
- ///
- Release,
-
- ///
- /// Break the lease.
- ///
- Break,
-
- ///
- /// Change the lease ID.
- ///
- Change,
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/LeaseDuration.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/LeaseDuration.cs
deleted file mode 100644
index 5f1926080655b..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/LeaseDuration.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// The lease duration of a resource.
- ///
- public enum LeaseDuration
- {
- ///
- /// The lease duration is not specified.
- ///
- Unspecified,
-
- ///
- /// The lease duration is finite.
- ///
- Fixed,
-
- ///
- /// The lease duration is infinite.
- ///
- Infinite
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/LeaseState.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/LeaseState.cs
deleted file mode 100644
index cd0b089ab1aa8..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/LeaseState.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// The lease state of a resource.
- ///
- public enum LeaseState
- {
- ///
- /// The lease state is not specified.
- ///
- Unspecified,
-
- ///
- /// The lease is in the Available state.
- ///
- Available,
-
- ///
- /// The lease is in the Leased state.
- ///
- Leased,
-
- ///
- /// The lease is in the Expired state.
- ///
- Expired,
-
- ///
- /// The lease is in the Breaking state.
- ///
- Breaking,
-
- ///
- /// The lease is in the Broken state.
- ///
- Broken,
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/LeaseStatus.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/LeaseStatus.cs
deleted file mode 100644
index 45f33a4bf51ab..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/LeaseStatus.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// The lease status of a resource.
- ///
- public enum LeaseStatus
- {
- ///
- /// The lease status is not specified.
- ///
- Unspecified,
-
- ///
- /// The resource is locked.
- ///
- Locked,
-
- ///
- /// The resource is available to be locked.
- ///
- Unlocked
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/ListBlockItem.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/ListBlockItem.cs
deleted file mode 100644
index 7e03ffe5063c0..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/ListBlockItem.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Represents a block retrieved from the blob's block list.
- ///
- public sealed class ListBlockItem
- {
- ///
- /// Gets the name of the block.
- ///
- /// The block name.
- public string Name { get; internal set; }
-
- ///
- /// Gets the size of block in bytes.
- ///
- /// The block size.
- public long Length { get; internal set; }
-
- ///
- /// Gets a value indicating whether or not the block has been committed.
- ///
- /// True if the block has been committed; otherwise, false.
- public bool Committed { get; internal set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/PageRange.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/PageRange.cs
deleted file mode 100644
index f51e7e6f8070a..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/PageRange.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Globalization;
-
- ///
- /// Represents a range of pages in a page blob.
- ///
- public sealed class PageRange
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The starting offset.
- /// The ending offset.
- public PageRange(long start, long end)
- {
- this.StartOffset = start;
- this.EndOffset = end;
- }
-
- ///
- /// Gets the starting offset of the page range.
- ///
- /// The starting offset.
- public long StartOffset { get; internal set; }
-
- ///
- /// Gets the ending offset of the page range.
- ///
- /// The ending offset.
- public long EndOffset { get; internal set; }
-
- ///
- /// Returns the content of the page range as a string.
- ///
- /// The content of the page range.
- public override string ToString()
- {
- return string.Format(CultureInfo.InvariantCulture, "bytes={0}-{1}", this.StartOffset, this.EndOffset);
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobAccessPolicyResponse.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobAccessPolicyResponse.cs
deleted file mode 100644
index 333cc4a5e531c..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobAccessPolicyResponse.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Core.Util;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.IO;
- using System.Xml.Linq;
-
- ///
- /// Parses the response XML from an operation to set the access policy for a container.
- ///
- internal class BlobAccessPolicyResponse : AccessPolicyResponseBase
- {
- ///
- /// Initializes a new instance of the BlobAccessPolicyResponse class.
- ///
- /// The stream to be parsed.
- internal BlobAccessPolicyResponse(Stream stream)
- : base(stream)
- {
- }
-
- ///
- /// Parses the current element.
- ///
- /// The shared access policy element to parse.
- /// The shared access policy.
- protected override SharedAccessBlobPolicy ParseElement(XElement accessPolicyElement)
- {
- CommonUtility.AssertNotNull("accessPolicyElement", accessPolicyElement);
-
- SharedAccessBlobPolicy accessPolicy = new SharedAccessBlobPolicy();
- string sharedAccessStartTimeString = (string)accessPolicyElement.Element(Constants.Start);
- if (!string.IsNullOrEmpty(sharedAccessStartTimeString))
- {
- accessPolicy.SharedAccessStartTime = Uri.UnescapeDataString(sharedAccessStartTimeString).ToUTCTime();
- }
-
- string sharedAccessExpiryTimeString = (string)accessPolicyElement.Element(Constants.Expiry);
- if (!string.IsNullOrEmpty(sharedAccessExpiryTimeString))
- {
- accessPolicy.SharedAccessExpiryTime = Uri.UnescapeDataString(sharedAccessExpiryTimeString).ToUTCTime();
- }
-
- string permissionsString = (string)accessPolicyElement.Element(Constants.Permission);
- if (!string.IsNullOrEmpty(permissionsString))
- {
- accessPolicy.Permissions = SharedAccessBlobPolicy.PermissionsFromString(permissionsString);
- }
-
- return accessPolicy;
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobContainerEntry.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobContainerEntry.cs
deleted file mode 100644
index d378165608430..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobContainerEntry.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.
-//
-//
-// Contains code for the CloudStorageAccount class.
-//
-//-----------------------------------------------------------------------
-
-namespace Microsoft.WindowsAzure.Storage.Blob.Protocol
-{
- using System;
- using System.Collections.Generic;
-
- ///
- /// Represents a container item returned in the XML response for a container listing operation.
- ///
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- sealed class BlobContainerEntry
- {
- ///
- /// Initializes a new instance of the class.
- ///
- internal BlobContainerEntry()
- {
- }
-
- ///
- /// Gets the user-defined metadata for the container.
- ///
- /// The container's metadata, as a collection of name-value pairs.
- public IDictionary Metadata { get; internal set; }
-
- ///
- /// Gets the container's system properties.
- ///
- /// The container's properties.
- public BlobContainerProperties Properties { get; internal set; }
-
- ///
- /// Gets the name of the container.
- ///
- /// The container's name.
- public string Name { get; internal set; }
-
- ///
- /// Gets the container's URI.
- ///
- /// The absolute URI to the container.
- public Uri Uri { get; internal set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobErrorCodeStrings.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobErrorCodeStrings.cs
deleted file mode 100644
index 53f22edee07c0..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobErrorCodeStrings.cs
+++ /dev/null
@@ -1,168 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.
-//
-//
-// Contains code for the CloudStorageAccount class.
-//
-//-----------------------------------------------------------------------
-
-namespace Microsoft.WindowsAzure.Storage.Blob.Protocol
-{
- ///
- /// Provides error code strings that are specific to the Blob service.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- static class BlobErrorCodeStrings
- {
- ///
- /// Error code that may be returned when a block ID is invalid.
- ///
- public const string InvalidBlockId = "InvalidBlockId";
-
- ///
- /// Error code that may be returned when a blob with the specified address cannot be found.
- ///
- public const string BlobNotFound = "BlobNotFound";
-
- ///
- /// Error code that may be returned when a client attempts to create a blob that already exists.
- ///
- public const string BlobAlreadyExists = "BlobAlreadyExists";
-
- ///
- /// Error code that may be returned when the specified block or blob is invalid.
- ///
- public const string InvalidBlobOrBlock = "InvalidBlobOrBlock";
-
- ///
- /// Error code that may be returned when a block list is invalid.
- ///
- public const string InvalidBlockList = "InvalidBlockList";
-
- ///
- /// The specified container was not found.
- ///
- public const string ContainerNotFound = "ContainerNotFound";
-
- ///
- /// The specified container already exists.
- ///
- public const string ContainerAlreadyExists = "ContainerAlreadyExists";
-
- ///
- /// The specified container is disabled.
- ///
- public const string ContainerDisabled = "ContainerDisabled";
-
- ///
- /// The specified container is being deleted.
- ///
- public const string ContainerBeingDeleted = "ContainerBeingDeleted";
-
- ///
- /// Error code that may be returned when there is currently no lease on the blob.
- ///
- public const string LeaseNotPresentWithBlobOperation = "LeaseNotPresentWithBlobOperation";
-
- ///
- /// Error code that may be returned when there is currently no lease on the container.
- ///
- public const string LeaseNotPresentWithContainerOperation = "LeaseNotPresentWithContainerOperation";
-
- ///
- /// Error code that may be returned when a lease ID was specified, but the lease has expired.
- ///
- public const string LeaseLost = "LeaseLost";
-
- ///
- /// Error code that may be returned when the lease ID specified did not match the lease ID for the blob.
- ///
- public const string LeaseIdMismatchWithBlobOperation = "LeaseIdMismatchWithBlobOperation";
-
- ///
- /// Error code that may be returned when the lease ID specified did not match the lease ID for the container.
- ///
- public const string LeaseIdMismatchWithContainerOperation = "LeaseIdMismatchWithContainerOperation";
-
- ///
- /// Error code that may be returned when there is currently a lease on the resource and no lease ID was specified in the request.
- ///
- public const string LeaseIdMissing = "LeaseIdMissing";
-
- ///
- /// Error code that may be returned when there is currently no lease on the resource.
- ///
- public const string LeaseNotPresentWithLeaseOperation = "LeaseNotPresentWithLeaseOperation";
-
- ///
- /// Error code that may be returned when the lease ID specified did not match the lease ID.
- ///
- public const string LeaseIdMismatchWithLeaseOperation = "LeaseIdMismatchWithLeaseOperation";
-
- ///
- /// Error code that may be returned when there is already a lease present.
- ///
- public const string LeaseAlreadyPresent = "LeaseAlreadyPresent";
-
- ///
- /// Error code that may be returned when the lease has already been broken and cannot be broken again.
- ///
- public const string LeaseAlreadyBroken = "LeaseAlreadyBroken";
-
- ///
- /// Error code that may be returned when the lease ID matched, but the lease has been broken explicitly and cannot be renewed.
- ///
- public const string LeaseIsBrokenAndCannotBeRenewed = "LeaseIsBrokenAndCannotBeRenewed";
-
- ///
- /// Error code that may be returned when the lease ID matched, but the lease is breaking and cannot be acquired.
- ///
- public const string LeaseIsBreakingAndCannotBeAcquired = "LeaseIsBreakingAndCannotBeAcquired";
-
- ///
- /// Error code that may be returned when the lease ID matched, but the lease is breaking and cannot be changed.
- ///
- public const string LeaseIsBreakingAndCannotBeChanged = "LeaseIsBreakingAndCannotBeChanged";
-
- ///
- /// Error code that may be returned when the copy ID specified in an Abort Copy operation does not match the current pending copy ID.
- ///
- public const string CopyIdMismatch = "CopyIdMismatch";
-
- ///
- /// Error code that may be returned when an Abort Copy operation is called when there is no pending copy.
- ///
- public const string NoPendingCopyOperation = "NoPendingCopyOperation";
-
- ///
- /// Error code that may be returned when an attempt to modify the destination of a pending copy is made.
- ///
- public const string PendingCopyOperation = "PendingCopyOperation";
-
- ///
- /// Error code that may be returned when the source of a copy cannot be accessed.
- ///
- public const string CannotVerifyCopySource = "CannotVerifyCopySource";
-
- ///
- /// Error code that may be returned when the destination of a copy operation has a lease of fixed duration.
- ///
- public const string InfiniteLeaseDurationRequired = "InfiniteLeaseDurationRequired";
- }
-}
\ No newline at end of file
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobHttpResponseParsers.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobHttpResponseParsers.Common.cs
deleted file mode 100644
index 4ec8473b3c413..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobHttpResponseParsers.Common.cs
+++ /dev/null
@@ -1,203 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.
-//
-//
-// Contains code for the CloudStorageAccount class.
-//
-//-----------------------------------------------------------------------
-
-namespace Microsoft.WindowsAzure.Storage.Blob.Protocol
-{
- using Microsoft.WindowsAzure.Storage.Core;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Globalization;
- using System.IO;
-
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- static partial class BlobHttpResponseParsers
- {
- ///
- /// Reads service properties from a stream.
- ///
- /// The stream from which to read the service properties.
- /// The service properties stored in the stream.
- public static ServiceProperties ReadServiceProperties(Stream inputStream)
- {
- return HttpResponseParsers.ReadServiceProperties(inputStream);
- }
-
- ///
- /// Gets a from a string.
- ///
- /// The lease status string.
- /// A enumeration.
- /// If a null or empty string is supplied, a status of is returned.
- /// The string contains an unrecognized value.
- internal static LeaseStatus GetLeaseStatus(string leaseStatus)
- {
- if (!string.IsNullOrEmpty(leaseStatus))
- {
- switch (leaseStatus)
- {
- case Constants.LockedValue:
- return LeaseStatus.Locked;
-
- case Constants.UnlockedValue:
- return LeaseStatus.Unlocked;
-
- default:
- throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, SR.InvalidLeaseStatus, leaseStatus), "leaseStatus");
- }
- }
-
- return LeaseStatus.Unspecified;
- }
-
- ///
- /// Gets a from a string.
- ///
- /// The lease state string.
- /// A enumeration.
- /// If a null or empty string is supplied, a status of is returned.
- /// The string contains an unrecognized value.
- internal static LeaseState GetLeaseState(string leaseState)
- {
- if (!string.IsNullOrEmpty(leaseState))
- {
- switch (leaseState)
- {
- case Constants.LeaseAvailableValue:
- return LeaseState.Available;
-
- case Constants.LeasedValue:
- return LeaseState.Leased;
-
- case Constants.LeaseExpiredValue:
- return LeaseState.Expired;
-
- case Constants.LeaseBreakingValue:
- return LeaseState.Breaking;
-
- case Constants.LeaseBrokenValue:
- return LeaseState.Broken;
-
- default:
- throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, SR.InvalidLeaseState, leaseState), "leaseState");
- }
- }
-
- return LeaseState.Unspecified;
- }
-
- ///
- /// Gets a from a string.
- ///
- /// The lease duration string.
- /// A enumeration.
- /// If a null or empty string is supplied, a status of is returned.
- /// The string contains an unrecognized value.
- internal static LeaseDuration GetLeaseDuration(string leaseDuration)
- {
- if (!string.IsNullOrEmpty(leaseDuration))
- {
- switch (leaseDuration)
- {
- case Constants.LeaseFixedValue:
- return LeaseDuration.Fixed;
-
- case Constants.LeaseInfiniteValue:
- return LeaseDuration.Infinite;
-
- default:
- throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, SR.InvalidLeaseDuration, leaseDuration), "leaseDuration");
- }
- }
-
- return LeaseDuration.Unspecified;
- }
-
- ///
- /// Builds a object from the given strings containing formatted copy information.
- ///
- /// The copy status, as a string.
- /// The copy ID.
- /// The source URI of the copy, as a string.
- /// A string formatted as progressBytes/TotalBytes.
- /// The copy completion time, as a string, or null.
- /// The copy status description, if any.
- /// A object populated from the given strings.
- internal static CopyState GetCopyAttributes(
- string copyStatusString,
- string copyId,
- string copySourceString,
- string copyProgressString,
- string copyCompletionTimeString,
- string copyStatusDescription)
- {
- CopyState copyAttributes = new CopyState
- {
- CopyId = copyId,
- StatusDescription = copyStatusDescription
- };
-
- switch (copyStatusString)
- {
- case Constants.CopySuccessValue:
- copyAttributes.Status = CopyStatus.Success;
- break;
-
- case Constants.CopyPendingValue:
- copyAttributes.Status = CopyStatus.Pending;
- break;
-
- case Constants.CopyAbortedValue:
- copyAttributes.Status = CopyStatus.Aborted;
- break;
-
- case Constants.CopyFailedValue:
- copyAttributes.Status = CopyStatus.Failed;
- break;
-
- default:
- copyAttributes.Status = CopyStatus.Invalid;
- break;
- }
-
- if (!string.IsNullOrEmpty(copyProgressString))
- {
- string[] progressSequence = copyProgressString.Split('/');
- copyAttributes.BytesCopied = long.Parse(progressSequence[0], CultureInfo.InvariantCulture);
- copyAttributes.TotalBytes = long.Parse(progressSequence[1], CultureInfo.InvariantCulture);
- }
-
- if (!string.IsNullOrEmpty(copySourceString))
- {
- copyAttributes.Source = new Uri(copySourceString);
- }
-
- if (!string.IsNullOrEmpty(copyCompletionTimeString))
- {
- copyAttributes.CompletionTime = copyCompletionTimeString.ToUTCTime();
- }
-
- return copyAttributes;
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobListingContext.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobListingContext.cs
deleted file mode 100644
index 070b6593ada31..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobListingContext.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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;
-
- ///
- /// Provides a set of parameters for a blob listing operation.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- sealed class BlobListingContext : ListingContext
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The blob prefix.
- /// The maximum number of results to return.
- /// The blob delimiter.
- /// The include parameter.
- public BlobListingContext(string prefix, int? maxResults, string delimiter, BlobListingDetails details)
- : base(prefix, maxResults)
- {
- this.Delimiter = delimiter;
- this.Details = details;
- }
-
- ///
- /// Gets or sets the delimiter for a blob listing operation.
- ///
- /// The delimiter to use to traverse the virtual hierarchy of blobs.
- ///
- /// The delimiter parameter enables the caller to traverse the blob namespace by using a user-configured delimiter.
- /// Using this parameter, it is possible to traverse a virtual hierarchy of blobs as though it were a file system.
- ///
- public string Delimiter { get; set; }
-
- ///
- /// Gets or sets the details for the listing operation, which indicates the types of data to include in the
- /// response.
- ///
- /// The details to include in the listing operation.
- ///
- /// The include parameter specifies that the response should include one or more of the following subsets: snapshots,
- /// metadata, uncommitted blobs.
- ///
- public BlobListingDetails Details { get; set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobRequest.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobRequest.cs
deleted file mode 100644
index 47eb0bcf49533..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/BlobRequest.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Core.Auth;
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.IO;
- using System.Text;
- using System.Xml;
-
- ///
- /// Provides a set of helper methods for constructing a request against the Blob service.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- static class BlobRequest
- {
- ///
- /// Converts the date time to snapshot string.
- ///
- /// The date time.
- /// The converted string.
- internal static string ConvertDateTimeToSnapshotString(DateTimeOffset dateTime)
- {
- return dateTime.UtcDateTime.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffff'Z'", CultureInfo.InvariantCulture);
- }
-
- ///
- /// Writes a collection of shared access policies to the specified stream in XML format.
- ///
- /// A collection of shared access policies.
- /// An output stream.
- public static void WriteSharedAccessIdentifiers(SharedAccessBlobPolicies sharedAccessPolicies, Stream outputStream)
- {
- Request.WriteSharedAccessIdentifiers(
- sharedAccessPolicies,
- outputStream,
- (policy, writer) =>
- {
- writer.WriteElementString(
- Constants.Start,
- SharedAccessSignatureHelper.GetDateTimeOrEmpty(policy.SharedAccessStartTime));
- writer.WriteElementString(
- Constants.Expiry,
- SharedAccessSignatureHelper.GetDateTimeOrEmpty(policy.SharedAccessExpiryTime));
- writer.WriteElementString(
- Constants.Permission,
- SharedAccessBlobPolicy.PermissionsToString(policy.Permissions));
- });
- }
-
- ///
- /// Writes the body of the block list to the specified stream in XML format.
- ///
- /// An enumerable collection of objects.
- /// The stream to which the block list is written.
- public static void WriteBlockListBody(IEnumerable blocks, Stream outputStream)
- {
- CommonUtility.AssertNotNull("blocks", blocks);
-
- XmlWriterSettings settings = new XmlWriterSettings();
- settings.Encoding = Encoding.UTF8;
- using (XmlWriter writer = XmlWriter.Create(outputStream, settings))
- {
- writer.WriteStartElement(Constants.BlockListElement);
-
- foreach (PutBlockListItem block in blocks)
- {
- if (block.SearchMode == BlockSearchMode.Committed)
- {
- writer.WriteElementString(Constants.CommittedElement, block.Id);
- }
- else if (block.SearchMode == BlockSearchMode.Uncommitted)
- {
- writer.WriteElementString(Constants.UncommittedElement, block.Id);
- }
- else if (block.SearchMode == BlockSearchMode.Latest)
- {
- writer.WriteElementString(Constants.LatestElement, block.Id);
- }
- }
-
- writer.WriteEndDocument();
- }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ContainerHttpResponseParsers.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ContainerHttpResponseParsers.Common.cs
deleted file mode 100644
index 7701aa19f957f..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ContainerHttpResponseParsers.Common.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Core;
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
- using System.IO;
-
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- static partial class ContainerHttpResponseParsers
- {
- ///
- /// Reads the share access policies from a stream in XML.
- ///
- /// The stream of XML policies.
- /// The permissions object to which the policies are to be written.
- public static void ReadSharedAccessIdentifiers(Stream inputStream, BlobContainerPermissions permissions)
- {
- CommonUtility.AssertNotNull("permissions", permissions);
-
- Response.ReadSharedAccessIdentifiers(permissions.SharedAccessPolicies, new BlobAccessPolicyResponse(inputStream));
- }
-
- ///
- /// Converts the ACL string to a object.
- ///
- /// The string to convert.
- /// The resulting object.
- [SuppressMessage("Microsoft.Globalization", "CA1304:SpecifyCultureInfo", MessageId = "System.String.ToLower", Justification = "ToLower(CultureInfo) is not present in RT and ToLowerInvariant() also violates FxCop")]
- private static BlobContainerPublicAccessType GetContainerAcl(string acl)
- {
- BlobContainerPublicAccessType accessType = BlobContainerPublicAccessType.Off;
-
- if (!string.IsNullOrEmpty(acl))
- {
- switch (acl.ToLower())
- {
- case "container":
- accessType = BlobContainerPublicAccessType.Container;
- break;
- case "blob":
- accessType = BlobContainerPublicAccessType.Blob;
- break;
- default:
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.InvalidAclType, acl);
- throw new InvalidOperationException(errorMessage);
- }
- }
-
- return accessType;
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/GetBlockListResponse.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/GetBlockListResponse.cs
deleted file mode 100644
index 53ec166542884..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/GetBlockListResponse.cs
+++ /dev/null
@@ -1,156 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 return a block list.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- class GetBlockListResponse : ResponseParsingBase
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The stream to be parsed.
- public GetBlockListResponse(Stream stream)
- : base(stream)
- {
- }
-
- ///
- /// Gets an enumerable collection of objects from the response.
- ///
- /// An enumerable collection of objects.
- public IEnumerable Blocks
- {
- get
- {
- return this.ObjectsToParse;
- }
- }
-
- ///
- /// Reads a block item for block listing.
- ///
- /// Whether we are currently listing committed blocks or not
- /// Block listing entry
- private ListBlockItem ParseBlockItem(bool committed)
- {
- ListBlockItem block = new ListBlockItem()
- {
- Committed = committed,
- };
-
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- switch (this.reader.Name)
- {
- case Constants.SizeElement:
- block.Length = reader.ReadElementContentAsLong();
- break;
-
- case Constants.NameElement:
- block.Name = reader.ReadElementContentAsString();
- break;
-
- default:
- reader.Skip();
- break;
- }
- }
- }
-
- this.reader.ReadEndElement();
-
- return block;
- }
-
- ///
- /// Parses the XML response returned by an operation to retrieve a list of blocks.
- ///
- /// An enumerable collection of objects.
- protected override IEnumerable ParseXml()
- {
- if (this.reader.ReadToFollowing(Constants.BlockListElement))
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- switch (this.reader.Name)
- {
- case Constants.CommittedBlocksElement:
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement(Constants.BlockElement))
- {
- yield return this.ParseBlockItem(true);
- }
-
- this.reader.ReadEndElement();
- break;
-
- case Constants.UncommittedBlocksElement:
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement(Constants.BlockElement))
- {
- yield return this.ParseBlockItem(false);
- }
-
- this.reader.ReadEndElement();
- break;
-
- default:
- reader.Skip();
- break;
- }
- }
- }
-
- this.allObjectsParsed = true;
- this.reader.ReadEndElement();
- }
- }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/GetPageRangesResponse.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/GetPageRangesResponse.cs
deleted file mode 100644
index bff376c62a0ef..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/GetPageRangesResponse.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 pages for a page blob.
- ///
-#if WINDOWS_DESKTOP
- public
-#else
- internal
-#endif
- sealed class GetPageRangesResponse : ResponseParsingBase
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The stream of page ranges to be parsed.
- public GetPageRangesResponse(Stream stream)
- : base(stream)
- {
- }
-
- ///
- /// Gets an enumerable collection of objects from the response.
- ///
- /// An enumerable collection of objects.
- public IEnumerable PageRanges
- {
- get
- {
- return this.ObjectsToParse;
- }
- }
-
- ///
- /// Reads a page range.
- ///
- /// Page range entry
- private PageRange ParsePageRange()
- {
- 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 PageRange(start, end);
- }
-
- ///
- /// 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(Constants.PageRangeElement))
- {
- yield return this.ParsePageRange();
- }
-
- this.allObjectsParsed = true;
- this.reader.ReadEndElement();
- }
- }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/IListBlobEntry.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/IListBlobEntry.cs
deleted file mode 100644
index 1d01ad67166e3..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/IListBlobEntry.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Represents an item that may be returned by a blob listing operation.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- interface IListBlobEntry
- {
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ListBlobEntry.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ListBlobEntry.cs
deleted file mode 100644
index ec969204f4da0..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ListBlobEntry.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 System;
- using System.Collections.Generic;
-
- ///
- /// Represents a blob item returned in the XML response for a blob listing operation.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- sealed class ListBlobEntry : IListBlobEntry
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The name of the blob.
- /// The blob's attributes.
- internal ListBlobEntry(string name, BlobAttributes attributes)
- {
- this.Name = name;
- this.Attributes = attributes;
- }
-
- ///
- /// Stores the blob item's attributes.
- ///
- internal BlobAttributes Attributes { get; private set; }
-
- ///
- /// Gets the name of the blob item.
- ///
- /// The name of the blob item.
- public string Name { get; private set; }
-
- ///
- /// Gets the blob item's system properties.
- ///
- /// The blob item's properties.
- public BlobProperties Properties
- {
- get
- {
- return this.Attributes.Properties;
- }
- }
-
- ///
- /// Gets the user-defined metadata for the blob item.
- ///
- /// The blob item's metadata, as a collection of name-value pairs.
- public IDictionary Metadata
- {
- get
- {
- return this.Attributes.Metadata;
- }
- }
-
- ///
- /// Gets the blob item's URI.
- ///
- /// The absolute URI to the blob item.
- public Uri Uri
- {
- get
- {
- return this.Attributes.Uri;
- }
- }
-
- ///
- /// Gets the date and time that the blob snapshot was taken, if this blob is a snapshot.
- ///
- /// The blob's snapshot time if the blob is a snapshot; otherwise, null.
- ///
- /// If the blob is not a snapshot, the value of this property is null.
- ///
- public DateTimeOffset? SnapshotTime
- {
- get
- {
- return this.Attributes.SnapshotTime;
- }
- }
-
- ///
- /// Gets the state of the most recent or pending copy operation.
- ///
- /// A object containing the copy state, or null if no copy blob state exists for this blob.
- public CopyState CopyState
- {
- get
- {
- return this.Attributes.CopyState;
- }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ListBlobPrefixEntry.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ListBlobPrefixEntry.cs
deleted file mode 100644
index 4fd6b93289c4a..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ListBlobPrefixEntry.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Represents the blob name prefix that is returned in the XML response for a blob listing operation.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- sealed class ListBlobPrefixEntry : IListBlobEntry
- {
- ///
- /// Gets the blob name prefix.
- ///
- /// The blob name prefix.
- public string Name
- {
- get;
- internal set;
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ListBlobsResponse.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ListBlobsResponse.cs
deleted file mode 100644
index 51322791b06b0..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ListBlobsResponse.cs
+++ /dev/null
@@ -1,510 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Core.Util;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
- using System.IO;
-
- ///
- /// Provides methods for parsing the response from a blob listing operation.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- sealed class ListBlobsResponse : ResponseParsingBase
- {
- ///
- /// Stores the blob prefix.
- ///
- private string prefix;
-
- ///
- /// Signals when the blob prefix can be consumed.
- ///
- private bool prefixConsumable;
-
- ///
- /// Stores the marker.
- ///
- private string marker;
-
- ///
- /// Signals when the marker can be consumed.
- ///
- private bool markerConsumable;
-
- ///
- /// Stores the blob delimiter.
- ///
- private string delimiter;
-
- ///
- /// Signals when the blob delimiter can be consumed.
- ///
- private bool delimiterConsumable;
-
- ///
- /// Stores the max results.
- ///
- private int maxResults;
-
- ///
- /// Signals when the max results can be consumed.
- ///
- private bool maxResultsConsumable;
-
- ///
- /// Stores the next marker.
- ///
- private string nextMarker;
-
- ///
- /// Signals when the next marker can be consumed.
- ///
- private bool nextMarkerConsumable;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The stream to be parsed.
- public ListBlobsResponse(Stream stream)
- : base(stream)
- {
- }
-
- ///
- /// Gets the listing context from the XML response.
- ///
- /// A set of parameters for the listing operation.
- public BlobListingContext ListingContext
- {
- get
- {
- string prefixString = this.Prefix;
- int maximumResults = this.MaxResults;
- string delimiterString = this.Delimiter;
- string nextMarkerString = this.NextMarker;
- BlobListingContext listingContext = new BlobListingContext(
- prefixString,
- maximumResults,
- delimiterString,
- BlobListingDetails.None);
- listingContext.Marker = nextMarkerString;
- return listingContext;
- }
- }
-
- ///
- /// Gets an enumerable collection of objects that implement from the response.
- ///
- /// An enumerable collection of objects that implement .
- public IEnumerable Blobs
- {
- get
- {
- return this.ObjectsToParse;
- }
- }
-
- ///
- /// Gets the Prefix value provided for the listing operation from the XML response.
- ///
- /// The Prefix value.
- public string Prefix
- {
- get
- {
- this.Variable(ref this.prefixConsumable);
-
- return this.prefix;
- }
- }
-
- ///
- /// Gets the Marker value provided for the listing operation from the XML response.
- ///
- /// The Marker value.
- public string Marker
- {
- get
- {
- this.Variable(ref this.markerConsumable);
-
- return this.marker;
- }
- }
-
- ///
- /// Gets the Delimiter value provided for the listing operation from the XML response.
- ///
- /// The Delimiter value.
- public string Delimiter
- {
- get
- {
- this.Variable(ref this.delimiterConsumable);
-
- return this.delimiter;
- }
- }
-
- ///
- /// Gets the MaxResults value provided for the listing operation from the XML response.
- ///
- /// The MaxResults value.
- public int MaxResults
- {
- get
- {
- this.Variable(ref this.maxResultsConsumable);
-
- return this.maxResults;
- }
- }
-
- ///
- /// Gets the NextMarker value from the XML response, if the listing was not complete.
- ///
- /// The NextMarker value.
- public string NextMarker
- {
- get
- {
- this.Variable(ref this.nextMarkerConsumable);
-
- return this.nextMarker;
- }
- }
-
- ///
- /// Parses a blob entry in a blob listing response.
- ///
- /// Blob listing entry
- [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "Reviewed.")]
- private IListBlobEntry ParseBlobEntry()
- {
- BlobAttributes blob = new BlobAttributes();
- string url = null;
- string name = null;
-
- // copy blob attribute strings
- string copyId = null;
- string copyStatus = null;
- string copyCompletionTime = null;
- string copyProgress = null;
- string copySource = null;
- string copyStatusDescription = null;
-
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- switch (this.reader.Name)
- {
- case Constants.UrlElement:
- url = reader.ReadElementContentAsString();
- break;
-
- case Constants.NameElement:
- name = reader.ReadElementContentAsString();
- break;
-
- case Constants.SnapshotElement:
- blob.SnapshotTime = reader.ReadElementContentAsString().ToUTCTime();
- break;
-
- case Constants.PropertiesElement:
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- switch (this.reader.Name)
- {
- case Constants.LastModifiedElement:
- blob.Properties.LastModified = reader.ReadElementContentAsString().ToUTCTime();
- break;
-
- case Constants.EtagElement:
- blob.Properties.ETag = string.Format(CultureInfo.InvariantCulture, "\"{0}\"", reader.ReadElementContentAsString());
- break;
-
- case Constants.ContentLengthElement:
- blob.Properties.Length = reader.ReadElementContentAsLong();
- break;
-
- case Constants.CacheControlElement:
- blob.Properties.CacheControl = reader.ReadElementContentAsString();
- break;
-
- case Constants.ContentTypeElement:
- blob.Properties.ContentType = reader.ReadElementContentAsString();
- break;
-
- case Constants.ContentEncodingElement:
- blob.Properties.ContentEncoding = reader.ReadElementContentAsString();
- break;
-
- case Constants.ContentLanguageElement:
- blob.Properties.ContentLanguage = reader.ReadElementContentAsString();
- break;
-
- case Constants.ContentMD5Element:
- blob.Properties.ContentMD5 = reader.ReadElementContentAsString();
- break;
-
- case Constants.BlobTypeElement:
- string blobTypeString = reader.ReadElementContentAsString();
- switch (blobTypeString)
- {
- case Constants.BlockBlobValue:
- blob.Properties.BlobType = BlobType.BlockBlob;
- break;
-
- case Constants.PageBlobValue:
- blob.Properties.BlobType = BlobType.PageBlob;
- break;
- }
-
- break;
-
- case Constants.LeaseStatusElement:
- blob.Properties.LeaseStatus = BlobHttpResponseParsers.GetLeaseStatus(reader.ReadElementContentAsString());
- break;
-
- case Constants.LeaseStateElement:
- blob.Properties.LeaseState = BlobHttpResponseParsers.GetLeaseState(reader.ReadElementContentAsString());
- break;
-
- case Constants.LeaseDurationElement:
- blob.Properties.LeaseDuration = BlobHttpResponseParsers.GetLeaseDuration(reader.ReadElementContentAsString());
- break;
-
- case Constants.CopyIdElement:
- copyId = reader.ReadElementContentAsString();
- break;
-
- case Constants.CopyCompletionTimeElement:
- copyCompletionTime = reader.ReadElementContentAsString();
- break;
-
- case Constants.CopyStatusElement:
- copyStatus = reader.ReadElementContentAsString();
- break;
-
- case Constants.CopyProgressElement:
- copyProgress = reader.ReadElementContentAsString();
- break;
-
- case Constants.CopySourceElement:
- copySource = reader.ReadElementContentAsString();
- break;
-
- case Constants.CopyStatusDescriptionElement:
- copyStatusDescription = reader.ReadElementContentAsString();
- break;
-
- default:
- reader.Skip();
- break;
- }
- }
- }
-
- this.reader.ReadEndElement();
- break;
-
- case Constants.MetadataElement:
- blob.Metadata = Response.ParseMetadata(this.reader);
- break;
-
- default:
- this.reader.Skip();
- break;
- }
- }
- }
-
- this.reader.ReadEndElement();
-
- int blobNameSectionIndex = url.LastIndexOf(NavigationHelper.Slash + name, StringComparison.Ordinal);
- string baseUri = url.Substring(0, blobNameSectionIndex + 1);
- UriBuilder ub = new UriBuilder(baseUri);
- ub.Path += Uri.EscapeUriString(name);
- if (baseUri.Length + name.Length < url.Length)
- {
- // it's a url for snapshot.
- // Snapshot blob URI example:http://.blob.core.windows.net//?snapshot=2009-12-03T15%3a26%3a19.4466877Z
- ub.Query = url.Substring(baseUri.Length + name.Length + 1);
- }
-
- blob.Uri = ub.Uri;
-
- if (!string.IsNullOrEmpty(copyStatus))
- {
- blob.CopyState = BlobHttpResponseParsers.GetCopyAttributes(
- copyStatus,
- copyId,
- copySource,
- copyProgress,
- copyCompletionTime,
- copyStatusDescription);
- }
-
- return new ListBlobEntry(name, blob);
- }
-
- ///
- /// Parses a blob prefix entry in a blob listing response.
- ///
- /// Blob listing entry
- private IListBlobEntry ParseBlobPrefixEntry()
- {
- ListBlobPrefixEntry commonPrefix = new ListBlobPrefixEntry();
-
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- switch (this.reader.Name)
- {
- case Constants.NameElement:
- commonPrefix.Name = reader.ReadElementContentAsString();
- break;
-
- default:
- reader.Skip();
- break;
- }
- }
- }
-
- this.reader.ReadEndElement();
-
- return commonPrefix;
- }
-
- ///
- /// Parses the response XML for a blob listing operation.
- ///
- /// An enumerable collection of objects that implement .
- protected override IEnumerable ParseXml()
- {
- if (this.reader.ReadToFollowing(Constants.EnumerationResultsElement))
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- switch (this.reader.Name)
- {
- case Constants.DelimiterElement:
- this.delimiter = reader.ReadElementContentAsString();
- this.delimiterConsumable = true;
- yield return null;
- break;
-
- case Constants.MarkerElement:
- this.marker = reader.ReadElementContentAsString();
- this.markerConsumable = true;
- yield return null;
- break;
-
- case Constants.NextMarkerElement:
- this.nextMarker = reader.ReadElementContentAsString();
- this.nextMarkerConsumable = true;
- yield return null;
- break;
-
- case Constants.MaxResultsElement:
- this.maxResults = reader.ReadElementContentAsInt();
- this.maxResultsConsumable = true;
- yield return null;
- break;
-
- case Constants.PrefixElement:
- this.prefix = reader.ReadElementContentAsString();
- this.prefixConsumable = true;
- yield return null;
- break;
-
- case Constants.BlobsElement:
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- switch (this.reader.Name)
- {
- case Constants.BlobElement:
- yield return this.ParseBlobEntry();
- break;
-
- case Constants.BlobPrefixElement:
- yield return this.ParseBlobPrefixEntry();
- break;
- }
- }
-
- this.reader.ReadEndElement();
- this.allObjectsParsed = true;
- break;
-
- default:
- reader.Skip();
- break;
- }
- }
- }
-
- this.reader.ReadEndElement();
- }
- }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ListContainersResponse.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ListContainersResponse.cs
deleted file mode 100644
index c04fce23a8fd1..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/ListContainersResponse.cs
+++ /dev/null
@@ -1,339 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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;
- using System.Collections.Generic;
- using System.IO;
-
- ///
- /// Provides methods for parsing the response from a container listing operation.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- sealed class ListContainersResponse : ResponseParsingBase
- {
- ///
- /// Stores the container prefix.
- ///
- private string prefix;
-
- ///
- /// Signals when the container prefix can be consumed.
- ///
- private bool prefixConsumable;
-
- ///
- /// Stores the marker.
- ///
- private string marker;
-
- ///
- /// Signals when the marker can be consumed.
- ///
- private bool markerConsumable;
-
- ///
- /// Stores the max results.
- ///
- private int maxResults;
-
- ///
- /// Signals when the max results can be consumed.
- ///
- private bool maxResultsConsumable;
-
- ///
- /// Stores the next marker.
- ///
- private string nextMarker;
-
- ///
- /// Signals when the next marker can be consumed.
- ///
- private bool nextMarkerConsumable;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The stream to be parsed.
- public ListContainersResponse(Stream stream)
- : base(stream)
- {
- }
-
- ///
- /// Gets the listing context from the XML response.
- ///
- /// A set of parameters for the listing operation.
- public ListingContext ListingContext
- {
- get
- {
- // Force a parsing in order
- ListingContext listingContext = new ListingContext(this.Prefix, this.MaxResults);
- listingContext.Marker = this.NextMarker;
- return listingContext;
- }
- }
-
- ///
- /// Gets an enumerable collection of objects from the response.
- ///
- /// An enumerable collection of objects.
- public IEnumerable Containers
- {
- get
- {
- return this.ObjectsToParse;
- }
- }
-
- ///
- /// Gets the Prefix value provided for the listing operation from the XML response.
- ///
- /// The Prefix value.
- public string Prefix
- {
- get
- {
- this.Variable(ref this.prefixConsumable);
-
- return this.prefix;
- }
- }
-
- ///
- /// Gets the Marker value provided for the listing operation from the XML response.
- ///
- /// The Marker value.
- public string Marker
- {
- get
- {
- this.Variable(ref this.markerConsumable);
-
- return this.marker;
- }
- }
-
- ///
- /// Gets the MaxResults value provided for the listing operation from the XML response.
- ///
- /// The MaxResults value.
- public int MaxResults
- {
- get
- {
- this.Variable(ref this.maxResultsConsumable);
-
- return this.maxResults;
- }
- }
-
- ///
- /// Gets the NextMarker value from the XML response, if the listing was not complete.
- ///
- /// The NextMarker value.
- public string NextMarker
- {
- get
- {
- this.Variable(ref this.nextMarkerConsumable);
-
- return this.nextMarker;
- }
- }
-
- ///
- /// Reads a container entry completely including its properties and metadata.
- ///
- /// Container listing entry
- private BlobContainerEntry ParseContainerEntry()
- {
- Uri uri = null;
- string name = null;
- IDictionary metadata = null;
- BlobContainerProperties containerProperties = new BlobContainerProperties();
-
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- switch (this.reader.Name)
- {
- case Constants.UrlElement:
- string url = this.reader.ReadElementContentAsString();
- Uri.TryCreate(url, UriKind.Absolute, out uri);
- break;
-
- case Constants.NameElement:
- name = this.reader.ReadElementContentAsString();
- break;
-
- case Constants.PropertiesElement:
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- switch (this.reader.Name)
- {
- case Constants.LastModifiedElement:
- containerProperties.LastModified = reader.ReadElementContentAsString().ToUTCTime();
- break;
-
- case Constants.EtagElement:
- containerProperties.ETag = reader.ReadElementContentAsString();
- break;
-
- case Constants.LeaseStatusElement:
- containerProperties.LeaseStatus = BlobHttpResponseParsers.GetLeaseStatus(reader.ReadElementContentAsString());
- break;
-
- case Constants.LeaseStateElement:
- containerProperties.LeaseState = BlobHttpResponseParsers.GetLeaseState(reader.ReadElementContentAsString());
- break;
-
- case Constants.LeaseDurationElement:
- containerProperties.LeaseDuration = BlobHttpResponseParsers.GetLeaseDuration(reader.ReadElementContentAsString());
- break;
-
- default:
- reader.Skip();
- break;
- }
- }
- }
-
- this.reader.ReadEndElement();
- break;
-
- case Constants.MetadataElement:
- metadata = Response.ParseMetadata(this.reader);
- break;
-
- default:
- reader.Skip();
- break;
- }
- }
- }
-
- this.reader.ReadEndElement();
-
- if (metadata == null)
- {
- metadata = new Dictionary();
- }
-
- return new BlobContainerEntry
- {
- Properties = containerProperties,
- Name = name,
- Uri = uri,
- Metadata = metadata,
- };
- }
-
- ///
- /// Parses the response XML for a container listing operation.
- ///
- /// An enumerable collection of objects.
- protected override IEnumerable ParseXml()
- {
- if (this.reader.ReadToFollowing(Constants.EnumerationResultsElement))
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- switch (this.reader.Name)
- {
- case Constants.MarkerElement:
- this.marker = this.reader.ReadElementContentAsString();
- this.markerConsumable = true;
- yield return null;
- break;
-
- case Constants.NextMarkerElement:
- this.nextMarker = this.reader.ReadElementContentAsString();
- this.nextMarkerConsumable = true;
- yield return null;
- break;
-
- case Constants.MaxResultsElement:
- this.maxResults = this.reader.ReadElementContentAsInt();
- this.maxResultsConsumable = true;
- yield return null;
- break;
-
- case Constants.PrefixElement:
- this.prefix = this.reader.ReadElementContentAsString();
- this.prefixConsumable = true;
- yield return null;
- break;
-
- case Constants.ContainersElement:
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement(Constants.ContainerElement))
- {
- yield return this.ParseContainerEntry();
- }
-
- this.reader.ReadEndElement();
- this.allObjectsParsed = true;
- break;
-
- default:
- reader.Skip();
- break;
- }
- }
- }
-
- this.reader.ReadEndElement();
- }
- }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/PageWrite.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/PageWrite.cs
deleted file mode 100644
index 682fe67fc66ea..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/PageWrite.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Describes actions that may be used for writing to a page blob or clearing a set of pages.
- ///
- public enum PageWrite
- {
- ///
- /// Update the page with new data.
- ///
- Update,
-
- ///
- /// Clear the page.
- ///
- Clear
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/PutBlockListItem.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/PutBlockListItem.cs
deleted file mode 100644
index 260450cd903ef..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/Protocol/PutBlockListItem.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Represents a block in a block list.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- sealed class PutBlockListItem
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The block ID.
- /// One of the enumeration values that specifies in which block lists to search for the block.
- public PutBlockListItem(string id, BlockSearchMode searchMode)
- {
- this.Id = id;
- this.SearchMode = searchMode;
- }
-
- ///
- /// Gets the block ID.
- ///
- /// The block ID.
- public string Id { get; private set; }
-
- ///
- /// Gets a value that indicates which block lists to search for the block.
- ///
- /// One of the enumeration values that specifies in which block lists to search for the block.
- public BlockSearchMode SearchMode { get; private set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/SequenceNumberAction.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/SequenceNumberAction.cs
deleted file mode 100644
index bdb0dc2ad8a8d..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/SequenceNumberAction.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Describes actions that can be performed on a page blob sequence number.
- ///
- public enum SequenceNumberAction
- {
- ///
- /// Sets the sequence number to be the higher of the value included with the request and the value currently stored for the blob.
- ///
- Max,
-
- ///
- /// Sets the sequence number to the value included with the request.
- ///
- Update,
-
- ///
- /// Increments the value of the sequence number by 1.
- ///
- Increment,
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/SharedAccessBlobPermissions.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/SharedAccessBlobPermissions.cs
deleted file mode 100644
index e9d55beb7c47e..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/SharedAccessBlobPermissions.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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;
-
- ///
- /// Specifies the set of possible permissions for a shared access policy.
- ///
- [Flags]
- public enum SharedAccessBlobPermissions
- {
- ///
- /// No shared access granted.
- ///
- None = 0x0,
-
- ///
- /// Read access granted.
- ///
- Read = 0x1,
-
- ///
- /// Write access granted.
- ///
- Write = 0x2,
-
- ///
- /// Delete access granted for blobs.
- ///
- Delete = 0x4,
-
- ///
- /// List access granted.
- ///
- List = 0x8
- }
-}
\ No newline at end of file
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/SharedAccessBlobPolicies.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/SharedAccessBlobPolicies.cs
deleted file mode 100644
index eed93cbf241b4..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/SharedAccessBlobPolicies.cs
+++ /dev/null
@@ -1,234 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 Microsoft.WindowsAzure.Storage.Core.Util;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
-
- ///
- /// Represents the collection of shared access policies defined for a container.
- ///
- [SuppressMessage(
- "Microsoft.Naming",
- "CA1710:IdentifiersShouldHaveCorrectSuffix",
- Justification = "Public APIs should not expose base collection types.")]
- public sealed class SharedAccessBlobPolicies : IDictionary
- {
- private Dictionary policies =
- new Dictionary();
-
- ///
- /// Adds the specified key and value to the collection of shared access policies.
- ///
- /// The key of the value to add.
- /// The value to add the collection of shared access policies.
- public void Add(string key, SharedAccessBlobPolicy value)
- {
- this.policies.Add(key, value);
- }
-
- ///
- /// Determines whether the collection of shared access policies contains the specified key.
- ///
- /// The key to locate in the collection of shared access policies.
- /// true if the collection of shared access policies contains an element with the specified key; otherwise, false.
- public bool ContainsKey(string key)
- {
- return this.policies.ContainsKey(key);
- }
-
- ///
- /// Gets a collection containing the keys in the shared access policies collection.
- ///
- /// A collection containing the keys in the of shared access policies collection.
- public ICollection Keys
- {
- get
- {
- return this.policies.Keys;
- }
- }
-
- ///
- /// Removes the value with the specified key from the shared access policies collection.
- ///
- /// The key of the item to remove.
- /// true if the element is successfully found and removed; otherwise, false. This method returns false if the key is not found.
- public bool Remove(string key)
- {
- return this.policies.Remove(key);
- }
-
- ///
- /// Gets the item associated with the specified key.
- ///
- /// The key of the value to get.
- /// The item to get.
- /// The item associated with the specified key, if the key is found; otherwise, the default value for the type.
- public bool TryGetValue(string key, out SharedAccessBlobPolicy value)
- {
- return this.policies.TryGetValue(key, out value);
- }
-
- ///
- /// Gets a collection containing the values in the shared access policies collection.
- ///
- /// A collection of items in the shared access policies collection.
- public ICollection Values
- {
- get
- {
- return this.policies.Values;
- }
- }
-
- ///
- /// Gets or sets the item associated with the specified key.
- ///
- /// The key of the value to get or set.
- /// The item associated with the specified key, or null if key is not in the shared access policies collection.
- public SharedAccessBlobPolicy this[string key]
- {
- get
- {
- return this.policies[key];
- }
-
- set
- {
- this.policies[key] = value;
- }
- }
-
- ///
- /// Adds the specified key/ value, stored in a , to the collection of shared access policies.
- ///
- /// The object, containing a key/ value pair, to add to the shared access policies collection.
- public void Add(KeyValuePair item)
- {
- this.Add(item.Key, item.Value);
- }
-
- ///
- /// Removes all keys and values from the shared access collection.
- ///
- public void Clear()
- {
- this.policies.Clear();
- }
-
- ///
- /// Determines whether the collection of shared access policies contains the key and value in the specified object.
- ///
- /// A object containing the key and value to search for.
- /// true if the shared access policies collection contains the specified key/value; otherwise, false.
- public bool Contains(KeyValuePair item)
- {
- SharedAccessBlobPolicy storedItem;
- if (this.TryGetValue(item.Key, out storedItem))
- {
- if (string.Equals(
- SharedAccessBlobPolicy.PermissionsToString(item.Value.Permissions),
- SharedAccessBlobPolicy.PermissionsToString(storedItem.Permissions),
- StringComparison.Ordinal))
- {
- return true;
- }
- }
-
- return false;
- }
-
- ///
- /// Copies each key/ value pair in the shared access policies collection to a compatible one-dimensional array, starting at the specified index of the target array.
- ///
- /// The one-dimensional array of objects that is the destination of the elements copied from the shared access policies collection.
- /// The zero-based index in at which copying begins.
- public void CopyTo(KeyValuePair[] array, int arrayIndex)
- {
- CommonUtility.AssertNotNull("array", array);
-
- foreach (KeyValuePair item in this.policies)
- {
- array[arrayIndex++] = item;
- }
- }
-
- ///
- /// Gets the number of key/ value pairs contained in the shared access policies collection.
- ///
- /// The number of key/ value pairs contained in the shared access policies collection.
- public int Count
- {
- get
- {
- return this.policies.Count;
- }
- }
-
- ///
- /// Gets a value indicating whether the collection of shared access policies is read-only.
- ///
- /// true if the collection of shared access policies is read-only; otherwise, false.
- public bool IsReadOnly
- {
- get
- {
- return false;
- }
- }
-
- ///
- /// Removes the value, specified in the object, from the shared access policies collection.
- ///
- /// The object, containing a key and value, to remove from the shared access policies collection.
- /// true if the item was successfully removed; otherwise, false.
- public bool Remove(KeyValuePair item)
- {
- if (this.Contains(item))
- {
- return this.Remove(item.Key);
- }
- else
- {
- return false;
- }
- }
-
- ///
- /// Returns an enumerator that iterates through the collection of shared access policies.
- ///
- /// An of type .
- public IEnumerator> GetEnumerator()
- {
- return this.policies.GetEnumerator();
- }
-
- ///
- /// Returns an enumerator that iterates through the collection of shared access policies.
- ///
- /// An object that can be used to iterate through the collection of shared access policies.
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- System.Collections.IEnumerable enumerable = this.policies;
- return enumerable.GetEnumerator();
- }
- }
-}
\ No newline at end of file
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/SharedAccessBlobPolicy.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Blob/SharedAccessBlobPolicy.cs
deleted file mode 100644
index a87e70409a04d..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Blob/SharedAccessBlobPolicy.cs
+++ /dev/null
@@ -1,133 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 Microsoft.WindowsAzure.Storage.Core.Util;
- using System;
- using System.Text;
-
- ///
- /// Represents a shared access policy, which specifies the start time, expiry time,
- /// and permissions for a shared access signature.
- ///
- public sealed class SharedAccessBlobPolicy
- {
- ///
- /// Initializes a new instance of the class.
- ///
- public SharedAccessBlobPolicy()
- {
- }
-
- ///
- /// Gets or sets the start time for a shared access signature associated with this shared access policy.
- ///
- /// The shared access start time.
- public DateTimeOffset? SharedAccessStartTime { get; set; }
-
- ///
- /// Gets or sets the expiry time for a shared access signature associated with this shared access policy.
- ///
- /// The shared access expiry time.
- public DateTimeOffset? SharedAccessExpiryTime { get; set; }
-
- ///
- /// Gets or sets the permissions for a shared access signature associated with this shared access policy.
- ///
- /// The permissions.
- public SharedAccessBlobPermissions Permissions { get; set; }
-
- ///
- /// Converts the permissions specified for the shared access policy to a string.
- ///
- /// The shared access permissions.
- /// The shared access permissions in string format.
- public static string PermissionsToString(SharedAccessBlobPermissions permissions)
- {
- // The service supports a fixed order => rwdl
- StringBuilder builder = new StringBuilder();
-
- if ((permissions & SharedAccessBlobPermissions.Read) == SharedAccessBlobPermissions.Read)
- {
- builder.Append("r");
- }
-
- if ((permissions & SharedAccessBlobPermissions.Write) == SharedAccessBlobPermissions.Write)
- {
- builder.Append("w");
- }
-
- if ((permissions & SharedAccessBlobPermissions.Delete) == SharedAccessBlobPermissions.Delete)
- {
- builder.Append("d");
- }
-
- if ((permissions & SharedAccessBlobPermissions.List) == SharedAccessBlobPermissions.List)
- {
- builder.Append("l");
- }
-
- return builder.ToString();
- }
-
- ///
- /// Constructs a object from a permissions string.
- ///
- /// The shared access permissions in string format.
- /// A set of shared access permissions.
- public static SharedAccessBlobPermissions PermissionsFromString(string input)
- {
- CommonUtility.AssertNotNull("input", input);
-
- SharedAccessBlobPermissions permissions = 0;
-
- foreach (char c in input)
- {
- switch (c)
- {
- case 'r':
- permissions |= SharedAccessBlobPermissions.Read;
- break;
-
- case 'w':
- permissions |= SharedAccessBlobPermissions.Write;
- break;
-
- case 'd':
- permissions |= SharedAccessBlobPermissions.Delete;
- break;
-
- case 'l':
- permissions |= SharedAccessBlobPermissions.List;
- break;
-
- default:
- throw new ArgumentOutOfRangeException("input");
- }
- }
-
- // Incase we ever change none to be something other than 0
- if (permissions == 0)
- {
- permissions |= SharedAccessBlobPermissions.None;
- }
-
- return permissions;
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/CloudStorageAccount.cs b/microsoft-azure-api/Services/Storage/Lib/Common/CloudStorageAccount.cs
deleted file mode 100644
index 52541ddb7103e..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/CloudStorageAccount.cs
+++ /dev/null
@@ -1,1068 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- using Microsoft.WindowsAzure.Storage.Auth;
- using Microsoft.WindowsAzure.Storage.Blob;
- using Microsoft.WindowsAzure.Storage.Core;
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using Microsoft.WindowsAzure.Storage.Queue;
- using Microsoft.WindowsAzure.Storage.Table;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
- using System.Linq;
- using AccountSetting = System.Collections.Generic.KeyValuePair>;
-
- ///
- /// Represents a Windows Azure Storage account.
- ///
- public sealed class CloudStorageAccount
- {
- ///
- /// The FISMA compliance default value.
- ///
- private static bool version1MD5 = true;
-
- ///
- /// Gets or sets a value indicating whether the FISMA MD5 setting will be used.
- ///
- /// false to use the FISMA MD5 setting; true to use the .NET default implementation.
-#if WINDOWS_PHONE
- internal
-#else
- public
-#endif
- static bool UseV1MD5
- {
- get { return version1MD5; }
- set { version1MD5 = value; }
- }
-
- ///
- /// The setting name for using the development storage.
- ///
- internal const string UseDevelopmentStorageSettingString = "UseDevelopmentStorage";
-
- ///
- /// The setting name for specifying a development storage proxy Uri.
- ///
- internal const string DevelopmentStorageProxyUriSettingString = "DevelopmentStorageProxyUri";
-
- ///
- /// The setting name for using the default storage endpoints with the specified protocol.
- ///
- internal const string DefaultEndpointsProtocolSettingString = "DefaultEndpointsProtocol";
-
- ///
- /// The setting name for the account name.
- ///
- internal const string AccountNameSettingString = "AccountName";
-
- ///
- /// The setting name for the account key name.
- ///
- internal const string AccountKeyNameSettingString = "AccountKeyName";
-
- ///
- /// The setting name for the account key.
- ///
- internal const string AccountKeySettingString = "AccountKey";
-
- ///
- /// The setting name for a custom blob storage endpoint.
- ///
- internal const string BlobEndpointSettingString = "BlobEndpoint";
-
- ///
- /// The setting name for a custom queue endpoint.
- ///
- internal const string QueueEndpointSettingString = "QueueEndpoint";
-
- ///
- /// The setting name for a custom table storage endpoint.
- ///
- internal const string TableEndpointSettingString = "TableEndpoint";
-
- ///
- /// The setting name for a custom storage endpoint suffix.
- ///
- internal const string EndpointSuffixSettingString = "EndpointSuffix";
-
- ///
- /// The setting name for a shared access key.
- ///
- internal const string SharedAccessSignatureSettingString = "SharedAccessSignature";
-
- ///
- /// The default account name for the development storage.
- ///
- private const string DevstoreAccountName = "devstoreaccount1";
-
- ///
- /// The default account key for the development storage.
- ///
- private const string DevstoreAccountKey = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";
-
- ///
- /// The credentials string used to test for the development storage credentials.
- ///
- private const string DevstoreCredentialInString =
- CloudStorageAccount.AccountNameSettingString + "=" + DevstoreAccountName + ";" +
- CloudStorageAccount.AccountKeySettingString + "=" + DevstoreAccountKey;
-
- ///
- /// The default storage service hostname suffix.
- ///
- private const string DefaultEndpointSuffix = "core.windows.net";
-
- ///
- /// The default blob storage DNS hostname prefix.
- ///
- private const string DefaultBlobHostnamePrefix = "blob";
-
- ///
- /// The root queue DNS name prefix.
- ///
- private const string DefaultQueueHostnamePrefix = "queue";
-
- ///
- /// The root table storage DNS name prefix.
- ///
- private const string DefaultTableHostnamePrefix = "table";
-
- ///
- /// Validator for the UseDevelopmentStorage setting. Must be "true".
- ///
- private static readonly AccountSetting UseDevelopmentStorageSetting = Setting(UseDevelopmentStorageSettingString, "true");
-
- ///
- /// Validator for the DevelopmentStorageProxyUri setting. Must be a valid Uri.
- ///
- private static readonly AccountSetting DevelopmentStorageProxyUriSetting = Setting(DevelopmentStorageProxyUriSettingString, IsValidUri);
-
- ///
- /// Validator for the DefaultEndpointsProtocol setting. Must be either "http" or "https".
- ///
- private static readonly AccountSetting DefaultEndpointsProtocolSetting = Setting(DefaultEndpointsProtocolSettingString, "http", "https");
-
- ///
- /// Validator for the AccountName setting. No restrictions.
- ///
- private static readonly AccountSetting AccountNameSetting = Setting(AccountNameSettingString);
-
- ///
- /// Validator for the AccountKey setting. No restrictions.
- ///
- private static readonly AccountSetting AccountKeyNameSetting = Setting(AccountKeyNameSettingString);
-
- ///
- /// Validator for the AccountKey setting. Must be a valid base64 string.
- ///
- private static readonly AccountSetting AccountKeySetting = Setting(AccountKeySettingString, IsValidBase64String);
-
- ///
- /// Validator for the BlobEndpoint setting. Must be a valid Uri.
- ///
- private static readonly AccountSetting BlobEndpointSetting = Setting(BlobEndpointSettingString, IsValidUri);
-
- ///
- /// Validator for the QueueEndpoint setting. Must be a valid Uri.
- ///
- private static readonly AccountSetting QueueEndpointSetting = Setting(QueueEndpointSettingString, IsValidUri);
-
- ///
- /// Validator for the TableEndpoint setting. Must be a valid Uri.
- ///
- private static readonly AccountSetting TableEndpointSetting = Setting(TableEndpointSettingString, IsValidUri);
-
- ///
- /// Validator for the EndpointSuffix setting. Must be a valid Uri.
- ///
- private static readonly AccountSetting EndpointSuffixSetting = Setting(EndpointSuffixSettingString, IsValidDomain);
-
- ///
- /// Validator for the SharedAccessSignature setting. No restrictions.
- ///
- private static readonly AccountSetting SharedAccessSignatureSetting = Setting(SharedAccessSignatureSettingString);
-
- ///
- /// Singleton instance for the development storage account.
- ///
- private static CloudStorageAccount devStoreAccount;
-
- ///
- /// Initializes a new instance of the class using the specified
- /// account credentials and service endpoints.
- ///
- /// The account credentials.
- /// The Blob service endpoint.
- /// The Queue service endpoint.
- /// The Table service endpoint.
- public CloudStorageAccount(StorageCredentials storageCredentials, Uri blobEndpoint, Uri queueEndpoint, Uri tableEndpoint)
- {
- this.Credentials = storageCredentials;
- this.BlobEndpoint = blobEndpoint;
- this.QueueEndpoint = queueEndpoint;
- this.TableEndpoint = tableEndpoint;
- this.DefaultEndpoints = false;
- }
-
- ///
- /// Initializes a new instance of the class using the specified
- /// account credentials and the default service endpoints.
- ///
- /// An object of type that
- /// specifies the account name and account key for the storage account.
- /// True to use HTTPS to connect to storage service endpoints; otherwise, false.
- public CloudStorageAccount(StorageCredentials storageCredentials, bool useHttps)
- : this(storageCredentials, null /* endpointSuffix */, useHttps)
- {
- }
-
- ///
- /// Initializes a new instance of the class using the specified
- /// account credentials and the default service endpoints.
- ///
- /// An object of type that
- /// specifies the account name and account key for the storage account.
- /// The DNS endpoint suffix for all storage services, e.g. "core.windows.net".
- /// True to use HTTPS to connect to storage service endpoints; otherwise, false.
- public CloudStorageAccount(StorageCredentials storageCredentials, string endpointSuffix, bool useHttps)
- {
- CommonUtility.AssertNotNull("storageCredentials", storageCredentials);
-
- string protocol = useHttps ? "https" : "http";
- this.BlobEndpoint = new Uri(ConstructBlobEndpoint(protocol, storageCredentials.AccountName, endpointSuffix));
- this.QueueEndpoint = new Uri(ConstructQueueEndpoint(protocol, storageCredentials.AccountName, endpointSuffix));
- this.TableEndpoint = new Uri(ConstructTableEndpoint(protocol, storageCredentials.AccountName, endpointSuffix));
- this.Credentials = storageCredentials;
- this.EndpointSuffix = endpointSuffix;
- this.DefaultEndpoints = true;
- }
-
- ///
- /// Gets a object that references the development storage account.
- ///
- /// A reference to the development storage account.
- public static CloudStorageAccount DevelopmentStorageAccount
- {
- get
- {
- if (devStoreAccount == null)
- {
- devStoreAccount = GetDevelopmentStorageAccount(null);
- }
-
- return devStoreAccount;
- }
- }
-
- ///
- /// Indicates whether this account is a development storage account.
- ///
- private bool IsDevStoreAccount { get; set; }
-
- ///
- /// The storage service hostname suffix set by the user, if any.
- ///
- private string EndpointSuffix { get; set; }
-
- ///
- /// The connection string parsed into settings.
- ///
- private IDictionary Settings { get; set; }
-
- ///
- /// True if the user used a constructor that auto-generates endpoints.
- ///
- private bool DefaultEndpoints { get; set; }
-
- ///
- /// Gets the endpoint for the Blob service, as configured for the storage account.
- ///
- /// The Blob service endpoint.
- public Uri BlobEndpoint { get; private set; }
-
- ///
- /// Gets the endpoint for the Queue service, as configured for the storage account.
- ///
- /// The Queue service endpoint.
- public Uri QueueEndpoint { get; private set; }
-
- ///
- /// Gets the endpoint for the Table service, as configured for the storage account.
- ///
- /// The Table service endpoint.
- public Uri TableEndpoint { get; private set; }
-
- ///
- /// Gets the credentials used to create this object.
- ///
- /// The credentials used to create the object.
- public StorageCredentials Credentials { get; private set; }
-
- ///
- /// Parses a connection string and returns a created
- /// from the connection string.
- ///
- /// A valid connection string.
- /// Thrown if is null or empty.
- /// Thrown if is not a valid connection string.
- /// Thrown if cannot be parsed.
- /// A object constructed from the values provided in the connection string.
- public static CloudStorageAccount Parse(string connectionString)
- {
- CloudStorageAccount ret;
-
- if (string.IsNullOrEmpty(connectionString))
- {
- throw new ArgumentNullException("connectionString");
- }
-
- if (ParseImpl(connectionString, out ret, err => { throw new FormatException(err); }))
- {
- return ret;
- }
-
- throw new ArgumentException(SR.ParseError);
- }
-
- ///
- /// Indicates whether a connection string can be parsed to return a object.
- ///
- /// The connection string to parse.
- /// A object to hold the instance returned if
- /// the connection string can be parsed.
- /// true if the connection string was successfully parsed; otherwise, false.
- public static bool TryParse(string connectionString, out CloudStorageAccount account)
- {
- if (string.IsNullOrEmpty(connectionString))
- {
- account = null;
- return false;
- }
-
- try
- {
- return ParseImpl(connectionString, out account, err => { });
- }
- catch (Exception)
- {
- account = null;
- return false;
- }
- }
-
- ///
- /// Creates the Table service client.
- ///
- /// A client object that specifies the Table service endpoint.
- public CloudTableClient CreateCloudTableClient()
- {
- if (this.TableEndpoint == null)
- {
- throw new InvalidOperationException(SR.TableEndPointNotConfigured);
- }
-
- if (this.Credentials == null)
- {
- throw new InvalidOperationException(SR.MissingCredentials);
- }
-
- return new CloudTableClient(this.TableEndpoint, this.Credentials);
- }
-
- ///
- /// Creates the Queue service client.
- ///
- /// A client object that specifies the Queue service endpoint.
- public CloudQueueClient CreateCloudQueueClient()
- {
- if (this.QueueEndpoint == null)
- {
- throw new InvalidOperationException(SR.QueueEndPointNotConfigured);
- }
-
- if (this.Credentials == null)
- {
- throw new InvalidOperationException(SR.MissingCredentials);
- }
-
- return new CloudQueueClient(this.QueueEndpoint, this.Credentials);
- }
-
- ///
- /// Creates the Blob service client.
- ///
- /// A client object that specifies the Blob service endpoint.
- public CloudBlobClient CreateCloudBlobClient()
- {
- if (this.BlobEndpoint == null)
- {
- throw new InvalidOperationException(SR.BlobEndPointNotConfigured);
- }
-
- if (this.Credentials == null)
- {
- throw new InvalidOperationException(SR.MissingCredentials);
- }
-
- return new CloudBlobClient(this.BlobEndpoint, this.Credentials);
- }
-
- ///
- /// Returns a connection string for this storage account, without sensitive data.
- ///
- /// A connection string.
- public override string ToString()
- {
- return this.ToString(false);
- }
-
- ///
- /// Returns a connection string for the storage account, optionally with sensitive data.
- ///
- /// True to include sensitive data in the string; otherwise, false.
- /// A connection string.
- public string ToString(bool exportSecrets)
- {
- if (this.Settings == null)
- {
- this.Settings = new Dictionary();
-
- if (this.DefaultEndpoints)
- {
- this.Settings.Add(DefaultEndpointsProtocolSettingString, this.BlobEndpoint.Scheme);
-
- if (this.EndpointSuffix != null)
- {
- this.Settings.Add(EndpointSuffixSettingString, this.EndpointSuffix);
- }
- }
- else
- {
- if (this.BlobEndpoint != null)
- {
- this.Settings.Add(BlobEndpointSettingString, this.BlobEndpoint.ToString());
- }
-
- if (this.QueueEndpoint != null)
- {
- this.Settings.Add(QueueEndpointSettingString, this.QueueEndpoint.ToString());
- }
-
- if (this.TableEndpoint != null)
- {
- this.Settings.Add(TableEndpointSettingString, this.TableEndpoint.ToString());
- }
- }
- }
-
- List listOfSettings = this.Settings.Select(pair => string.Format(CultureInfo.InvariantCulture, "{0}={1}", pair.Key, pair.Value)).ToList();
-
- if (this.Credentials != null && !this.IsDevStoreAccount)
- {
- listOfSettings.Add(this.Credentials.ToString(exportSecrets));
- }
-
- return string.Join(";", listOfSettings);
- }
-
- ///
- /// Returns a with development storage credentials using the specified proxy Uri.
- ///
- /// The proxy endpoint to use.
- /// The new .
- private static CloudStorageAccount GetDevelopmentStorageAccount(Uri proxyUri)
- {
- UriBuilder builder = proxyUri != null ?
- new UriBuilder(proxyUri.Scheme, proxyUri.Host) :
- new UriBuilder("http", "127.0.0.1");
-
- builder.Path = DevstoreAccountName;
-
- builder.Port = 10000;
- Uri blobEndpoint = builder.Uri;
-
- builder.Port = 10001;
- Uri queueEndpoint = builder.Uri;
-
- builder.Port = 10002;
- Uri tableEndpoint = builder.Uri;
-
- StorageCredentials credentials = new StorageCredentials(DevstoreAccountName, DevstoreAccountKey);
- CloudStorageAccount account = new CloudStorageAccount(credentials, blobEndpoint, queueEndpoint, tableEndpoint);
-
- account.Settings = new Dictionary();
- account.Settings.Add(UseDevelopmentStorageSettingString, "true");
- if (proxyUri != null)
- {
- account.Settings.Add(DevelopmentStorageProxyUriSettingString, proxyUri.ToString());
- }
-
- account.IsDevStoreAccount = true;
-
- return account;
- }
-
- ///
- /// Internal implementation of Parse/TryParse.
- ///
- /// The string to parse.
- /// The to return.
- /// A callback for reporting errors.
- /// If true, the parse was successful. Otherwise, false.
- internal static bool ParseImpl(string connectionString, out CloudStorageAccount accountInformation, Action error)
- {
- IDictionary settings = ParseStringIntoSettings(connectionString, error);
-
- // malformed settings string
- if (settings == null)
- {
- accountInformation = null;
-
- return false;
- }
-
- // devstore case
- if (MatchesSpecification(
- settings,
- AllRequired(UseDevelopmentStorageSetting),
- Optional(DevelopmentStorageProxyUriSetting)))
- {
- string proxyUri = null;
- if (settings.TryGetValue(DevelopmentStorageProxyUriSettingString, out proxyUri))
- {
- accountInformation = GetDevelopmentStorageAccount(new Uri(proxyUri));
- }
- else
- {
- accountInformation = DevelopmentStorageAccount;
- }
-
- accountInformation.Settings = ValidCredentials(settings);
- return true;
- }
-
- // automatic case
- if (MatchesSpecification(
- settings,
- AllRequired(DefaultEndpointsProtocolSetting, AccountNameSetting, AccountKeySetting),
- Optional(BlobEndpointSetting, QueueEndpointSetting, TableEndpointSetting, AccountKeyNameSetting, EndpointSuffixSetting)))
- {
- string blobEndpoint = null;
- settings.TryGetValue(BlobEndpointSettingString, out blobEndpoint);
-
- string queueEndpoint = null;
- settings.TryGetValue(QueueEndpointSettingString, out queueEndpoint);
-
- string tableEndpoint = null;
- settings.TryGetValue(TableEndpointSettingString, out tableEndpoint);
-
- accountInformation = new CloudStorageAccount(
- GetCredentials(settings),
- new Uri(blobEndpoint ?? ConstructBlobEndpoint(settings)),
- new Uri(queueEndpoint ?? ConstructQueueEndpoint(settings)),
- new Uri(tableEndpoint ?? ConstructTableEndpoint(settings)));
-
- string endpointSuffix = null;
- if (settings.TryGetValue(EndpointSuffixSettingString, out endpointSuffix))
- {
- accountInformation.EndpointSuffix = endpointSuffix;
- }
-
- accountInformation.Settings = ValidCredentials(settings);
- return true;
- }
-
- // explicit case
- if (MatchesSpecification(
- settings,
- AtLeastOne(BlobEndpointSetting, QueueEndpointSetting, TableEndpointSetting),
- ValidCredentials))
- {
- Uri blobUri = !settings.ContainsKey(BlobEndpointSettingString) || settings[BlobEndpointSettingString] == null ? null : new Uri(settings[BlobEndpointSettingString]);
- Uri queueUri = !settings.ContainsKey(QueueEndpointSettingString) || settings[QueueEndpointSettingString] == null ? null : new Uri(settings[QueueEndpointSettingString]);
- Uri tableUri = !settings.ContainsKey(TableEndpointSettingString) || settings[TableEndpointSettingString] == null ? null : new Uri(settings[TableEndpointSettingString]);
-
- accountInformation = new CloudStorageAccount(GetCredentials(settings), blobUri, queueUri, tableUri);
-
- accountInformation.Settings = ValidCredentials(settings);
- return true;
- }
-
- // not valid
- accountInformation = null;
-
- error("No valid combination of account information found.");
-
- return false;
- }
-
- ///
- /// Tokenizes input and stores name value pairs.
- ///
- /// The string to parse.
- /// Error reporting delegate.
- /// Tokenized collection.
- private static IDictionary ParseStringIntoSettings(string connectionString, Action error)
- {
- IDictionary settings = new Dictionary();
- string[] splitted = connectionString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
-
- foreach (string nameValue in splitted)
- {
- string[] splittedNameValue = nameValue.Split(new char[] { '=' }, 2);
-
- if (splittedNameValue.Length != 2)
- {
- error("Settings must be of the form \"name=value\".");
- return null;
- }
-
- if (settings.ContainsKey(splittedNameValue[0]))
- {
- error(string.Format(CultureInfo.InvariantCulture, "Duplicate setting '{0}' found.", splittedNameValue[0]));
- return null;
- }
-
- settings.Add(splittedNameValue[0], splittedNameValue[1]);
- }
-
- return settings;
- }
-
- ///
- /// Encapsulates a validation rule for an enumeration based account setting.
- ///
- /// The name of the setting.
- /// A list of valid values for the setting.
- /// An representing the enumeration constraint.
- private static AccountSetting Setting(string name, params string[] validValues)
- {
- return new AccountSetting(
- name,
- (settingValue) =>
- {
- if (validValues.Length == 0)
- {
- return true;
- }
-
- return validValues.Contains(settingValue);
- });
- }
-
- ///
- /// Encapsulates a validation rule using a func.
- ///
- /// The name of the setting.
- /// A func that determines if the value is valid.
- /// An representing the constraint.
- private static AccountSetting Setting(string name, Func isValid)
- {
- return new AccountSetting(name, isValid);
- }
-
- ///
- /// Determines whether the specified setting value is a valid base64 string.
- ///
- /// The setting value.
- /// true if the specified setting value is a valid base64 string; otherwise, false.
- private static bool IsValidBase64String(string settingValue)
- {
- try
- {
- Convert.FromBase64String(settingValue);
-
- return true;
- }
- catch (FormatException)
- {
- return false;
- }
- }
-
- ///
- /// Validation function that validates Uris.
- ///
- /// Value to validate.
- /// true if the specified setting value is a valid Uri; otherwise, false.
- private static bool IsValidUri(string settingValue)
- {
- return Uri.IsWellFormedUriString(settingValue, UriKind.Absolute);
- }
-
- ///
- /// Validation function that validates a domain name.
- ///
- /// Value to validate.
- /// true if the specified setting value is a valid domain; otherwise, false.
- private static bool IsValidDomain(string settingValue)
- {
- return Uri.CheckHostName(settingValue).Equals(UriHostNameType.Dns);
- }
-
- ///
- /// Settings filter that requires all specified settings be present and valid.
- ///
- /// A list of settings that must be present.
- /// The remaining settings or null if the filter's requirement is not satisfied.
- private static Func, IDictionary> AllRequired(params AccountSetting[] requiredSettings)
- {
- return (settings) =>
- {
- IDictionary result = new Dictionary(settings);
-
- foreach (AccountSetting requirement in requiredSettings)
- {
- string value;
- if (result.TryGetValue(requirement.Key, out value) && requirement.Value(value))
- {
- result.Remove(requirement.Key);
- }
- else
- {
- return null;
- }
- }
-
- return result;
- };
- }
-
- ///
- /// Settings filter that removes optional values.
- ///
- /// A list of settings that are optional.
- /// The remaining settings or null if the filter's requirement is not satisfied.
- private static Func, IDictionary> Optional(params AccountSetting[] optionalSettings)
- {
- return (settings) =>
- {
- IDictionary result = new Dictionary(settings);
-
- foreach (AccountSetting requirement in optionalSettings)
- {
- string value;
- if (result.TryGetValue(requirement.Key, out value) && requirement.Value(value))
- {
- result.Remove(requirement.Key);
- }
- }
-
- return result;
- };
- }
-
- ///
- /// Settings filter that ensures that at least one setting is present.
- ///
- /// A list of settings of which one must be present.
- /// The remaining settings or null if the filter's requirement is not satisfied.
- [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation", Justification = "Reviewed.")]
- private static Func, IDictionary> AtLeastOne(params AccountSetting[] atLeastOneSettings)
- {
- return (settings) =>
- {
- IDictionary result = new Dictionary(settings);
- bool foundOne = false;
-
- foreach (AccountSetting requirement in atLeastOneSettings)
- {
- string value;
- if (result.TryGetValue(requirement.Key, out value) && requirement.Value(value))
- {
- result.Remove(requirement.Key);
- foundOne = true;
- }
- }
-
- return foundOne ? result : null;
- };
- }
-
- ///
- /// Settings filter that ensures that a valid combination of credentials is present.
- ///
- /// The remaining settings or null if the filter's requirement is not satisfied.
- private static IDictionary ValidCredentials(IDictionary settings)
- {
- string accountName;
- string accountKey;
- string accountKeyName;
- string sharedAccessSignature;
- IDictionary result = new Dictionary(settings);
-
- if (settings.TryGetValue(AccountNameSettingString, out accountName) &&
- !AccountNameSetting.Value(accountName))
- {
- return null;
- }
-
- if (settings.TryGetValue(AccountKeySettingString, out accountKey) &&
- !AccountKeySetting.Value(accountKey))
- {
- return null;
- }
-
- if (settings.TryGetValue(AccountKeyNameSettingString, out accountKeyName) &&
- !AccountKeyNameSetting.Value(accountKeyName))
- {
- return null;
- }
-
- if (settings.TryGetValue(SharedAccessSignatureSettingString, out sharedAccessSignature) &&
- !SharedAccessSignatureSetting.Value(sharedAccessSignature))
- {
- return null;
- }
-
- result.Remove(AccountNameSettingString);
- result.Remove(AccountKeySettingString);
- result.Remove(AccountKeyNameSettingString);
- result.Remove(SharedAccessSignatureSettingString);
-
- // AccountAndKey
- if (accountName != null && accountKey != null && sharedAccessSignature == null)
- {
- return result;
- }
-
- // SharedAccessSignature
- if (accountName == null && accountKey == null && accountKeyName == null && sharedAccessSignature != null)
- {
- return result;
- }
-
- // Anonymous
- if (accountName == null && accountKey == null && accountKeyName == null && sharedAccessSignature == null)
- {
- return result;
- }
-
- return null;
- }
-
- ///
- /// Tests to see if a given list of settings matches a set of filters exactly.
- ///
- /// The settings to check.
- /// A list of filters to check.
- ///
- /// If any filter returns null, false.
- /// If there are any settings left over after all filters are processed, false.
- /// Otherwise true.
- ///
- private static bool MatchesSpecification(
- IDictionary settings,
- params Func, IDictionary>[] constraints)
- {
- foreach (Func, IDictionary> constraint in constraints)
- {
- IDictionary remainingSettings = constraint(settings);
-
- if (remainingSettings == null)
- {
- return false;
- }
- else
- {
- settings = remainingSettings;
- }
- }
-
- if (settings.Count == 0)
- {
- return true;
- }
-
- return false;
- }
-
- ///
- /// Gets a StorageCredentials object corresponding to whatever credentials are supplied in the given settings.
- ///
- /// The settings to check.
- /// The StorageCredentials object specified in the settings.
- private static StorageCredentials GetCredentials(IDictionary settings)
- {
- string accountName;
- string accountKey;
- string accountKeyName;
- string sharedAccessSignature;
-
- settings.TryGetValue(AccountNameSettingString, out accountName);
- settings.TryGetValue(AccountKeySettingString, out accountKey);
- settings.TryGetValue(AccountKeyNameSettingString, out accountKeyName);
- settings.TryGetValue(SharedAccessSignatureSettingString, out sharedAccessSignature);
-
- if (accountName != null && accountKey != null && sharedAccessSignature == null)
- {
- return new StorageCredentials(accountName, accountKey, accountKeyName);
- }
-
- if (accountName == null && accountKey == null && accountKeyName == null && sharedAccessSignature != null)
- {
- return new StorageCredentials(sharedAccessSignature);
- }
-
- return null;
- }
-
- ///
- /// Gets the default blob endpoint using specified settings.
- ///
- /// The settings to use.
- /// The default blob endpoint.
- private static string ConstructBlobEndpoint(IDictionary settings)
- {
- return ConstructBlobEndpoint(
- settings[DefaultEndpointsProtocolSettingString],
- settings[AccountNameSettingString],
- settings.ContainsKey(EndpointSuffixSettingString) ? settings[EndpointSuffixSettingString] : null);
- }
-
- ///
- /// Gets the default blob endpoint using the specified protocol and account name.
- ///
- /// The protocol to use.
- /// The name of the storage account.
- /// The Endpoint DNS suffix; use null for default.
- /// The default blob endpoint.
- private static string ConstructBlobEndpoint(string scheme, string accountName, string endpointSuffix)
- {
- if (string.IsNullOrEmpty(scheme))
- {
- throw new ArgumentNullException("scheme");
- }
-
- if (string.IsNullOrEmpty(accountName))
- {
- throw new ArgumentNullException("accountName");
- }
-
- if (string.IsNullOrEmpty(endpointSuffix))
- {
- endpointSuffix = DefaultEndpointSuffix;
- }
-
- return string.Format(
- CultureInfo.InvariantCulture,
- "{0}://{1}.{2}.{3}/",
- scheme,
- accountName,
- DefaultBlobHostnamePrefix,
- endpointSuffix);
- }
-
- ///
- /// Gets the default queue endpoint using the specified settings.
- ///
- /// The settings.
- /// The default queue endpoint.
- private static string ConstructQueueEndpoint(IDictionary settings)
- {
- return ConstructQueueEndpoint(
- settings[DefaultEndpointsProtocolSettingString],
- settings[AccountNameSettingString],
- settings.ContainsKey(EndpointSuffixSettingString) ? settings[EndpointSuffixSettingString] : null);
- }
-
- ///
- /// Gets the default queue endpoint using the specified protocol and account name.
- ///
- /// The protocol to use.
- /// The name of the storage account.
- /// The Endpoint DNS suffix; use null for default.
- /// The default queue endpoint.
- private static string ConstructQueueEndpoint(string scheme, string accountName, string endpointSuffix)
- {
- if (string.IsNullOrEmpty(scheme))
- {
- throw new ArgumentNullException("scheme");
- }
-
- if (string.IsNullOrEmpty(accountName))
- {
- throw new ArgumentNullException("accountName");
- }
-
- if (string.IsNullOrEmpty(endpointSuffix))
- {
- endpointSuffix = DefaultEndpointSuffix;
- }
-
- return string.Format(
- CultureInfo.InvariantCulture,
- "{0}://{1}.{2}.{3}/",
- scheme,
- accountName,
- DefaultQueueHostnamePrefix,
- endpointSuffix);
- }
-
- ///
- /// Gets the default table endpoint using the specified settings.
- ///
- /// The settings.
- /// The default table endpoint.
- private static string ConstructTableEndpoint(IDictionary settings)
- {
- return ConstructTableEndpoint(
- settings[DefaultEndpointsProtocolSettingString],
- settings[AccountNameSettingString],
- settings.ContainsKey(EndpointSuffixSettingString) ? settings[EndpointSuffixSettingString] : null);
- }
-
- ///
- /// Gets the default table endpoint using the specified protocol and account name.
- ///
- /// The protocol to use.
- /// The name of the storage account.
- /// The Endpoint DNS suffix; use null for default.
- /// The default table endpoint.
- private static string ConstructTableEndpoint(string scheme, string accountName, string endpointSuffix)
- {
- if (string.IsNullOrEmpty(scheme))
- {
- throw new ArgumentNullException("scheme");
- }
-
- if (string.IsNullOrEmpty(accountName))
- {
- throw new ArgumentNullException("accountName");
- }
-
- if (string.IsNullOrEmpty(endpointSuffix))
- {
- endpointSuffix = DefaultEndpointSuffix;
- }
-
- return string.Format(
- CultureInfo.InvariantCulture,
- "{0}://{1}.{2}.{3}/",
- scheme,
- accountName,
- DefaultTableHostnamePrefix,
- endpointSuffix);
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Auth/SharedAccessSignatureHelper.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Auth/SharedAccessSignatureHelper.cs
deleted file mode 100644
index ebb1e9bd9e75c..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Auth/SharedAccessSignatureHelper.cs
+++ /dev/null
@@ -1,609 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Auth
-{
- using Microsoft.WindowsAzure.Storage.Auth;
- using Microsoft.WindowsAzure.Storage.Blob;
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using Microsoft.WindowsAzure.Storage.Queue;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using Microsoft.WindowsAzure.Storage.Table;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
-
- ///
- /// Contains helper methods for implementing shared access signatures.
- ///
- internal static class SharedAccessSignatureHelper
- {
- ///
- /// Get the complete query builder for creating the Shared Access Signature query.
- ///
- /// The shared access policy to hash.
- /// An optional identifier for the policy.
- /// Either "b" for blobs or "c" for containers.
- /// The signature to use.
- /// The name of the key used to create the signature, or null if the key is implicit.
- /// The finished query builder.
- internal static UriQueryBuilder GetSharedAccessSignatureImpl(
- SharedAccessBlobPolicy policy,
- string accessPolicyIdentifier,
- string resourceType,
- string signature,
- string accountKeyName)
- {
- CommonUtility.AssertNotNullOrEmpty("resourceType", resourceType);
- CommonUtility.AssertNotNull("signature", signature);
-
- if (policy == null)
- {
- return GetSharedAccessSignatureImpl(
- null /* policy.Permissions */,
- null /* policy.SharedAccessStartTime */,
- null /* policy.SharedAccessExpiryTime */,
- null /* startPatitionKey (table only) */,
- null /* startRowKey (table only) */,
- null /* endPatitionKey (table only) */,
- null /* endRowKey (table only) */,
- accessPolicyIdentifier,
- resourceType,
- null /* tableName (table only) */,
- signature,
- accountKeyName);
- }
-
- string permissions = SharedAccessBlobPolicy.PermissionsToString(policy.Permissions);
- if (string.IsNullOrEmpty(permissions))
- {
- permissions = null;
- }
-
- return GetSharedAccessSignatureImpl(
- permissions,
- policy.SharedAccessStartTime,
- policy.SharedAccessExpiryTime,
- null /* startPartitionKey (table only) */,
- null /* startRowKey (table only) */,
- null /* endPartitionKey (table only) */,
- null /* endRowKey (table only) */,
- accessPolicyIdentifier,
- resourceType,
- null /* tableName (table only) */,
- signature,
- accountKeyName);
- }
-
- ///
- /// Get the complete query builder for creating the Shared Access Signature query.
- ///
- /// The shared access policy to hash.
- /// An optional identifier for the policy.
- /// The signature to use.
- /// The name of the key used to create the signature, or null if the key is implicit.
- /// The finished query builder.
- internal static UriQueryBuilder GetSharedAccessSignatureImpl(
- SharedAccessQueuePolicy policy,
- string accessPolicyIdentifier,
- string signature,
- string accountKeyName)
- {
- CommonUtility.AssertNotNull("signature", signature);
-
- if (policy == null)
- {
- return GetSharedAccessSignatureImpl(
- null /* permissions*/,
- null /* policy.SharedAccessStartTime*/,
- null /* policy.SharedAccessExpiryTime*/,
- null /* startPartitionKey (table only) */,
- null /* startRowKey (table only) */,
- null /* endPartitionKey (table only) */,
- null /* endRowKey (table only) */,
- accessPolicyIdentifier,
- null /* resourceType (blob only) */,
- null /* tableName (table only) */,
- signature,
- accountKeyName);
- }
-
- string permissions = SharedAccessQueuePolicy.PermissionsToString(policy.Permissions);
- if (string.IsNullOrEmpty(permissions))
- {
- permissions = null;
- }
-
- return GetSharedAccessSignatureImpl(
- permissions,
- policy.SharedAccessStartTime,
- policy.SharedAccessExpiryTime,
- null /* startPartitionKey (table only) */,
- null /* startRowKey (table only) */,
- null /* endPartitionKey (table only) */,
- null /* endRowKey (table only) */,
- accessPolicyIdentifier,
- null /* resourceType (blob only) */,
- null /* tableName (table only) */,
- signature,
- accountKeyName);
- }
-
- ///
- /// Get the complete query builder for creating the Shared Access Signature query.
- ///
- /// The shared access policy to hash.
- /// The name of the table associated with this shared access signature.
- /// An optional identifier for the policy.
- /// The start partition key, or null.
- /// The start row key, or null.
- /// The end partition key, or null.
- /// The end row key, or null.
- /// The signature to use.
- /// The name of the key used to create the signature, or null if the key is implicit.
- /// The finished query builder.
- internal static UriQueryBuilder GetSharedAccessSignatureImpl(
- SharedAccessTablePolicy policy,
- string tableName,
- string accessPolicyIdentifier,
- string startPartitionKey,
- string startRowKey,
- string endPartitionKey,
- string endRowKey,
- string signature,
- string accountKeyName)
- {
- CommonUtility.AssertNotNull("signature", signature);
-
- if (policy == null)
- {
- return GetSharedAccessSignatureImpl(
- null /* policy.Permissions */,
- null /* policy.SharedAccessStartTime */,
- null /* policy.SharedAccessExpiryTime */,
- startPartitionKey,
- startRowKey,
- endPartitionKey,
- endRowKey,
- accessPolicyIdentifier,
- null /* resourceType (blob only) */,
- tableName,
- signature,
- accountKeyName);
- }
-
- string permissions = SharedAccessTablePolicy.PermissionsToString(policy.Permissions);
- if (string.IsNullOrEmpty(permissions))
- {
- permissions = null;
- }
-
- return GetSharedAccessSignatureImpl(
- permissions,
- policy.SharedAccessStartTime,
- policy.SharedAccessExpiryTime,
- startPartitionKey,
- startRowKey,
- endPartitionKey,
- endRowKey,
- accessPolicyIdentifier,
- null /* resourceType (blob only) */,
- tableName,
- signature,
- accountKeyName);
- }
-
- ///
- /// Converts the specified value to either a string representation or .
- ///
- /// The value to convert.
- /// A string representing the specified value.
- internal static string GetDateTimeOrEmpty(DateTimeOffset? value)
- {
- string result = GetDateTimeOrNull(value) ?? string.Empty;
- return result;
- }
-
- ///
- /// Converts the specified value to either a string representation or null.
- ///
- /// The value to convert.
- /// A string representing the specified value.
- internal static string GetDateTimeOrNull(DateTimeOffset? value)
- {
- string result = value != null ? value.Value.UtcDateTime.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture) : null;
- return result;
- }
-
- ///
- /// Escapes and adds the specified name/value pair to the query builder if it is not null.
- ///
- /// The builder to add the value to.
- /// The name of the pair.
- /// The value to be escaped.
- internal static void AddEscapedIfNotNull(UriQueryBuilder builder, string name, string value)
- {
- if (value != null)
- {
- builder.Add(name, value);
- }
- }
-
- ///
- /// Parses the query.
- ///
- /// The query parameters.
- /// A boolean that represents whether SignedResource is part of Sas or not. True for blobs, False for Queues and Tables.
- [SuppressMessage("Microsoft.Globalization", "CA1304:SpecifyCultureInfo", MessageId = "System.String.ToLower", Justification = "ToLower(CultureInfo) is not present in RT and ToLowerInvariant() also violates FxCop")]
- internal static StorageCredentials ParseQuery(IDictionary queryParameters, bool mandatorySignedResource)
- {
- string signature = null;
- string signedStart = null;
- string signedExpiry = null;
- string signedResource = null;
- string sigendPermissions = null;
- string signedIdentifier = null;
- string signedVersion = null;
- string tableName = null;
-
- bool sasParameterFound = false;
-
- foreach (KeyValuePair parameter in queryParameters)
- {
- switch (parameter.Key.ToLower())
- {
- case Constants.QueryConstants.SignedStart:
- signedStart = parameter.Value;
- sasParameterFound = true;
- break;
-
- case Constants.QueryConstants.SignedExpiry:
- signedExpiry = parameter.Value;
- sasParameterFound = true;
- break;
-
- case Constants.QueryConstants.SignedPermissions:
- sigendPermissions = parameter.Value;
- sasParameterFound = true;
- break;
-
- case Constants.QueryConstants.SignedResource:
- signedResource = parameter.Value;
- sasParameterFound = true;
- break;
-
- case Constants.QueryConstants.SignedIdentifier:
- signedIdentifier = parameter.Value;
- sasParameterFound = true;
- break;
-
- case Constants.QueryConstants.Signature:
- signature = parameter.Value;
- sasParameterFound = true;
- break;
-
- case Constants.QueryConstants.SignedVersion:
- signedVersion = parameter.Value;
- sasParameterFound = true;
- break;
-
- case Constants.QueryConstants.SasTableName:
- tableName = parameter.Value;
- sasParameterFound = true;
- break;
-
- default:
- break;
- }
- }
-
- if (sasParameterFound)
- {
- if (signature == null || (mandatorySignedResource && signedResource == null))
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.MissingMandatoryParametersForSAS);
- throw new ArgumentException(errorMessage);
- }
-
- UriQueryBuilder builder = new UriQueryBuilder();
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SignedStart, signedStart);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SignedExpiry, signedExpiry);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SignedPermissions, sigendPermissions);
- if (signedResource != null)
- {
- builder.Add(Constants.QueryConstants.SignedResource, signedResource);
- }
-
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SignedIdentifier, signedIdentifier);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SignedVersion, signedVersion);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.Signature, signature);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SasTableName, tableName);
-
- return new StorageCredentials(builder.ToString());
- }
-
- return null;
- }
-
- ///
- /// Get the complete query builder for creating the Shared Access Signature query.
- ///
- /// The permissions string for the resource, or null.
- /// The start time, or null.
- /// The expiration time, or null.
- /// The start partition key, or null.
- /// The start row key, or null.
- /// The end partition key, or null.
- /// The end row key, or null.
- /// An optional identifier for the policy.
- /// Either "b" for blobs or "c" for containers, or null if neither.
- /// The name of the table this signature is associated with,
- /// or null if not using table SAS.
- /// The signature to use.
- /// The name of the key used to create the signature, or null if the key is implicit.
- /// The finished query builder.
- private static UriQueryBuilder GetSharedAccessSignatureImpl(
- string permissions,
- DateTimeOffset? startTime,
- DateTimeOffset? expiryTime,
- string startPartitionKey,
- string startRowKey,
- string endPartitionKey,
- string endRowKey,
- string accessPolicyIdentifier,
- string resourceType,
- string tableName,
- string signature,
- string accountKeyName)
- {
- UriQueryBuilder builder = new UriQueryBuilder();
-
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SignedVersion, Constants.HeaderConstants.TargetStorageVersion);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SignedStart, GetDateTimeOrNull(startTime));
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SignedExpiry, GetDateTimeOrNull(expiryTime));
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SignedResource, resourceType);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SasTableName, tableName);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SignedPermissions, permissions);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.StartPartitionKey, startPartitionKey);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.StartRowKey, startRowKey);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.EndPartitionKey, endPartitionKey);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.EndRowKey, endRowKey);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SignedIdentifier, accessPolicyIdentifier);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.SignedKey, accountKeyName);
- AddEscapedIfNotNull(builder, Constants.QueryConstants.Signature, signature);
-
- return builder;
- }
-
- ///
- /// Get the signature hash embedded inside the Shared Access Signature.
- ///
- /// The shared access policy to hash.
- /// An optional identifier for the policy.
- /// The canonical resource string, unescaped.
- /// The key value retrieved as an atomic operation used for signing.
- /// The signed hash.
- internal static string GetSharedAccessSignatureHashImpl(
- SharedAccessBlobPolicy policy,
- string accessPolicyIdentifier,
- string resourceName,
- byte[] keyValue)
- {
- if (policy == null)
- {
- return GetSharedAccessSignatureHashImpl(
- null /* policy.Permissions */,
- null /* policy.SharedAccessStartTime */,
- null /* policy.SharedAccessExpiryTime */,
- null /* startPatitionKey (table only) */,
- null /* startRowKey (table only) */,
- null /* endPatitionKey (table only) */,
- null /* endRowKey (table only) */,
- false /* not using table SAS */,
- accessPolicyIdentifier,
- resourceName,
- keyValue);
- }
-
- return GetSharedAccessSignatureHashImpl(
- SharedAccessBlobPolicy.PermissionsToString(policy.Permissions),
- policy.SharedAccessStartTime,
- policy.SharedAccessExpiryTime,
- null /* startPartitionKey (table only) */,
- null /* startRowKey (table only) */,
- null /* endPartitionKey (table only) */,
- null /* endRowKey (table only) */,
- false /* not using table SAS */,
- accessPolicyIdentifier,
- resourceName,
- keyValue);
- }
-
- ///
- /// Get the signature hash embedded inside the Shared Access Signature.
- ///
- /// The shared access policy to hash.
- /// An optional identifier for the policy.
- /// The canonical resource string, unescaped.
- /// The key value retrieved as an atomic operation used for signing.
- /// The signed hash.
- internal static string GetSharedAccessSignatureHashImpl(
- SharedAccessQueuePolicy policy,
- string accessPolicyIdentifier,
- string resourceName,
- byte[] keyValue)
- {
- if (policy == null)
- {
- return GetSharedAccessSignatureHashImpl(
- null /*SharedAccessQueuePolicy.Permissions */,
- null /*policy.SharedAccessStartTime*/,
- null /*policy.SharedAccessExpiryTime*/,
- null /* startPartitionKey (table only) */,
- null /* startRowKey (table only) */,
- null /* endPartitionKey (table only) */,
- null /* endRowKey (table only) */,
- false /* not using table SAS */,
- accessPolicyIdentifier,
- resourceName,
- keyValue);
- }
- else
- {
- return GetSharedAccessSignatureHashImpl(
- SharedAccessQueuePolicy.PermissionsToString(policy.Permissions),
- policy.SharedAccessStartTime,
- policy.SharedAccessExpiryTime,
- null /* startPartitionKey (table only) */,
- null /* startRowKey (table only) */,
- null /* endPartitionKey (table only) */,
- null /* endRowKey (table only) */,
- false /* not using table SAS */,
- accessPolicyIdentifier,
- resourceName,
- keyValue);
- }
- }
-
- ///
- /// Get the signature hash embedded inside the Shared Access Signature.
- ///
- /// The shared access policy to hash.
- /// An optional identifier for the policy.
- /// The start partition key, or null.
- /// The start row key, or null.
- /// The end partition key, or null.
- /// The end row key, or null.
- /// The canonical resource string, unescaped.
- /// The key value retrieved as an atomic operation used for signing.
- /// The signed hash.
- internal static string GetSharedAccessSignatureHashImpl(
- SharedAccessTablePolicy policy,
- string accessPolicyIdentifier,
- string startPartitionKey,
- string startRowKey,
- string endPartitionKey,
- string endRowKey,
- string resourceName,
- byte[] keyValue)
- {
- if (policy == null)
- {
- return GetSharedAccessSignatureHashImpl(
- null /* policy.Permissions */,
- null /* policy.SharedAccessStartTime */,
- null /* policy.SharedAccessExpiryTime */,
- startPartitionKey,
- startRowKey,
- endPartitionKey,
- endRowKey,
- true /* using table SAS */,
- accessPolicyIdentifier,
- resourceName,
- keyValue);
- }
-
- return GetSharedAccessSignatureHashImpl(
- SharedAccessTablePolicy.PermissionsToString(policy.Permissions),
- policy.SharedAccessStartTime,
- policy.SharedAccessExpiryTime,
- startPartitionKey,
- startRowKey,
- endPartitionKey,
- endRowKey,
- true /* using table SAS */,
- accessPolicyIdentifier,
- resourceName,
- keyValue);
- }
-
- ///
- /// Get the signature hash embedded inside the Shared Access Signature.
- ///
- /// The permissions string for the resource, or null.
- /// The start time, or null.
- /// The expiration time, or null.
- /// The start partition key, or null.
- /// The start row key, or null.
- /// The end partition key, or null.
- /// The end row key, or null.
- /// Whether to use the table string-to-sign.
- /// An optional identifier for the policy.
- /// The canonical resource string, unescaped.
- /// The key value retrieved as an atomic operation used for signing.
- /// The signed hash.
- [SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Microsoft.WindowsAzure.Storage.Core.Util.CryptoUtility.ComputeHmac256(System.Byte[],System.String)", Justification = "Reviewed")]
- private static string GetSharedAccessSignatureHashImpl(
- string permissions,
- DateTimeOffset? startTime,
- DateTimeOffset? expiryTime,
- string startPartitionKey,
- string startRowKey,
- string endPartitionKey,
- string endRowKey,
- bool useTableSas,
- string accessPolicyIdentifier,
- string resourceName,
- byte[] keyValue)
- {
- CommonUtility.AssertNotNullOrEmpty("resourceName", resourceName);
- CommonUtility.AssertNotNull("keyValue", keyValue);
-
- //// StringToSign = signedpermissions + "\n" +
- //// signedstart + "\n" +
- //// signedexpiry + "\n" +
- //// canonicalizedresource + "\n" +
- //// signedidentifier + "\n" +
- //// signedversion
- ////
- //// TableStringToSign = StringToSign + "\n" +
- //// startpk + "\n" +
- //// startrk + "\n" +
- //// endpk + "\n" +
- //// endrk
- ////
- //// HMAC-SHA256(UTF8.Encode(StringToSign))
-
- string stringToSign = string.Format(
- CultureInfo.InvariantCulture,
- "{0}\n{1}\n{2}\n{3}\n{4}\n{5}",
- permissions,
- GetDateTimeOrEmpty(startTime),
- GetDateTimeOrEmpty(expiryTime),
- resourceName,
- accessPolicyIdentifier,
- Constants.HeaderConstants.TargetStorageVersion);
-
- if (useTableSas)
- {
- stringToSign = string.Format(
- CultureInfo.InvariantCulture,
- "{0}\n{1}\n{2}\n{3}\n{4}",
- stringToSign,
- startPartitionKey,
- startRowKey,
- endPartitionKey,
- endRowKey);
- }
-
- string signature = CryptoUtility.ComputeHmac256(keyValue, stringToSign);
-
- return signature;
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/CanonicalizedString.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/CanonicalizedString.cs
deleted file mode 100644
index 7b0a42fb5c7c0..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/CanonicalizedString.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 System.Text;
-
- ///
- /// Represents a canonicalized string used in authenticating a request against the azure service.
- ///
- internal class CanonicalizedString
- {
- private const int DefaultCapacity = 300;
- private const char ElementDelimiter = '\n';
-
- ///
- /// Stores the internal that holds the canonicalized string.
- ///
- private readonly StringBuilder canonicalizedString;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The first canonicalized element to start the string with.
- public CanonicalizedString(string initialElement)
- : this(initialElement, CanonicalizedString.DefaultCapacity)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The first canonicalized element to start the string with.
- /// The starting size of the string.
- public CanonicalizedString(string initialElement, int capacity)
- {
- this.canonicalizedString = new StringBuilder(initialElement, capacity);
- }
-
- ///
- /// Append additional canonicalized element to the string.
- ///
- /// An additional canonicalized element to append to the string.
- public void AppendCanonicalizedElement(string element)
- {
- this.canonicalizedString.Append(CanonicalizedString.ElementDelimiter);
- this.canonicalizedString.Append(element);
- }
-
- ///
- /// Converts the value of this instance to a string.
- ///
- /// A string whose value is the same as this instance.
- public override string ToString()
- {
- return this.canonicalizedString.ToString();
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/ExecutionState.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/ExecutionState.cs
deleted file mode 100644
index f29fa8caf7168..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/ExecutionState.cs
+++ /dev/null
@@ -1,293 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Executor
-{
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using Microsoft.WindowsAzure.Storage.RetryPolicies;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Globalization;
- using System.IO;
- using System.Threading;
-
-#if WINDOWS_RT
- using System.Net.Http;
-#else
- using System.Net;
-#endif
-
- // This class encapsulates a StorageCommand and stores state about its execution.
- // Note conceptually there is some overlap between ExecutionState and operationContext, however the
- // operationContext is the user visible object and the ExecutionState is an internal object used to coordinate execution.
-#if WINDOWS_RT
- internal class ExecutionState : IDisposable
-#else
- // If we are exposing APM then derive this class from the StorageCommandAsyncResult
- internal class ExecutionState : StorageCommandAsyncResult
-#endif
- {
- public ExecutionState(StorageCommandBase cmd, IRetryPolicy policy, OperationContext operationContext)
- {
- this.Cmd = cmd;
- this.RetryPolicy = policy != null ? policy.CreateInstance() : new NoRetry();
- this.OperationContext = operationContext ?? new OperationContext();
-
-#if WINDOWS_RT
- if (this.OperationContext.StartTime == DateTimeOffset.MinValue)
- {
- this.OperationContext.StartTime = DateTimeOffset.Now;
- }
-#else
- if (this.OperationContext.StartTime == DateTime.MinValue)
- {
- this.OperationContext.StartTime = DateTime.Now;
- }
-#endif
- }
-
-#if WINDOWS_DESKTOP
- public ExecutionState(StorageCommandBase cmd, IRetryPolicy policy, OperationContext operationContext, AsyncCallback callback, object asyncState)
- : base(callback, asyncState)
- {
- this.Cmd = cmd;
- this.RetryPolicy = policy != null ? policy.CreateInstance() : new NoRetry();
- this.OperationContext = operationContext ?? new OperationContext();
-
- if (this.OperationContext.StartTime == DateTime.MinValue)
- {
- this.OperationContext.StartTime = DateTime.Now;
- }
- }
-#endif
-
- internal void Init()
- {
- this.Req = null;
- this.resp = null;
-
-#if !WINDOWS_RT
- this.ReqTimedOut = false;
- this.CancelDelegate = null;
-#endif
- }
-
-#if WINDOWS_RT
- public void Dispose()
- {
- this.CheckDisposeSendStream();
- }
-#else
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- Timer backoffTimer = this.BackoffTimer;
- if (backoffTimer != null)
- {
- this.BackoffTimer = null;
- backoffTimer.Dispose();
- }
-
- this.CheckDisposeSendStream();
- }
-
- base.Dispose(disposing);
- }
-
- internal Timer BackoffTimer { get; set; }
-#endif
-
- internal OperationContext OperationContext { get; set; }
-
- internal DateTime? OperationExpiryTime
- {
- get { return this.Cmd.OperationExpiryTime; }
- }
-
- internal IRetryPolicy RetryPolicy { get; set; }
-
- internal StorageCommandBase Cmd { get; set; }
-
- internal RESTCommand RestCMD
- {
- get
- {
- return this.Cmd as RESTCommand;
- }
- }
-
- internal ExecutorOperation CurrentOperation { get; set; }
-
- internal TimeSpan RemainingTimeout
- {
- get
- {
- if (!this.OperationExpiryTime.HasValue || this.OperationExpiryTime.Value.Equals(DateTime.MaxValue))
- {
- // User did not specify a timeout, so we will set the request timeout to avoid
- // waiting for the response infinitely
- return Constants.DefaultClientSideTimeout;
- }
- else
- {
- TimeSpan potentialTimeout = this.OperationExpiryTime.Value - DateTime.Now;
-
- if (potentialTimeout <= TimeSpan.Zero)
- {
- throw Exceptions.GenerateTimeoutException(this.Cmd.CurrentResult, null);
- }
-
- return potentialTimeout;
- }
- }
- }
-
- private int retryCount = 0;
-
- internal int RetryCount
- {
- get { return this.retryCount; }
- set { this.retryCount = value; }
- }
-
- internal Stream ReqStream { get; set; }
-
- private volatile Exception exceptionRef = null;
-
- internal Exception ExceptionRef
- {
- get
- {
- return this.exceptionRef;
- }
-
- set
- {
- this.exceptionRef = value;
- if (this.Cmd != null && this.Cmd.CurrentResult != null)
- {
- this.Cmd.CurrentResult.Exception = value;
- }
- }
- }
-
- internal T Result { get; set; }
-
- private object timeoutLockerObj = new object();
- private bool reqTimedOut = false;
-
- internal bool ReqTimedOut
- {
- get
- {
- lock (this.timeoutLockerObj)
- {
- return this.reqTimedOut;
- }
- }
-
- set
- {
- lock (this.timeoutLockerObj)
- {
- this.reqTimedOut = value;
- }
- }
- }
-
- private void CheckDisposeSendStream()
- {
- RESTCommand cmd = this.RestCMD;
-
- if ((cmd != null) && (cmd.StreamToDispose != null))
- {
- cmd.StreamToDispose.Dispose();
- cmd.StreamToDispose = null;
- }
- }
-
-#if WINDOWS_RT
- internal HttpClient Client { get; set; }
-
- internal HttpRequestMessage Req { get; set; }
-
- private HttpResponseMessage resp = null;
-
- internal HttpResponseMessage Resp
- {
- get
- {
- return this.resp;
- }
-
- set
- {
- this.resp = value;
-
- if (value != null)
- {
- this.Cmd.CurrentResult.ServiceRequestID = HttpResponseMessageUtils.GetHeaderSingleValueOrDefault(this.resp.Headers, Constants.HeaderConstants.RequestIdHeader);
- this.Cmd.CurrentResult.ContentMd5 = this.resp.Content.Headers.ContentMD5 != null ? Convert.ToBase64String(this.resp.Content.Headers.ContentMD5) : null;
- this.Cmd.CurrentResult.Etag = this.resp.Headers.ETag != null ? this.resp.Headers.ETag.ToString() : null;
- this.Cmd.CurrentResult.RequestDate = this.resp.Headers.Date.HasValue ? this.resp.Headers.Date.Value.UtcDateTime.ToString("R", CultureInfo.InvariantCulture) : null;
- this.Cmd.CurrentResult.HttpStatusMessage = this.resp.ReasonPhrase;
- this.Cmd.CurrentResult.HttpStatusCode = (int)this.resp.StatusCode;
- }
- }
- }
-#else
- internal HttpWebRequest Req { get; set; }
-
- private HttpWebResponse resp = null;
-
- internal HttpWebResponse Resp
- {
- get
- {
- return this.resp;
- }
-
- set
- {
- this.resp = value;
-
- if (this.resp != null)
- {
- if (value.Headers != null)
- {
-#if WINDOWS_DESKTOP
- this.Cmd.CurrentResult.ServiceRequestID = HttpWebUtility.TryGetHeader(this.resp, Constants.HeaderConstants.RequestIdHeader, null);
- this.Cmd.CurrentResult.ContentMd5 = HttpWebUtility.TryGetHeader(this.resp, "Content-MD5", null);
- string tempDate = HttpWebUtility.TryGetHeader(this.resp, "Date", null);
- this.Cmd.CurrentResult.RequestDate = string.IsNullOrEmpty(tempDate) ? DateTime.Now.ToString("R", CultureInfo.InvariantCulture) : tempDate;
- this.Cmd.CurrentResult.Etag = this.resp.Headers[HttpResponseHeader.ETag];
-#endif
- }
-
- this.Cmd.CurrentResult.HttpStatusMessage = this.Cmd.CurrentResult.HttpStatusMessage ?? this.resp.StatusDescription;
-
- if (this.Cmd.CurrentResult.HttpStatusCode == -1)
- {
- this.Cmd.CurrentResult.HttpStatusCode = (int)this.resp.StatusCode;
- }
- }
- }
- }
-#endif
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/ExecutorBase.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/ExecutorBase.cs
deleted file mode 100644
index 0756cbf62e260..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/ExecutorBase.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Executor
-{
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
-
- internal abstract class ExecutorBase
- {
- protected static void ApplyUserHeaders(ExecutionState executionState)
- {
- if (!string.IsNullOrEmpty(executionState.OperationContext.ClientRequestID))
- {
- executionState.Req.Headers.Add(Constants.HeaderConstants.ClientRequestIdHeader, executionState.OperationContext.ClientRequestID);
- }
-
- if (executionState.OperationContext.UserHeaders != null && executionState.OperationContext.UserHeaders.Count > 0)
- {
- foreach (string key in executionState.OperationContext.UserHeaders.Keys)
- {
- executionState.Req.Headers.Add(key, executionState.OperationContext.UserHeaders[key]);
- }
- }
- }
-
- protected static void StartRequestAttempt(ExecutionState executionState)
- {
- executionState.Cmd.CurrentResult = new RequestResult();
-
- // Need to clear this explicitly for retries
- executionState.ExceptionRef = null;
-
- lock (executionState.OperationContext.RequestResults)
- {
- executionState.OperationContext.RequestResults.Add(executionState.Cmd.CurrentResult);
- }
-
- executionState.Cmd.CurrentResult.StartTime = DateTime.Now;
- }
-
- protected static void FinishRequestAttempt(ExecutionState executionState)
- {
- executionState.Cmd.CurrentResult.EndTime = DateTime.Now;
- executionState.OperationContext.EndTime = DateTime.Now;
- }
-
- protected static void FireSendingRequest(ExecutionState executionState)
- {
- RequestEventArgs args = new RequestEventArgs(executionState.Cmd.CurrentResult);
-#if WINDOWS_RT
- args.RequestUri = executionState.Req.RequestUri;
-#else
- args.Request = executionState.Req;
-#endif
- executionState.OperationContext.FireSendingRequest(args);
- }
-
- protected static void FireResponseReceived(ExecutionState executionState)
- {
- RequestEventArgs args = new RequestEventArgs(executionState.Cmd.CurrentResult);
-#if WINDOWS_RT
- args.RequestUri = executionState.Req.RequestUri;
-#else
- args.Request = executionState.Req;
- args.Response = executionState.Resp;
-#endif
- executionState.OperationContext.FireResponseReceived(args);
- }
-
- protected static bool CheckTimeout(ExecutionState executionState, bool throwOnTimeout)
- {
- if (executionState.ReqTimedOut || (executionState.OperationExpiryTime.HasValue && executionState.Cmd.CurrentResult.StartTime.CompareTo(executionState.OperationExpiryTime.Value) > 0))
- {
- executionState.ReqTimedOut = true;
-
- StorageException storageEx = Exceptions.GenerateTimeoutException(executionState.Cmd.CurrentResult, null);
- executionState.ExceptionRef = storageEx;
-
- if (throwOnTimeout)
- {
- throw executionState.ExceptionRef;
- }
-
- return true;
- }
-
- return false;
- }
-
-#if WINDOWS_DESKTOP
- protected static bool CheckCancellation(ExecutionState executionState)
- {
- if (executionState.CancelRequested)
- {
- executionState.ExceptionRef = Exceptions.GenerateCancellationException(executionState.Cmd.CurrentResult, null);
- }
-
- return executionState.CancelRequested;
- }
-#endif
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/ExecutorOperation.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/ExecutorOperation.cs
deleted file mode 100644
index da93bb5c13b82..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/ExecutorOperation.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Executor
-{
- internal enum ExecutorOperation
- {
- NotStarted = 0,
- BeginOperation,
- BeginGetRequestStream,
- EndGetRequestStream,
- BeginUploadRequest,
- EndUploadRequest,
- BeginGetResponse,
- EndGetResponse,
- PreProcess,
- GetResponseStream,
- BeginDownloadResponse,
- EndDownloadResponse,
- PostProcess,
- EndOperation,
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/RESTCommand.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/RESTCommand.cs
deleted file mode 100644
index 4d4780cbd4db0..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/RESTCommand.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Executor
-{
- using Microsoft.WindowsAzure.Storage.Auth;
- using System;
- using System.Diagnostics.CodeAnalysis;
- using System.IO;
-
-#if WINDOWS_RT
-using System.Net.Http;
-using System.Threading.Tasks;
-#else
- using System.Net;
-#endif
-
- [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed.")]
- internal class RESTCommand : StorageCommandBase
- {
- #region Ctors
- public RESTCommand(StorageCredentials credentials, Uri uri)
- : this(credentials, uri, null)
- {
- }
-
- public RESTCommand(StorageCredentials credentials, Uri uri, UriQueryBuilder builder)
- {
- this.Uri = credentials.TransformUri(uri);
- this.Builder = builder;
- }
- #endregion
-
- // Reference to hold stream from webresponse
- public Stream ResponseStream = null;
-
- // Stream to potentially copy response into
- public Stream DestinationStream = null;
-
- // if true, the inStream will be set before processresponse is called.
- public bool RetrieveResponseStream = false;
-
- // if true the executor will calculate the md5 on retrieved data
- public bool CalculateMd5ForResponseStream = false;
-
- public Stream StreamToDispose { get; set; }
-
-#if WINDOWS_RT
- public Func, OperationContext, HttpClient> BuildClient;
-
- public Func, OperationContext, HttpContent> BuildContent;
-
- public Func, HttpContent, OperationContext, HttpRequestMessage> 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;
-
- // Post-Stream Retrieval Func ( if retreiveStream is true after ProcessResponse, the stream is retrieved and then PostProcess is called
- public Func, HttpResponseMessage, OperationContext, Task> PostProcessResponse;
-#else
- // Stream to send to server
- private Stream sendStream = null;
-
- public Stream SendStream
- {
- get
- {
- return this.sendStream;
- }
-
- set
- {
- MultiBufferMemoryStream tempStream = value as MultiBufferMemoryStream;
- if (tempStream != null)
- {
- this.StreamToDispose = tempStream;
- }
-
- this.sendStream = value;
- }
- }
-
- // Length of data to send to server from stream.
- public long? SendStreamLength = null;
-
- // Func to construct the request
- public Func BuildRequestDelegate = null;
-
- // Delegate to Set custom headers
- public Action SetHeaders = null;
-
- // Delegate to Sign headers - note this is important that it doesnt have a type dependency on StorageCredentials here
- // due to build issues and WinRT restrictions.
- public Action SignRequest = null;
-
- // Pre-Stream Retrival func (i.e. if 409 no stream is retrieved), in some cases this method will return directly
- public Func, HttpWebResponse, Exception, OperationContext, T> PreProcessResponse = null;
-
- // Post-Stream Retrieval Func ( if retreiveStream is true after ProcessResponse, the stream is retrieved and then PostProcess is called
- public Func, HttpWebResponse, OperationContext, T> PostProcessResponse = null;
-#endif
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/StorageCommandBase.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/StorageCommandBase.cs
deleted file mode 100644
index 0ccd88669e86a..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Executor/StorageCommandBase.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Executor
-{
- using Microsoft.WindowsAzure.Storage;
- using Microsoft.WindowsAzure.Storage.Blob;
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using Microsoft.WindowsAzure.Storage.Queue;
- using Microsoft.WindowsAzure.Storage.Table;
- using System;
- using System.Diagnostics.CodeAnalysis;
-
-#if WINDOWS_RT
- using System.Net.Http;
-#endif
-
- [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed.")]
- internal abstract class StorageCommandBase
- {
- public Uri Uri;
-
- // The UriQueryBuilder used to create the request
- public UriQueryBuilder Builder;
-
- // Server Timeout to send
- public int? ServerTimeoutInSeconds = null;
-
- // Max client timeout, enforced over entire operation on client side
- internal DateTime? OperationExpiryTime = null;
-
- // State- different than async state, this is used for ops to communicate state between invocations, i.e. bytes downloaded etc
- internal object OperationState = null;
-
- // Used to keep track of Md5 / Length of a stream as it is being copied
- private volatile StreamDescriptor streamCopyState = null;
-
- internal StreamDescriptor StreamCopyState
- {
- get { return this.streamCopyState; }
- set { this.streamCopyState = value; }
- }
-
- private volatile RequestResult currentResult = null;
-
- internal RequestResult CurrentResult
- {
- get { return this.currentResult; }
- set { this.currentResult = value; }
- }
-
-#if WINDOWS_RT
- public HttpClientHandler Handler = null;
-#endif
-
- // Delegate that will be executed in the event of an Exception after signing
- public Action, Exception, OperationContext> RecoveryAction = null;
-
- internal void ApplyRequestOptions(BlobRequestOptions options)
- {
- if (options.ServerTimeout.HasValue)
- {
- this.ServerTimeoutInSeconds = (int)options.ServerTimeout.Value.TotalSeconds;
- }
-
- if (options.OperationExpiryTime.HasValue)
- {
- this.OperationExpiryTime = options.OperationExpiryTime;
- }
- else if (options.MaximumExecutionTime.HasValue)
- {
- this.OperationExpiryTime = DateTime.Now + options.MaximumExecutionTime.Value;
- }
- }
-
- internal void ApplyRequestOptions(TableRequestOptions options)
- {
- if (options.ServerTimeout.HasValue)
- {
- this.ServerTimeoutInSeconds = (int)options.ServerTimeout.Value.TotalSeconds;
- }
-
- if (options.OperationExpiryTime.HasValue)
- {
- this.OperationExpiryTime = options.OperationExpiryTime;
- }
- else if (options.MaximumExecutionTime.HasValue)
- {
- this.OperationExpiryTime = DateTime.Now + options.MaximumExecutionTime.Value;
- }
- }
-
- internal void ApplyRequestOptions(QueueRequestOptions options)
- {
- if (options.ServerTimeout.HasValue)
- {
- this.ServerTimeoutInSeconds = (int)options.ServerTimeout.Value.TotalSeconds;
- }
-
- if (options.OperationExpiryTime.HasValue)
- {
- this.OperationExpiryTime = options.OperationExpiryTime;
- }
- else if (options.MaximumExecutionTime.HasValue)
- {
- this.OperationExpiryTime = DateTime.Now + options.MaximumExecutionTime.Value;
- }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Logger.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Logger.Common.cs
deleted file mode 100644
index 8425704cd233e..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Logger.Common.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 System.Globalization;
-
- internal static partial class Logger
- {
- private const string TraceFormat = "{0}: {1}";
-
- ///
- /// Creates a well-formatted log entry so that logs can be easily parsed
- ///
- /// An object that represents the context for the current operation.
- /// A composite format string.
- /// An object array that contains zero or more objects to format.
- /// Log entry that contains common log prefix and a copy of format in which the format items have been replaced by the string representation of the corresponding objects in args.
- private static string FormatLine(OperationContext operationContext, string format, object[] args)
- {
- return string.Format(
- CultureInfo.InvariantCulture,
- Logger.TraceFormat,
- (operationContext == null) ? "*" : operationContext.ClientRequestID,
- (args == null) ? format : string.Format(CultureInfo.InvariantCulture, format, args).Replace('\n', '.'));
- }
-
- ///
- /// Determines if the current operation context allows for a specific level of log entry.
- ///
- /// Level of the log entry.
- /// An object that represents the context for the current operation.
- /// true if the entry should be logged; otherwise false.
- private static bool ShouldLog(LogLevel level, OperationContext operationContext)
- {
- return (operationContext == null) || (level <= operationContext.LogLevel);
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/MultiBufferMemoryStream.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/MultiBufferMemoryStream.cs
deleted file mode 100644
index d8e0d2cf56520..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/MultiBufferMemoryStream.cs
+++ /dev/null
@@ -1,770 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
- using System.IO;
-
-#if WINDOWS_RT
- using System.Threading;
- using System.Threading.Tasks;
-#endif
-
- ///
- /// This class provides MemoryStream-like behavior but uses a list of buffers rather than a single buffer.
- ///
- internal class MultiBufferMemoryStream : Stream
- {
- private class CopyState
- {
- public Stream Destination { get; set; }
-
- public DateTime? ExpiryTime { get; set; }
- }
-
- ///
- /// The default small buffer size.
- ///
- private const int DefaultSmallBufferSize = (int)(64 * Constants.KB);
-
- ///
- /// The size of each buffer.
- ///
- private readonly int bufferSize;
-
- ///
- /// The underlying buffer blocks for the stream.
- ///
- private List bufferBlocks = new List();
-
- ///
- /// The currently used length.
- ///
- private long length;
-
- ///
- /// The total capacity of the stream.
- ///
- private long capacity;
-
- ///
- /// The current position.
- ///
- private long position;
-
- ///
- /// A reference to the IBufferManager for the stream to use to acquire and return buffers.
- ///
- private IBufferManager bufferManager;
-
- ///
- /// Initializes a new instance of the MultiBufferMemoryStream class with provided IBufferManager.
- ///
- /// A reference to the IBufferManager for the stream to use to acquire and return buffers. May be null.
- /// The Buffer size to use for each block, default is 64 KB. Note this parameter is disregarded when a IBufferManager is specified.
- public MultiBufferMemoryStream(IBufferManager bufferManager, int bufferSize = MultiBufferMemoryStream.DefaultSmallBufferSize)
- {
- this.bufferManager = bufferManager;
-
- this.bufferSize = this.bufferManager == null ? bufferSize : this.bufferManager.GetDefaultBufferSize();
-
- if (bufferSize <= 0)
- {
- throw new ArgumentOutOfRangeException("bufferSize", "Buffer size must be a positive, non-zero value");
- }
- }
-
- ///
- /// Gets a value indicating whether the current stream supports reading.
- ///
- /// Is true if the stream supports reading; otherwise, false.
- public override bool CanRead
- {
- get
- {
- return true;
- }
- }
-
- ///
- /// Gets a value indicating whether the current stream supports seeking.
- ///
- /// Is true if the stream supports seeking; otherwise, false.
- public override bool CanSeek
- {
- get
- {
- return true;
- }
- }
-
- ///
- /// Gets a value indicating whether the current stream supports writing.
- ///
- /// Is true if the stream supports writing; otherwise, false.
- public override bool CanWrite
- {
- get
- {
- return true;
- }
- }
-
- ///
- /// Gets the currently written length.
- ///
- public override long Length
- {
- get
- {
- return this.length;
- }
- }
-
- ///
- /// Represents the current position in the stream.
- ///
- /// Thrown if position is outside the stream size
- public override long Position
- {
- get
- {
- return this.position;
- }
-
- set
- {
- this.Seek(value, SeekOrigin.Begin);
- }
- }
-
- ///
- /// Reads a block of bytes from the current stream and writes the data to a buffer.
- ///
- /// When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
- /// The zero-based byte offset in buffer at which to begin storing the data read from the current stream.
- /// The maximum number of bytes to be read.
- /// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream has been reached.
- public override int Read(byte[] buffer, int offset, int count)
- {
- CommonUtility.AssertNotNull("buffer", buffer);
- CommonUtility.AssertInBounds("offset", offset, 0, buffer.Length);
- CommonUtility.AssertInBounds("count", count, 0, buffer.Length - offset);
-
- return this.ReadInternal(buffer, offset, count);
- }
-
-#if WINDOWS_DESKTOP
- ///
- /// Begins an asynchronous read operation.
- ///
- /// When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
- /// The zero-based byte offset in buffer at which to begin storing the data read from the current stream.
- /// The maximum number of bytes to be read.
- /// An optional asynchronous callback, to be called when the read is complete.
- /// A user-provided object that distinguishes this particular asynchronous read request from other requests.
- /// An IAsyncResult that represents the asynchronous read, which could still be pending.
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Needed to ensure exceptions are not thrown on threadpool threads.")]
- public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
- {
- CommonUtility.AssertNotNull("buffer", buffer);
- CommonUtility.AssertInBounds("offset", offset, 0, buffer.Length);
- CommonUtility.AssertInBounds("count", count, 0, buffer.Length - offset);
-
- StorageAsyncResult result = new StorageAsyncResult(callback, state);
-
- try
- {
- result.Result = this.Read(buffer, offset, count);
- result.OnComplete();
- }
- catch (Exception e)
- {
- result.OnComplete(e);
- }
-
- return result;
- }
-
- ///
- /// Waits for the pending asynchronous read to complete.
- ///
- /// The reference to the pending asynchronous request to finish.
- /// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream has been reached.
- public override int EndRead(IAsyncResult asyncResult)
- {
- StorageAsyncResult result = (StorageAsyncResult)asyncResult;
- result.End();
- return result.Result;
- }
-#endif
-
-#if WINDOWS_RT
- ///
- /// Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
- ///
- /// The buffer to write the data into.
- /// The byte offset in buffer at which to begin writing data from the stream.
- /// The maximum number of bytes to read.
- /// The token to monitor for cancellation requests.
- /// A task that represents the asynchronous read operation.
- public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
- {
- return Task.FromResult(this.Read(buffer, offset, count));
- }
-#endif
-
- ///
- /// Sets the position within the current stream.
- ///
- /// A byte offset relative to the origin parameter.
- /// A value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position.
- /// The new position within the current stream.
- /// Thrown if is invalid for SeekOrigin.
- public override long Seek(long offset, SeekOrigin origin)
- {
- long newPosition;
- switch (origin)
- {
- case SeekOrigin.Begin:
- newPosition = offset;
- break;
-
- case SeekOrigin.Current:
- newPosition = this.position + offset;
- break;
-
- case SeekOrigin.End:
- newPosition = this.Length + offset;
- break;
-
- default:
- CommonUtility.ArgumentOutOfRange("origin", origin);
- throw new ArgumentOutOfRangeException("origin");
- }
-
- CommonUtility.AssertInBounds("offset", newPosition, 0, this.Length);
-
- this.position = newPosition;
- return this.position;
- }
-
- ///
- /// Sets the length of the current stream to the specified value. (pre-allocating the bufferBlocks).
- ///
- /// The desired length of the current stream in bytes.
- /// If the is negative.
- public override void SetLength(long value)
- {
- this.Reserve(value);
- this.length = value;
- }
-
- ///
- /// Writes a block of bytes to the current stream using data read from a buffer.
- ///
- /// The buffer to write data from.
- /// The zero-based byte offset in buffer at which to begin copying bytes to the current stream.
- /// The number of bytes to write.
- public override void Write(byte[] buffer, int offset, int count)
- {
- CommonUtility.AssertNotNull("buffer", buffer);
- CommonUtility.AssertInBounds("offset", offset, 0, buffer.Length);
- CommonUtility.AssertInBounds("count", count, 0, buffer.Length - offset);
-
- // Grow the buffer if more space is needed
- if (this.position + count > this.capacity)
- {
- this.Reserve(this.position + count);
- }
-
- this.WriteInternal(buffer, offset, count);
-
- // Adjust the length to be the max of currently written data.
- this.length = Math.Max(this.length, this.position);
- }
-
-#if WINDOWS_DESKTOP
- ///
- /// Begins an asynchronous write operation.
- ///
- /// The buffer to write data from.
- /// The zero-based byte offset in buffer at which to begin copying bytes to the current stream.
- /// The number of bytes to write.
- /// An optional asynchronous callback, to be called when the write is complete.
- /// A user-provided object that distinguishes this particular asynchronous write request from other requests.
- /// An IAsyncResult that represents the asynchronous write, which could still be pending.
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Needed to ensure exceptions are not thrown on threadpool threads")]
- public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
- {
- CommonUtility.AssertNotNull("buffer", buffer);
- CommonUtility.AssertInBounds("offset", offset, 0, buffer.Length);
- CommonUtility.AssertInBounds("count", count, 0, buffer.Length - offset);
-
- StorageAsyncResult result = new StorageAsyncResult(callback, state);
-
- try
- {
- this.Write(buffer, offset, count);
- result.OnComplete();
- }
- catch (Exception e)
- {
- result.OnComplete(e);
- }
-
- return result;
- }
-
- ///
- /// Ends an asynchronous write operation.
- ///
- /// The reference to the pending asynchronous request to finish.
- public override void EndWrite(IAsyncResult asyncResult)
- {
- StorageAsyncResult result = (StorageAsyncResult)asyncResult;
- result.End();
- }
-#endif
-
-#if WINDOWS_RT
- ///
- /// Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
- ///
- /// The buffer to write data from.
- /// The zero-based byte offset in buffer from which to begin copying bytes to the stream.
- /// The maximum number of bytes to write.
- /// The token to monitor for cancellation requests.
- /// A task that represents the asynchronous write operation.
- public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
- {
- this.Write(buffer, offset, count);
- return Task.FromResult(true);
- }
-#endif
- ///
- /// Does not perform any operation as it's an in-memory stream.
- ///
- public override void Flush()
- {
- }
-
-#if WINDOWS_RT
- ///
- /// Does not perform any operation as it's an in-memory stream.
- ///
- /// The token to monitor for cancellation requests.
- /// A task that represents the asynchronous flush operation.
- public override Task FlushAsync(CancellationToken cancellationToken)
- {
- return Task.FromResult(true);
- }
-#endif
-
-#if WINDOWS_DESKTOP
- ///
- /// Reads the bytes from the current stream and writes them to another stream. However, this method eliminates copying the data into a temporary buffer by directly writing to the destination stream.
- ///
- /// The stream to which the contents of the current stream will be copied.
- /// DateTime indicating the expiry time.
- public void FastCopyTo(Stream destination, DateTime? expiryTime)
- {
- CommonUtility.AssertNotNull("destination", destination);
-
- // Maximum amount you can read is from current spot to the end.
- long leftToRead = this.Length - this.Position;
-
- try
- {
- while (leftToRead != 0)
- {
- if (expiryTime.HasValue && DateTime.Now.CompareTo(expiryTime.Value) > 0)
- {
- throw new TimeoutException();
- }
-
- ArraySegment currentBlock = this.GetCurrentBlock();
-
- // Copy the block
- int blockReadLength = (int)Math.Min(leftToRead, currentBlock.Count);
- destination.Write(currentBlock.Array, currentBlock.Offset, blockReadLength);
-
- this.AdvancePosition(ref leftToRead, blockReadLength);
- }
- }
- catch (Exception)
- {
- if (expiryTime.HasValue && DateTime.Now.CompareTo(expiryTime.Value) > 0)
- {
- throw new TimeoutException();
- }
- else
- {
- throw;
- }
- }
- }
-
- ///
- /// Begins an asynchronous fast-copy operation.
- ///
- /// The stream to which the contents of the current stream will be copied.
- /// DateTime indicating the expiry time.
- /// An optional asynchronous callback, to be called when the copy is complete.
- /// A user-provided object that distinguishes this particular asynchronous copy request from other requests.
- /// An IAsyncResult that represents the asynchronous copy, which could still be pending.
- public IAsyncResult BeginFastCopyTo(Stream destination, DateTime? expiryTime, AsyncCallback callback, object state)
- {
- CommonUtility.AssertNotNull("destination", destination);
-
- StorageAsyncResult result = new StorageAsyncResult(callback, state);
- result.OperationState = new CopyState()
- {
- Destination = destination,
- ExpiryTime = expiryTime,
- };
-
- this.FastCopyToInternal(result);
- return result;
- }
-
- ///
- /// Initiates a write operation for the next buffer in line.
- ///
- /// Internal StorageAsyncResult that represents the asynchronous copy.
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Needed to ensure exceptions are not thrown on threadpool threads.")]
- private void FastCopyToInternal(StorageAsyncResult result)
- {
- CopyState copyState = (CopyState)result.OperationState;
-
- // Maximum amount you can read is from current spot to the end.
- long leftToRead = this.Length - this.Position;
-
- try
- {
- while (leftToRead != 0)
- {
- if (copyState.ExpiryTime.HasValue && DateTime.Now.CompareTo(copyState.ExpiryTime.Value) > 0)
- {
- throw new TimeoutException();
- }
-
- ArraySegment currentBlock = this.GetCurrentBlock();
-
- int blockReadLength = (int)Math.Min(leftToRead, currentBlock.Count);
- this.AdvancePosition(ref leftToRead, blockReadLength);
-
- IAsyncResult asyncResult = copyState.Destination.BeginWrite(currentBlock.Array, currentBlock.Offset, blockReadLength, this.FastCopyToCallback, result);
-
- if (!asyncResult.CompletedSynchronously)
- {
- return;
- }
-
- copyState.Destination.EndWrite(asyncResult);
- }
-
- result.OnComplete();
- }
- catch (Exception e)
- {
- if (copyState.ExpiryTime.HasValue && DateTime.Now.CompareTo(copyState.ExpiryTime.Value) > 0)
- {
- result.OnComplete(new TimeoutException());
- }
- else
- {
- result.OnComplete(e);
- }
- }
- }
-
- ///
- /// Callback method to be called when the corresponding write operation completes.
- ///
- /// The result of the asynchronous operation.
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Needed to ensure exceptions are not thrown on threadpool threads.")]
- private void FastCopyToCallback(IAsyncResult asyncResult)
- {
- if (asyncResult.CompletedSynchronously)
- {
- return;
- }
-
- StorageAsyncResult result = (StorageAsyncResult)asyncResult.AsyncState;
- result.UpdateCompletedSynchronously(asyncResult.CompletedSynchronously);
-
- CopyState copyState = (CopyState)result.OperationState;
-
- try
- {
- copyState.Destination.EndWrite(asyncResult);
- this.FastCopyToInternal(result);
- }
- catch (Exception e)
- {
- if (copyState.ExpiryTime.HasValue && DateTime.Now.CompareTo(copyState.ExpiryTime.Value) > 0)
- {
- result.OnComplete(new TimeoutException());
- }
- else
- {
- result.OnComplete(e);
- }
- }
- }
-
- ///
- /// Ends an asynchronous copy operation.
- ///
- /// The reference to the pending asynchronous request to finish.
- public void EndFastCopyTo(IAsyncResult asyncResult)
- {
- StorageAsyncResult result = (StorageAsyncResult)asyncResult;
- result.End();
- }
-#endif
-
-#if WINDOWS_RT
- ///
- /// Asynchronously reads the bytes from the current stream and writes them to another stream. However, this method eliminates copying the data into a temporary buffer by directly writing to the destination stream.
- ///
- /// The stream to which the contents of the current stream will be copied.
- /// DateTime indicating the expiry time.
- /// A task that represents the asynchronous copy operation.
- public async Task FastCopyToAsync(Stream destination, DateTime? expiryTime)
- {
- CommonUtility.AssertNotNull("destination", destination);
-
- // Maximum amount you can read is from current spot to the end.
- long leftToRead = this.Length - this.Position;
-
- try
- {
- while (leftToRead != 0)
- {
- if (expiryTime.HasValue && DateTime.Now.CompareTo(expiryTime.Value) > 0)
- {
- throw new TimeoutException();
- }
-
- ArraySegment currentBlock = this.GetCurrentBlock();
-
- // Copy the block
- int blockReadLength = (int)Math.Min(leftToRead, currentBlock.Count);
- await destination.WriteAsync(currentBlock.Array, currentBlock.Offset, blockReadLength);
-
- this.AdvancePosition(ref leftToRead, blockReadLength);
- }
- }
- catch (Exception)
- {
- if (expiryTime.HasValue && DateTime.Now.CompareTo(expiryTime.Value) > 0)
- {
- throw new TimeoutException();
- }
- else
- {
- throw;
- }
- }
- }
-#endif
-
-#if !WINDOWS_PHONE
- ///
- /// Computes the hash value for this stream.
- ///
- /// String representation of the computed hash value.
- public string ComputeMD5Hash()
- {
- using (MD5Wrapper md5 = new MD5Wrapper())
- {
- // Maximum amount you can read is from current spot to the end.
- long leftToRead = this.Length - this.Position;
-
- while (leftToRead != 0)
- {
- ArraySegment currentBlock = this.GetCurrentBlock();
-
- // Update hash with the block
- int blockReadLength = (int)Math.Min(leftToRead, currentBlock.Count);
- md5.UpdateHash(currentBlock.Array, currentBlock.Offset, blockReadLength);
-
- this.AdvancePosition(ref leftToRead, blockReadLength);
- }
-
- return md5.ComputeHash();
- }
- }
-#endif
-
- ///
- /// Ensures that the amount of bufferBlocks is greater than or equal to the required size.
- /// Does not trim the size.
- ///
- /// The required size.
- /// If the is negative.
- private void Reserve(long requiredSize)
- {
- if (requiredSize < 0)
- {
- throw new ArgumentOutOfRangeException("requiredSize", "The size must be positive");
- }
-
- while (requiredSize > this.capacity)
- {
- this.AddBlock();
- }
- }
-
- ///
- /// Adds another block to the underlying bufferBlocks.
- ///
- private void AddBlock()
- {
- byte[] newBuff = this.bufferManager == null ? new byte[this.bufferSize] : this.bufferManager.TakeBuffer(this.bufferSize);
- if (newBuff.Length != this.bufferSize)
- {
- throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, SR.BufferManagerProvidedIncorrectLengthBuffer, this.bufferSize, newBuff.Length));
- }
-
- this.bufferBlocks.Add(newBuff);
- this.capacity += this.bufferSize;
- }
-
- ///
- /// Copies the specified amount of data from internal buffers to the buffer and advances the position.
- ///
- /// An array of bytes. When this method returns, the buffer contains the specified byte array with the values
- /// between offset and (offset + count - 1) replaced by the bytes read from the current source.
- /// The zero-based byte offset in buffer at which to begin storing the data read from the current stream.
- /// The maximum number of bytes to be read from the current stream.
- /// The total number of bytes read into the buffer. This can be less than the number of bytes requested
- /// if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.
- ///
- private int ReadInternal(byte[] buffer, int offset, int count)
- {
- // Maximum amount you can read is from current spot to the end.
- int readLength = (int)Math.Min(this.Length - this.Position, count);
- int leftToRead = readLength;
-
- while (leftToRead != 0)
- {
- ArraySegment currentBlock = this.GetCurrentBlock();
-
- // Copy the block
- int blockReadLength = (int)Math.Min(leftToRead, currentBlock.Count);
- Buffer.BlockCopy(currentBlock.Array, currentBlock.Offset, buffer, offset, blockReadLength);
-
- this.AdvancePosition(ref offset, ref leftToRead, blockReadLength);
- }
-
- return readLength;
- }
-
- ///
- /// Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
- /// (Requires the stream to be of sufficient size for writing).
- ///
- /// An array of bytes. This method copies count bytes from buffer to the current stream.
- /// The zero-based byte offset in buffer at which to begin copying bytes to the current stream.
- /// The number of bytes to be written to the current stream.
- private void WriteInternal(byte[] buffer, int offset, int count)
- {
- while (count != 0)
- {
- ArraySegment currentBlock = this.GetCurrentBlock();
-
- // Copy the block
- int blockWriteLength = (int)Math.Min(count, currentBlock.Count);
- Buffer.BlockCopy(buffer, offset, currentBlock.Array, currentBlock.Offset, blockWriteLength);
-
- this.AdvancePosition(ref offset, ref count, blockWriteLength);
- }
- }
-
- ///
- /// Advances the current position of the stream and adjust the offset and remainder based on the amount completed.
- ///
- /// The current offset in the external buffer.
- /// The amount of data left to process.
- /// The amount of data processed.
- private void AdvancePosition(ref int offset, ref int leftToProcess, int amountProcessed)
- {
- // Advance the position in the stream and in the destination buffer
- this.position += amountProcessed;
- offset += amountProcessed;
- leftToProcess -= amountProcessed;
- }
-
- ///
- /// Advances the current position of the stream and adjust the remainder based on the amount completed.
- ///
- /// The amount of data left to process.
- /// The amount of data processed.
- private void AdvancePosition(ref long leftToProcess, int amountProcessed)
- {
- // Advance the position in the stream and in the destination buffer
- this.position += amountProcessed;
- leftToProcess -= amountProcessed;
- }
-
- ///
- /// Calculate the block for the current position.
- ///
- private ArraySegment GetCurrentBlock()
- {
- // Calculate the block and position in a block
- int blockID = (int)(this.position / this.bufferSize);
- int blockPosition = (int)(this.position % this.bufferSize);
- byte[] currentBlock = this.bufferBlocks[blockID];
-
- return new ArraySegment(currentBlock, blockPosition, currentBlock.Length - blockPosition);
- }
-
- private volatile bool disposed = false;
-
- protected override void Dispose(bool disposing)
- {
- if (!this.disposed)
- {
- this.disposed = true;
- if (disposing)
- {
- if (this.bufferManager != null)
- {
- foreach (byte[] buff in this.bufferBlocks)
- {
- this.bufferManager.ReturnBuffer(buff);
- }
- }
-
- this.bufferBlocks.Clear();
- }
- }
-
- base.Dispose(disposing);
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/NullType.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/NullType.cs
deleted file mode 100644
index 90518fff5b10c..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/NullType.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// A NullTaskReturn type.
- ///
- public sealed class NullType
- {
- ///
- /// Represents a no-return from a task.
- ///
- internal static readonly NullType Value = new NullType();
-
- ///
- /// Prevents a default instance of the class from being created.
- ///
- private NullType()
- {
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/SR.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/SR.cs
deleted file mode 100644
index 829b614061121..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/SR.cs
+++ /dev/null
@@ -1,187 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Provides a standard set of errors that could be thrown from the client library.
- ///
- internal class SR
- {
- public const string ArgumentEmptyError = "The argument must not be empty string.";
- public const string ArgumentOutOfRangeError = "The argument is out of range. Value passed: {0}";
- public const string ArgumentTooLargeError = "The argument '{0}' is larger than maximum of '{1}'";
- public const string ArgumentTooSmallError = "The argument '{0}' is smaller than minimum of '{1}'";
- public const string BatchWithRetreiveContainsOtherOperations = "A batch transaction with a retrieve operation cannot contain any other operations.";
- public const string BinaryMessageShouldUseBase64Encoding = "EncodeMessage should be true for binary message.";
- public const string BlobDataCorrupted = "Blob data corrupted (integrity check failed), Expected value is '{0}', retrieved '{1}'";
- public const string BlobEndPointNotConfigured = "No blob endpoint configured.";
- public const string BlobInvalidSequenceNumber = "The sequence number may not be specified for an increment operation.";
- public const string BlobStreamAlreadyCommitted = "Blob stream has already been committed once.";
- public const string BlobStreamFlushPending = "Blob stream has a pending flush operation. Please call EndFlush first.";
- public const string BlobStreamReadPending = "Blob stream has a pending read operation. Please call EndRead first.";
- public const string BlobTypeMismatch = "Blob type of the blob reference doesn't match blob type of the blob.";
- public const string BufferTooSmall = "The provided buffer is too small to fit in the blob data given the offset.";
- public const string BufferManagerProvidedIncorrectLengthBuffer = "The IBufferManager provided an incorrect length buffer to the stream, Expected {0}, received {1}. Buffer length should equal the value returned by IBufferManager.GetDefaultBufferSize().";
- public const string CannotCreateSASForSnapshot = "Cannot create Shared Access Signature for snapshots. Perform the operation on the root blob instead.";
- public const string CannotCreateSASSignatureForGivenCred = "Cannot create Shared Access Signature as the credentials does not have account name information. Please check that the credentials used support creating Shared Access Signature.";
- public const string CannotCreateSASWithoutAccountKey = "Cannot create Shared Access Signature unless Account Key credentials are used.";
- public const string CannotModifySnapshot = "Cannot perform this operation on a blob representing a snapshot.";
- public const string CannotUpdateKeyWithoutAccountKeyCreds = "Cannot update key unless Account Key credentials are used.";
- public const string CannotUpdateSasWithoutSasCreds = "Cannot update Shared Access Signature unless Sas credentials are used.";
- public const string ConcurrentOperationsNotSupported = "Could not acquire exclusive use of the TableServiceContext, Concurrent operations are not supported.";
- public const string ContentMD5NotCalculated = "The operation requires a response body but no data was copied to the destination buffer.";
- public const string CopyAborted = "The copy operation has been aborted by the user.";
- public const string CopyFailed = "The copy operation failed with the following error message: {0}";
- public const string CryptoFunctionFailed = "Crypto function failed with error code '{0}'";
- public const string DeleteSnapshotsNotValidError = "The option '{0}' must be 'None' to delete a specific snapshot specified by '{1}'";
- public const string EmptyBatchOperation = "Cannot execute an empty batch operation";
- public const string ETagMissingForDelete = "Delete requires an ETag (which may be the '*' wildcard).";
- public const string ETagMissingForMerge = "Merge requires an ETag (which may be the '*' wildcard).";
- public const string ETagMissingForReplace = "Replace requires an ETag (which may be the '*' wildcard).";
- public const string ExceptionOccurred = "An exception has occurred. For more information please deserialize this message via RequestResult.TranslateFromExceptionMessage.";
- public const string ExtendedErrorUnavailable = "An unknown error has occurred, extended error information not available.";
- public const string IncorrectNumberOfBytes = "Incorrect number of bytes received. Expected '{0}', received '{1}'";
- public const string InternalStorageError = "Unexpected internal storage client error.";
- public const string InvalidAclType = "Invalid acl public access type returned '{0}'. Expected blob or container.";
- public const string InvalidBlobListItem = "Invalid blob list item returned";
- public const string InvalidBlobName = "Blob name is invalid. Valid names should be 1 through 1024 characters long and should not end with a . or /";
- public const string InvalidContainerName = "Container name is invalid. Valid names start and end with a lower case letter or a number and has in between a lower case letter, number or dash with no consecutive dashes and is 3 through 63 characters long";
- public const string InvalidDirectoryName = "Directory name is invalid. Valid names should be 1 through 1024 characters long and should not end with a . or /";
- public const string InvalidLeaseStatus = "Invalid lease status in response: '{0}'";
- public const string InvalidLeaseState = "Invalid lease state in response: '{0}'";
- public const string InvalidLeaseDuration = "Invalid lease duration in response: '{0}'";
- public const string InvalidLoggingLevel = "Invalid logging operations specified.";
- public const string InvalidMetricsLevel = "Invalid metrics level specified.";
- public const string InvalidPageSize = "Page data must be a multiple of 512 bytes.";
- public const string InvalidQueueName = "Queue name is invalid. Valid names start and end with a lower case letter or a number and has in between a lower case letter, number or dash with no consecutive dashes and is 3 through 63 characters long";
- public const string InvalidTableName = "Table name is invalid. Valid names are case insensitive, start with a letter and is followed by letters or numbers and is 3 through 63 characters long";
- public const string IQueryableExtensionObjectMustBeTableQuery = "Query must be a TableQuery";
- public const string LeaseConditionOnSource = "A lease condition cannot be specified on the source of a copy.";
- public const string LeaseTimeNotReceived = "Valid lease time expected but not received from the service.";
- public const string LengthNotInRange = "The length provided is out of range. The range must be between 0 and the length of the byte array.";
- public const string ListSnapshotsWithDelimiterError = "Listing snapshots is only supported in flat mode (no delimiter). Consider setting the useFlatBlobListing parameter to true.";
- public const string LoggingVersionNull = "The logging version is null or empty.";
- public const string MD5MismatchError = "Calculated MD5 does not match existing property";
- public const string MD5NotPossible = "MD5 cannot be calculated for an existing page blob because it would require reading the existing data. Please disable StoreBlobContentMD5.";
- public const string MD5NotPresentError = "MD5 does not exist. If you do not want to force validation, please disable UseTransactionalMD5.";
- public const string MessageTooLarge = "Messages cannot be larger than {0} bytes.";
- public const string MetricVersionNull = "The metrics version is null or empty.";
- public const string MissingAccountInformationInUri = "Cannot find account information inside Uri '{0}'";
- public const string MissingContainerInformation = "Invalid blob address '{0}', missing container information";
- public const string MissingCredentials = "No credentials provided.";
- public const string MissingLeaseIDChanging = "A lease ID must be specified when changing a lease.";
- public const string MissingLeaseIDReleasing = "A lease ID must be specified when releasing a lease.";
- public const string MissingLeaseIDRenewing = "A lease ID must be specified when renewing a lease.";
- public const string MissingMandatoryParametersForSAS = "Missing mandatory parameters for valid Shared Access Signature";
- public const string MultipleCredentialsProvided = "Cannot provide credentials as part of the address and as constructor parameter. Either pass in the address or use a different constructor.";
- public const string MultipleSnapshotTimesProvided = "Multiple different snapshot times provided as part of query '{0}' and as constructor parameter '{1}'.";
- public const string ODataReaderNotInCompletedState = "OData Reader state expected to be Completed state. Actual state: {0}.";
- public const string OperationCanceled = "Operation was canceled by user.";
- public const string ParseError = "Error parsing value";
- public const string PartitionKey = "All entities in a given batch must have the same partition key.";
- public const string PathStyleUriMissingAccountNameInformation = "Missing account name information inside path style uri. Path style uris should be of the form http:///";
- public const string PutBlobNeedsStoreBlobContentMD5 = "When uploading a blob in a single request, StoreBlobContentMD5 must be set to true if UseTransactionalMD5 is true, because the MD5 calculated for the transaction will be stored in the blob.";
- public const string QueueEndPointNotConfigured = "No queue endpoint configured.";
- public const string RelativeAddressNotPermitted = "Address '{0}' is not an absolute address. Relative addresses are not permitted in here.";
- public const string ResourceConsumed = "Resource consumed";
- public const string StreamLengthError = "The length of the stream exceeds the permitted length.";
- public const string StreamLengthMismatch = "Cannot specify both copyLength and maxLength.";
- public const string StreamLengthShortError = "The requested number of bytes exceeds the length of the stream remaining from the specified position.";
- public const string TableEndPointNotConfigured = "No table endpoint configured.";
- public const string TableQueryDynamicPropertyAccess = "Accessing property dictionary of DynamicTableEntity requires a string constant for property name.";
- public const string TableQueryEntityPropertyInQueryNotSupported = "Referencing {0} on EntityProperty only supported with properties dictionary exposed via DynamicTableEntity.";
- public const string TableQueryFluentMethodNotAllowed = "Fluent methods may not be invoked on a Query created via CloudTable.CreateQuery()";
- public const string TableQueryMustHaveQueryProvider = "Unknown Table. The TableQuery does not have an associated CloudTable Reference. Please execute the query via the CloudTable ExecuteQuery APIs.";
- public const string TableQueryTypeMustImplementITableEnitty = "TableQuery Generic Type must implement the ITableEntity Interface";
- public const string TableQueryTypeMustHaveDefaultParameterlessCtor = "TableQuery Generic Type must provide a default parameterless constructor.";
- public const string TakeCountNotPositive = "Take count must be positive and greater than 0.";
- public const string TimeoutExceptionMessage = "The client could not finish the operation within specified timeout.";
- public const string TooManyPolicyIdentifiers = "Too many '{0}' shared access policy identifiers provided. Server does not support setting more than '{1}' on a single container, queue, or table.";
- public const string TraceAbort = "Aborting pending request due to timeout.";
- public const string TraceAbortError = "Could not abort pending request because of {0}.";
- public const string TraceAbortRetry = "Aborting pending retry due to user request.";
- public const string TraceDownload = "Downloading response body.";
- public const string TraceGenericError = "Exception thrown during the operation: {0}.";
- public const string TraceGetResponse = "Waiting for response.";
- public const string TraceGetResponseError = "Exception thrown while waiting for response: {0}.";
- public const string TraceIgnoreAttribute = "Omitting property '{0}' from serialization/de-serialization because IgnoreAttribute has been set on that property.";
- public const string TraceInitRequestError = "Exception thrown while initializing request: {0}.";
- public const string TraceMissingDictionaryEntry = "Omitting property '{0}' from de-serialization because there is no corresponding entry in the dictionary provided.";
- public const string TraceNonPublicGetSet = "Omitting property '{0}' from serialization/de-serialization because the property's getter/setter are not public.";
- public const string TracePrepareUpload = "Preparing to write request data.";
- public const string TracePrepareUploadError = "Exception thrown while preparing to write request data: {0}.";
- public const string TracePreProcessDone = "Response headers were processed successfully, proceeding with the rest of the operation.";
- public const string TracePreProcessError = "Exception thrown while processing response: {0}.";
- public const string TracePostProcess = "Processing response body.";
- public const string TracePostProcessError = "Exception thrown while ending operation: {0}.";
- public const string TraceResponse = "Response received. Status code = {0}, Request ID = {1}, Content-MD5 = {2}, ETag = {3}.";
- public const string TraceRetry = "Retrying failed operation.";
- public const string TraceRetryCheck = "Checking if the operation should be retried. Retry count = {0}, HTTP status code = {1}, Retryable exception = {2}, Exception = {3}.";
- public const string TraceRetryDecisionPolicy = "Retry policy did not allow for a retry. Failing with {0}.";
- public const string TraceRetryDecisionTimeout = "Operation cannot be retried because we are out of time. Failing with {0}.";
- public const string TraceRetryDelay = "Operation will be retried after {0}ms.";
- public const string TraceRetryError = "Exception thrown while retrying operation: {0}.";
- public const string TraceStartRequestAsync = "Starting asynchronous request to {0}.";
- public const string TraceStartRequestSync = "Starting synchronous request to {0}.";
- public const string TraceStringToSign = "StringToSign = {0}.";
- public const string TraceSuccess = "Operation completed successfully.";
- public const string TraceUpload = "Writing request data.";
- public const string TraceUploadError = "Exception thrown while writing request data: {0}.";
- public const string UndefinedBlobType = "The blob type cannot be undefined.";
- public const string UnexpectedElement = "Unexpected Element '{0}'";
- public const string UnexpectedEmptyElement = "Unexpected Empty Element '{0}'";
- public const string UnexpectedContinuationType = "Unexpected Continuation Type";
- public const string UnexpectedResponseCode = "Unexpected response code, Expected:{0}, Received:{1}";
- public const string UnexpectedResponseCodeForOperation = "Unexpected response code for operation : ";
- public const string UpdateMessageVisibilityRequired = "Calls to UpdateMessage must include the Visibility flag.";
-
-#if WINDOWS_PHONE
- public const string WindowsPhoneDoesNotSupportMD5 = "MD5 is not supported on Windows Phone";
-#endif
- // Table IQueryable Exception messages
- public const string ALinqCouldNotConvert = "Could not convert constant {0} expression to string.";
- public const string ALinqMethodNotSupported = "The method '{0}' is not supported.";
- public const string ALinqUnaryNotSupported = "The unary operator '{0}' is not supported.";
- public const string ALinqBinaryNotSupported = "The binary operator '{0}' is not supported.";
- public const string ALinqConstantNotSupported = "The constant for '{0}' is not supported.";
- public const string ALinqTypeBinaryNotSupported = "An operation between an expression and a type is not supported.";
- public const string ALinqConditionalNotSupported = "The conditional expression is not supported.";
- public const string ALinqParameterNotSupported = "The parameter expression is not supported.";
- public const string ALinqMemberAccessNotSupported = "The member access of '{0}' is not supported.";
- public const string ALinqLambdaNotSupported = "Lambda Expressions not supported.";
- public const string ALinqNewNotSupported = "New Expressions not supported.";
- public const string ALinqMemberInitNotSupported = "Member Init Expressions not supported.";
- public const string ALinqListInitNotSupported = "List Init Expressions not supported.";
- public const string ALinqNewArrayNotSupported = "New Array Expressions not supported.";
- public const string ALinqInvocationNotSupported = "Invocation Expressions not supported.";
- public const string ALinqUnsupportedExpression = "The expression type {0} is not supported.";
- public const string ALinqCanOnlyProjectTheLeaf = "Can only project the last entity type in the query being translated.";
- public const string ALinqCantCastToUnsupportedPrimitive = "Can't cast to unsupported type '{0}'";
- public const string ALinqCantTranslateExpression = "The expression {0} is not supported.";
- public const string ALinqCantNavigateWithoutKeyPredicate = "Navigation properties can only be selected from a single resource. Specify a key predicate to restrict the entity set to a single instance.";
- public const string ALinqCantReferToPublicField = "Referencing public field '{0}' not supported in query option expression. Use public property instead.";
- public const string ALinqCannotConstructKnownEntityTypes = "Construction of entity type instances must use object initializer with default constructor.";
- public const string ALinqCannotCreateConstantEntity = "Referencing of local entity type instances not supported when projecting results.";
- public const string ALinqExpressionNotSupportedInProjectionToEntity = "Initializing instances of the entity type {0} with the expression {1} is not supported.";
- public const string ALinqExpressionNotSupportedInProjection = "Constructing or initializing instances of the type {0} with the expression {1} is not supported.";
- public const string ALinqProjectionMemberAssignmentMismatch = "Cannot initialize an instance of entity type '{0}' because '{1}' and '{2}' do not refer to the same source entity.";
- public const string ALinqPropertyNamesMustMatchInProjections = "Cannot assign the value from the {0} property to the {1} property. When projecting results into a entity type, the property names of the source type and the target type must match for the properties being projected.";
- public const string ALinqQueryOptionOutOfOrder = "The {0} query option cannot be specified after the {1} query option.";
- public const string ALinqQueryOptionsOnlyAllowedOnLeafNodes = "Can only specify query options (orderby, where, take, skip) after last navigation.";
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/SyncMemoryStream.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/SyncMemoryStream.cs
deleted file mode 100644
index 1749a5985ddf8..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/SyncMemoryStream.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 System;
- using System.Diagnostics.CodeAnalysis;
- using System.IO;
-
- ///
- /// This class provides APM Read/Write overrides for memory stream to improve performance.
- ///
- internal class SyncMemoryStream : MemoryStream
- {
- ///
- /// Initializes a new instance of the SyncMemoryStream class with an expandable capacity initialized to zero.
- ///
- public SyncMemoryStream()
- : base()
- {
- }
-
- ///
- /// Initializes a new non-resizable instance of the SyncMemoryStream class based on the specified byte array.
- ///
- /// The array of unsigned bytes from which to create the current stream.
- public SyncMemoryStream(byte[] buffer)
- : base(buffer)
- {
- }
-
- ///
- /// Initializes a new non-resizable instance of the SyncMemoryStream class based on the specified region (index) of a byte array.
- ///
- /// The array of unsigned bytes from which to create the current stream.
- /// The index into buffer at which the stream begins.
- public SyncMemoryStream(byte[] buffer, int index)
- : base(buffer, index, buffer.Length - index)
- {
- }
-
- ///
- /// Initializes a new non-resizable instance of the SyncMemoryStream class based on the specified region (index) of a byte array.
- ///
- /// The array of unsigned bytes from which to create the current stream.
- /// The index into buffer at which the stream begins.
- /// The length of the stream in bytes.
- public SyncMemoryStream(byte[] buffer, int index, int count)
- : base(buffer, index, count)
- {
- }
-
-#if !WINDOWS_RT
- ///
- /// Begins an asynchronous read operation.
- ///
- /// When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
- /// The zero-based byte offset in buffer at which to begin storing the data read from the current stream.
- /// The maximum number of bytes to be read.
- /// An optional asynchronous callback, to be called when the read is complete.
- /// A user-provided object that distinguishes this particular asynchronous read request from other requests.
- /// An IAsyncResult that represents the asynchronous read, which could still be pending.
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Needed to ensure exceptions are not thrown on threadpool threads.")]
- public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
- {
- CommonUtility.AssertNotNull("buffer", buffer);
- CommonUtility.AssertInBounds("offset", offset, 0, buffer.Length);
- CommonUtility.AssertInBounds("count", count, 0, buffer.Length - offset);
-
- StorageAsyncResult result = new StorageAsyncResult(callback, state);
-
- try
- {
- result.Result = this.Read(buffer, offset, count);
- result.OnComplete();
- }
- catch (Exception e)
- {
- result.OnComplete(e);
- }
-
- return result;
- }
-
- ///
- /// Waits for the pending asynchronous read to complete.
- ///
- /// The reference to the pending asynchronous request to finish.
- /// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream has been reached.
- public override int EndRead(IAsyncResult asyncResult)
- {
- StorageAsyncResult result = (StorageAsyncResult)asyncResult;
- result.End();
- return result.Result;
- }
-
- ///
- /// Begins an asynchronous write operation.
- ///
- /// The buffer to write data from.
- /// The zero-based byte offset in buffer at which to begin copying bytes to the current stream.
- /// The number of bytes to write.
- /// An optional asynchronous callback, to be called when the write is complete.
- /// A user-provided object that distinguishes this particular asynchronous write request from other requests.
- /// An IAsyncResult that represents the asynchronous write, which could still be pending.
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Needed to ensure exceptions are not thrown on threadpool threads")]
- public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
- {
- CommonUtility.AssertNotNull("buffer", buffer);
- CommonUtility.AssertInBounds("offset", offset, 0, buffer.Length);
- CommonUtility.AssertInBounds("count", count, 0, buffer.Length - offset);
-
- StorageAsyncResult result = new StorageAsyncResult(callback, state);
-
- try
- {
- this.Write(buffer, offset, count);
- result.OnComplete();
- }
- catch (Exception e)
- {
- result.OnComplete(e);
- }
-
- return result;
- }
-
- ///
- /// Ends an asynchronous write operation.
- ///
- /// The reference to the pending asynchronous request to finish.
- public override void EndWrite(IAsyncResult asyncResult)
- {
- StorageAsyncResult result = (StorageAsyncResult)asyncResult;
- result.End();
- }
-#endif
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/UriQueryBuilder.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/UriQueryBuilder.cs
deleted file mode 100644
index b249cb47428b6..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/UriQueryBuilder.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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 System;
- using System.Collections.Generic;
- using System.Text;
-
- ///
- /// A convenience class for constructing URI query strings.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- class UriQueryBuilder
- {
- ///
- /// Stores the query parameters.
- ///
- private Dictionary parameters = new Dictionary();
-
- ///
- /// Add the value with URI escaping.
- ///
- /// The query name.
- /// The query value.
- public void Add(string name, string value)
- {
- if (value != null)
- {
- value = Uri.EscapeDataString(value);
- }
-
- this.parameters.Add(name, value);
- }
-
- ///
- /// Returns a containing the URI.
- ///
- ///
- /// A containing the URI.
- ///
- public override string ToString()
- {
- StringBuilder sb = new StringBuilder();
- bool first = true;
-
- foreach (KeyValuePair pair in this.parameters)
- {
- if (first)
- {
- first = false;
- sb.Append("?");
- }
- else
- {
- sb.Append("&");
- }
-
- sb.Append(pair.Key);
-
- if (pair.Value != null)
- {
- sb.AppendFormat("={0}", pair.Value);
- }
- }
-
- return sb.ToString();
- }
-
- ///
- /// Adds a query parameter to a URI.
- ///
- /// The original URI, including any existing query parameters.
- /// The URI with the new query parameter appended.
- public Uri AddToUri(Uri uri)
- {
- // The correct way to add query parameters to a URI http://msdn.microsoft.com/en-us/library/system.uribuilder.query.aspx
- string queryToAppend = this.ToString();
-
- if (queryToAppend.Length > 1)
- {
- queryToAppend = queryToAppend.Substring(1);
- }
-
- UriBuilder baseUri = new UriBuilder(uri);
-
- if (baseUri.Query != null && baseUri.Query.Length > 1)
- {
- baseUri.Query = baseUri.Query.Substring(1) + "&" + queryToAppend;
- }
- else
- {
- baseUri.Query = queryToAppend;
- }
-
- return baseUri.Uri;
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/AsyncSemaphore.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/AsyncSemaphore.Common.cs
deleted file mode 100644
index 00b68ba3f7cb6..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/AsyncSemaphore.Common.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Util
-{
- internal partial class AsyncSemaphore
- {
- private int count;
-
- public AsyncSemaphore(int initialCount)
- {
- CommonUtility.AssertInBounds("initialCount", initialCount, 0, int.MaxValue);
- this.count = initialCount;
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/AuthenticationUtility.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/AuthenticationUtility.cs
deleted file mode 100644
index 3f638521ac585..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/AuthenticationUtility.cs
+++ /dev/null
@@ -1,297 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Util
-{
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
- using System.Net;
- using System.Text;
-#if WINDOWS_RT
- using System.Net.Http;
-#endif
-
- internal static class AuthenticationUtility
- {
- private const int ExpectedResourceStringLength = 100;
- private const int ExpectedHeaderNameAndValueLength = 50;
- private const char HeaderNameValueSeparator = ':';
- private const char HeaderValueDelimiter = ',';
-
-#if WINDOWS_RT
- ///
- /// Gets the value of the x-ms-date or Date header.
- ///
- /// The request where the value is read from.
- /// The value of the x-ms-date or Date header.
- public static string GetPreferredDateHeaderValue(HttpRequestMessage request)
- {
- string microsoftDateHeaderValue = HttpResponseMessageUtils.GetHeaderSingleValueOrDefault(request.Headers, Constants.HeaderConstants.Date);
- if (!string.IsNullOrEmpty(microsoftDateHeaderValue))
- {
- return microsoftDateHeaderValue;
- }
-
- return AuthenticationUtility.GetCanonicalizedHeaderValue(request.Headers.Date);
- }
-
- ///
- /// Appends the value of the Content-Length header to the specified canonicalized string.
- ///
- /// The canonicalized string where the value is appended.
- /// The request where the value is read from.
- public static void AppendCanonicalizedContentLengthHeader(CanonicalizedString canonicalizedString, HttpRequestMessage request)
- {
- long? contentLength = request.Content.Headers.ContentLength;
- if (contentLength.HasValue && contentLength.Value != -1L)
- {
- canonicalizedString.AppendCanonicalizedElement(contentLength.Value.ToString(CultureInfo.InvariantCulture));
- }
- else
- {
- canonicalizedString.AppendCanonicalizedElement(null);
- }
- }
-
- ///
- /// Appends the value of the Date header (or, optionally, the x-ms-date header) to the specified canonicalized string.
- ///
- /// The canonicalized string where the value is appended.
- /// The request where the value is read from.
- /// true if the value of the x-ms-date header can be used and is preferred; otherwise, false.
- public static void AppendCanonicalizedDateHeader(CanonicalizedString canonicalizedString, HttpRequestMessage request, bool allowMicrosoftDateHeader = false)
- {
- string microsoftDateHeaderValue = HttpResponseMessageUtils.GetHeaderSingleValueOrDefault(request.Headers, Constants.HeaderConstants.Date);
- if (string.IsNullOrEmpty(microsoftDateHeaderValue))
- {
- canonicalizedString.AppendCanonicalizedElement(AuthenticationUtility.GetCanonicalizedHeaderValue(request.Headers.Date));
- }
- else if (allowMicrosoftDateHeader)
- {
- canonicalizedString.AppendCanonicalizedElement(microsoftDateHeaderValue);
- }
- else
- {
- canonicalizedString.AppendCanonicalizedElement(null);
- }
- }
-
- ///
- /// Appends the values of the x-ms-* headers to the specified canonicalized string.
- ///
- /// The canonicalized string where the values are appended.
- /// The request where the values are read from.
- public static void AppendCanonicalizedCustomHeaders(CanonicalizedString canonicalizedString, HttpRequestMessage request)
- {
- CultureInfo sortingCulture = new CultureInfo("en-US");
- StringComparer sortingComparer = new CultureStringComparer(sortingCulture, false);
- SortedDictionary> headers = new SortedDictionary>(sortingComparer);
-
- foreach (KeyValuePair> header in request.Headers)
- {
- string headerName = header.Key;
- if (headerName.StartsWith(Constants.HeaderConstants.PrefixForStorageHeader, StringComparison.OrdinalIgnoreCase))
- {
- headers.Add(headerName.ToLowerInvariant(), header.Value);
- }
- }
-
- if (request.Content != null)
- {
- foreach (KeyValuePair> header in request.Content.Headers)
- {
- string headerName = header.Key;
- if (headerName.StartsWith(Constants.HeaderConstants.PrefixForStorageHeader, StringComparison.OrdinalIgnoreCase))
- {
- headers.Add(headerName.ToLowerInvariant(), header.Value);
- }
- }
- }
-
- StringBuilder canonicalizedElement = new StringBuilder(ExpectedHeaderNameAndValueLength);
- foreach (KeyValuePair> header in headers)
- {
- canonicalizedElement.Clear();
- canonicalizedElement.Append(header.Key);
- canonicalizedElement.Append(HeaderNameValueSeparator);
-
- foreach (string value in header.Value)
- {
- canonicalizedElement.Append(value.TrimStart().Replace("\r\n", string.Empty));
- canonicalizedElement.Append(HeaderValueDelimiter);
- }
-
- canonicalizedString.AppendCanonicalizedElement(canonicalizedElement.ToString(0, canonicalizedElement.Length - 1));
- }
- }
-#else
- ///
- /// Gets the value of the x-ms-date or Date header.
- ///
- /// The request where the value is read from.
- /// The value of the x-ms-date or Date header.
- public static string GetPreferredDateHeaderValue(HttpWebRequest request)
- {
- string microsoftDateHeaderValue = request.Headers[Constants.HeaderConstants.Date];
- if (!string.IsNullOrEmpty(microsoftDateHeaderValue))
- {
- return microsoftDateHeaderValue;
- }
-
- return request.Headers[HttpRequestHeader.Date];
- }
-
- ///
- /// Appends the value of the Content-Length header to the specified canonicalized string.
- ///
- /// The canonicalized string where the value is appended.
- /// The request where the value is read from.
- public static void AppendCanonicalizedContentLengthHeader(CanonicalizedString canonicalizedString, HttpWebRequest request)
- {
- if (request.ContentLength != -1L)
- {
- canonicalizedString.AppendCanonicalizedElement(request.ContentLength.ToString(CultureInfo.InvariantCulture));
- }
- else
- {
- canonicalizedString.AppendCanonicalizedElement(null);
- }
- }
-
- ///
- /// Appends the value of the Date header (or, optionally, the x-ms-date header) to the specified canonicalized string.
- ///
- /// The canonicalized string where the value is appended.
- /// The request where the value is read from.
- /// true if the value of the x-ms-date header can be used and is preferred; otherwise, false.
- public static void AppendCanonicalizedDateHeader(CanonicalizedString canonicalizedString, HttpWebRequest request, bool allowMicrosoftDateHeader = false)
- {
- string microsoftDateHeaderValue = request.Headers[Constants.HeaderConstants.Date];
- if (string.IsNullOrEmpty(microsoftDateHeaderValue))
- {
- canonicalizedString.AppendCanonicalizedElement(request.Headers[HttpRequestHeader.Date]);
- }
- else if (allowMicrosoftDateHeader)
- {
- canonicalizedString.AppendCanonicalizedElement(microsoftDateHeaderValue);
- }
- else
- {
- canonicalizedString.AppendCanonicalizedElement(null);
- }
- }
-
- ///
- /// Appends the values of the x-ms-* headers to the specified canonicalized string.
- ///
- /// The canonicalized string where the values are appended.
- /// The request where the values are read from.
- [SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "Reviewed.")]
- public static void AppendCanonicalizedCustomHeaders(CanonicalizedString canonicalizedString, HttpWebRequest request)
- {
- List headerNames = new List(request.Headers.AllKeys.Length);
- foreach (string headerName in request.Headers.AllKeys)
- {
- if (headerName.StartsWith(Constants.HeaderConstants.PrefixForStorageHeader, StringComparison.OrdinalIgnoreCase))
- {
- headerNames.Add(headerName.ToLowerInvariant());
- }
- }
-
- CultureInfo sortingCulture = new CultureInfo("en-US");
- StringComparer sortingComparer = StringComparer.Create(sortingCulture, false);
- headerNames.Sort(sortingComparer);
-
- StringBuilder canonicalizedElement = new StringBuilder(ExpectedHeaderNameAndValueLength);
- foreach (string headerName in headerNames)
- {
- string value = request.Headers[headerName];
- if (!string.IsNullOrEmpty(value))
- {
- canonicalizedElement.Length = 0;
- canonicalizedElement.Append(headerName);
- canonicalizedElement.Append(HeaderNameValueSeparator);
- canonicalizedElement.Append(value.TrimStart().Replace("\r\n", string.Empty));
-
- canonicalizedString.AppendCanonicalizedElement(canonicalizedElement.ToString());
- }
- }
- }
-#endif
-
- ///
- /// Gets the canonicalized header value to use for the specified date/time or null if it does not have a value.
- ///
- /// The date/time.
- /// The canonicalized header value to use for the specified date/time or null if it does not have a value.
- public static string GetCanonicalizedHeaderValue(DateTimeOffset? value)
- {
- if (value.HasValue)
- {
- return HttpWebUtility.ConvertDateTimeToHttpString(value.Value);
- }
-
- return null;
- }
-
- ///
- /// Gets the canonicalized resource string for the specified URI.
- ///
- /// The resource URI.
- /// The name of the storage account.
- /// true when using the Shared Key Lite authentication scheme or the table service; otherwise, false.
- /// The canonicalized resource string.
- [SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "Reviewed.")]
- public static string GetCanonicalizedResourceString(Uri uri, string accountName, bool isSharedKeyLiteOrTableService = false)
- {
- StringBuilder canonicalizedResource = new StringBuilder(ExpectedResourceStringLength);
- canonicalizedResource.Append('/');
- canonicalizedResource.Append(accountName);
- canonicalizedResource.Append(uri.AbsolutePath);
-
- IDictionary queryParameters = HttpWebUtility.ParseQueryString(uri.Query);
- if (!isSharedKeyLiteOrTableService)
- {
- List queryParameterNames = new List(queryParameters.Keys);
- queryParameterNames.Sort(StringComparer.OrdinalIgnoreCase);
-
- foreach (string queryParameterName in queryParameterNames)
- {
- canonicalizedResource.Append('\n');
- canonicalizedResource.Append(queryParameterName.ToLowerInvariant());
- canonicalizedResource.Append(':');
- canonicalizedResource.Append(queryParameters[queryParameterName]);
- }
- }
- else
- {
- // Add only the comp parameter
- string compQueryParameterValue;
- if (queryParameters.TryGetValue("comp", out compQueryParameterValue) && compQueryParameterValue != null)
- {
- canonicalizedResource.Append("?comp=");
- canonicalizedResource.Append(compQueryParameterValue);
- }
- }
-
- return canonicalizedResource.ToString();
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/CommonUtility.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/CommonUtility.cs
deleted file mode 100644
index 7043560d32519..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/CommonUtility.cs
+++ /dev/null
@@ -1,311 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Util
-{
- using Microsoft.WindowsAzure.Storage.Auth;
- using Microsoft.WindowsAzure.Storage.Blob;
- using Microsoft.WindowsAzure.Storage.Core.Executor;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Xml;
-
-#if WINDOWS_DESKTOP
- using System.Net;
-#endif
-
- internal static class CommonUtility
- {
- ///
- /// Create an ExecutionState object that can be used for pre-request operations
- /// such as buffering user's data.
- ///
- /// Request options
- /// Temporary ExecutionState object
- internal static ExecutionState CreateTemporaryExecutionState(BlobRequestOptions options)
- {
- RESTCommand cmdWithTimeout = new RESTCommand(new StorageCredentials(), null /* Uri */);
- if (options != null)
- {
- cmdWithTimeout.ApplyRequestOptions(options);
- }
-
- return new ExecutionState(cmdWithTimeout, options.RetryPolicy, new OperationContext());
- }
-
- ///
- /// Gets the first header value or null if no header values exist.
- ///
- /// The type of header objects contained in the enumerable.
- /// An enumerable that contains header values.
- /// The first header value or null if no header values exist.
- public static string GetFirstHeaderValue(IEnumerable headerValues) where T : class
- {
- if (headerValues != null)
- {
- T result = headerValues.FirstOrDefault();
- if (result != null)
- {
- return result.ToString().TrimStart();
- }
- }
-
- return null;
- }
-
- ///
- /// Throws an exception if the string is empty or null.
- ///
- /// The name of the parameter.
- /// The value of the parameter.
- /// Thrown if value is empty.
- /// Thrown if value is null.
- internal static void AssertNotNullOrEmpty(string paramName, string value)
- {
- AssertNotNull(paramName, value);
-
- if (string.IsNullOrEmpty(value))
- {
- throw new ArgumentException(SR.ArgumentEmptyError, paramName);
- }
- }
-
- ///
- /// Throw an exception if the value is null.
- ///
- /// The name of the parameter.
- /// The value of the parameter.
- /// Thrown if value is null.
- internal static void AssertNotNull(string paramName, object value)
- {
- if (value == null)
- {
- throw new ArgumentNullException(paramName);
- }
- }
-
- ///
- /// Throw an exception indicating argument is out of range.
- ///
- /// The name of the parameter.
- /// The value of the parameter.
- internal static void ArgumentOutOfRange(string paramName, object value)
- {
- throw new ArgumentOutOfRangeException(paramName, string.Format(CultureInfo.InvariantCulture, SR.ArgumentOutOfRangeError, value));
- }
-
- ///
- /// Throw an exception if the argument is out of bounds.
- ///
- /// The type of the value.
- /// The name of the parameter.
- /// The value of the parameter.
- /// The minimum value for the parameter.
- /// The maximum value for the parameter.
- internal static void AssertInBounds(string paramName, T val, T min, T max)
- where T : IComparable
- {
- if (val.CompareTo(min) < 0)
- {
- throw new ArgumentOutOfRangeException(paramName, string.Format(CultureInfo.InvariantCulture, SR.ArgumentTooSmallError, paramName, min));
- }
-
- if (val.CompareTo(max) > 0)
- {
- throw new ArgumentOutOfRangeException(paramName, string.Format(CultureInfo.InvariantCulture, SR.ArgumentTooLargeError, paramName, max));
- }
- }
-
- ///
- /// Throw an exception if the argument is out of bounds.
- ///
- /// The type of the value.
- /// The name of the parameter.
- /// The value of the parameter.
- /// The minimum value for the parameter.
- internal static void AssertInBounds(string paramName, T val, T min)
- where T : IComparable
- {
- if (val.CompareTo(min) < 0)
- {
- throw new ArgumentOutOfRangeException(paramName, string.Format(CultureInfo.InvariantCulture, SR.ArgumentTooSmallError, paramName, min));
- }
- }
-
- ///
- /// Checks that the given timeout in within allowed bounds.
- ///
- /// The timeout to check.
- /// The timeout is not within allowed bounds.
- internal static void CheckTimeoutBounds(TimeSpan timeout)
- {
- CommonUtility.AssertInBounds("Timeout", timeout, TimeSpan.FromSeconds(1), Constants.MaximumAllowedTimeout);
- }
-
- ///
- /// Combines AssertNotNullOrEmpty and AssertInBounds for convenience.
- ///
- /// The name of the parameter.
- /// Turns on or off null/empty checking.
- /// The value of the parameter.
- /// The maximum size of value.
- internal static void CheckStringParameter(string paramName, bool canBeNullOrEmpty, string value, int maxSize)
- {
- if (!canBeNullOrEmpty)
- {
- AssertNotNullOrEmpty(value, paramName);
- }
-
- AssertInBounds(value, paramName.Length, 0, maxSize);
- }
-
- ///
- /// Rounds up to seconds.
- ///
- /// The time span.
- /// The time rounded to seconds.
- internal static int RoundUpToSeconds(this TimeSpan timeSpan)
- {
- return (int)Math.Ceiling(timeSpan.TotalSeconds);
- }
-
- ///
- /// Determines if a URI requires path style addressing.
- ///
- /// The URI to check.
- /// Returns true if the Uri uses path style addressing; otherwise, false.
- internal static bool UsePathStyleAddressing(Uri uri)
- {
- if (uri.HostNameType != UriHostNameType.Dns)
- {
- return true;
- }
-
- switch (uri.Port)
- {
- case 10000:
- case 10001:
- case 10002:
- case 10003:
- case 10004:
- return true;
- }
-
- return false;
- }
-
- ///
- /// Read the value of an element in the XML.
- ///
- /// The name of the element whose value is retrieved.
- /// A reader that provides access to XML data.
- /// A string representation of the element's value.
- internal static string ReadElementAsString(string elementName, XmlReader reader)
- {
- string res = null;
-
- if (reader.IsStartElement(elementName))
- {
- if (reader.IsEmptyElement)
- {
- reader.Skip();
- }
- else
- {
- res = reader.ReadElementContentAsString();
- }
- }
- else
- {
- throw new XmlException(elementName);
- }
-
- reader.MoveToContent();
-
- return res;
- }
-
- ///
- /// Returns an enumerable collection of results that is retrieved lazily.
- ///
- /// The type of ResultSegment like Blob, Container, Queue and Table.
- /// The segment generator.
- /// >A non-negative integer value that indicates the maximum number of results to be returned
- /// in the result segment, up to the per-operation limit of 5000.
- ///
- internal static IEnumerable LazyEnumerable(Func> segmentGenerator, long maxResults)
- {
- ResultSegment currentSeg = segmentGenerator(null);
- long count = 0;
- while (true)
- {
- foreach (T result in currentSeg.Results)
- {
- yield return result;
- count++;
- if (count >= maxResults)
- {
- break;
- }
- }
-
- if (count >= maxResults)
- {
- break;
- }
-
- if (currentSeg.ContinuationToken != null)
- {
- currentSeg = segmentGenerator(currentSeg.ContinuationToken);
- }
- else
- {
- break;
- }
- }
- }
-
-#if WINDOWS_DESKTOP
- ///
- /// Applies the request optimizations such as disabling buffering and 100 continue.
- ///
- /// The request to be modified.
- /// The length of the content, -1 if the content length is not settable.
- internal static void ApplyRequestOptimizations(HttpWebRequest request, long length)
- {
- if (length >= Constants.DefaultBufferSize)
- {
- request.AllowWriteStreamBuffering = false;
- }
-
- // Set the length of the stream if the value is known
- if (length >= 0)
- {
- request.ContentLength = length;
- }
-
-#if !WINDOWS_PHONE
- // Disable the Expect 100-Continue
- request.ServicePoint.Expect100Continue = false;
-#endif
- }
-#endif
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/CounterEvent.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/CounterEvent.cs
deleted file mode 100644
index 1ae45608bb20b..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/CounterEvent.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Util
-{
- using System;
- using System.Threading;
-
- internal sealed class CounterEvent : IDisposable
- {
- private ManualResetEvent internalEvent = new ManualResetEvent(true);
- private object counterLock = new object();
- private int counter = 0;
-
- ///
- /// Gets a WaitHandle that is used to wait for the event to be set.
- ///
- /// A WaitHandle that is used to wait for the event to be set.
- public WaitHandle WaitHandle
- {
- get
- {
- return this.internalEvent;
- }
- }
-
- ///
- /// Increments the counter by one and thus sets the state of the event to non-signaled, causing threads to block.
- ///
- public void Increment()
- {
- lock (this.counterLock)
- {
- this.counter++;
- this.internalEvent.Reset();
- }
- }
-
- ///
- /// Decrements the counter by one. If the counter reaches zero, sets the state of the event to signaled, allowing one or more waiting threads to proceed.
- ///
- public void Decrement()
- {
- lock (this.counterLock)
- {
- if (--this.counter == 0)
- {
- this.internalEvent.Set();
- }
- }
- }
-
- ///
- /// Blocks the current thread until the CounterEvent is set.
- ///
- public void Wait()
- {
- this.internalEvent.WaitOne();
- }
-
- ///
- /// Blocks the current thread until the CounterEvent is set, using a 32-bit signed integer to measure the timeout.
- ///
- /// The number of milliseconds to wait, or Infinite(-1) to wait indefinitely.
- /// true if the CounterEvent was set; otherwise, false.
- public bool Wait(int millisecondsTimeout)
- {
- return this.internalEvent.WaitOne(millisecondsTimeout);
- }
-
- ///
- /// Releases all resources used by the current instance of the CounterEvent class.
- ///
- public void Dispose()
- {
- if (this.internalEvent != null)
- {
- this.internalEvent.Dispose();
- this.internalEvent = null;
- }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/CryptoUtility.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/CryptoUtility.cs
deleted file mode 100644
index 624020102a1de..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/CryptoUtility.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Util
-{
-#if WINDOWS_RT
- using Windows.Security.Cryptography;
- using Windows.Security.Cryptography.Core;
- using Windows.Storage.Streams;
-#else
- using System;
- using System.Security.Cryptography;
- using System.Text;
-#endif
-
- internal static class CryptoUtility
- {
- internal static string ComputeHmac256(byte[] key, string message)
- {
-#if WINDOWS_RT
- MacAlgorithmProvider macAlgorithmProvider = MacAlgorithmProvider.OpenAlgorithm("HMAC_SHA256");
- IBuffer keyMaterial = CryptographicBuffer.CreateFromByteArray(key);
- CryptographicKey hmacKey = macAlgorithmProvider.CreateKey(keyMaterial);
- IBuffer messageBuffer = CryptographicBuffer.ConvertStringToBinary(message, BinaryStringEncoding.Utf8);
- IBuffer signedMessage = CryptographicEngine.Sign(hmacKey, messageBuffer);
- return CryptographicBuffer.EncodeToBase64String(signedMessage);
-#else
- using (HashAlgorithm hashAlgorithm = new HMACSHA256(key))
- {
- byte[] messageBuffer = Encoding.UTF8.GetBytes(message);
- return Convert.ToBase64String(hashAlgorithm.ComputeHash(messageBuffer));
- }
-#endif
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/Exceptions.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/Exceptions.cs
deleted file mode 100644
index 52e5f737f8236..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/Exceptions.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Util
-{
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
-
-#if WINDOWS_RT
- using System.Globalization;
- using System.IO;
- using System.Net.Http;
- using System.Threading.Tasks;
-#endif
-
- internal class Exceptions
- {
-#if WINDOWS_RT
- internal async static Task PopulateStorageExceptionFromHttpResponseMessage(HttpResponseMessage response, RequestResult currentResult)
- {
- if (!response.IsSuccessStatusCode)
- {
- try
- {
- currentResult.HttpStatusMessage = response.ReasonPhrase;
- currentResult.HttpStatusCode = (int)response.StatusCode;
- currentResult.ServiceRequestID = HttpResponseMessageUtils.GetHeaderSingleValueOrDefault(response.Headers, Constants.HeaderConstants.RequestIdHeader);
-
- string tempDate = HttpResponseMessageUtils.GetHeaderSingleValueOrDefault(response.Headers, Constants.HeaderConstants.Date);
- currentResult.RequestDate = string.IsNullOrEmpty(tempDate) ? DateTime.Now.ToString("R", CultureInfo.InvariantCulture) : tempDate;
-
- if (response.Headers.ETag != null)
- {
- currentResult.Etag = response.Headers.ETag.ToString();
- }
-
- if (response.Content != null && response.Content.Headers.ContentMD5 != null)
- {
- currentResult.ContentMd5 = Convert.ToBase64String(response.Content.Headers.ContentMD5);
- }
- }
- catch (Exception)
- {
- // no op
- }
-
- try
- {
- Stream errStream = await response.Content.ReadAsStreamAsync();
- currentResult.ExtendedErrorInformation = StorageExtendedErrorInformation.ReadFromStream(errStream.AsInputStream());
- }
- catch (Exception)
- {
- // no op
- }
-
- return new StorageException(currentResult, response.ReasonPhrase, null);
- }
- else
- {
- return null;
- }
- }
-#endif
-
- internal static StorageException GenerateTimeoutException(RequestResult res, Exception inner)
- {
- if (res != null)
- {
- res.HttpStatusCode = 408; // RequestTimeout
- }
-
- TimeoutException timeoutEx = new TimeoutException(SR.TimeoutExceptionMessage, inner);
- return new StorageException(res, timeoutEx.Message, timeoutEx)
- {
- IsRetryable = false
- };
- }
-
-#if WINDOWS_DESKTOP
- internal static StorageException GenerateCancellationException(RequestResult res, Exception inner)
- {
- if (res != null)
- {
- res.HttpStatusCode = 306;
- res.HttpStatusMessage = "Unused";
- }
-
- OperationCanceledException cancelEx = new OperationCanceledException(SR.OperationCanceled, inner);
- return new StorageException(res, cancelEx.Message, cancelEx) { IsRetryable = false };
- }
-#endif
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/HttpWebUtility.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/HttpWebUtility.cs
deleted file mode 100644
index c68692ba2e8e0..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/HttpWebUtility.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Util
-{
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
-
-#if WINDOWS_RT
- using System.Net.Http;
-#else
- using System.Net;
-#endif
-
- ///
- /// Provides helper functions for http request/response processing.
- ///
- internal static class HttpWebUtility
- {
- ///
- /// Parse the http query string.
- ///
- /// Http query string.
- ///
- public static IDictionary ParseQueryString(string query)
- {
- Dictionary retVal = new Dictionary();
- if (string.IsNullOrEmpty(query))
- {
- return retVal;
- }
-
- if (query.StartsWith("?", StringComparison.Ordinal))
- {
- if (query.Length == 1)
- {
- return retVal;
- }
-
- query = query.Substring(1);
- }
-
- string[] valuePairs = query.Split('&');
- foreach (string pair in valuePairs)
- {
- string key;
- string value;
-
- int equalDex = pair.IndexOf("=", StringComparison.Ordinal);
- if (equalDex < 0)
- {
- key = string.Empty;
- value = Uri.UnescapeDataString(pair);
- }
- else
- {
- key = Uri.UnescapeDataString(pair.Substring(0, equalDex));
- value = Uri.UnescapeDataString(pair.Substring(equalDex + 1));
- }
-
- string existingValue;
- if (retVal.TryGetValue(key, out existingValue))
- {
- retVal[key] = string.Concat(existingValue, ",", value);
- }
- else
- {
- retVal[key] = value;
- }
- }
-
- return retVal;
- }
-
- ///
- /// Converts the DateTimeOffset object to an Http string of form: Sun, 28 Jan 2008 12:11:37 GMT.
- ///
- /// The DateTimeOffset object to convert to an Http string.
- /// String of form: Sun, 28 Jan 2008 12:11:37 GMT.
- public static string ConvertDateTimeToHttpString(DateTimeOffset dateTime)
- {
- // 'R' means rfc1123 date which is what the storage services use for all dates...
- // It will be in the following format:
- // Sun, 28 Jan 2008 12:11:37 GMT
- return dateTime.UtcDateTime.ToString("R", CultureInfo.InvariantCulture);
- }
-
-#if WINDOWS_RT
- ///
- /// Combine all the header values in the IEnumerable to a single comma separated string.
- ///
- /// An IEnumerable object representing the header values.
- /// A comma separated string of header values.
- public static string CombineHttpHeaderValues(IEnumerable headerValues)
- {
- if (headerValues == null)
- {
- return null;
- }
-
- return (headerValues.Count() == 0) ?
- null :
- string.Join(",", headerValues);
- }
-#endif
-
-#if WINDOWS_DESKTOP
- ///
- /// Try to get the value of the specified header name.
- ///
- /// The Http web response from which to get the header value.
- /// The name of the header whose value is to be retrieved.
- /// The default value for the header that is returned if we can't get the actual header value.
- /// A string representing the header value.
- public static string TryGetHeader(HttpWebResponse resp, string headerName, string defaultValue)
- {
- string value = resp.Headers[headerName];
- if (string.IsNullOrEmpty(value))
- {
- return defaultValue;
- }
- else
- {
- return value;
- }
- }
-#endif
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/MD5Wrapper.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/MD5Wrapper.cs
deleted file mode 100644
index 406d4a64d5151..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/MD5Wrapper.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Util
-{
- using System;
- using System.Diagnostics.CodeAnalysis;
-
-#if WINDOWS_RT
- using System.Runtime.InteropServices.WindowsRuntime;
- using Windows.Security.Cryptography;
- using Windows.Security.Cryptography.Core;
- using Windows.Storage.Streams;
-#else
- using System.Security.Cryptography;
-#endif
-
- ///
- /// Wrapper class for MD5.
- ///
- internal class MD5Wrapper : IDisposable
- {
- [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed.")]
- private readonly bool version1MD5 = CloudStorageAccount.UseV1MD5;
-
-#if WINDOWS_RT
- private CryptographicHash hash = null;
-#elif WINDOWS_PHONE
-
-#else
- private MD5 hash = null;
-#endif
-
- [SuppressMessage("Microsoft.Cryptographic.Standard", "CA5350:MD5CannotBeUsed", Justification = "Used as a hash, not encryption")]
- internal MD5Wrapper()
- {
-#if WINDOWS_RT
- this.hash = HashAlgorithmProvider.OpenAlgorithm("MD5").CreateHash();
-#elif WINDOWS_PHONE
- throw new NotSupportedException(SR.WindowsPhoneDoesNotSupportMD5);
-#else
- this.hash = this.version1MD5 ? MD5.Create() : new NativeMD5();
-#endif
- }
-
- ///
- /// Calculates an on-going hash using the input byte array.
- ///
- /// The input array used for calculating the hash.
- /// The offset in the input buffer to calculate from.
- /// The number of bytes to use from input.
- internal void UpdateHash(byte[] input, int offset, int count)
- {
- if (count > 0)
- {
-#if WINDOWS_RT
- this.hash.Append(input.AsBuffer(offset, count));
-#elif WINDOWS_PHONE
- throw new NotSupportedException(SR.WindowsPhoneDoesNotSupportMD5);
-#else
- this.hash.TransformBlock(input, offset, count, null, 0);
-#endif
- }
- }
-
- ///
- /// Retrieves the string representation of the hash. (Completes the creation of the hash).
- ///
- /// String representation of the computed hash value.
- internal string ComputeHash()
- {
-#if WINDOWS_RT
- IBuffer md5HashBuff = this.hash.GetValueAndReset();
- return CryptographicBuffer.EncodeToBase64String(md5HashBuff);
-#elif WINDOWS_PHONE
- throw new NotSupportedException(SR.WindowsPhoneDoesNotSupportMD5);
-#else
- this.hash.TransformFinalBlock(new byte[0], 0, 0);
- return Convert.ToBase64String(this.hash.Hash);
-#endif
- }
-
- public void Dispose()
- {
-#if WINDOWS_DESKTOP && !WINDOWS_PHONE
- if (this.hash != null)
- {
- ((IDisposable)this.hash).Dispose();
- this.hash = null;
- }
-#endif
- }
- }
-}
\ No newline at end of file
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/NavigationHelper.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/NavigationHelper.cs
deleted file mode 100644
index a7c181f2a4e81..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/NavigationHelper.cs
+++ /dev/null
@@ -1,544 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Util
-{
- using Microsoft.WindowsAzure.Storage.Auth;
- using Microsoft.WindowsAzure.Storage.Core.Auth;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
-
- ///
- /// Contains methods for dealing with navigation.
- ///
- internal static class NavigationHelper
- {
- ///
- /// The name of the root container.
- ///
- public const string RootContainerName = "$root";
-
- ///
- /// Used in address parsing.
- ///
- public const string Slash = "/";
-
- ///
- /// Used in address parsing.
- ///
- public const string Dot = ".";
-
- ///
- /// Used in address parsing.
- ///
- public const char SlashChar = '/';
-
- ///
- /// Used to split string on slash.
- ///
- public static readonly char[] SlashAsSplitOptions = Slash.ToCharArray();
-
- ///
- /// Used to split hostname.
- ///
- public static readonly char[] DotAsSplitOptions = Dot.ToCharArray();
-
- ///
- /// Retrieves the container part of a storage Uri, or "$root" if the container is implicit.
- ///
- /// The blob address.
- /// If set to true use path style Uris.
- /// Name of the container.
- ///
- /// The trailing slash is always removed.
- ///
- /// GetContainerName(new Uri("http://test.blob.core.windows.net/mycontainer/myfolder/myblob")) will return "mycontainer"
- /// GetContainerName(new Uri("http://test.blob.core.windows.net/mycontainer/")) will return "mycontainer"
- /// GetContainerName(new Uri("http://test.blob.core.windows.net/myblob")) will return "$root"
- /// GetContainerName(new Uri("http://test.blob.core.windows.net/")) will throw ArgumentException
- ///
- ///
- internal static string GetContainerName(Uri blobAddress, bool? usePathStyleUris)
- {
- string containerName;
- string blobName;
-
- GetContainerNameAndBlobName(blobAddress, usePathStyleUris, out containerName, out blobName);
-
- return containerName;
- }
-
- ///
- /// Retrieves the blob part of a storage Uri.
- ///
- /// The blob address.
- /// If set to true use path style Uris.
- /// The name of the blob.
- internal static string GetBlobName(Uri blobAddress, bool? usePathStyleUris)
- {
- string containerName;
- string blobName;
-
- GetContainerNameAndBlobName(blobAddress, usePathStyleUris, out containerName, out blobName);
-
- return Uri.UnescapeDataString(blobName);
- }
-
- ///
- /// Retrieves the complete container address from a storage Uri
- /// Example GetContainerAddress(new Uri("http://test.blob.core.windows.net/mycontainer/myfolder/myblob"))
- /// will return http://test.blob.core.windows.net/mycontainer.
- ///
- /// The blob address.
- /// True to use path style Uris.
- /// Uri of the container.
- internal static Uri GetContainerAddress(Uri blobAddress, bool? usePathStyleUris)
- {
- string containerName;
- Uri containerAddress;
-
- GetContainerNameAndAddress(blobAddress, usePathStyleUris, out containerName, out containerAddress);
-
- return containerAddress;
- }
-
- ///
- /// Retrieves the parent name from a storage Uri.
- ///
- /// The blob address.
- /// The delimiter.
- /// If set to true use path style Uris.
- /// The name of the parent.
- ///
- /// Adds the trailing delimiter as the prefix returned by the storage REST api always contains the delimiter.
- ///
- ///
- /// GetParentName(new Uri("http://test.blob.core.windows.net/mycontainer/myfolder/myblob", "/")) will return "/mycontainer/myfolder/"
- /// GetParentName(new Uri("http://test.blob.core.windows.net/mycontainer/myfolder|myblob", "|") will return "/mycontainer/myfolder|"
- /// GetParentName(new Uri("http://test.blob.core.windows.net/mycontainer/myblob", "/") will return "/mycontainer/"
- /// GetParentName(new Uri("http://test.blob.core.windows.net/mycontainer/", "/") will return "/mycontainer/"
- ///
- internal static string GetParentName(Uri blobAddress, string delimiter, bool? usePathStyleUris)
- {
- CommonUtility.AssertNotNull("blobAbsoluteUriString", blobAddress);
- CommonUtility.AssertNotNullOrEmpty("delimiter", delimiter);
-
- string containerName;
- Uri containerUri;
- GetContainerNameAndAddress(blobAddress, usePathStyleUris, out containerName, out containerUri);
- containerName += NavigationHelper.Slash;
-
- // Get the blob path as the rest of the Uri
- Uri blobPathUri = containerUri.MakeRelativeUri(blobAddress);
- string blobPath = blobPathUri.OriginalString;
-
- delimiter = Uri.EscapeUriString(delimiter);
- if (blobPath.EndsWith(delimiter, StringComparison.Ordinal))
- {
- blobPath = blobPath.Substring(0, blobPath.Length - delimiter.Length);
- }
-
- string parentName = null;
-
- if (string.IsNullOrEmpty(blobPath))
- {
- // Case 1 /[Delimiter]*? => /
- // Parent of container is container itself
- parentName = null;
- }
- else
- {
- int parentLength = blobPath.LastIndexOf(delimiter, StringComparison.Ordinal);
-
- if (parentLength <= 0)
- {
- // Case 2 //
- // Parent of a folder is container
- parentName = null;
- }
- else
- {
- // Case 3 ///[/]*
- // Parent of blob is folder
- parentName = Uri.UnescapeDataString(blobPath.Substring(0, parentLength + delimiter.Length));
- if (parentName == containerName)
- {
- parentName = null;
- }
- }
- }
-
- return parentName;
- }
-
- ///
- /// Retrieves the parent address for a blob Uri.
- ///
- /// The blob address.
- /// The delimiter.
- /// If set to true use path style Uris.
- /// The address of the parent.
- ///
- /// GetParentName(new Uri("http://test.blob.core.windows.net/mycontainer/myfolder/myblob", null))
- /// will return "http://test.blob.core.windows.net/mycontainer/myfolder/"
- ///
- internal static Uri GetParentAddress(Uri blobAddress, string delimiter, bool? usePathStyleUris)
- {
- string parentName = GetParentName(blobAddress, delimiter, usePathStyleUris);
- if (parentName == null)
- {
- return null;
- }
-
- Uri parentUri = NavigationHelper.AppendPathToUri(NavigationHelper.GetServiceClientBaseAddress(blobAddress, usePathStyleUris), parentName);
- return parentUri;
- }
-
- ///
- /// Gets the service client base address.
- ///
- /// The address Uri.
- /// The use path style Uris.
- /// The base address of the client.
- ///
- /// GetServiceClientBaseAddress("http://testaccount.blob.core.windows.net/testcontainer/blob1")
- /// returns "http://testaccount.blob.core.windows.net"
- ///
- internal static Uri GetServiceClientBaseAddress(Uri addressUri, bool? usePathStyleUris)
- {
- if (usePathStyleUris == null)
- {
- // Automatically determine whether to use path style vs host style uris
- usePathStyleUris = CommonUtility.UsePathStyleAddressing(addressUri);
- }
-
- Uri authority = new Uri(addressUri.GetComponents(UriComponents.SchemeAndServer, UriFormat.UriEscaped));
- if (usePathStyleUris.Value)
- {
- // Path style uri
- string[] segments = addressUri.Segments;
- if (segments.Length < 2)
- {
- string error = string.Format(CultureInfo.CurrentCulture, SR.PathStyleUriMissingAccountNameInformation);
- throw new ArgumentException("address", error);
- }
-
- return new Uri(authority, segments[1]);
- }
- else
- {
- return authority;
- }
- }
-
- ///
- /// Appends a path to a URI correctly using "/" as separator.
- ///
- /// The base URI.
- /// The relative or absolute URI.
- /// The appended Uri.
- ///
- /// AppendPathToUri(new Uri("http://test.blob.core.windows.net/test", "abc")
- /// will return "http://test.blob.core.windows.net/test/abc"
- /// AppendPathToUri(new Uri("http://test.blob.core.windows.net/test"), "http://test.blob.core.windows.net/test/abc")
- /// will return "http://test.blob.core.windows.net/test/abc"
- ///
- internal static Uri AppendPathToUri(Uri uri, string relativeOrAbsoluteUri)
- {
- return AppendPathToUri(uri, relativeOrAbsoluteUri, NavigationHelper.Slash);
- }
-
- ///
- /// Append a relative path to a URI, handling trailing slashes appropriately.
- ///
- /// The base URI.
- /// The relative or absolute URI.
- /// The separator.
- /// The appended Uri.
- internal static Uri AppendPathToUri(Uri uri, string relativeOrAbsoluteUri, string sep)
- {
- Uri relativeUri;
-
- // Because of URI's Scheme, URI.TryCreate() can't differentiate a string with colon from an absolute URI.
- // A workaround is added here to verify if a given string is an absolute URI.
- if (Uri.TryCreate(relativeOrAbsoluteUri, UriKind.Absolute, out relativeUri) && (relativeUri.Scheme == "http" || relativeUri.Scheme == "https"))
- {
- // Handle case if relPath is an absolute Uri
- if (uri.IsBaseOf(relativeUri))
- {
- return relativeUri;
- }
- else
- {
- // Happens when using fiddler, DNS aliases, or potentially NATs
- Uri absoluteUri = new Uri(relativeOrAbsoluteUri);
- return new Uri(uri, absoluteUri.AbsolutePath);
- }
- }
-
- sep = Uri.EscapeUriString(sep);
- relativeOrAbsoluteUri = Uri.EscapeUriString(relativeOrAbsoluteUri);
-
- UriBuilder ub = new UriBuilder(uri);
- string appendString = null;
- if (ub.Path.EndsWith(sep, StringComparison.Ordinal))
- {
- appendString = relativeOrAbsoluteUri;
- }
- else
- {
- appendString = sep + relativeOrAbsoluteUri;
- }
-
- ub.Path += appendString;
- return ub.Uri;
- }
-
- ///
- /// Get container name from address for styles of paths
- /// Example: http://test.blob.core.windows.net/container/blob => container
- /// http://127.0.0.1:10000/test/container/blob => container.
- ///
- /// The container Uri.
- /// If set to true use path style Uris.
- /// The container name.
- internal static string GetContainerNameFromContainerAddress(Uri uri, bool? usePathStyleUris)
- {
- if (usePathStyleUris == null)
- {
- // Automatically determine whether to use path style vs host style uris
- usePathStyleUris = CommonUtility.UsePathStyleAddressing(uri);
- }
-
- if (usePathStyleUris.Value)
- {
- string[] parts = uri.AbsolutePath.Split(NavigationHelper.SlashAsSplitOptions);
-
- if (parts.Length < 3)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.MissingAccountInformationInUri, uri.AbsoluteUri);
- throw new InvalidOperationException(errorMessage);
- }
-
- return parts[2];
- }
- else
- {
- return uri.AbsolutePath.Substring(1);
- }
- }
-
- ///
- /// Gets the canonical path from creds.
- ///
- /// The credentials.
- /// The absolute path.
- /// The canonical path.
- internal static string GetCanonicalPathFromCreds(StorageCredentials credentials, string absolutePath)
- {
- string account = credentials.AccountName;
-
- if (account == null)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotCreateSASSignatureForGivenCred);
- throw new InvalidOperationException(errorMessage);
- }
-
- return NavigationHelper.Slash + account + absolutePath;
- }
-
- ///
- /// Similar to getting container name from Uri.
- ///
- /// The queue Uri.
- /// If set to true use path style Uris.
- /// The queue name.
- internal static string GetQueueNameFromUri(Uri uri, bool? usePathStyleUris)
- {
- return GetContainerNameFromContainerAddress(uri, usePathStyleUris);
- }
-
- ///
- /// Extracts a table name from the table's Uri.
- ///
- /// The queue Uri.
- /// If set to true use path style Uris.
- /// The queue name.
- internal static string GetTableNameFromUri(Uri uri, bool? usePathStyleUris)
- {
- return GetContainerNameFromContainerAddress(uri, usePathStyleUris);
- }
-
- ///
- /// Retrieve the container address and address.
- ///
- /// The blob address.
- /// True to use path style Uris.
- /// Name of the container.
- /// The container URI.
- private static void GetContainerNameAndAddress(Uri blobAddress, bool? usePathStyleUris, out string containerName, out Uri containerUri)
- {
- containerName = GetContainerName(blobAddress, usePathStyleUris);
- containerUri = NavigationHelper.AppendPathToUri(GetServiceClientBaseAddress(blobAddress, usePathStyleUris), containerName);
- }
-
- ///
- /// Retrieve the container name and the blob name from a blob address.
- ///
- /// The blob address.
- /// If set to true use path style Uris.
- /// The resulting container name.
- /// The resulting blob name.
- private static void GetContainerNameAndBlobName(Uri blobAddress, bool? usePathStyleUris, out string containerName, out string blobName)
- {
- CommonUtility.AssertNotNull("blobAddress", blobAddress);
-
- if (usePathStyleUris == null)
- {
- // Automatically determine whether to use path style vs host style uris
- usePathStyleUris = CommonUtility.UsePathStyleAddressing(blobAddress);
- }
-
- string[] addressParts = blobAddress.Segments;
-
- int containerIndex = usePathStyleUris.Value ? 2 : 1;
- int firstBlobIndex = containerIndex + 1;
-
- if (addressParts.Length - 1 < containerIndex)
- {
- // No reference appears to any container or blob
- string error = string.Format(CultureInfo.CurrentCulture, SR.MissingContainerInformation, blobAddress);
- throw new ArgumentException(error, "blobAddress");
- }
- else if (addressParts.Length - 1 == containerIndex)
- {
- // This is either the root directory of a container or a blob in the root container
- string containerOrBlobName = addressParts[containerIndex];
- if (containerOrBlobName[containerOrBlobName.Length - 1] == SlashChar)
- {
- // This is the root directory of a container
- containerName = containerOrBlobName.Trim(SlashChar);
- blobName = string.Empty;
- }
- else
- {
- // This is a blob implicitly in the root container
- containerName = RootContainerName;
- blobName = containerOrBlobName;
- }
- }
- else
- {
- // This is a blob in an explicit container
- containerName = addressParts[containerIndex].Trim(SlashChar);
- string[] blobNameSegments = new string[addressParts.Length - firstBlobIndex];
- Array.Copy(addressParts, firstBlobIndex, blobNameSegments, 0, blobNameSegments.Length);
- blobName = string.Concat(blobNameSegments);
- }
- }
-
- ///
- /// Parses the snapshot time.
- ///
- /// The snapshot time.
- /// The parsed snapshot time.
- internal static DateTimeOffset ParseSnapshotTime(string snapshot)
- {
- DateTimeOffset snapshotTime;
-
- if (!DateTimeOffset.TryParse(
- snapshot,
- CultureInfo.InvariantCulture,
- DateTimeStyles.AdjustToUniversal,
- out snapshotTime))
- {
- CommonUtility.ArgumentOutOfRange("snapshot", snapshot);
- }
-
- return snapshotTime;
- }
-
- ///
- /// Parse Uri for SAS (Shared access signature) information.
- ///
- /// The complete Uri.
- /// The credentials to use.
- /// The parsed snapshot.
- /// The blob URI without credentials or snapshot info
- /// address
- ///
- /// Validate that no other query parameters are passed in.
- /// Any SAS information will be recorded as corresponding credentials instance.
- /// If credentials is passed in and it does not match the SAS information found, an
- /// exception will be thrown.
- /// Otherwise a new client is created based on SAS information or as anonymous credentials.
- ///
- internal static Uri ParseBlobQueryAndVerify(Uri address, out StorageCredentials parsedCredentials, out DateTimeOffset? parsedSnapshot)
- {
- CommonUtility.AssertNotNull("address", address);
- if (!address.IsAbsoluteUri)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.RelativeAddressNotPermitted, address.ToString());
- throw new ArgumentException(errorMessage, "address");
- }
-
- IDictionary queryParameters = HttpWebUtility.ParseQueryString(address.Query);
-
- parsedSnapshot = null;
- string snapshot;
- if (queryParameters.TryGetValue(Constants.QueryConstants.Snapshot, out snapshot))
- {
- if (!string.IsNullOrEmpty(snapshot))
- {
- parsedSnapshot = ParseSnapshotTime(snapshot);
- }
- }
-
- parsedCredentials = SharedAccessSignatureHelper.ParseQuery(queryParameters, true);
- return new Uri(address.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped));
- }
-
- ///
- /// Parse Uri for SAS (Shared access signature) information.
- ///
- /// The complete Uri.
- /// The credentials to use.
- ///
- /// Validate that no other query parameters are passed in.
- /// Any SAS information will be recorded as corresponding credentials instance.
- /// If credentials is passed in and it does not match the SAS information found, an
- /// exception will be thrown.
- /// Otherwise a new client is created based on SAS information or as anonymous credentials.
- ///
- internal static Uri ParseQueueTableQueryAndVerify(Uri address, out StorageCredentials parsedCredentials)
- {
- CommonUtility.AssertNotNull("address", address);
- if (!address.IsAbsoluteUri)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.RelativeAddressNotPermitted, address.ToString());
- throw new ArgumentException(errorMessage, "address");
- }
-
- IDictionary queryParameters = HttpWebUtility.ParseQueryString(address.Query);
-
- parsedCredentials = SharedAccessSignatureHelper.ParseQuery(queryParameters, false);
- return new Uri(address.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped));
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/PlatformAgnosticReflectionExtensions.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/PlatformAgnosticReflectionExtensions.cs
deleted file mode 100644
index 09fa3b09c44f4..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/PlatformAgnosticReflectionExtensions.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Util
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
-
- ///
- /// Represents a canonicalized string used in authenticating a request against the azure service.
- ///
- internal static class PlatformAgnosticReflectionExtensions
- {
- public static IEnumerable FindStaticMethods(this Type type, string name)
- {
-#if WINDOWS_RT
- return type.GetRuntimeMethods();
-#else
- // Note currently this looks for nonpublic statics and instance methods, may need to be updated in future to accomodate publics
- return type.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static).Where((m) => m.Name == name);
-#endif
- }
-
- public static IEnumerable FindMethods(this Type type)
- {
-#if WINDOWS_RT
- return type.GetRuntimeMethods();
-#else
- return type.GetMethods();
-#endif
- }
-
- public static MethodInfo FindMethod(this Type type, string name, Type[] parameters)
- {
-#if WINDOWS_RT
- return type.GetRuntimeMethod(name, parameters);
-#else
- return type.GetMethod(name, parameters);
-#endif
- }
-
- public static PropertyInfo FindProperty(this Type type, string name)
- {
-#if WINDOWS_RT
- return type.GetRuntimeProperty(name);
-#else
- // Currently this looks for instance public / non publics, may need to be updated to support wider selection
- return type.GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
-#endif
- }
-
- public static MethodInfo FindGetProp(this PropertyInfo property)
- {
-#if WINDOWS_RT
- return property.GetMethod;
-#else
- return property.GetGetMethod();
-#endif
- }
-
- public static MethodInfo FindSetProp(this PropertyInfo property)
- {
-#if WINDOWS_RT
- return property.SetMethod;
-#else
- return property.GetSetMethod();
-#endif
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/StreamDescriptor.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/StreamDescriptor.cs
deleted file mode 100644
index dbbfc184e28ae..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/StreamDescriptor.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Util
-{
- using System.Threading;
-
- ///
- /// Provides properties to keep track of Md5 hash / Length of a stream as it is being copied.
- ///
- internal class StreamDescriptor
- {
- private long length = 0;
-
- public long Length
- {
- get { return Interlocked.Read(ref this.length); }
- set { Interlocked.Exchange(ref this.length, value); }
- }
-
- private volatile string md5 = null;
-
- public string Md5
- {
- get { return this.md5; }
- set { this.md5 = value; }
- }
-
- private volatile MD5Wrapper md5HashRef = null;
-
- public MD5Wrapper Md5HashRef
- {
- get { return this.md5HashRef; }
- set { this.md5HashRef = value; }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/StreamExtensions.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/StreamExtensions.cs
deleted file mode 100644
index 4ee52d2aef2fb..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Core/Util/StreamExtensions.cs
+++ /dev/null
@@ -1,353 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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.Util
-{
- using Microsoft.WindowsAzure.Storage.Core.Executor;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Diagnostics;
- using System.Diagnostics.CodeAnalysis;
- using System.IO;
- using System.Threading;
-
-#if WINDOWS_RT
- using System.Threading.Tasks;
-#endif
-
- ///
- /// Provides stream helper methods that allow us to copy streams and measure the stream size.
- ///
- internal static class StreamExtensions
- {
- [DebuggerNonUserCode]
- internal static int GetBufferSize(Stream inStream)
- {
- if (inStream.CanSeek && inStream.Length - inStream.Position > 0)
- {
- return (int)Math.Min(inStream.Length - inStream.Position, (long)Constants.DefaultBufferSize);
- }
- else
- {
- return Constants.DefaultBufferSize;
- }
- }
-
-#if !WINDOWS_RT
- ///
- /// Reads synchronously the specified content of the stream and writes it to the given output stream.
- ///
- /// The origin stream.
- /// The destination stream.
- /// Number of bytes to copy from source stream to destination stream. Cannot be passed with a value for maxLength.
- /// Maximum length of the stream to write.
- /// true to calculate the MD5 hash.
- /// A boolean indicating whether the write happens synchronously.
- /// An object that stores state of the operation.
- /// State of the stream copy.
- /// stream
- [DebuggerNonUserCode]
- [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "Reviewed")]
- internal static void WriteToSync(this Stream stream, Stream toStream, long? copyLength, long? maxLength, bool calculateMd5, bool syncRead, ExecutionState executionState, StreamDescriptor streamCopyState)
- {
- if (copyLength.HasValue && maxLength.HasValue)
- {
- throw new ArgumentException(SR.StreamLengthMismatch);
- }
-
- if (stream.CanSeek && maxLength.HasValue && stream.Length - stream.Position > maxLength)
- {
- throw new InvalidOperationException(SR.StreamLengthError);
- }
-
- if (stream.CanSeek && copyLength.HasValue && stream.Length - stream.Position < copyLength)
- {
- throw new ArgumentOutOfRangeException("copyLength", SR.StreamLengthShortError);
- }
-
- byte[] buffer = new byte[GetBufferSize(stream)];
-
- if (streamCopyState != null && calculateMd5 && streamCopyState.Md5HashRef == null)
- {
- streamCopyState.Md5HashRef = new MD5Wrapper();
- }
-
- RegisteredWaitHandle waitHandle = null;
- ManualResetEvent completedEvent = null;
- if (!syncRead && executionState.OperationExpiryTime.HasValue)
- {
- completedEvent = new ManualResetEvent(false);
- waitHandle = ThreadPool.RegisterWaitForSingleObject(
- completedEvent,
- StreamExtensions.MaximumCopyTimeCallback,
- executionState,
- executionState.RemainingTimeout,
- true);
- }
-
- try
- {
- long? bytesRemaining = copyLength;
- int readCount;
- do
- {
- if (executionState.OperationExpiryTime.HasValue && DateTime.Now.CompareTo(executionState.OperationExpiryTime.Value) > 0)
- {
- throw Exceptions.GenerateTimeoutException(executionState.Cmd != null ? executionState.Cmd.CurrentResult : null, null);
- }
-
- // Determine how many bytes to read this time so that no more than copyLength bytes are read
- int bytesToRead = MinBytesToRead(bytesRemaining, buffer.Length);
-
- if (bytesToRead == 0)
- {
- break;
- }
-
- // Read synchronously or asynchronously
- readCount = syncRead
- ? stream.Read(buffer, 0, bytesToRead)
- : stream.EndRead(stream.BeginRead(buffer, 0, bytesToRead, null /* Callback */, null /* State */));
-
- // Decrement bytes to write from bytes read
- if (bytesRemaining.HasValue)
- {
- bytesRemaining -= readCount;
- }
-
- // Write
- if (readCount > 0)
- {
- toStream.Write(buffer, 0, readCount);
-
- // Update the StreamDescriptor after the bytes are successfully committed to the output stream
- if (streamCopyState != null)
- {
- 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);
-
- if (bytesRemaining.HasValue && bytesRemaining != 0)
- {
- throw new ArgumentOutOfRangeException("copyLength", SR.StreamLengthShortError);
- }
- }
- catch (Exception)
- {
- if (executionState.OperationExpiryTime.HasValue && DateTime.Now.CompareTo(executionState.OperationExpiryTime.Value) > 0)
- {
- throw Exceptions.GenerateTimeoutException(executionState.Cmd != null ? executionState.Cmd.CurrentResult : null, null);
- }
- else
- {
- throw;
- }
- }
- finally
- {
- if (waitHandle != null)
- {
- waitHandle.Unregister(null);
- }
-
- if (completedEvent != null)
- {
- completedEvent.Close();
- }
- }
-
- if (streamCopyState != null && streamCopyState.Md5HashRef != null)
- {
- streamCopyState.Md5 = streamCopyState.Md5HashRef.ComputeHash();
- streamCopyState.Md5HashRef = null;
- }
- }
-
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "If aborting the request fails, we can still continue executing it.")]
- private static void MaximumCopyTimeCallback(object state, bool timedOut)
- {
- ExecutionState executionState = (ExecutionState)state;
-
- if (timedOut)
- {
- if (executionState.Req != null)
- {
- try
- {
- executionState.ReqTimedOut = true;
- executionState.Req.Abort();
- }
- catch (Exception)
- {
- // no op
- }
- }
- }
- }
-
- private static int MinBytesToRead(long? val1, int val2)
- {
- if (val1.HasValue && val1 < val2)
- {
- return (int)val1;
- }
-
- return val2;
- }
-#endif
-
-#if WINDOWS_RT
- ///
- /// Asynchronously reads the entire content of the stream and writes it to the given output stream.
- ///
- /// The origin stream.
- /// The destination stream.
- /// Number of bytes to copy from source stream to destination stream. Cannot be passed with a value for maxLength.
- /// Maximum length of the source stream. Cannot be passed with a value for copyLength.
- /// Bool value indicating whether the Md5 should be calculated.
- /// An object that stores state of the operation.
- /// An object that represents the current state for the copy operation.
- /// A CancellationToken to observe while waiting for the copy to complete.
- /// The task object representing the asynchronous operation.
- internal static async Task WriteToAsync(this Stream stream, Stream toStream, long? copyLength, long? maxLength, bool calculateMd5, ExecutionState executionState, StreamDescriptor streamCopyState, CancellationToken token)
- {
- if (copyLength.HasValue && maxLength.HasValue)
- {
- throw new ArgumentException(SR.StreamLengthMismatch);
- }
-
- if (stream.CanSeek && maxLength.HasValue && stream.Length - stream.Position > maxLength)
- {
- throw new InvalidOperationException(SR.StreamLengthError);
- }
-
- if (stream.CanSeek && copyLength.HasValue && stream.Length - stream.Position < copyLength)
- {
- throw new ArgumentOutOfRangeException("copyLength", SR.StreamLengthShortError);
- }
-
- if (streamCopyState != null && calculateMd5 && streamCopyState.Md5HashRef == null)
- {
- 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;
- }
-
- byte[] buffer = new byte[GetBufferSize(stream)];
- long? bytesRemaining = copyLength;
- int readCount;
- do
- {
- // 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)
- {
- break;
- }
-
- readCount = await stream.ReadAsync(buffer, 0, bytesToRead, token);
-
- if (bytesRemaining.HasValue)
- {
- bytesRemaining -= readCount;
- }
-
- if (readCount > 0)
- {
- await toStream.WriteAsync(buffer, 0, readCount, token);
-
- // Update the StreamDescriptor after the bytes are successfully committed to the output stream
- if (streamCopyState != null)
- {
- 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);
-
- if (bytesRemaining.HasValue && bytesRemaining != 0)
- {
- throw new ArgumentOutOfRangeException("copyLength", SR.StreamLengthShortError);
- }
-
- // Streams opened with AsStreamForWrite extension need to be flushed
- // to write all buffered data to the underlying Windows Runtime stream.
- await toStream.FlushAsync();
-
- if (streamCopyState != null && streamCopyState.Md5HashRef != null)
- {
- streamCopyState.Md5 = streamCopyState.Md5HashRef.ComputeHash();
- streamCopyState.Md5HashRef = null;
- }
- }
-
-#elif WINDOWS_DESKTOP
- ///
- /// Asynchronously reads the entire content of the stream and writes it to the given output stream.
- ///
- /// The result type of the ExecutionState
- /// The origin stream.
- /// The destination stream.
- /// Number of bytes to copy from source stream to destination stream. Cannot be passed with a value for maxLength.
- /// Maximum length of the source stream. Cannot be passed with a value for copyLength.
- /// Bool value indicating whether the Md5 should be calculated.
- /// An object that stores state of the operation.
- /// State of the stream copy.
- /// The action taken when the execution is completed.
- [DebuggerNonUserCode]
- internal static void WriteToAsync(this Stream stream, Stream toStream, long? copyLength, long? maxLength, bool calculateMd5, ExecutionState executionState, StreamDescriptor streamCopyState, Action> completed)
- {
- AsyncStreamCopier copier = new AsyncStreamCopier(stream, toStream, executionState, GetBufferSize(stream), calculateMd5, streamCopyState);
- copier.StartCopyStream(completed, copyLength, maxLength);
- }
-#endif
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/DoesServiceRequest.cs b/microsoft-azure-api/Services/Storage/Lib/Common/DoesServiceRequest.cs
deleted file mode 100644
index 9510d447e2e24..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/DoesServiceRequest.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- using System.Diagnostics.CodeAnalysis;
-
- ///
- /// Specifies that the method will make one or more requests to the storage service.
- ///
- [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "Back compatibility.")]
- [System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple = false)]
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- sealed class DoesServiceRequest : System.Attribute
- {
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/IBufferManager.cs b/microsoft-azure-api/Services/Storage/Lib/Common/IBufferManager.cs
deleted file mode 100644
index 3db8b34b256bf..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/IBufferManager.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
-#if WINDOWS_RT
- using System.Runtime.InteropServices.WindowsRuntime;
-#endif
-
- ///
- /// An interface that allows clients to provide a buffer manager to a given service client. This interface is patterned after
- /// the System.ServiceModel.Channels.BufferManager class.
- ///
- public interface IBufferManager
- {
- ///
- /// Returns a buffer to the pool.
- ///
- /// A reference to the buffer being returned.
- /// Buffer reference cannot be null.
- /// Length of buffer does not match the pool's buffer length property.
-#if WINDOWS_RT
- void ReturnBuffer([ReadOnlyArray] byte[] buffer);
-#else
- void ReturnBuffer(byte[] buffer);
-#endif
-
- ///
- /// Gets a buffer of at least the specified size from the pool.
- ///
- /// The size, in bytes, of the requested buffer.
- /// The value specified for cannot be less than zero.
- /// A byte array that is the requested size of the buffer.
- byte[] TakeBuffer(int bufferSize);
-
- ///
- /// Gets the size, in bytes, of the buffers managed by the given pool. Note that the buffer manager must return buffers of the exact size requested by the client.
- ///
- /// The size, in bytes, of the buffers managed by the given pool.
- int GetDefaultBufferSize();
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/IContinuationToken.cs b/microsoft-azure-api/Services/Storage/Lib/Common/IContinuationToken.cs
deleted file mode 100644
index 771f55dacf6d0..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/IContinuationToken.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// An interface required for continuation token types.
- ///
- /// The , ,
- /// and classes implement the interface.
- public interface IContinuationToken
- {
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/IRequestOptions.cs b/microsoft-azure-api/Services/Storage/Lib/Common/IRequestOptions.cs
deleted file mode 100644
index b04645b1945bb..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/IRequestOptions.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- using Microsoft.WindowsAzure.Storage.RetryPolicies;
- using System;
-
- ///
- /// An interface required for request option types.
- ///
- /// The , , and classes implement the interface.
- public interface IRequestOptions
- {
- ///
- /// Gets or sets the retry policy for the request.
- ///
- /// The retry policy delegate.
- IRetryPolicy RetryPolicy { get; set; }
-
- ///
- /// Gets or sets the server timeout for the request.
- ///
- /// The client and server timeout interval for the request.
- TimeSpan? ServerTimeout { get; set; }
-
- ///
- /// Gets or sets the maximum execution time across all potential retries.
- ///
- /// The maximum execution time across all potential retries.
- TimeSpan? MaximumExecutionTime { get; set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/LogLevel.cs b/microsoft-azure-api/Services/Storage/Lib/Common/LogLevel.cs
deleted file mode 100644
index 86385380ce9f8..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/LogLevel.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- ///
- /// Specifies what messages to output to the log.
- ///
- public enum LogLevel
- {
- ///
- /// Output no tracing and debugging messages.
- ///
- Off = 0,
-
- ///
- /// Output error-handling messages.
- ///
- Error,
-
- ///
- /// Output warnings and error-handling messages.
- ///
- Warning,
-
- ///
- /// Output informational messages, warnings, and error-handling messages.
- ///
- Informational,
-
- ///
- /// Output all debugging and tracing messages.
- ///
- Verbose,
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/OperationContext.cs b/microsoft-azure-api/Services/Storage/Lib/Common/OperationContext.cs
deleted file mode 100644
index 0e9b7c84150df..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/OperationContext.cs
+++ /dev/null
@@ -1,167 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
-
- ///
- /// Represents the context for a request operation against the storage service, and provides additional runtime information about its execution.
- ///
- public sealed class OperationContext
- {
- static OperationContext()
- {
- OperationContext.DefaultLogLevel = LogLevel.Verbose;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public OperationContext()
- {
- this.ClientRequestID = Guid.NewGuid().ToString();
- this.LogLevel = OperationContext.DefaultLogLevel;
- }
-
- #region Headers
-
- ///
- /// Gets or sets additional headers on the request, for example, for proxy or logging information.
- ///
- /// A object containing additional header information.
- public IDictionary UserHeaders { get; set; }
-
- ///
- /// Gets or sets the client request ID.
- ///
- /// The client request ID.
- [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ID", Justification = "Back compatibility.")]
- public string ClientRequestID { get; set; }
-
- #endregion
-
- #region Events
-
- ///
- /// Gets or sets the default logging level to be used for subsequently created instances of the class.
- ///
- /// A value of type that specifies which events are logged by default by instances of the .
- public static LogLevel DefaultLogLevel { get; set; }
-
- ///
- /// Gets or sets the logging level to be used for an instance of the class.
- ///
- /// A value of type that specifies which events are logged by the .
- public LogLevel LogLevel { get; set; }
-
- ///
- /// Occurs immediately before a request is signed.
- ///
- public event EventHandler SendingRequest;
-
- ///
- /// Occurs when a response is received from the server.
- ///
- public event EventHandler ResponseReceived;
-
- internal void FireSendingRequest(RequestEventArgs args)
- {
- EventHandler handler = this.SendingRequest;
- if (handler != null)
- {
- handler(this, args);
- }
- }
-
- internal void FireResponseReceived(RequestEventArgs args)
- {
- EventHandler handler = this.ResponseReceived;
- if (handler != null)
- {
- handler(this, args);
- }
- }
- #endregion
-
- #region Times
-#if WINDOWS_RT
- ///
- /// Gets or sets the start time of the operation.
- ///
- /// The start time of the operation.
- public System.DateTimeOffset StartTime { get; set; }
-
- ///
- /// Gets or sets the end time of the operation.
- ///
- /// The end time of the operation.
- public System.DateTimeOffset EndTime { get; set; }
-#else
- ///
- /// Gets or sets the start time of the operation.
- ///
- /// The start time of the operation.
- public DateTime StartTime { get; set; }
-
- ///
- /// Gets or sets the end time of the operation.
- ///
- /// The end time of the operation.
- public DateTime EndTime { get; set; }
-#endif
- #endregion
-
- #region Request Results
-
- private IList requestResults = new List();
-
- ///
- /// Gets or sets the set of request results that the current operation has created.
- ///
- /// An object that contains objects that represent the request results created by the current operation.
- public IList RequestResults
- {
- get
- {
- return this.requestResults;
- }
- }
-
- ///
- /// Gets the last request result encountered for the operation.
- ///
- /// A object that represents the last request result.
- public RequestResult LastResult
- {
- get
- {
- if (this.requestResults == null || this.requestResults.Count == 0)
- {
- return null;
- }
- else
- {
- return this.requestResults[this.requestResults.Count - 1];
- }
- }
- }
- #endregion
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Properties/AssemblyInfo.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Properties/AssemblyInfo.cs
deleted file mode 100644
index e16d055cb7aa1..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System.Resources;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Common")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Microsoft")]
-[assembly: AssemblyProduct("Common")]
-[assembly: AssemblyCopyright("Copyright © Microsoft 2012")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-[assembly: NeutralResourcesLanguage("en")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// 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("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/CloudQueue.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/CloudQueue.Common.cs
deleted file mode 100644
index e371e532e9209..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/CloudQueue.Common.cs
+++ /dev/null
@@ -1,256 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue
-{
- 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.Queue.Protocol;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
-
- ///
- /// This class represents a queue in the Windows Azure Queue service.
- ///
- [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix", Justification = "Reviewed.")]
- public sealed partial class CloudQueue
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The absolute URI to the queue.
- public CloudQueue(Uri queueAddress)
- : this(queueAddress, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The absolute URI to the queue.
- /// The account credentials.
- public CloudQueue(Uri queueAddress, StorageCredentials credentials)
- {
- this.ParseQueryAndVerify(queueAddress, credentials);
- this.Metadata = new Dictionary();
- this.EncodeMessage = true;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The queue name.
- /// A client object that specifies the endpoint for the queue service.
- internal CloudQueue(string queueName, CloudQueueClient serviceClient)
- {
- this.Uri = NavigationHelper.AppendPathToUri(serviceClient.BaseUri, queueName);
- this.ServiceClient = serviceClient;
- this.Name = queueName;
- this.Metadata = new Dictionary();
- this.EncodeMessage = true;
- }
-
- ///
- /// Gets the service client for the queue.
- ///
- /// A client object that specifies the endpoint for the queue service.
- public CloudQueueClient ServiceClient { get; private set; }
-
- ///
- /// Gets the queue's URI.
- ///
- /// The absolute URI to the queue.
- public Uri Uri { get; private set; }
-
- ///
- /// Gets the name of the queue.
- ///
- /// The queue's name.
- public string Name { get; private set; }
-
- ///
- /// Gets the approximate message count for the queue.
- ///
- /// The approximate message count.
- public int? ApproximateMessageCount { get; private set; }
-
- ///
- /// Gets or sets a value indicating whether to apply base64 encoding when adding or retrieving messages.
- ///
- /// True to encode messages; otherwise, false. The default value is true.
- public bool EncodeMessage { get; set; }
-
- ///
- /// Gets the queue's metadata.
- ///
- /// The queue's metadata.
- public IDictionary Metadata { get; private set; }
-
- ///
- /// Uri for the messages.
- ///
- private Uri messageRequestAddress;
-
- ///
- /// Gets the Uri for general message operations.
- ///
- internal Uri GetMessageRequestAddress()
- {
- if (this.messageRequestAddress == null)
- {
- this.messageRequestAddress = NavigationHelper.AppendPathToUri(this.Uri, Constants.Messages);
- }
-
- return this.messageRequestAddress;
- }
-
- ///
- /// Gets the individual message address.
- ///
- /// The message id.
- /// The URI of the message.
- internal Uri GetIndividualMessageAddress(string messageId)
- {
- Uri individualMessageUri = NavigationHelper.AppendPathToUri(this.GetMessageRequestAddress(), messageId);
-
- return individualMessageUri;
- }
-
- ///
- /// Parse URI for SAS (Shared Access Signature) information.
- ///
- /// The complete Uri.
- /// The credentials to use.
- private void ParseQueryAndVerify(Uri address, StorageCredentials credentials)
- {
- StorageCredentials parsedCredentials;
- this.Uri = NavigationHelper.ParseQueueTableQueryAndVerify(address, out parsedCredentials);
-
- if ((parsedCredentials != null) && (credentials != null) && !parsedCredentials.Equals(credentials))
- {
- string error = string.Format(CultureInfo.CurrentCulture, SR.MultipleCredentialsProvided);
- throw new ArgumentException(error);
- }
-
- this.ServiceClient = new CloudQueueClient(NavigationHelper.GetServiceClientBaseAddress(this.Uri, null), credentials ?? parsedCredentials);
- this.Name = NavigationHelper.GetQueueNameFromUri(this.Uri, this.ServiceClient.UsePathStyleUris);
- }
-
- ///
- /// Returns the canonical name for shared access.
- ///
- /// The canonical name.
- private string GetCanonicalName()
- {
- if (this.ServiceClient.UsePathStyleUris)
- {
- return this.Uri.AbsolutePath;
- }
- else
- {
- return NavigationHelper.GetCanonicalPathFromCreds(this.ServiceClient.Credentials, this.Uri.AbsolutePath);
- }
- }
-
- ///
- /// Selects the get message response.
- ///
- /// The protocol message.
- /// The parsed message.
- private CloudQueueMessage SelectGetMessageResponse(QueueMessage protocolMessage)
- {
- CloudQueueMessage message = this.SelectPeekMessageResponse(protocolMessage);
- message.PopReceipt = protocolMessage.PopReceipt;
-
- if (protocolMessage.NextVisibleTime.HasValue)
- {
- message.NextVisibleTime = protocolMessage.NextVisibleTime.Value;
- }
-
- return message;
- }
-
- ///
- /// Selects the peek message response.
- ///
- /// The protocol message.
- /// The parsed message.
- private CloudQueueMessage SelectPeekMessageResponse(QueueMessage protocolMessage)
- {
- CloudQueueMessage message = null;
- if (this.EncodeMessage)
- {
- // if EncodeMessage is true, we assume the string returned from server is Base64 encoding of original message;
- // if this is not true, exception will likely be thrown.
- // it is user's responsibility to make sure EncodeMessage setting matches the queue that is being read.
- message = new CloudQueueMessage(protocolMessage.Text, true);
- }
- else
- {
- message = new CloudQueueMessage(protocolMessage.Text);
- }
-
- message.Id = protocolMessage.Id;
- message.InsertionTime = protocolMessage.InsertionTime;
- message.ExpirationTime = protocolMessage.ExpirationTime;
- message.DequeueCount = protocolMessage.DequeueCount;
-
- // PopReceipt and TimeNextVisible are not returned during peek
- return message;
- }
-
- ///
- /// Returns a shared access signature for the queue.
- ///
- /// The access policy for the shared access signature.
- /// A queue-level access policy.
- /// A shared access signature, as a URI query string.
- /// The query string returned includes the leading question mark.
- public string GetSharedAccessSignature(SharedAccessQueuePolicy policy, string accessPolicyIdentifier)
- {
- if (!this.ServiceClient.Credentials.IsSharedKey)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotCreateSASWithoutAccountKey);
- throw new InvalidOperationException(errorMessage);
- }
-
- string resourceName = this.GetCanonicalName();
- StorageAccountKey accountKey = this.ServiceClient.Credentials.Key;
-
- string signature = SharedAccessSignatureHelper.GetSharedAccessSignatureHashImpl(
- policy,
- accessPolicyIdentifier,
- resourceName,
- accountKey.KeyValue);
-
- string accountKeyName = accountKey.KeyName;
-
- UriQueryBuilder builder = SharedAccessSignatureHelper.GetSharedAccessSignatureImpl(
- policy,
- accessPolicyIdentifier,
- signature,
- accountKeyName);
-
- return builder.ToString();
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/CloudQueueClient.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/CloudQueueClient.Common.cs
deleted file mode 100644
index 9429c186b5e14..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/CloudQueueClient.Common.cs
+++ /dev/null
@@ -1,206 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue
-{
- 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;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Globalization;
-
- ///
- /// 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
- {
- ///
- /// The default server and client timeout interval.
- ///
- private TimeSpan? timeout;
-
- ///
- /// Max execution time across all potential retries.
- ///
- private TimeSpan? maximumExecutionTime;
-
- private AuthenticationScheme authenticationScheme;
-
- ///
- /// Initializes a new instance of the class using the specified queue service endpoint
- /// and anonymous credentials.
- ///
- /// The queue service endpoint to use to create the client.
- public CloudQueueClient(Uri baseUri)
- : this(baseUri, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class using the specified queue service endpoint
- /// and account credentials.
- ///
- /// The queue service endpoint to use to create the client.
- /// The account credentials.
- public CloudQueueClient(Uri baseUri, StorageCredentials credentials)
- : this(null, baseUri, credentials)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// True to use path style Uris.
- /// The queue service endpoint to use to create the client.
- /// The account credentials.
- internal CloudQueueClient(bool? usePathStyleUris, Uri baseUri, StorageCredentials credentials)
- {
- CommonUtility.AssertNotNull("baseUri", baseUri);
-
- if (credentials == null)
- {
- credentials = new StorageCredentials();
- }
-
- if (baseUri == null)
- {
- throw new ArgumentNullException("baseUri");
- }
-
- if (!baseUri.IsAbsoluteUri)
- {
- string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.RelativeAddressNotPermitted, baseUri.ToString());
- throw new ArgumentException(errorMessage, "baseUri");
- }
-
- this.BaseUri = baseUri;
- this.Credentials = credentials;
- this.RetryPolicy = new ExponentialRetry();
- this.ServerTimeout = Constants.DefaultServerSideTimeout;
- this.AuthenticationScheme = AuthenticationScheme.SharedKey;
-
- if (usePathStyleUris.HasValue)
- {
- this.UsePathStyleUris = usePathStyleUris.Value;
- }
- else
- {
- // Automatically decide whether to use host style uri or path style uri
- this.UsePathStyleUris = CommonUtility.UsePathStyleAddressing(this.BaseUri);
- }
- }
-
- ///
- /// Gets or sets a buffer manager that implements the interface,
- /// specifying a buffer pool for use with operations against the Queue service client.
- ///
- public IBufferManager BufferManager { get; set; }
-
- ///
- /// Gets the account credentials used to create the queue service client.
- ///
- /// The account credentials.
- public StorageCredentials Credentials { get; private set; }
-
- ///
- /// Gets the base URI for the Queue service client.
- ///
- /// The base URI used to construct the Queue service client.
- public Uri BaseUri { get; private set; }
-
- ///
- /// Gets or sets the default retry policy for requests made via the Queue service client.
- ///
- /// The retry policy.
- public IRetryPolicy RetryPolicy { get; set; }
-
- ///
- /// Gets or sets the default server and client timeout for requests made via the Queue service client.
- ///
- /// The server and client timeout interval.
- public TimeSpan? ServerTimeout
- {
- get
- {
- return this.timeout;
- }
-
- set
- {
- if (value.HasValue)
- {
- CommonUtility.CheckTimeoutBounds(value.Value);
- }
-
- this.timeout = value;
- }
- }
-
- ///
- /// Gets or sets the maximum execution time across all potential retries.
- ///
- /// The maximum execution time across all potential retries.
- public TimeSpan? MaximumExecutionTime
- {
- get
- {
- return this.maximumExecutionTime;
- }
-
- set
- {
- if (value.HasValue)
- {
- CommonUtility.CheckTimeoutBounds(value.Value);
- }
-
- this.maximumExecutionTime = value;
- }
- }
-
- ///
- /// Gets a value indicating whether the service client is used with Path style or Host style.
- ///
- /// Is true if use path style uris; otherwise, false.
- internal bool UsePathStyleUris { get; private set; }
-
- ///
- /// Returns a reference to a object with the specified name.
- ///
- /// The name of the queue, or an absolute URI to the queue.
- /// A reference to a queue.
- public CloudQueue GetQueueReference(string queueName)
- {
- CommonUtility.AssertNotNullOrEmpty("queueName", queueName);
- return new CloudQueue(queueName, this);
- }
-
- private ICanonicalizer GetCanonicalizer()
- {
- if (this.AuthenticationScheme == AuthenticationScheme.SharedKeyLite)
- {
- return SharedKeyLiteCanonicalizer.Instance;
- }
-
- return SharedKeyCanonicalizer.Instance;
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/CloudQueueMessage.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/CloudQueueMessage.Common.cs
deleted file mode 100644
index c689edcd36786..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/CloudQueueMessage.Common.cs
+++ /dev/null
@@ -1,298 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue
-{
- using Microsoft.WindowsAzure.Storage.Core;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
- using System.Text;
-
- ///
- /// Represents a message in the Windows Azure Queue service.
- ///
- public sealed partial class CloudQueueMessage
- {
- ///
- /// The maximum message size in bytes.
- ///
- private const long MaximumMessageSize = 64 * Constants.KB;
-
- ///
- /// Gets the maximum message size in bytes.
- ///
- /// The maximum message size in bytes.
- public static long MaxMessageSize
- {
- get
- {
- return MaximumMessageSize;
- }
- }
-
- ///
- /// The maximum amount of time a message is kept in the queue.
- ///
- private static readonly TimeSpan MaximumTimeToLive = TimeSpan.FromDays(7);
-
- ///
- /// Gets the maximum amount of time a message is kept in the queue.
- ///
- /// The maximum amount of time a message is kept in the queue.
- public static TimeSpan MaxTimeToLive
- {
- get
- {
- return MaximumTimeToLive;
- }
- }
-
- ///
- /// The maximum number of messages that can be peeked at a time.
- ///
- private const int MaximumNumberOfMessagesToPeek = 32;
-
- ///
- /// Gets the maximum number of messages that can be peeked at a time.
- ///
- /// The maximum number of messages that can be peeked at a time.
- public static int MaxNumberOfMessagesToPeek
- {
- get
- {
- return MaximumNumberOfMessagesToPeek;
- }
- }
-
- ///
- /// Custom UTF8Encoder to throw exception in case of invalid bytes.
- ///
- private static UTF8Encoding utf8Encoder = new UTF8Encoding(false, true);
-
- ///
- /// Initializes a new instance of the class with the given byte array.
- ///
- internal CloudQueueMessage()
- {
- }
-
- ///
- /// Initializes a new instance of the class with the given string.
- ///
- /// The content of the message as a string of text.
- public CloudQueueMessage(string content)
- {
- this.SetMessageContent(content);
-
- // At this point, without knowing whether or not the message will be Base64 encoded, we can't fully validate the message size.
- // So we leave it to CloudQueue so that we have a central place for this logic.
- }
-
- ///
- /// Initializes a new instance of the class with the given message ID and pop receipt.
- ///
- /// The message ID.
- /// The pop receipt token.
- public CloudQueueMessage(string messageId, string popReceipt)
- {
- this.Id = messageId;
- this.PopReceipt = popReceipt;
- }
-
- ///
- /// Initializes a new instance of the class with the given Base64 encoded string.
- /// This method is only used internally.
- ///
- /// The text string.
- /// Whether the string is Base64 encoded.
- internal CloudQueueMessage(string content, bool isBase64Encoded)
- {
- if (content == null)
- {
- content = string.Empty;
- }
-
- this.RawString = content;
- this.MessageType = isBase64Encoded ? QueueMessageType.Base64Encoded : QueueMessageType.RawString;
- }
-
- ///
- /// Gets the content of the message as a byte array.
- ///
- /// The content of the message as a byte array.
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Reviewed.")]
- public byte[] AsBytes
- {
- get
- {
- if (this.MessageType == QueueMessageType.RawString)
- {
- return Encoding.UTF8.GetBytes(this.RawString);
- }
- else
- {
- return Convert.FromBase64String(this.RawString);
- }
- }
- }
-
- ///
- /// Gets the message ID.
- ///
- /// The message ID.
- public string Id { get; internal set; }
-
- ///
- /// Gets the message's pop receipt.
- ///
- /// The pop receipt value.
- public string PopReceipt { get; internal set; }
-
- ///
- /// Gets the time that the message was added to the queue.
- ///
- /// The time that the message was added to the queue.
- public DateTimeOffset? InsertionTime { get; internal set; }
-
- ///
- /// Gets the time that the message expires.
- ///
- /// The time that the message expires.
- public DateTimeOffset? ExpirationTime { get; internal set; }
-
- ///
- /// Gets the time that the message will next be visible.
- ///
- /// The time that the message will next be visible.
- public DateTimeOffset? NextVisibleTime { get; internal set; }
-
- ///
- /// Gets the content of the message, as a string.
- ///
- /// The message content.
- public string AsString
- {
- get
- {
- if (this.MessageType == QueueMessageType.RawString)
- {
- return this.RawString;
- }
- else
- {
- byte[] messageData = Convert.FromBase64String(this.RawString);
- return utf8Encoder.GetString(messageData, 0, messageData.Length);
- }
- }
- }
-
- ///
- /// Gets the number of times this message has been dequeued.
- ///
- /// The number of times this message has been dequeued.
- public int DequeueCount { get; internal set; }
-
- ///
- /// Gets message type that indicates if the RawString is the original message string or Base64 encoding of the original binary data.
- ///
- internal QueueMessageType MessageType { get; private set; }
-
- ///
- /// Gets or sets the original message string or Base64 encoding of the original binary data.
- ///
- /// The original message string.
- internal string RawString { get; set; }
-
- ///
- /// Gets the content of the message for transfer (internal use only).
- ///
- /// Indicates if the message should be encoded.
- /// The message content as a string.
- internal string GetMessageContentForTransfer(bool shouldEncodeMessage)
- {
- if (!shouldEncodeMessage && this.MessageType == QueueMessageType.Base64Encoded)
- {
- throw new ArgumentException(SR.BinaryMessageShouldUseBase64Encoding);
- }
-
- string outgoingMessageString = null;
- if (this.MessageType == QueueMessageType.RawString)
- {
- if (shouldEncodeMessage)
- {
- outgoingMessageString = Convert.ToBase64String(this.AsBytes);
-
- // the size of Base64 encoded string is the number of bytes this message will take up on server.
- if (outgoingMessageString.Length > CloudQueueMessage.MaxMessageSize)
- {
- throw new ArgumentException(string.Format(
- CultureInfo.InvariantCulture,
- SR.MessageTooLarge,
- CloudQueueMessage.MaxMessageSize));
- }
- }
- else
- {
- outgoingMessageString = this.RawString;
-
- // we need to calculate the size of its UTF8 byte array, as that will be the storage usage on server.
- if (Encoding.UTF8.GetBytes(outgoingMessageString).Length > CloudQueueMessage.MaxMessageSize)
- {
- throw new ArgumentException(string.Format(
- CultureInfo.InvariantCulture,
- SR.MessageTooLarge,
- CloudQueueMessage.MaxMessageSize));
- }
- }
- }
- else
- {
- // at this point, this.EncodeMessage must be true
- outgoingMessageString = this.RawString;
-
- // the size of Base64 encoded string is the number of bytes this message will take up on server.
- if (outgoingMessageString.Length > CloudQueueMessage.MaxMessageSize)
- {
- throw new ArgumentException(string.Format(
- CultureInfo.InvariantCulture,
- SR.MessageTooLarge,
- CloudQueueMessage.MaxMessageSize));
- }
- }
-
- return outgoingMessageString;
- }
-
- ///
- /// Sets the content of this message.
- ///
- /// The new message content.
- public void SetMessageContent(string content)
- {
- if (content == null)
- {
- // Protocol will return null for empty content
- content = string.Empty;
- }
-
- this.RawString = content;
- this.MessageType = QueueMessageType.RawString;
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/MessageUpdateFields.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/MessageUpdateFields.cs
deleted file mode 100644
index 167b2525ff913..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/MessageUpdateFields.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue
-{
- using System;
-
- ///
- /// Enumeration controlling the options for updating queue messages.
- ///
- [Flags]
- public enum MessageUpdateFields
- {
- ///
- /// Update the message visibility timeout.
- ///
- Visibility = 0x1,
-
- ///
- /// Update the message content.
- ///
- Content = 0x2
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/GetMessagesResponse.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/GetMessagesResponse.cs
deleted file mode 100644
index 3cd3464970cdc..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/GetMessagesResponse.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue.Protocol
-{
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Collections.Generic;
- using System.IO;
-
- ///
- /// Provides methods for parsing the response from an operation to get messages from a queue.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- sealed class GetMessagesResponse : ResponseParsingBase
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The stream of messages to parse.
- public GetMessagesResponse(Stream stream)
- : base(stream)
- {
- }
-
- ///
- /// Gets an enumerable collection of objects from the response.
- ///
- /// An enumerable collection of objects.
- public IEnumerable Messages
- {
- get
- {
- return this.ObjectsToParse;
- }
- }
-
- ///
- /// Parses a message entry in a queue get messages response.
- ///
- /// Message entry
- private QueueMessage ParseMessageEntry()
- {
- QueueMessage message = null;
- string id = null;
- string popReceipt = null;
- DateTime? insertionTime = null;
- DateTime? expirationTime = null;
- DateTime? timeNextVisible = null;
- string text = null;
- int dequeueCount = 0;
-
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- switch (reader.Name)
- {
- case Constants.MessageIdElement:
- id = reader.ReadElementContentAsString();
- break;
-
- case Constants.PopReceiptElement:
- popReceipt = reader.ReadElementContentAsString();
- break;
-
- case Constants.InsertionTimeElement:
- insertionTime = reader.ReadElementContentAsString().ToUTCTime();
- break;
-
- case Constants.ExpirationTimeElement:
- expirationTime = reader.ReadElementContentAsString().ToUTCTime();
- break;
-
- case Constants.TimeNextVisibleElement:
- timeNextVisible = reader.ReadElementContentAsString().ToUTCTime();
- break;
-
- case Constants.MessageTextElement:
- text = reader.ReadElementContentAsString();
- break;
-
- case Constants.DequeueCountElement:
- dequeueCount = reader.ReadElementContentAsInt();
- break;
-
- default:
- reader.Skip();
- break;
- }
- }
- }
-
- this.reader.ReadEndElement();
- message = new QueueMessage();
- message.Text = text;
- message.Id = id;
- message.PopReceipt = popReceipt;
- message.DequeueCount = dequeueCount;
-
- if (insertionTime != null)
- {
- message.InsertionTime = (DateTime)insertionTime;
- }
-
- if (expirationTime != null)
- {
- message.ExpirationTime = (DateTime)expirationTime;
- }
-
- if (timeNextVisible != null)
- {
- message.NextVisibleTime = (DateTime)timeNextVisible;
- }
-
- return message;
- }
-
- ///
- /// Parses the XML response returned by an operation to get messages from a queue.
- ///
- /// An enumerable collection of objects.
- protected override IEnumerable ParseXml()
- {
- if (this.reader.ReadToFollowing(Constants.MessagesElement))
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- switch (this.reader.Name)
- {
- case Constants.MessageElement:
- while (this.reader.IsStartElement())
- {
- yield return this.ParseMessageEntry();
- }
-
- break;
-
- default:
- reader.Skip();
- break;
- }
- }
- }
-
- this.allObjectsParsed = true;
- this.reader.ReadEndElement();
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/ListQueuesResponse.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/ListQueuesResponse.cs
deleted file mode 100644
index e06aa728356e4..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/ListQueuesResponse.cs
+++ /dev/null
@@ -1,272 +0,0 @@
-namespace Microsoft.WindowsAzure.Storage.Queue.Protocol
-{
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.Collections.Generic;
- using System.IO;
-
- ///
- /// Provides methods for parsing the response from a queue listing operation.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- sealed class ListQueuesResponse : ResponseParsingBase
- {
- ///
- /// Stores the container prefix.
- ///
- private string prefix;
-
- ///
- /// Signals when the container prefix can be consumed.
- ///
- private bool prefixConsumable;
-
- ///
- /// Stores the marker.
- ///
- private string marker;
-
- ///
- /// Signals when the marker can be consumed.
- ///
- private bool markerConsumable;
-
- ///
- /// Stores the max results.
- ///
- private int maxResults;
-
- ///
- /// Signals when the max results can be consumed.
- ///
- private bool maxResultsConsumable;
-
- ///
- /// Stores the next marker.
- ///
- private string nextMarker;
-
- ///
- /// Signals when the next marker can be consumed.
- ///
- private bool nextMarkerConsumable;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The stream to be parsed.
- public ListQueuesResponse(Stream stream)
- : base(stream)
- {
- }
-
- ///
- /// Gets the listing context from the XML response.
- ///
- /// A set of parameters for the listing operation.
- public ListingContext ListingContext
- {
- get
- {
- // Force a parsing in order
- ListingContext listingContext = new ListingContext(this.Prefix, this.MaxResults);
- listingContext.Marker = this.NextMarker;
- return listingContext;
- }
- }
-
- ///
- /// Gets an enumerable collection of objects from the response.
- ///
- /// An enumerable collection of objects.
- public IEnumerable Queues
- {
- get
- {
- return this.ObjectsToParse;
- }
- }
-
- ///
- /// Gets the Prefix value provided for the listing operation from the XML response.
- ///
- /// The Prefix value.
- public string Prefix
- {
- get
- {
- this.Variable(ref this.prefixConsumable);
-
- return this.prefix;
- }
- }
-
- ///
- /// Gets the Marker value provided for the listing operation from the XML response.
- ///
- /// The Marker value.
- public string Marker
- {
- get
- {
- this.Variable(ref this.markerConsumable);
-
- return this.marker;
- }
- }
-
- ///
- /// Gets the MaxResults value provided for the listing operation from the XML response.
- ///
- /// The MaxResults value.
- public int MaxResults
- {
- get
- {
- this.Variable(ref this.maxResultsConsumable);
-
- return this.maxResults;
- }
- }
-
- ///
- /// Gets the NextMarker value from the XML response, if the listing was not complete.
- ///
- /// The NextMarker value.
- public string NextMarker
- {
- get
- {
- this.Variable(ref this.nextMarkerConsumable);
-
- return this.nextMarker;
- }
- }
-
- ///
- /// Parses a queue entry in a queue listing response.
- ///
- /// Queue listing entry
- private QueueEntry ParseQueueEntry()
- {
- Uri uri = null;
- string name = null;
- IDictionary metadata = null;
-
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- switch (reader.Name)
- {
- case Constants.UrlElement:
- string url = reader.ReadElementContentAsString();
- Uri.TryCreate(url, UriKind.Absolute, out uri);
- break;
-
- case Constants.NameElement:
- name = reader.ReadElementContentAsString();
- break;
-
- case Constants.MetadataElement:
- metadata = Response.ParseMetadata(this.reader);
- break;
-
- default:
- this.reader.Skip();
- break;
- }
- }
- }
-
- this.reader.ReadEndElement();
- if (metadata == null)
- {
- metadata = new Dictionary();
- }
-
- return new QueueEntry(name, uri, metadata);
- }
-
- ///
- /// Parses the response XML for a queue listing operation.
- ///
- /// An enumerable collection of objects.
- protected override IEnumerable ParseXml()
- {
- if (this.reader.ReadToFollowing(Constants.EnumerationResultsElement))
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- if (this.reader.IsEmptyElement)
- {
- this.reader.Skip();
- }
- else
- {
- switch (reader.Name)
- {
- case Constants.MarkerElement:
- this.marker = reader.ReadElementContentAsString();
- this.markerConsumable = true;
- yield return null;
- break;
-
- case Constants.NextMarkerElement:
- this.nextMarker = reader.ReadElementContentAsString();
- this.nextMarkerConsumable = true;
- yield return null;
- break;
-
- case Constants.MaxResultsElement:
- this.maxResults = reader.ReadElementContentAsInt();
- this.maxResultsConsumable = true;
- yield return null;
- break;
-
- case Constants.PrefixElement:
- this.prefix = reader.ReadElementContentAsString();
- this.prefixConsumable = true;
- yield return null;
- break;
-
- case Constants.QueuesElement:
- this.reader.ReadStartElement();
- while (this.reader.IsStartElement())
- {
- yield return this.ParseQueueEntry();
- }
-
- this.reader.ReadEndElement();
- this.allObjectsParsed = true;
- break;
-
- default:
- reader.Skip();
- break;
- }
- }
- }
-
- this.reader.ReadEndElement();
- }
- }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueAccessPolicyResponse.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueAccessPolicyResponse.cs
deleted file mode 100644
index 049c3476113c9..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueAccessPolicyResponse.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue.Protocol
-{
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System;
- using System.IO;
- using System.Xml.Linq;
-
- ///
- /// Parses the response XML from an operation to set the access policy for a queue.
- ///
- internal class QueueAccessPolicyResponse : AccessPolicyResponseBase
- {
- ///
- /// Initializes a new instance of the QueueAccessPolicyResponse class.
- ///
- /// The stream to be parsed.
- internal QueueAccessPolicyResponse(Stream stream)
- : base(stream)
- {
- }
-
- ///
- /// Parses the current element.
- ///
- /// The shared access policy element to parse.
- /// The shared access policy.
- protected override SharedAccessQueuePolicy ParseElement(XElement accessPolicyElement)
- {
- CommonUtility.AssertNotNull("accessPolicyElement", accessPolicyElement);
-
- SharedAccessQueuePolicy accessPolicy = new SharedAccessQueuePolicy();
- string sharedAccessStartTimeString = (string)accessPolicyElement.Element(Constants.Start);
- if (!string.IsNullOrEmpty(sharedAccessStartTimeString))
- {
- accessPolicy.SharedAccessStartTime = Uri.UnescapeDataString(sharedAccessStartTimeString).ToUTCTime();
- }
-
- string sharedAccessExpiryTimeString = (string)accessPolicyElement.Element(Constants.Expiry);
- if (!string.IsNullOrEmpty(sharedAccessExpiryTimeString))
- {
- accessPolicy.SharedAccessExpiryTime = Uri.UnescapeDataString(sharedAccessExpiryTimeString).ToUTCTime();
- }
-
- string permissionsString = (string)accessPolicyElement.Element(Constants.Permission);
- if (!string.IsNullOrEmpty(permissionsString))
- {
- accessPolicy.Permissions = SharedAccessQueuePolicy.PermissionsFromString(permissionsString);
- }
-
- return accessPolicy;
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueContinuationToken.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueContinuationToken.cs
deleted file mode 100644
index bdef3f745b32d..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueContinuationToken.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue.Protocol
-{
- using Microsoft.WindowsAzure.Storage.Core;
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
- using System.Xml;
- using System.Xml.Schema;
- using System.Xml.Serialization;
-
- ///
- /// Represents a continuation token returned by the Queue service.
- ///
- /// continuation tokens are used in methods that return a object, such as .
- [SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1001:CommasMustBeSpacedCorrectly", Justification = "Reviewed.")]
- public sealed class QueueContinuationToken : IContinuationToken
-#if WINDOWS_DESKTOP
-, IXmlSerializable
-#endif
- {
- ///
- /// Gets or sets the NextMarker for continuing results for CloudQueue enumeration operations.
- ///
- /// The next marker.
- public string NextMarker { get; set; }
-
-#if WINDOWS_DESKTOP
- ///
- /// Gets an XML representation of an object.
- ///
- ///
- /// An that describes the XML representation of the object that is produced by the method and consumed by the method.
- ///
- public XmlSchema GetSchema()
- {
- return null;
- }
-
- ///
- /// Generates a serializable continuation token from its XML representation.
- ///
- /// The stream from which the continuation token is deserialized.
- public void ReadXml(XmlReader reader)
- {
- CommonUtility.AssertNotNull("reader", reader);
-
- reader.MoveToContent();
-
- if (reader.IsEmptyElement)
- {
- reader.Skip();
- }
- else
- {
- reader.ReadStartElement();
- while (reader.IsStartElement())
- {
- if (reader.IsEmptyElement)
- {
- reader.Skip();
- }
- else
- {
- switch (reader.Name)
- {
- case Constants.ContinuationConstants.VersionElement:
- string version = reader.ReadElementContentAsString();
- if (version != Constants.ContinuationConstants.CurrentVersion)
- {
- throw new XmlException(string.Format(CultureInfo.InvariantCulture, SR.UnexpectedElement, version));
- }
-
- break;
-
- case Constants.ContinuationConstants.NextMarkerElement:
- this.NextMarker = reader.ReadElementContentAsString();
- break;
-
- case Constants.ContinuationConstants.TypeElement:
- string continuationType = reader.ReadElementContentAsString();
- if (Constants.ContinuationConstants.QueueType != continuationType)
- {
- throw new XmlException(SR.UnexpectedContinuationType);
- }
-
- break;
-
- default:
- throw new XmlException(string.Format(CultureInfo.InvariantCulture, SR.UnexpectedElement, reader.Name));
- }
- }
- }
-
- reader.ReadEndElement();
- }
- }
-
- ///
- /// Converts a serializable continuation token into its XML representation.
- ///
- /// The stream to which the continuation token is serialized.
- public void WriteXml(XmlWriter writer)
- {
- CommonUtility.AssertNotNull("writer", writer);
-
- writer.WriteStartElement(Constants.ContinuationConstants.ContinuationTopElement);
-
- writer.WriteElementString(Constants.ContinuationConstants.VersionElement, Constants.ContinuationConstants.CurrentVersion);
-
- writer.WriteElementString(Constants.ContinuationConstants.TypeElement, Constants.ContinuationConstants.QueueType);
-
- if (this.NextMarker != null)
- {
- writer.WriteElementString(Constants.ContinuationConstants.NextMarkerElement, this.NextMarker);
- }
-
- writer.WriteEndElement(); // End ContinuationToken
- }
-#endif
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueEntry.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueEntry.cs
deleted file mode 100644
index 18a241bf5b34b..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueEntry.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue.Protocol
-{
- using System;
- using System.Collections.Generic;
-
- ///
- /// Represents a queue item returned in the XML response for a queue listing operation.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- sealed class QueueEntry
- {
- ///
- /// Initializes a new instance of the class.
- ///
- internal QueueEntry()
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The name of the queue.
- /// The Uri of the queue.
- /// The queue's metadata.
- internal QueueEntry(string name, Uri uri, IDictionary metadata)
- {
- this.Name = name;
- this.Uri = uri;
- this.Metadata = metadata;
- }
-
- ///
- /// Gets the user-defined metadata for the queue.
- ///
- /// The queue's metadata, as a collection of name-value pairs.
- public IDictionary Metadata { get; internal set; }
-
- ///
- /// Gets the name of the queue.
- ///
- /// The queue's name.
- public string Name { get; internal set; }
-
- ///
- /// Gets the queue's URI.
- ///
- /// The absolute URI to the queue.
- public Uri Uri { get; internal set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueErrorCodeStrings.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueErrorCodeStrings.cs
deleted file mode 100644
index 292659ce692f2..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueErrorCodeStrings.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue.Protocol
-{
- ///
- /// Provides error code strings that are specific to the Queue service.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- static class QueueErrorCodeStrings
- {
- ///
- /// Error code that may be returned when the specified queue was not found.
- ///
- public const string QueueNotFound = "QueueNotFound";
-
- ///
- /// Error code that may be returned when the specified queue is disabled.
- ///
- public const string QueueDisabled = "QueueDisabled";
-
- ///
- /// Error code that may be returned when the specified queue already exists.
- ///
- public const string QueueAlreadyExists = "QueueAlreadyExists";
-
- ///
- /// Error code that may be returned when the specified queue is not empty.
- ///
- public const string QueueNotEmpty = "QueueNotEmpty";
-
- ///
- /// Error code that may be returned when the specified queue is being deleted.
- ///
- public const string QueueBeingDeleted = "QueueBeingDeleted";
-
- ///
- /// Error code that may be returned when the specified pop receipt does not match.
- ///
- public const string PopReceiptMismatch = "PopReceiptMismatch";
-
- ///
- /// Error code that may be returned when one or more request parameters are invalid.
- ///
- public const string InvalidParameter = "InvalidParameter";
-
- ///
- /// Error code that may be returned when the specified message was not found.
- ///
- public const string MessageNotFound = "MessageNotFound";
-
- ///
- /// Error code that may be returned when the specified message is too large.
- ///
- public const string MessageTooLarge = "MessageTooLarge";
-
- ///
- /// Error code that may be returned when the specified marker is invalid.
- ///
- public const string InvalidMarker = "InvalidMarker";
- }
-}
\ No newline at end of file
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueHttpResponseParsers.Common.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueHttpResponseParsers.Common.cs
deleted file mode 100644
index 587e494fd0de7..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueHttpResponseParsers.Common.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue.Protocol
-{
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System.IO;
-
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- static partial class QueueHttpResponseParsers
- {
- ///
- /// Reads service properties from a stream.
- ///
- /// The stream from which to read the service properties.
- /// The service properties stored in the stream.
- public static ServiceProperties ReadServiceProperties(Stream inputStream)
- {
- return HttpResponseParsers.ReadServiceProperties(inputStream);
- }
-
- ///
- /// Reads the share access policies from a stream in XML.
- ///
- /// The stream of XML policies.
- /// The permissions object to which the policies are to be written.
- public static void ReadSharedAccessIdentifiers(Stream inputStream, QueuePermissions permissions)
- {
- CommonUtility.AssertNotNull("permissions", permissions);
-
- Response.ReadSharedAccessIdentifiers(permissions.SharedAccessPolicies, new QueueAccessPolicyResponse(inputStream));
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueListingContext.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueListingContext.cs
deleted file mode 100644
index 44ff634dd57b0..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueListingContext.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue.Protocol
-{
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
-
- ///
- /// Provides a set of parameters for a queue listing operation.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- sealed class QueueListingContext : ListingContext
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The queue prefix.
- /// The maximum number of results to return.
- /// The include parameter.
- public QueueListingContext(string prefix, int? maxResults, QueueListingDetails include)
- : base(prefix, maxResults)
- {
- this.Include = include;
- }
-
- ///
- /// Gets or sets the details for the listing operation, which indicates the types of data to include in the
- /// response.
- ///
- /// The details to include in the listing operation.
- public QueueListingDetails Include { get; set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueListingDetails.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueListingDetails.cs
deleted file mode 100644
index 48bc23f60906f..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueListingDetails.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue.Protocol
-{
- using System;
-
- ///
- /// Specifies which details to include when listing the queues in this storage account.
- ///
- [Flags]
- public enum QueueListingDetails
- {
- ///
- /// No additional details.
- ///
- None = 0x0,
-
- ///
- /// Retrieve queue metadata.
- ///
- Metadata = 0x1,
-
- ///
- /// Retrieve all available details.
- ///
- All = 0x1
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueMessage.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueMessage.cs
deleted file mode 100644
index 87a024d63bd18..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueMessage.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue.Protocol
-{
- using System;
-
- ///
- /// Represents a message retrieved from a queue.
- ///
-#if !WINDOWS_RT
- public class QueueMessage
-#else
- internal class QueueMessage
-#endif
- {
- ///
- /// Initializes a new instance of the class.
- ///
- internal QueueMessage()
- {
- }
-
- ///
- /// Gets the message expiration time.
- ///
- /// The message expiration time.
- public DateTimeOffset? ExpirationTime { get; internal set; }
-
- ///
- /// Gets the message ID.
- ///
- /// The message ID.
- public string Id { get; internal set; }
-
- ///
- /// Gets the time the message was added to the queue.
- ///
- /// The message insertion time.
- public DateTimeOffset? InsertionTime { get; internal set; }
-
- ///
- /// Gets the time the message is next visible.
- ///
- /// The time the message is next visible.
- public DateTimeOffset? NextVisibleTime { get; internal set; }
-
- ///
- /// Gets the pop receipt for the message.
- ///
- /// The message's pop receipt.
- public string PopReceipt { get; internal set; }
-
- ///
- /// Gets the text of the message.
- ///
- /// The message text.
- public string Text { get; internal set; }
-
- ///
- /// Gets the number of times this message has been dequeued.
- ///
- /// The dequeue count.
- public int DequeueCount { get; internal set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueuePermissions.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueuePermissions.cs
deleted file mode 100644
index 35ef82ff97483..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueuePermissions.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue.Protocol
-{
- ///
- /// Represents the permissions for a queue.
- ///
- public sealed class QueuePermissions
- {
- ///
- /// Initializes a new instance of the class.
- ///
- public QueuePermissions()
- {
- this.SharedAccessPolicies = new SharedAccessQueuePolicies();
- }
-
- ///
- /// Gets the set of shared access policies for the queue.
- ///
- /// The set of shared access policies for the queue.
- public SharedAccessQueuePolicies SharedAccessPolicies { get; private set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueRequest.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueRequest.cs
deleted file mode 100644
index 78e1e1fe2e7f4..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/Protocol/QueueRequest.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue.Protocol
-{
- using Microsoft.WindowsAzure.Storage.Core.Auth;
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using Microsoft.WindowsAzure.Storage.Shared.Protocol;
- using System.IO;
- using System.Text;
- using System.Xml;
-
- ///
- /// Provides a set of helper methods for constructing a request against the Queue service.
- ///
-#if WINDOWS_RT
- internal
-#else
- public
-#endif
- static class QueueRequest
- {
- ///
- /// Writes a collection of shared access policies to the specified stream in XML format.
- ///
- /// A collection of shared access policies.
- /// An output stream.
- public static void WriteSharedAccessIdentifiers(SharedAccessQueuePolicies sharedAccessPolicies, Stream outputStream)
- {
- Request.WriteSharedAccessIdentifiers(
- sharedAccessPolicies,
- outputStream,
- (policy, writer) =>
- {
- writer.WriteElementString(
- Constants.Start,
- SharedAccessSignatureHelper.GetDateTimeOrEmpty(policy.SharedAccessStartTime));
- writer.WriteElementString(
- Constants.Expiry,
- SharedAccessSignatureHelper.GetDateTimeOrEmpty(policy.SharedAccessExpiryTime));
- writer.WriteElementString(
- Constants.Permission,
- SharedAccessQueuePolicy.PermissionsToString(policy.Permissions));
- });
- }
-
- ///
- /// Writes a message to the specified stream in XML format.
- ///
- /// The message body.
- /// An output stream.
- internal static void WriteMessageContent(string messageContent, Stream outputStream)
- {
- CommonUtility.AssertNotNull("outputStream", outputStream);
-
- XmlWriterSettings settings = new XmlWriterSettings();
- settings.Encoding = Encoding.UTF8;
- settings.NewLineHandling = NewLineHandling.Entitize;
-
- using (XmlWriter writer = XmlWriter.Create(outputStream, settings))
- {
- writer.WriteStartElement(Constants.MessageElement);
- writer.WriteElementString(Constants.MessageTextElement, messageContent);
- writer.WriteEndDocument();
- }
- }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/QueueMessageType.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/QueueMessageType.cs
deleted file mode 100644
index 5e00943fb7077..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/QueueMessageType.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue
-{
- ///
- /// Enum for Queue message type.
- /// Internal use only.
- ///
- internal enum QueueMessageType
- {
- ///
- /// Indicates the message object stores the raw text string.
- ///
- RawString,
-
- ///
- /// Indicates the message object stores the Base64-Encoded representation of the raw data.
- ///
- Base64Encoded
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/QueueRequestOptions.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/QueueRequestOptions.cs
deleted file mode 100644
index 62b55f9f01e52..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/QueueRequestOptions.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue
-{
- using Microsoft.WindowsAzure.Storage.RetryPolicies;
- using System;
-
- ///
- /// Represents a set of timeout and retry policy options that may be specified for a request against the Queue service.
- ///
- public sealed class QueueRequestOptions : IRequestOptions
- {
- ///
- /// Initializes a new instance of the class.
- ///
- public QueueRequestOptions()
- {
- }
-
- ///
- /// Clones an instance of QueueRequestOptions so that we can apply defaults.
- ///
- /// QueueRequestOptions instance to be cloned.
- internal QueueRequestOptions(QueueRequestOptions other)
- : this()
- {
- if (other != null)
- {
- this.RetryPolicy = other.RetryPolicy;
- this.ServerTimeout = other.ServerTimeout;
- this.MaximumExecutionTime = other.MaximumExecutionTime;
- this.OperationExpiryTime = other.OperationExpiryTime;
- }
- }
-
- internal static QueueRequestOptions ApplyDefaults(QueueRequestOptions options, CloudQueueClient serviceClient)
- {
- QueueRequestOptions modifiedOptions = new QueueRequestOptions(options);
- modifiedOptions.RetryPolicy = modifiedOptions.RetryPolicy ?? serviceClient.RetryPolicy;
- modifiedOptions.ServerTimeout = modifiedOptions.ServerTimeout ?? serviceClient.ServerTimeout;
- modifiedOptions.MaximumExecutionTime = modifiedOptions.MaximumExecutionTime ?? serviceClient.MaximumExecutionTime;
-
- if (!modifiedOptions.OperationExpiryTime.HasValue && modifiedOptions.MaximumExecutionTime.HasValue)
- {
- modifiedOptions.OperationExpiryTime = DateTime.Now + modifiedOptions.MaximumExecutionTime.Value;
- }
-
- return modifiedOptions;
- }
-
- ///
- /// Gets or sets the absolute expiry time across all potential retries for the request.
- ///
- internal DateTime? OperationExpiryTime { get; set; }
-
- ///
- /// Gets or sets the retry policy for the request.
- ///
- /// The retry policy delegate.
- public IRetryPolicy RetryPolicy { get; set; }
-
- ///
- /// Gets or sets the server timeout for the request.
- ///
- /// The client and server timeout interval for the request.
- public TimeSpan? ServerTimeout { get; set; }
-
- ///
- /// Gets or sets the maximum execution time across all potential retries for the request.
- ///
- /// A representing the maximum execution time for retries for the request.
- public TimeSpan? MaximumExecutionTime { get; set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/QueueResultSegment.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/QueueResultSegment.cs
deleted file mode 100644
index 019778453c647..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/QueueResultSegment.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue
-{
- using Microsoft.WindowsAzure.Storage.Queue.Protocol;
- using System.Collections.Generic;
-
- ///
- /// Represents a segment of results, with continuation information for pagination scenarios.
- ///
- public sealed class QueueResultSegment
- {
- internal QueueResultSegment(IEnumerable queues, QueueContinuationToken continuationToken)
- {
- this.Results = queues;
- this.ContinuationToken = continuationToken;
- }
-
- ///
- /// Gets an enumerable collection of results.
- ///
- /// An enumerable collection of results.
- public IEnumerable Results { get; private set; }
-
- ///
- /// Gets the continuation token used to retrieve the next segment of results. Returns null if there are no more results.
- ///
- /// The continuation token.
- public QueueContinuationToken ContinuationToken { get; private set; }
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/SharedAccessQueuePermissions.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/SharedAccessQueuePermissions.cs
deleted file mode 100644
index d477920fbd03b..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/SharedAccessQueuePermissions.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue
-{
- using System;
-
- ///
- /// Specifies the set of possible permissions for a shared access queue policy.
- ///
- [Flags]
- public enum SharedAccessQueuePermissions
- {
- ///
- /// No shared access granted.
- ///
- None = 0x0,
-
- ///
- /// Permission to peek messages and get queue metadata granted.
- ///
- Read = 0x1,
-
- ///
- /// Permission to add messages granted.
- ///
- Add = 0x2,
-
- ///
- /// Permissions to update messages granted.
- ///
- Update = 0x4,
-
- ///
- /// Permission to get and delete messages granted.
- ///
- ProcessMessages = 0x8
- }
-}
diff --git a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/SharedAccessQueuePolicies.cs b/microsoft-azure-api/Services/Storage/Lib/Common/Queue/SharedAccessQueuePolicies.cs
deleted file mode 100644
index 065ed31c84323..0000000000000
--- a/microsoft-azure-api/Services/Storage/Lib/Common/Queue/SharedAccessQueuePolicies.cs
+++ /dev/null
@@ -1,234 +0,0 @@
-// -----------------------------------------------------------------------------------------
-//
-// Copyright 2012 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.Queue
-{
- using Microsoft.WindowsAzure.Storage.Core.Util;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
-
- ///
- /// Represents the collection of shared access policies defined for a queue.
- ///
- [SuppressMessage(
- "Microsoft.Naming",
- "CA1710:IdentifiersShouldHaveCorrectSuffix",
- Justification = "Public APIs should not expose base collection types.")]
- public sealed class SharedAccessQueuePolicies : IDictionary
- {
- private Dictionary policies =
- new Dictionary();
-
- ///
- /// Adds the specified key and value to the collection of shared access policies.
- ///
- /// The key of the value to add.
- /// The value to add the collection of shared access policies.
- public void Add(string key, SharedAccessQueuePolicy value)
- {
- this.policies.Add(key, value);
- }
-
- ///
- /// Determines whether the collection of shared access policies contains the specified key.
- ///
- /// The key to locate in the collection of shared access policies.
- /// true if the collection of shared access policies contains an element with the specified key; otherwise, false.
- public bool ContainsKey(string key)
- {
- return this.policies.ContainsKey(key);
- }
-
- ///
- /// Gets a collection containing the keys in the shared access policies collection.
- ///
- /// A collection containing the keys in the of shared access policies collection.
- public ICollection Keys
- {
- get
- {
- return this.policies.Keys;
- }
- }
-
- ///
- /// Removes the value with the specified key from the shared access policies collection.
- ///
- /// The key of the item to remove.
- /// true if the element is successfully found and removed; otherwise, false. This method returns false if the key is not found.
- public bool Remove(string key)
- {
- return this.policies.Remove(key);
- }
-
- ///
- /// Gets the item associated with the specified key.
- ///
- /// The key of the value to get.
- /// The item to get.
- /// The item associated with the specified key, if the key is found; otherwise, the default value for the type.
- public bool TryGetValue(string key, out SharedAccessQueuePolicy value)
- {
- return this.policies.TryGetValue(key, out value);
- }
-
- ///
- /// Gets a collection containing the values in the shared access policies collection.
- ///
- /// A collection of items in the shared access policies collection.
- public ICollection Values
- {
- get
- {
- return this.policies.Values;
- }
- }
-
- ///
- /// Gets or sets the item associated with the specified key.
- ///
- /// The key of the value to get or set.
- /// The item associated with the specified key, or null if key is not in the shared access policies collection.
- public SharedAccessQueuePolicy this[string key]
- {
- get
- {
- return this.policies[key];
- }
-
- set
- {
- this.policies[key] = value;
- }
- }
-
- ///
- /// Adds the specified key/ value, stored in a , to the collection of shared access policies.
- ///
- /// The object, containing a key/ value pair, to add to the shared access policies collection.
- public void Add(KeyValuePair item)
- {
- this.Add(item.Key, item.Value);
- }
-
- ///
- /// Removes all keys and values from the shared access collection.
- ///
- public void Clear()
- {
- this.policies.Clear();
- }
-
- ///
- /// Determines whether the collection of shared access policies contains the key and value in the specified object.
- ///
- /// A object containing the key and value to search for.
- /// true if the shared access policies collection contains the specified key/value; otherwise, false.
- public bool Contains(KeyValuePair item)
- {
- SharedAccessQueuePolicy storedItem;
- if (this.TryGetValue(item.Key, out storedItem))
- {
- if (string.Equals(
- SharedAccessQueuePolicy.PermissionsToString(item.Value.Permissions),
- SharedAccessQueuePolicy.PermissionsToString(storedItem.Permissions),
- StringComparison.Ordinal))
- {
- return true;
- }
- }
-
- return false;
- }
-
- ///
- /// Copies each key/ value pair in the shared access policies collection to a compatible one-dimensional array, starting at the specified index of the target array.
- ///
- /// The one-dimensional array of objects that is the destination of the elements copied from the shared access policies collection.
- /// The zero-based index in at which copying begins.
- public void CopyTo(KeyValuePair[] array, int arrayIndex)
- {
- CommonUtility.AssertNotNull("array", array);
-
- foreach (KeyValuePair item in this.policies)
- {
- array[arrayIndex++] = item;
- }
- }
-
- ///
- /// Gets the number of key/ value pairs contained in the shared access policies collection.
- ///
- /// The number of key/ value pairs contained in the shared access policies collection.
- public int Count
- {
- get
- {
- return this.policies.Count;
- }
- }
-
- ///
- /// Gets a value indicating whether the collection of shared access policies is read-only.
- ///
- /// true if the collection of shared access policies is read-only; otherwise, false.
- public bool IsReadOnly
- {
- get
- {
- return false;
- }
- }
-
- ///
- /// Removes the value, specified in the object, from the shared access policies collection.
- ///
- /// The object, containing a key and value, to remove from the shared access policies collection.
- /// true if the item was successfully removed; otherwise, false.
- public bool Remove(KeyValuePair item)
- {
- if (this.Contains(item))
- {
- return this.Remove(item.Key);
- }
- else
- {
- return false;
- }
- }
-
- ///
- /// Returns an enumerator that iterates through the collection of shared access policies.
- ///
- /// An