public void Delete()
        {
            lock (commitLock) {
                // We possibly have things to clean up.
                CleanUp();

                // Go through and delete and close all the committed tables.
                foreach (var source in tableSources.Values)
                {
                    source.Drop();
                }

                // Delete the state file
                StateStore.Flush();
                StoreSystem.CloseStore(stateStore);
                StoreSystem.DeleteStore(stateStore);

                // Delete the blob store
                if (LargeObjectStore != null)
                {
                    StoreSystem.CloseStore(lobStore);
                    StoreSystem.DeleteStore(lobStore);
                }

                //tableSources = null;
                IsClosed = true;
            }

            // Release the storage system.
            StoreSystem.Unlock(StateStoreName);
        }
        public void Close()
        {
            lock (commitLock) {
                CleanUp();

                StoreSystem.SetCheckPoint();

                // Go through and close all the committed tables.
                foreach (var source in tableSources.Values)
                {
                    source.Close(false);
                }

                StateStore.Flush();
                StoreSystem.CloseStore(stateStore);

                //tableSources = null;
                IsClosed = true;
            }

            // Release the storage system
            StoreSystem.Unlock(StateStoreName);

            if (LargeObjectStore != null)
            {
                StoreSystem.CloseStore(lobStore);
            }
        }
        internal void Close(bool dropPending)
        {
            if (IsClosed)
            {
                return;
            }

            lock (this) {
                // NOTE: This method MUST be synchronized over the table to prevent
                //   establishing a root Lock on this table.  If a root Lock is established
                //   then the collection event could fail.

                lock (recordList) {
                    // If we are root locked, we must become un root locked.
                    ClearLocks();

                    try {
                        try {
                            Store.Lock();

                            // Force a garbage collection event.
                            if (!IsReadOnly)
                            {
                                GC.Collect(true);
                            }

                            // If we are closing pending a drop, we need to remove all blob
                            // references input the table.
                            // NOTE: This must only happen after the above collection event.
                            if (dropPending)
                            {
                                // Scan and remove all blob references for this dropped table.
                                ReleaseObjects();
                            }
                        } finally {
                            Store.Unlock();
                        }
                    } catch (Exception) {
                        // TODO: Register the error to the logs
                    }

                    // Synchronize the store
                    indexSetStore.Close();

                    // Close the store input the store system.
                    StoreSystem.CloseStore(Store);

                    // TableInfo = null;
                    IsClosed = true;
                }
            }
        }
        public void Dispose()
        {
            if (FieldCache != null)
            {
                FieldCache.Clear();
            }

            if (headerArea != null)
            {
                headerArea.Dispose();
            }

            if (recordList != null)
            {
                recordList.Dispose();
            }

            if (Registries != null)
            {
                Registries.Dispose();
            }

            if (indexSetStore != null)
            {
                indexSetStore.Dispose();
            }

            if (Store != null)
            {
                if (StoreSystem.CloseStore(Store))
                {
                    Store.Dispose();
                }
            }

            headerArea    = null;
            recordList    = null;
            Registries    = null;
            indexSetStore = null;
        }