public SqlServerDatabaseDefinition( string databaseName, DatabaseType databaseType, RecoveryMode recoveryMode, string dataFileLogicalName, string dataFilePath, long dataFileCurrentSizeInKb, long dataFileMaxSizeInKb, long dataFileGrowthSizeInKb, string logFileLogicalName, string logFilePath, long logFileCurrentSizeInKb, long logFileMaxSizeInKb, long logFileGrowthSizeInKb) { databaseName.MustForArg(nameof(databaseName)).NotBeNullNorWhiteSpace().And().BeAlphanumeric(DatabaseNameAlphanumericOtherAllowedCharacters); if (!string.IsNullOrWhiteSpace(dataFileLogicalName)) { dataFileLogicalName.MustForArg(nameof(dataFileLogicalName)).BeAlphanumeric(DatabaseLogicalFileNameAlphanumericOtherAllowedCharacters); } if (!string.IsNullOrWhiteSpace(dataFilePath)) { SqlInjectorChecker.ThrowIfNotValidPath(dataFilePath, nameof(dataFilePath)); } if (!string.IsNullOrWhiteSpace(logFileLogicalName)) { logFileLogicalName.MustForArg(nameof(logFileLogicalName)).BeAlphanumeric(DatabaseLogicalFileNameAlphanumericOtherAllowedCharacters); } if (!string.IsNullOrWhiteSpace(logFilePath)) { SqlInjectorChecker.ThrowIfNotValidPath(logFilePath, nameof(logFilePath)); } this.DatabaseName = databaseName; this.DatabaseType = databaseType; this.RecoveryMode = recoveryMode; this.DataFileLogicalName = dataFileLogicalName; this.DataFilePath = dataFilePath; this.LogFilePath = logFilePath; this.DataFileCurrentSizeInKb = dataFileCurrentSizeInKb; this.DataFileMaxSizeInKb = dataFileMaxSizeInKb; this.DataFileGrowthSizeInKb = dataFileGrowthSizeInKb; this.LogFileLogicalName = logFileLogicalName; this.LogFileCurrentSizeInKb = logFileCurrentSizeInKb; this.LogFileMaxSizeInKb = logFileMaxSizeInKb; this.LogFileGrowthSizeInKb = logFileGrowthSizeInKb; }
/// <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; }