Class BsonBinaryWriter
Represents a BSON writer to a BSON Stream.
public class BsonBinaryWriter : BsonWriter, IBsonWriter, IDisposable
- Inheritance
-
BsonBinaryWriter
- Implements
- Inherited Members
- Extension Methods
Constructors
BsonBinaryWriter(Stream)
Initializes a new instance of the BsonBinaryWriter class.
public BsonBinaryWriter(Stream stream)
Parameters
streamStreamA stream. The BsonBinaryWriter does not own the stream and will not Dispose it.
BsonBinaryWriter(Stream, BsonBinaryWriterSettings)
Initializes a new instance of the BsonBinaryWriter class.
public BsonBinaryWriter(Stream stream, BsonBinaryWriterSettings settings)
Parameters
streamStreamA stream. The BsonBinaryWriter does not own the stream and will not Dispose it.
settingsBsonBinaryWriterSettingsThe BsonBinaryWriter settings.
Properties
BaseStream
Gets the base stream.
public Stream BaseStream { get; }
Property Value
- Stream
The base stream.
BsonStream
Gets the BSON stream.
public BsonStream BsonStream { get; }
Property Value
- BsonStream
The BSON stream.
Position
Gets the position. Not all writers are able to report the position. Those that can't simply return zero.
public override long Position { get; }
Property Value
- long
The position.
Settings
Gets the settings of the writer.
public BsonBinaryWriterSettings Settings { get; }
Property Value
Methods
Close()
Closes the writer. Also closes the base stream.
public override void Close()
Dispose(bool)
Disposes of any resources used by the writer.
protected override void Dispose(bool disposing)
Parameters
disposingboolTrue if called from Dispose.
Flush()
Flushes any pending data to the output destination.
public override void Flush()
PopMaxDocumentSize()
Pops the max document size stack, restoring the previous max document size.
[Obsolete("Use PopSettings instead.")]
public void PopMaxDocumentSize()
PushMaxDocumentSize(int)
Pushes a new max document size onto the max document size stack.
[Obsolete("Use PushSettings instead.")]
public void PushMaxDocumentSize(int maxDocumentSize)
Parameters
maxDocumentSizeintThe maximum size of the document.
WriteBinaryData(BsonBinaryData)
Writes BSON binary data to the writer.
public override void WriteBinaryData(BsonBinaryData binaryData)
Parameters
binaryDataBsonBinaryDataThe binary data.
WriteBoolean(bool)
Writes a BSON Boolean to the writer.
public override void WriteBoolean(bool value)
Parameters
valueboolThe Boolean value.
WriteBytes(byte[])
Writes BSON binary data to the writer.
public override void WriteBytes(byte[] bytes)
Parameters
bytesbyte[]The bytes.
WriteDateTime(long)
Writes a BSON DateTime to the writer.
public override void WriteDateTime(long value)
Parameters
valuelongThe number of milliseconds since the Unix epoch.
WriteDecimal128(Decimal128)
Writes a BSON Decimal128 to the writer.
public override void WriteDecimal128(Decimal128 value)
Parameters
valueDecimal128The Decimal128 value.
WriteDouble(double)
Writes a BSON Double to the writer.
public override void WriteDouble(double value)
Parameters
valuedoubleThe Double value.
WriteEndArray()
Writes the end of a BSON array to the writer.
public override void WriteEndArray()
WriteEndDocument()
Writes the end of a BSON document to the writer.
public override void WriteEndDocument()
WriteInt32(int)
Writes a BSON Int32 to the writer.
public override void WriteInt32(int value)
Parameters
valueintThe Int32 value.
WriteInt64(long)
Writes a BSON Int64 to the writer.
public override void WriteInt64(long value)
Parameters
valuelongThe Int64 value.
WriteJavaScript(string)
Writes a BSON JavaScript to the writer.
public override void WriteJavaScript(string code)
Parameters
codestringThe JavaScript code.
WriteJavaScriptWithScope(string)
Writes a BSON JavaScript to the writer (call WriteStartDocument to start writing the scope).
public override void WriteJavaScriptWithScope(string code)
Parameters
codestringThe JavaScript code.
WriteMaxKey()
Writes a BSON MaxKey to the writer.
public override void WriteMaxKey()
WriteMinKey()
Writes a BSON MinKey to the writer.
public override void WriteMinKey()
WriteNull()
Writes a BSON null to the writer.
public override void WriteNull()
WriteObjectId(ObjectId)
Writes a BSON ObjectId to the writer.
public override void WriteObjectId(ObjectId objectId)
Parameters
objectIdObjectIdThe ObjectId.
WriteRawBsonArray(IByteBuffer)
Writes a raw BSON array.
public override void WriteRawBsonArray(IByteBuffer slice)
Parameters
sliceIByteBufferThe byte buffer containing the raw BSON array.
WriteRawBsonDocument(IByteBuffer)
Writes a raw BSON document.
public override void WriteRawBsonDocument(IByteBuffer slice)
Parameters
sliceIByteBufferThe byte buffer containing the raw BSON document.
WriteRegularExpression(BsonRegularExpression)
Writes a BSON regular expression to the writer.
public override void WriteRegularExpression(BsonRegularExpression regex)
Parameters
regexBsonRegularExpressionA BsonRegularExpression.
WriteStartArray()
Writes the start of a BSON array to the writer.
public override void WriteStartArray()
WriteStartDocument()
Writes the start of a BSON document to the writer.
public override void WriteStartDocument()
WriteString(string)
Writes a BSON String to the writer.
public override void WriteString(string value)
Parameters
valuestringThe String value.
WriteSymbol(string)
Writes a BSON Symbol to the writer.
public override void WriteSymbol(string value)
Parameters
valuestringThe symbol.
WriteTimestamp(long)
Writes a BSON timestamp to the writer.
public override void WriteTimestamp(long value)
Parameters
valuelongThe combined timestamp/increment value.
WriteUndefined()
Writes a BSON undefined to the writer.
public override void WriteUndefined()