Пример #1
0
        public IBlobStorage CreateBlobStorage(StorageConnectionString connectionString)
        {
            if (connectionString.Prefix == BlobPrefix)
            {
                if (bool.TryParse(connectionString.Get(Constants.UseDevelopmentStorage), out bool useDevelopment) && useDevelopment)
                {
                    return(AzureUniversalBlobStorageProvider.CreateForLocalEmulator());
                }
                else
                {
                    connectionString.GetRequired(AccountParam, true, out string accountName);
                    connectionString.GetRequired(KeyParam, true, out string key);

                    return(AzureUniversalBlobStorageProvider.CreateFromAccountNameAndKey(accountName, key));
                }
            }
            else
            {
                //try to re-parse native connection string
                var newcs = new StorageConnectionString(BlobPrefix + "://" + connectionString.Prefix);

                if (newcs.Parameters.TryGetValue("AccountName", out string accountName) &&
                    newcs.Parameters.TryGetValue("AccountKey", out string accountKey))
                {
                    return(AzureUniversalBlobStorageProvider.CreateFromAccountNameAndKey(accountName, accountKey));
                }
            }

            return(null);
        }
Пример #2
0
        public IBlobStorage CreateBlobStorage(StorageConnectionString connectionString)
        {
            if (connectionString.Prefix == Constants.AzureBlobConnectionPrefix)
            {
                if (bool.TryParse(connectionString.Get(Constants.UseDevelopmentStorage), out bool useDevelopment) && useDevelopment)
                {
                    return(AzureUniversalBlobStorageProvider.CreateForLocalEmulator());
                }
                else
                {
                    connectionString.GetRequired(Constants.AccountParam, true, out string accountName);
                    connectionString.GetRequired(Constants.KeyParam, true, out string key);

                    return(AzureUniversalBlobStorageProvider.CreateFromAccountNameAndKey(accountName, key));
                }
            }

            return(null);
        }
Пример #3
0
 /// <summary>
 /// Creates a blob storage implementation based on Microsoft Azure Blob Storage using development storage.
 /// </summary>
 /// <param name="factory">Reference to factory</param>
 /// <returns>Generic blob storage interface</returns>
 public static IBlobStorage AzureBlobDevelopmentStorage(this IBlobStorageFactory factory)
 {
     return(AzureUniversalBlobStorageProvider.CreateForLocalEmulator());
 }