/// <summary> /// Releases the unmanaged resources used by the <see cref="IoSession"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (!m_disposed) { try { // This will be done regardless of whether the object is finalized or disposed. if (disposing) { if (m_ioSessions != null) { m_ioSessions.Dispose(); m_ioSessions = null; } // This will be done only when the object is disposed by calling Dispose(). } } finally { m_parser = null; m_pager = null; m_disposed = true; // Prevent duplicate dispose. base.Dispose(disposing); // Call base class Dispose(). } } }
public IoSession(SubFileStream stream) { m_stream = stream; m_lastEditedBlock = stream.m_dataReader.LastCommittedHeader.LastAllocatedBlock; m_isReadOnly = stream.m_isReadOnly; m_blockDataLength = m_stream.m_blockSize - FileStructureConstants.BlockFooterLength; m_ioSessions = new SubFileDiskIoSessionPool(stream.m_dataReader, stream.m_fileHeaderBlock, stream.m_subFile, stream.m_isReadOnly); if (m_isReadOnly) { m_parser = new IndexParser(m_ioSessions); } else { m_pager = new ShadowCopyAllocator(m_ioSessions); m_parser = m_pager; } }