Microsoft.WindowsAzure.Management.Model.SubscriptionData.GetCurrentStorageAccount C# (CSharp) Method

GetCurrentStorageAccount() public method

public GetCurrentStorageAccount ( IServiceManagement channel ) : Microsoft.WindowsAzure.Storage.CloudStorageAccount
channel IServiceManagement
return Microsoft.WindowsAzure.Storage.CloudStorageAccount
        public CloudStorageAccount GetCurrentStorageAccount(IServiceManagement channel)
        {
            if (String.IsNullOrEmpty(CurrentStorageAccount))
            {
                return null;
            }

            if (this.CurrentCloudStorageAccount != null)
            {
                return CurrentCloudStorageAccount;
            }

            CloudStorageAccount currentStorage = null;
            using (new OperationContextScope(channel.ToContextChannel()))
            {
                var storageService = channel.GetStorageService(SubscriptionId, CurrentStorageAccount);
                var storageServiceKeys = channel.GetStorageKeys(SubscriptionId, CurrentStorageAccount);
                if (storageService != null && storageServiceKeys != null)
                {
                    string connectionString = General.BuildConnectionString("https", storageService.ServiceName, storageServiceKeys.StorageServiceKeys.Primary, storageService.StorageServiceProperties.Endpoints[0].Replace("http://", "https://"), storageService.StorageServiceProperties.Endpoints[2].Replace("http://", "https://"), storageService.StorageServiceProperties.Endpoints[1].Replace("http://", "https://"));
                    currentStorage = CloudStorageAccount.Parse(connectionString);
                }
            }

            this.CurrentCloudStorageAccount = currentStorage;
            return currentStorage;
        }