/// <summary> /// Initializes a new instance of the <see cref="FileStorage" /> class. /// </summary> /// <param name="shareName">A string containing the name of the share.</param> /// <param name="cloudFileClient">The cloud file client.</param> /// <param name="createIfNotExists">true to creates the share if it does not already exist; otherwise, false.</param> public FileStorage(string shareName, CloudFileClient cloudFileClient, bool createIfNotExists = true) { shareName.ValidateShareName(); cloudFileClient.ValidateNull(); this._fileClient = new FileClient(cloudFileClient); this._cloudFileShare = this._fileClient.InnerCloudFileClient.GetShareReference(shareName); if (createIfNotExists) { this._cloudFileShare.CreateIfNotExists(); } }
/// <summary> /// Initializes a new instance of the <see cref="FileStorage" /> class. /// </summary> /// <param name="shareName">A string containing the name of the share.</param> /// <param name="cloudStorageAccount">The cloud storage account.</param> /// <param name="createIfNotExists">true to creates the share if it does not already exist; otherwise, false.</param> public FileStorage(string shareName, CloudStorageAccount cloudStorageAccount, bool createIfNotExists = true) { shareName.ValidateShareName(); cloudStorageAccount.ValidateNull(); var cloudFileClient = cloudStorageAccount.CreateCloudFileClient(); this._fileClient = new FileClient(cloudFileClient); this.SetDefaultRetryIfNotExists(cloudFileClient); this._cloudFileShare = cloudFileClient.GetShareReference(shareName); if (createIfNotExists) { this._cloudFileShare.CreateIfNotExists(); } }
/// <summary> /// Initializes a new instance of the <see cref="FileStorage"/> class. /// </summary> /// <param name="shareName">A string containing the name of the share.</param> /// <param name="connectionString">The connection string.</param> /// <param name="createIfNotExists">true to creates the share if it does not already exist; otherwise, false.</param> public FileStorage(string shareName, string connectionString, bool createIfNotExists = true) { shareName.ValidateShareName(); connectionString.ValidateNullOrWhiteSpace(); var cloudStorageAccount = CloudStorageAccount.Parse(connectionString); var cloudFileClient = cloudStorageAccount.CreateCloudFileClient(); this._fileClient = new FileClient(cloudFileClient); this.SetDefaultRetryIfNotExists(cloudFileClient); this._cloudFileShare = cloudFileClient.GetShareReference(shareName); if (createIfNotExists) { this._cloudFileShare.CreateIfNotExists(); } }
/// <summary> /// Initializes a new instance of the <see cref="FileStorage"/> class. /// </summary> /// <param name="shareName">A string containing the name of the share.</param> /// <param name="accountName">A string that represents the name of the storage account.</param> /// <param name="keyValue">A string that represents the Base64-encoded account access key.</param> /// <param name="useHttps">true to use HTTPS to connect to storage service endpoints; otherwise, false.</param> /// <param name="createIfNotExists">true to creates the share if it does not already exist; otherwise, false.</param> public FileStorage(string shareName, string accountName, string keyValue, bool useHttps, bool createIfNotExists = true) { shareName.ValidateShareName(); accountName.ValidateNullOrWhiteSpace(); keyValue.ValidateNullOrWhiteSpace(); var cloudStorageAccount = new CloudStorageAccount(new StorageCredentials(accountName, keyValue), useHttps); var cloudFileClient = cloudStorageAccount.CreateCloudFileClient(); this._fileClient = new FileClient(cloudFileClient); this.SetDefaultRetryIfNotExists(cloudFileClient); this._cloudFileShare = cloudFileClient.GetShareReference(shareName); if (createIfNotExists) { this._cloudFileShare.CreateIfNotExists(); } }
/// <summary> /// Initializes a new instance of the <see cref="FileStorage"/> class. /// </summary> /// <param name="cloudFileShare">The CloudFileShare instance.</param> public FileStorage(CloudFileShare cloudFileShare) { this._cloudFileShare = cloudFileShare; this._fileClient = new FileClient(cloudFileShare.ServiceClient); }