// Dispose(bool disposing) executes in two distinct scenarios. If disposing equals true, the method has been called directly // or indirectly by a user's code. Managed and unmanaged resources can be disposed. // If disposing equals false, the method has been called by the runtime from inside the finalizer and you should not reference // other objects. Only unmanaged resources can be disposed. protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this.m_disposed) { // If disposing equals true, dispose all managed and unmanaged resources. if (disposing) { // Dispose managed resources. } // Call the appropriate methods to clean up unmanaged resources here. // If disposing is false, only the following code is executed. DatabaseContainer.Forget(this.ToString()); //m_db = null; // Note disposing has been done. m_disposed = true; } }
public DatabaseWrapper() { string _dbName = GetDatabaseName(); bool _needToCreate = !System.IO.File.Exists(_dbName); m_db = DatabaseContainer.Get(this.ToString(), _dbName); if (!_needToCreate) { try { OpenDatabase(); ValidateDatabase(); } catch (Exception _e) { #if DEBUG System.Windows.Forms.MessageBox.Show("Exception: " + _e.Message + "\r\nSource: " + _e.Source + "\r\nStack: " + _e.StackTrace); #endif RebuildDatabase(); } } else { // Create db structures try { CreateDatabase(); } catch (Exception _e) { #if DEBUG System.Windows.Forms.MessageBox.Show("Exception: " + _e.Message + "\r\nSource: " + _e.Source + "\r\nStack: " + _e.StackTrace); #endif } } }