Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions Madd0.AzureStorageDriver/ConnectionDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<Window.Resources>
<Style TargetType="TextBox">
<Style.Triggers>
Expand All @@ -17,9 +17,9 @@
</Style>
</Window.Resources>
<StackPanel Margin="7">

<Label Padding="0 0 0 3">Storage account name:</Label>

<DockPanel>
<CheckBox TabIndex="2" Content="Use _development storage" VerticalAlignment="Center"
Margin="30 0 0 0" DockPanel.Dock="Right"
Expand All @@ -35,7 +35,8 @@
IsChecked="{Binding UseHttps}" />
<CheckBox TabIndex="5" Content="_Remember this connection" Margin="0 5 0 0"
IsChecked="{Binding Persist}" />

<CheckBox TabIndex="6" Content="_China Azure" Margin="0 5 0 0"
IsChecked="{Binding ChinaAzure}" />
<DockPanel LastChildFill="False" Margin="0 10 0 0">
<DockPanel.Resources>
<Style TargetType="Button">
Expand All @@ -46,9 +47,9 @@
</Style>
</DockPanel.Resources>

<Button TabIndex="7" Grid.Row="5" Grid.Column="1" IsCancel="True">_Cancel</Button>
<Button TabIndex="6" Grid.Row="5" IsDefault="True" Click="OnOkClick">_OK</Button>
<Button TabIndex="8" Grid.Row="5" Grid.Column="1" IsCancel="True">_Cancel</Button>
<Button TabIndex="7" Grid.Row="5" IsDefault="True" Click="OnOkClick">_OK</Button>
</DockPanel>

</StackPanel>
</Window>
43 changes: 42 additions & 1 deletion Madd0.AzureStorageDriver/Model/StorageAccountProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ public bool UseHttps
}
}

public bool ChinaAzure
{
get
{
return (bool?)this._driverData.Element("ChinaAzure") ?? false;
}

set
{
this._driverData.SetElementValue("ChinaAzure", value);
}
}

/// <summary>
/// Gets or sets the name of the storage account.
/// </summary>
Expand Down Expand Up @@ -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));
}


/// <summary>
/// Clears the account name and key.
/// </summary>
Expand Down