public void Close()
 {
     if (this.m_stream != null)
     {
         this.m_stream.Close();
         this.m_stream = null;
         this.m_memoryStream.Close();
         this.m_memoryStream = null;
     }
 }
 public RIFStorage(IStreamHandler streamHandler, int bufferPageSize, int bufferPageCount, int tempStreamSize, ISpaceManager spaceManager, IScalabilityObjectCreator appObjectCreator, IReferenceCreator appReferenceCreator, GlobalIDOwnerCollection globalIdsFromOtherStream, bool fromExistingStream, int rifCompatVersion)
 {
     this.m_streamCreator            = streamHandler;
     this.m_scalabilityCache         = null;
     this.m_bufferPageSize           = bufferPageSize;
     this.m_bufferPageCount          = bufferPageCount;
     this.m_tempStreamSize           = tempStreamSize;
     this.m_stream                   = null;
     this.m_spaceManager             = spaceManager;
     this.m_unifiedObjectCreator     = new UnifiedObjectCreator(appObjectCreator, appReferenceCreator);
     this.m_referenceCreator         = new UnifiedReferenceCreator(appReferenceCreator);
     this.m_fromExistingStream       = fromExistingStream;
     this.m_globalIdsFromOtherStream = globalIdsFromOtherStream;
     this.m_rifCompatVersion         = rifCompatVersion;
 }
 private void SetupStorage()
 {
     if (this.m_stream == null)
     {
         Stream stream = this.m_streamCreator.OpenStream();
         this.m_streamCreator = null;
         this.m_stream        = new PageBufferedStream(stream, this.m_bufferPageSize, this.m_bufferPageCount);
         this.m_stream.FreezePageAllocations = this.m_freezeAllocations;
         List <Declaration> declarations = this.m_unifiedObjectCreator.GetDeclarations();
         this.m_memoryStream = new MemoryStream(this.m_tempStreamSize);
         this.m_writer       = new IntermediateFormatWriter(this.m_memoryStream, declarations, this.m_scalabilityCache, this.m_rifCompatVersion);
         if (this.m_fromExistingStream)
         {
             this.m_spaceManager.StreamEnd = this.m_stream.Length;
             this.m_reader = new IntermediateFormatReader(this.m_stream, this.m_unifiedObjectCreator, this.m_globalIdsFromOtherStream, this.m_scalabilityCache, declarations, IntermediateFormatVersion.Current, PersistenceFlags.Seekable);
         }
         else
         {
             this.m_spaceManager.StreamEnd = this.m_stream.Position;
             this.m_reader = new IntermediateFormatReader(this.m_stream, this.m_unifiedObjectCreator, this.m_globalIdsFromOtherStream, this.m_scalabilityCache, declarations, IntermediateFormatVersion.Current, PersistenceFlags.Seekable);
         }
     }
 }