/// <summary> /// protected virtual dispose. /// Closes this Collection on disk, its deleted blocks and Mru Segments. /// Sets the data block driver to null. /// </summary> protected internal virtual void InternalDispose() { if (FileStream != null) { Close(); } if (deletedBlocks != null) { deletedBlocks.Dispose(); deletedBlocks = null; } Parent = null; if (DataBlockDriver != null) { if (!IsCloned) { DataBlockDriver.Dispose(); } DataBlockDriver = null; } if (OnDiskBinaryReader != null) { OnDiskBinaryReader.Close(); OnDiskBinaryReader = null; } if (OnDiskBinaryWriter != null) { OnDiskBinaryWriter.Close(); OnDiskBinaryWriter = null; } _instanceTransaction = null; _parentTransactionLogger = null; File = null; }
/// <summary> /// protected virtual dispose. /// Closes this Collection on disk, its deleted blocks and Mru Segments. /// Sets the data block driver to null. /// </summary> protected internal virtual void InternalDispose() { // note: SOP's Dispose pattern is created to provide way to do early // garbage collection of the "graph" objects, simply. Not for freeing up unmanaged // resources, thus, no finalizer/SafeHandle "patterns". All members are "virtualized" // objects and they have custom Dispose for the same. if (isDisposed) { return; } isDisposed = true; // FileStream is a wrapper, not the .Net FileStream. if (FileStream != null) { Close(); } if (deletedBlocks != null) { deletedBlocks.Dispose(); deletedBlocks = null; } Parent = null; if (DataBlockDriver != null) { //if (!IsCloned) DataBlockDriver.Dispose(); DataBlockDriver = null; } if (OnDiskBinaryReader != null) { OnDiskBinaryReader.Close(); OnDiskBinaryReader = null; } if (OnDiskBinaryWriter != null) { OnDiskBinaryWriter.Close(); OnDiskBinaryWriter = null; } _instanceTransaction = null; _parentTransactionLogger = null; File = null; Blocks = null; var locker = _syncRoot as IDisposable; if (locker != null) { locker.Dispose(); } }