diff --git a/Madd0.AzureStorageDriver/ConnectionDialog.xaml b/Madd0.AzureStorageDriver/ConnectionDialog.xaml index c3bd036..2518c50 100644 --- a/Madd0.AzureStorageDriver/ConnectionDialog.xaml +++ b/Madd0.AzureStorageDriver/ConnectionDialog.xaml @@ -5,7 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" Width="400" Title="Azure Storage Account" ResizeMode="NoResize" - SizeToContent="Height" WindowStartupLocation="CenterScreen" Background="{StaticResource {x:Static SystemColors.ControlBrushKey}}"> + SizeToContent="Height" WindowStartupLocation="CenterScreen" Background="{StaticResource {x:Static SystemColors.ControlBrushKey}}" Height="229"> - + - + - + - - + + - + diff --git a/Madd0.AzureStorageDriver/Model/StorageAccountProperties.cs b/Madd0.AzureStorageDriver/Model/StorageAccountProperties.cs index d81d32a..1d18bbb 100644 --- a/Madd0.AzureStorageDriver/Model/StorageAccountProperties.cs +++ b/Madd0.AzureStorageDriver/Model/StorageAccountProperties.cs @@ -99,6 +99,19 @@ public bool UseHttps } } + public bool ChinaAzure + { + get + { + return (bool?)this._driverData.Element("ChinaAzure") ?? false; + } + + set + { + this._driverData.SetElementValue("ChinaAzure", value); + } + } + /// /// Gets or sets the name of the storage account. /// @@ -139,10 +152,38 @@ public CloudStorageAccount GetStorageAccount() } else { - return new CloudStorageAccount(new StorageCredentialsAccountAndKey(this.AccountName, this.AccountKey), this.UseHttps); + if (!ChinaAzure) + return new CloudStorageAccount(new StorageCredentialsAccountAndKey(this.AccountName, this.AccountKey), this.UseHttps); + return new CloudStorageAccount(new StorageCredentialsAccountAndKey(this.AccountName, this.AccountKey) + , BuildChinaAzureUri(AccountName, UseHttps, 0) + , BuildChinaAzureUri(AccountName, UseHttps, 2) + , BuildChinaAzureUri(AccountName, UseHttps, 1)); + + } + } + + private Uri BuildChinaAzureUri(string accountName, bool useHttps, int type) + { + string typeStr; + switch (type) + { + case 0: + typeStr = "blob"; + break; + case 1: + typeStr = "table"; + break; + case 2: + typeStr = "queue"; + break; + default: + typeStr = "blob"; + break; } + return new Uri(String.Format("http{0}://{1}.{2}.core.chinacloudapi.cn/", useHttps ? "s" : "", accountName, typeStr)); } + /// /// Clears the account name and key. ///