MongoDB.Bson.IO.BsonBinaryWriter.Close C# (CSharp) Method

Close() public method

Closes the writer.
public Close ( ) : void
return void
        public override void Close()
        {
            // Close can be called on Disposed objects
            if (State != BsonWriterState.Closed)
            {
                if (State == BsonWriterState.Done)
                {
                    Flush();
                }
                if (_stream != null && _binaryWriterSettings.CloseOutput)
                {
                    _stream.Close();
                }
                _context = null;
                State = BsonWriterState.Closed;
            }
        }

Usage Example

Example #1
0
 public void Test1ChunkPlus1()
 {
     var stream = new MemoryStream();
     using (var bsonWriter = new BsonBinaryWriter(stream))
     {
         bsonWriter.WriteStartDocument();
         bsonWriter.WriteBytes("Data", new byte[16 * 1024 - 15]);
         bsonWriter.WriteEndDocument();
         bsonWriter.Close();
     }
 }
All Usage Examples Of MongoDB.Bson.IO.BsonBinaryWriter::Close