Exemplo n.º 1
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged
 /// resources.
 /// </summary>
 public void Dispose()
 {
     _destinationName   = null;
     _sourceName        = null;
     _destinationHandle = null;
     _sourceHandle      = null;
     _backup            = null;
 }
Exemplo n.º 2
0
 /// <summary> Constructor. </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>
 /// <param name="destinationHandle"> Handle of the destination. </param>
 /// <param name="destinationName"> Name of the destination. </param>
 /// <param name="sourceHandle"> Handle of the source. </param>
 /// <param name="sourceName"> Name of the source. </param>
 /// <param name="backup"> The backup. </param>
 internal SqliteBackupHandle(
     SqliteDatabaseHandle destinationHandle,
     string destinationName,
     SqliteDatabaseHandle sourceHandle,
     string sourceName,
     DbProvider.sqlite3_backup backup)
 {
     _destinationHandle = destinationHandle ?? throw new ArgumentNullException(nameof(destinationHandle));
     _sourceHandle      = sourceHandle ?? throw new ArgumentNullException(nameof(sourceHandle));
     _backup            = backup ?? throw new ArgumentNullException(nameof(backup));
     _destinationName   = (!String.IsNullOrWhiteSpace(destinationName))
             ? destinationName.Trim()
             : throw new ArgumentOutOfRangeException(nameof(destinationName));
     _sourceName = (!String.IsNullOrWhiteSpace(sourceName))
             ? sourceName.Trim()
             : throw new ArgumentOutOfRangeException(nameof(sourceName));
 }
Exemplo n.º 3
0
        /// <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));
        }
Exemplo n.º 4
0
 static public int sqlite3_backup_pagecount(sqlite3_backup backup)
 {
     return _imp.sqlite3_backup_pagecount(backup.ptr);
 }
Exemplo n.º 5
0
 static public int sqlite3_backup_remaining(sqlite3_backup backup)
 {
     return _imp.sqlite3_backup_remaining(backup.ptr);
 }
Exemplo n.º 6
0
 static public int sqlite3_backup_finish(sqlite3_backup backup)
 {
     int rc = _imp.sqlite3_backup_finish(backup.ptr);
     backup.set_already_disposed();
     return rc;
 }
Exemplo n.º 7
0
 static public int sqlite3_backup_step(sqlite3_backup backup, int nPage)
 {
     return _imp.sqlite3_backup_step(backup.ptr, nPage);
 }
Exemplo n.º 8
0
 static public int sqlite3_backup_finish(sqlite3_backup backup)
 {
     int rc = _imp.sqlite3_backup_finish(backup.ptr);
     backup.done();
     return rc;
 }