/// <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_dataIoSession != null) { m_dataIoSession.Dispose(); m_dataIoSession = null; } // This will be done only when the object is disposed by calling Dispose(). } } finally { m_dataIoSession = null; m_disposed = true; // Prevent duplicate dispose. base.Dispose(disposing); // Call base class Dispose(). } } }
public SimplifiedIoSession(SubFileStream stream) { m_stream = stream; m_dataIoSession = stream.m_dataReader.CreateDiskIoSession(stream.m_fileHeaderBlock, stream.m_subFile); m_blockDataLength = m_stream.m_blockSize - FileStructureConstants.BlockFooterLength; }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <filterpriority>2</filterpriority> public void Dispose() { GC.SuppressFinalize(this); IsDisposed = true; if (SourceData != null) { SourceData.Dispose(); SourceData = null; } if (DestinationData != null) { DestinationData.Dispose(); DestinationData = null; } if (SourceIndex != null) { SourceIndex.Dispose(); SourceIndex = null; } if (DestinationIndex != null) { DestinationIndex.Dispose(); DestinationIndex = null; } }
/// <summary> /// Swaps the source and destination Data I/O Sessions /// </summary> public void SwapData() { if (IsReadOnly) throw new NotSupportedException("Not supported when in read only mode"); DiskIoSession swap = SourceData; SourceData = DestinationData; DestinationData = swap; }
/// <summary> /// Swaps the source and destination index I/O Sessions. /// </summary> public void SwapIndex() { if (IsReadOnly) throw new NotSupportedException("Not supported when in read only mode"); DiskIoSession swap = SourceIndex; SourceIndex = DestinationIndex; DestinationIndex = swap; }
/// <summary> /// Creates this file with the following data. /// </summary> /// <param name="diskIo"></param> /// <param name="header"></param> /// <param name="file"></param> /// <param name="isReadOnly"></param> public SubFileDiskIoSessionPool(DiskIo diskIo, FileHeaderBlock header, SubFileHeader file, bool isReadOnly) { LastReadonlyBlock = diskIo.LastCommittedHeader.LastAllocatedBlock; File = file; Header = header; IsReadOnly = isReadOnly; SourceData = diskIo.CreateDiskIoSession(header, file); SourceIndex = diskIo.CreateDiskIoSession(header, file); if (!isReadOnly) { DestinationData = diskIo.CreateDiskIoSession(header, file); DestinationIndex = diskIo.CreateDiskIoSession(header, file); } }