Beispiel #1
0
        /// <summary>
        /// Closes the database making it not accessible to connections.
        /// </summary>
        /// <exception cref="DatabaseSystemException">
        /// The database is not initialized.
        /// or
        /// An error occurred during database shutdown.
        /// </exception>
        /// <remarks>
        /// Typical implementations of this interface will automatically
        /// invoke the closure of the database on disposal (<see cref="IDisposable.Dispose" />.
        /// </remarks>
        public void Close()
        {
            if (!IsOpen)
            {
                throw new DatabaseSystemException("The database is not initialized.");
            }

            try {
                if (Context.DeleteOnClose())
                {
                    // Delete the tables if the database is set to delete on
                    // shutdown.
                    TableComposite.Delete();
                }
                else
                {
                    // Otherwise close the conglomerate.
                    TableComposite.Close();
                }
            } catch (DatabaseSystemException) {
                throw;
            } catch (Exception e) {
                throw new DatabaseSystemException("An error occurred during database shutdown.", e);
            } finally {
                IsOpen = false;
            }
        }
Beispiel #2
0
 internal void Delete()
 {
     try {
         TableComposite.Delete();
     } catch (DatabaseSystemException) {
         throw;
     } catch (Exception ex) {
         throw new DatabaseSystemException("An error occurred while deleting the database", ex);
     }
 }