Exemple #1
0
        /// <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;
        }
Exemple #2
0
 public RecoverableErrorEventArgs()
 {
     this.RecoveryOption = RecoveryOption.Abort;
 }
 public RecoverableErrorEventArgs()
 {
   this.RecoveryOption = RecoveryOption.Abort;
 }