Exemple #1
0
 /// <summary>
 /// Flushes any pending data to the output destination.
 /// </summary>
 public override void Flush()
 {
     if (disposed)
     {
         throw new ObjectDisposedException("BsonBinaryWriter");
     }
     if (state == BsonWriterState.Closed)
     {
         throw new InvalidOperationException("Flush called on closed BsonWriter.");
     }
     if (state != BsonWriterState.Done)
     {
         throw new InvalidOperationException("Flush called before BsonBinaryWriter was finished writing to buffer.");
     }
     if (stream != null)
     {
         buffer.WriteTo(stream);
         stream.Flush();
         buffer.Clear(); // only clear the buffer if we have written it to a stream
     }
 }