/// <summary> Sqlite 3 backup initialize. </summary> /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception> /// <exception cref="ArgumentOutOfRangeException"> Thrown when one or more arguments are outside /// the required range. </exception> /// <exception cref="InvalidOperationException"> Thrown when the requested operation is invalid. </exception> /// <exception cref="SqliteException"> Thrown when a Sqlite error condition occurs. </exception> /// <param name="destinationDb"> Destination database. </param> /// <param name="destinationName"> Name of the destination. </param> /// <param name="sourceDb"> Source database. </param> /// <param name="sourceName"> Name of the source. </param> /// <returns> A SqliteBackupHandle. </returns> internal SqliteBackupHandle sqlite3_backup_init( SqliteDatabaseHandle destinationDb, string destinationName, SqliteDatabaseHandle sourceDb, string sourceName) { if (destinationDb == null) { throw new ArgumentNullException(nameof(destinationDb)); } if (sourceDb == null) { throw new ArgumentNullException(nameof(sourceDb)); } if (String.IsNullOrWhiteSpace(destinationName)) { throw new ArgumentOutOfRangeException(nameof(destinationName)); } if (String.IsNullOrWhiteSpace(sourceName)) { throw new ArgumentOutOfRangeException(nameof(sourceName)); } if (!destinationDb.IsDatabaseInMaintenanceMode) { throw new InvalidOperationException("The destination database is not currently in maintenance mode."); } if (!sourceDb.IsDatabaseInMaintenanceMode) { throw new InvalidOperationException("The source database is not currently in maintenance mode."); } DbProvider.sqlite3_backup result = DbProviderOperations.sqlite3_backup_init(destinationDb.MaintenanceDb, destinationName, sourceDb.MaintenanceDb, sourceName); if (result == null) { throw new SqliteException("The resulting backup handle was NULL", SqliteResultCode.Empty); } return(new SqliteBackupHandle(destinationDb, destinationName, sourceDb, sourceName, result)); }