Beispiel #1
0
        private AzureFileSystem Init(ConnectionStringsSection connectionStrings, string containerName, bool isPrivate = false)
        {
            ConnectionStringSettings css = connectionStrings.ConnectionStrings["AzureStorageConnection"];
            string connectionString      = css != null
                                   ? css.ConnectionString
                                   : (ConfigurationManager.AppSettings["AzureStorageConnectionString"] ?? "UseDevelopmentStorage=true");
            var account = CloudStorageAccount.Parse(connectionString);

            if (string.IsNullOrEmpty(containerName))
            {
                containerName = ConfigurationManager.AppSettings["AzureStorageContainerName"] ?? "n2tests";
            }
            _root = ConfigurationManager.AppSettings["AzureStorageRootFolderName"] ?? "default"; // orchard: default
            string delAll = ConfigurationManager.AppSettings["AzureStorageDeleteAllOnStartup"] ?? "false";

            if (account == null)
            {
                throw new ConfigurationErrorsException("Bad Azure Storage Configuration");
            }

            var isp = new AzureFileSystem(containerName, _root, isPrivate, account);

            if (delAll.Equals("true", StringComparison.InvariantCultureIgnoreCase))
            {
                isp.Container.DeleteAllBlobs(); // start with a fresh container, used in unit tests
            }
            return(isp);
        }
Beispiel #2
0
 public AzureStorageFileSystem(ConnectionStringsSection connectionStrings, string containerName, bool isPrivate)
 {
     isp = Init(connectionStrings, containerName, isPrivate);
 }
Beispiel #3
0
 public AzureStorageFileSystem(ConnectionStringsSection connectionStrings)
 {
     isp = Init(connectionStrings, null);
 }