/// <summary> /// Initializes a new instance of the <see cref="RestoreSqlServerDatabaseDetails"/> class. /// </summary> /// <param name="dataFilePath">The data file path.</param> /// <param name="logFilePath">The log file path.</param> /// <param name="device">The device.</param> /// <param name="restoreFrom">The restore from.</param> /// <param name="credential">The credential.</param> /// <param name="checksumOption">The checksum option.</param> /// <param name="errorHandling">The error handling.</param> /// <param name="recoveryOption">The recovery option.</param> /// <param name="replaceOption">The replace option.</param> /// <param name="restrictedUserOption">The restricted user option.</param> /// <exception cref="System.ArgumentException"> /// Credential cannot be null or whitespace when Device is URL /// or /// ErrorHandling cannot be None when using checksum. /// </exception> public RestoreSqlServerDatabaseDetails( string dataFilePath, string logFilePath, Device device, Uri restoreFrom, string credential, ChecksumOption checksumOption, ErrorHandling errorHandling, RecoveryOption recoveryOption, ReplaceOption replaceOption, RestrictedUserOption restrictedUserOption) { if (!string.IsNullOrWhiteSpace(dataFilePath)) { SqlInjectorChecker.ThrowIfNotValidPath(dataFilePath, nameof(dataFilePath)); } if (!string.IsNullOrWhiteSpace(logFilePath)) { SqlInjectorChecker.ThrowIfNotValidPath(logFilePath, nameof(logFilePath)); } new { restoreFrom }.AsArg().Must().NotBeNull(); if (device == Device.Url) { credential.MustForArg(nameof(credential)).NotBeNullNorWhiteSpace("Credential cannot be null or whitespace when Device is URL").And().BeAlphanumeric(new[] { ' ', '_' }); } if (checksumOption == ChecksumOption.Checksum) { if (errorHandling == ErrorHandling.None) { throw new ArgumentException("ErrorHandling cannot be None when using checksum.", nameof(errorHandling)); } } this.ChecksumOption = checksumOption; this.Credential = credential; this.DataFilePath = dataFilePath; this.Device = device; this.ErrorHandling = errorHandling; this.LogFilePath = logFilePath; this.RecoveryOption = recoveryOption; this.ReplaceOption = replaceOption; this.RestoreFrom = restoreFrom; this.RestrictedUserOption = restrictedUserOption; }
public BackupSqlServerDatabaseDetails( string name, string description, Device device, Uri backupTo, string credential, CompressionOption compressionOption, ChecksumOption checksumOption, ErrorHandling errorHandling, Cipher cipher, Encryptor encryptor, string encryptorName) { if (!string.IsNullOrWhiteSpace(name)) { if (name.Length > 128) { throw new ArgumentException("Name cannot be more than 128 characters in length."); } new { name }.AsArg().Must().BeAlphanumeric(new[] { ' ', '_' }); } if (!string.IsNullOrWhiteSpace(description)) { if (description.Length > 255) { throw new ArgumentException("Description cannot be more than 255 characters in length."); } new { description }.AsArg().Must().BeAlphanumeric(new[] { ' ', '_' }); } backupTo.MustForArg(nameof(backupTo)).NotBeNull(); if (device == Device.Url) { credential.MustForArg(nameof(credential)).NotBeNullNorWhiteSpace("Credential cannot be null or whitespace when Device is URL").And().BeAlphanumeric(new[] { ' ', '_' }); } if (checksumOption == ChecksumOption.Checksum) { if (errorHandling == ErrorHandling.None) { throw new ArgumentException("ErrorHandling cannot be None when using checksum."); } } if (cipher != Cipher.NoEncryption) { if (encryptor == Encryptor.None) { throw new ArgumentException("Encryptor is required when any Cipher != NoEncryption"); } encryptorName.MustForArg(nameof(encryptorName)).NotBeNullNorWhiteSpace("EncryptorName is required when any Cipher != NoEncryption.").And().BeAlphanumeric(new[] { ' ', '_' }); } this.Name = name; this.Description = description; this.Device = device; this.BackupTo = backupTo; this.Credential = credential; this.CompressionOption = compressionOption; this.ChecksumOption = checksumOption; this.ErrorHandling = errorHandling; this.Cipher = cipher; this.Encryptor = encryptor; this.EncryptorName = encryptorName; }