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; } }
private void ClearIndexNodeCache(IoSession caller, IndexParser mostRecentParser) { if (!m_fileHeaderBlock.IsSimplifiedFileFormat) { if (m_ioStream1 != null && !m_ioStream1.IsDisposed && m_ioStream1 != caller) (m_ioStream1 as IoSession).ClearIndexCache(mostRecentParser); if (m_ioStream2 != null && !m_ioStream2.IsDisposed && m_ioStream2 != caller) (m_ioStream2 as IoSession).ClearIndexCache(mostRecentParser); } }
/// <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 void ClearIndexCache(IndexParser mostRecentParser) { if (IsDisposed || m_ioSessions.IsDisposed) throw new ObjectDisposedException(GetType().FullName); m_parser.ClearIndexCache(mostRecentParser); }
/// <summary> /// Resets the index cache with the information from the supplied <see cref="mostRecentParser"/> /// </summary> /// <param name="mostRecentParser"></param> public void ClearIndexCache(IndexParser mostRecentParser) { FirstIndirectBlockAddress = mostRecentParser.FirstIndirectBlockAddress; SecondIndirectBlockAddress = mostRecentParser.SecondIndirectBlockAddress; ThirdIndirectBlockAddress = mostRecentParser.ThirdIndirectBlockAddress; FourthIndirectBlockAddress = mostRecentParser.FourthIndirectBlockAddress; DataClusterAddress = mostRecentParser.DataClusterAddress; MapPosition(mostRecentParser.BaseVirtualAddressIndexValue); m_oldFirstOffset = -1; }