GSF.IO.FileStructure.SubFileDiskIoSessionPool.SwapData C# (CSharp) Method

SwapData() public method

Swaps the source and destination Data I/O Sessions
public SwapData ( ) : void
return void
        public void SwapData()
        {
            if (IsReadOnly)
                throw new NotSupportedException("Not supported when in read only mode");
            DiskIoSession swap = SourceData;
            SourceData = DestinationData;
            DestinationData = swap;
        }

Usage Example

 /// <summary>
 /// Makes a shadow copy of a data cluster.
 /// </summary>
 /// <param name="sourceClusterAddress">the address of the first block in the cluster.
 /// If address is zero, it simply creates an empty cluster.</param>
 /// <param name="indexValue">the index value of this first block</param>
 /// <param name="destinationClusterAddress">the first block of the destination cluster</param>
 private void ShadowCopyDataCluster(uint sourceClusterAddress, uint indexValue, uint destinationClusterAddress)
 {
     //if source exist
     if (sourceClusterAddress != 0)
     {
         DiskIoSession sourceData      = m_ioSessions.SourceData;
         DiskIoSession destinationData = m_ioSessions.DestinationData;
         sourceData.ReadOld(sourceClusterAddress, BlockType.DataBlock, indexValue);
         destinationData.WriteToNewBlock(destinationClusterAddress, BlockType.DataBlock, indexValue);
         Memory.Copy(sourceData.Pointer, destinationData.Pointer, sourceData.Length);
         m_ioSessions.SwapData();
     }
     //if source cluster does not exist.
     else
     {
         m_ioSessions.SourceData.WriteToNewBlock(destinationClusterAddress, BlockType.DataBlock, indexValue);
         Memory.Clear(m_ioSessions.SourceData.Pointer, m_ioSessions.SourceData.Length);
     }
 }