当前位置: 首页>>代码示例>>C#>>正文


C# CloudStorageAccount.ToString方法代码示例

本文整理汇总了C#中CloudStorageAccount.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# CloudStorageAccount.ToString方法的具体用法?C# CloudStorageAccount.ToString怎么用?C# CloudStorageAccount.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CloudStorageAccount的用法示例。


在下文中一共展示了CloudStorageAccount.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CloudStorageAccountAnonymousRoundtrip

        public void CloudStorageAccountAnonymousRoundtrip()
        {
            string accountString = "BlobEndpoint=http://blobs/";

            Assert.AreEqual(accountString, CloudStorageAccount.Parse(accountString).ToString(true));

            CloudStorageAccount account = new CloudStorageAccount(null, new Uri("http://blobs/"), null, null);

            AccountsAreEqual(account, CloudStorageAccount.Parse(account.ToString(true)));
        }
开发者ID:jdkillian,项目名称:azure-sdk-for-net,代码行数:10,代码来源:CloudStorageAccountTests.cs

示例2: CloudStorageAccountDefaultStorageAccountWithHttps

 public void CloudStorageAccountDefaultStorageAccountWithHttps()
 {
     StorageCredentials cred = new StorageCredentials(TestBase.TargetTenantConfig.AccountName, TestBase.TargetTenantConfig.AccountKey);
     CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(cred, true);
     Assert.AreEqual(cloudStorageAccount.BlobEndpoint,
         new Uri(String.Format("https://{0}.blob.core.windows.net", TestBase.TargetTenantConfig.AccountName)));
     Assert.AreEqual(cloudStorageAccount.QueueEndpoint,
         new Uri(String.Format("https://{0}.queue.core.windows.net", TestBase.TargetTenantConfig.AccountName)));
     Assert.AreEqual(cloudStorageAccount.TableEndpoint,
         new Uri(String.Format("https://{0}.table.core.windows.net", TestBase.TargetTenantConfig.AccountName)));
     string cloudStorageAccountToStringNoSecrets = cloudStorageAccount.ToString();
     string cloudStorageAccountToStringWithSecrets = cloudStorageAccount.ToString(true);
     CloudStorageAccount testAccount = CloudStorageAccount.Parse(cloudStorageAccountToStringWithSecrets);
     // make sure it round trips
     AccountsAreEqual(testAccount, cloudStorageAccount);
 }
开发者ID:jdkillian,项目名称:azure-sdk-for-net,代码行数:16,代码来源:CloudStorageAccountTests.cs

示例3: AccountsAreEqual

        private void AccountsAreEqual(CloudStorageAccount a, CloudStorageAccount b)
        {
            // endpoints are the same
            Assert.AreEqual(a.BlobEndpoint, b.BlobEndpoint);
            Assert.AreEqual(a.QueueEndpoint, b.QueueEndpoint);
            Assert.AreEqual(a.TableEndpoint, b.TableEndpoint);
            
            // seralized representatons are the same.
            string aToStringNoSecrets = a.ToString();
            string aToStringWithSecrets = a.ToString(true);
            string bToStringNoSecrets = b.ToString(false);
            string bToStringWithSecrets = b.ToString(true);
            Assert.AreEqual(aToStringNoSecrets, bToStringNoSecrets, false);
            Assert.AreEqual(aToStringWithSecrets, bToStringWithSecrets, false);
            
            // credentials are the same
            if (a.Credentials != null && b.Credentials != null)
            {
                Assert.AreEqual(a.Credentials.IsAnonymous, b.Credentials.IsAnonymous);
                Assert.AreEqual(a.Credentials.IsSAS, b.Credentials.IsSAS);
                Assert.AreEqual(a.Credentials.IsSharedKey, b.Credentials.IsSharedKey);

                // make sure 
                if (!a.Credentials.IsAnonymous &&
                    a.Credentials != CloudStorageAccount.DevelopmentStorageAccount.Credentials &&
                    b.Credentials != CloudStorageAccount.DevelopmentStorageAccount.Credentials)
                {
                    Assert.AreNotEqual(aToStringWithSecrets, bToStringNoSecrets, true);
                }
            }
            else if (a.Credentials == null && b.Credentials == null)
            {
                return;
            }
            else
            {
                Assert.Fail("credentials mismatch");
            }
        }
开发者ID:jdkillian,项目名称:azure-sdk-for-net,代码行数:39,代码来源:CloudStorageAccountTests.cs

示例4: StorageCredentialsEmptyKeyValue

        public void StorageCredentialsEmptyKeyValue()
        {
            string accountName = TestBase.TargetTenantConfig.AccountName;
            string keyValue = TestBase.TargetTenantConfig.AccountKey;
            string emptyKeyValueAsString = string.Empty;
            string emptyKeyConnectionString = string.Format(CultureInfo.InvariantCulture, "DefaultEndpointsProtocol=https;AccountName={0};AccountKey=", accountName);

            StorageCredentials credentials1 = new StorageCredentials(accountName, emptyKeyValueAsString);
            Assert.AreEqual(accountName, credentials1.AccountName);
            Assert.IsFalse(credentials1.IsAnonymous);
            Assert.IsFalse(credentials1.IsSAS);
            Assert.IsTrue(credentials1.IsSharedKey);
            Assert.AreEqual(emptyKeyValueAsString, Convert.ToBase64String(credentials1.ExportKey()));

            CloudStorageAccount account1 = new CloudStorageAccount(credentials1, true);
            Assert.AreEqual(emptyKeyConnectionString, account1.ToString(true));
            Assert.IsNotNull(account1.Credentials);
            Assert.AreEqual(accountName, account1.Credentials.AccountName);
            Assert.IsFalse(account1.Credentials.IsAnonymous);
            Assert.IsFalse(account1.Credentials.IsSAS);
            Assert.IsTrue(account1.Credentials.IsSharedKey);
            Assert.AreEqual(emptyKeyValueAsString, Convert.ToBase64String(account1.Credentials.ExportKey()));

            CloudStorageAccount account2 = CloudStorageAccount.Parse(emptyKeyConnectionString);
            Assert.AreEqual(emptyKeyConnectionString, account2.ToString(true));
            Assert.IsNotNull(account2.Credentials);
            Assert.AreEqual(accountName, account2.Credentials.AccountName);
            Assert.IsFalse(account2.Credentials.IsAnonymous);
            Assert.IsFalse(account2.Credentials.IsSAS);
            Assert.IsTrue(account2.Credentials.IsSharedKey);
            Assert.AreEqual(emptyKeyValueAsString, Convert.ToBase64String(account2.Credentials.ExportKey()));

            CloudStorageAccount account3;
            bool isValidAccount3 = CloudStorageAccount.TryParse(emptyKeyConnectionString, out account3);
            Assert.IsTrue(isValidAccount3);
            Assert.IsNotNull(account3);
            Assert.AreEqual(emptyKeyConnectionString, account3.ToString(true));
            Assert.IsNotNull(account3.Credentials);
            Assert.AreEqual(accountName, account3.Credentials.AccountName);
            Assert.IsFalse(account3.Credentials.IsAnonymous);
            Assert.IsFalse(account3.Credentials.IsSAS);
            Assert.IsTrue(account3.Credentials.IsSharedKey);
            Assert.AreEqual(emptyKeyValueAsString, Convert.ToBase64String(account3.Credentials.ExportKey()));

            StorageCredentials credentials2 = new StorageCredentials(accountName, keyValue);
            Assert.AreEqual(accountName, credentials2.AccountName);
            Assert.IsFalse(credentials2.IsAnonymous);
            Assert.IsFalse(credentials2.IsSAS);
            Assert.IsTrue(credentials2.IsSharedKey);
            Assert.AreEqual(keyValue, Convert.ToBase64String(credentials2.ExportKey()));

            credentials2.UpdateKey(emptyKeyValueAsString, null);
            Assert.AreEqual(emptyKeyValueAsString, Convert.ToBase64String(credentials2.ExportKey()));

#if !WINDOWS_RT
            byte[] emptyKeyValueAsByteArray = new byte[0];

            StorageCredentials credentials3 = new StorageCredentials(accountName, keyValue);
            Assert.AreEqual(accountName, credentials3.AccountName);
            Assert.IsFalse(credentials3.IsAnonymous);
            Assert.IsFalse(credentials3.IsSAS);
            Assert.IsTrue(credentials3.IsSharedKey);
            Assert.AreEqual(keyValue, Convert.ToBase64String(credentials3.ExportKey()));

            credentials3.UpdateKey(emptyKeyValueAsByteArray, null);
            Assert.AreEqual(Convert.ToBase64String(emptyKeyValueAsByteArray), Convert.ToBase64String(credentials3.ExportKey()));
#endif
        }
开发者ID:huoxudong125,项目名称:azure-sdk-for-net,代码行数:68,代码来源:CloudStorageAccountTests.cs

示例5: GetStorageServiceConnectionString

        /// <summary>
        /// Gets connection string of the given storage service name.
        /// </summary>
        /// <param name="name">The storage service name</param>
        /// <returns>The connection string</returns>
        public string GetStorageServiceConnectionString(string name)
        {
            StorageServiceGetResponse storageService;
            StorageAccountGetKeysResponse storageKeys;

            try
            {
                storageService = StorageClient.StorageAccounts.Get(name);
                storageKeys = StorageClient.StorageAccounts.GetKeys(name);
            }
            catch
            {
                throw new Exception(string.Format(Resources.StorageAccountNotFound, name));
            }

            Debug.Assert(storageService.ServiceName != null);
            Debug.Assert(storageKeys != null);

            StorageCredentials credentials = new StorageCredentials(
                storageService.ServiceName,
                storageKeys.PrimaryKey);

            CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(
                credentials,
                General.CreateHttpsEndpoint(storageService.Properties.Endpoints[0].ToString()),
                General.CreateHttpsEndpoint(storageService.Properties.Endpoints[1].ToString()),
                General.CreateHttpsEndpoint(storageService.Properties.Endpoints[2].ToString())
                );

            return cloudStorageAccount.ToString(true);
        }
开发者ID:ranjitk9,项目名称:azure-sdk-tools,代码行数:36,代码来源:CloudServiceClient.cs

示例6: CloudStorageAccountDefaultStorageAccountWithHttp

 public void CloudStorageAccountDefaultStorageAccountWithHttp()
 {
     StorageCredentials cred = new StorageCredentials(TestBase.TargetTenantConfig.AccountName, TestBase.TargetTenantConfig.AccountKey);
     CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(cred, false);
     Assert.AreEqual(cloudStorageAccount.BlobEndpoint,
         new Uri(String.Format("http://{0}.blob.core.windows.net", TestBase.TargetTenantConfig.AccountName)));
     Assert.AreEqual(cloudStorageAccount.QueueEndpoint,
         new Uri(String.Format("http://{0}.queue.core.windows.net", TestBase.TargetTenantConfig.AccountName)));
     Assert.AreEqual(cloudStorageAccount.TableEndpoint,
         new Uri(String.Format("http://{0}.table.core.windows.net", TestBase.TargetTenantConfig.AccountName)));
     Assert.AreEqual(cloudStorageAccount.FileEndpoint,
         new Uri(String.Format("http://{0}.file.core.windows.net", TestBase.TargetTenantConfig.AccountName)));
     Assert.AreEqual(cloudStorageAccount.BlobStorageUri.SecondaryUri,
         new Uri(String.Format("http://{0}-secondary.blob.core.windows.net", TestBase.TargetTenantConfig.AccountName)));
     Assert.AreEqual(cloudStorageAccount.QueueStorageUri.SecondaryUri,
         new Uri(String.Format("http://{0}-secondary.queue.core.windows.net", TestBase.TargetTenantConfig.AccountName)));
     Assert.AreEqual(cloudStorageAccount.TableStorageUri.SecondaryUri,
         new Uri(String.Format("http://{0}-secondary.table.core.windows.net", TestBase.TargetTenantConfig.AccountName)));
     Assert.AreEqual(cloudStorageAccount.FileStorageUri.SecondaryUri,
         new Uri(String.Format("http://{0}-secondary.file.core.windows.net", TestBase.TargetTenantConfig.AccountName)));
     
     string cloudStorageAccountToStringNoSecrets = cloudStorageAccount.ToString();
     string cloudStorageAccountToStringWithSecrets = cloudStorageAccount.ToString(true);
     CloudStorageAccount testAccount = CloudStorageAccount.Parse(cloudStorageAccountToStringWithSecrets);
     
     AccountsAreEqual(testAccount, cloudStorageAccount);
 }
开发者ID:jianghaolu,项目名称:azure-storage-net,代码行数:27,代码来源:CloudStorageAccountTests.cs


注:本文中的CloudStorageAccount.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。