Class BsonDocumentWriter
Represents a BSON writer to a BsonDocument.
public class BsonDocumentWriter : BsonWriter, IBsonWriter, IDisposable
- Inheritance
-
BsonDocumentWriter
- Implements
- Inherited Members
- Extension Methods
Constructors
BsonDocumentWriter(BsonDocument)
Initializes a new instance of the BsonDocumentWriter class.
public BsonDocumentWriter(BsonDocument document)
Parameters
document
BsonDocumentThe document to write to (normally starts out as an empty document).
BsonDocumentWriter(BsonDocument, BsonDocumentWriterSettings)
Initializes a new instance of the BsonDocumentWriter class.
public BsonDocumentWriter(BsonDocument document, BsonDocumentWriterSettings settings)
Parameters
document
BsonDocumentThe document to write to (normally starts out as an empty document).
settings
BsonDocumentWriterSettingsThe settings.
Properties
Document
Gets the BsonDocument being written to.
public BsonDocument Document { get; }
Property Value
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.
Methods
Close()
Closes the writer.
public override void Close()
Dispose(bool)
Disposes of any resources used by the writer.
protected override void Dispose(bool disposing)
Parameters
disposing
boolTrue if called from Dispose.
Flush()
Flushes any pending data to the output destination.
public override void Flush()
WriteBinaryData(BsonBinaryData)
Writes BSON binary data to the writer.
public override void WriteBinaryData(BsonBinaryData binaryData)
Parameters
binaryData
BsonBinaryDataThe binary data.
WriteBoolean(bool)
Writes a BSON Boolean to the writer.
public override void WriteBoolean(bool value)
Parameters
value
boolThe Boolean value.
WriteBytes(byte[])
Writes BSON binary data to the writer.
public override void WriteBytes(byte[] bytes)
Parameters
bytes
byte[]The bytes.
WriteDateTime(long)
Writes a BSON DateTime to the writer.
public override void WriteDateTime(long value)
Parameters
value
longThe number of milliseconds since the Unix epoch.
WriteDecimal128(Decimal128)
Writes a BSON Decimal128 to the writer.
public override void WriteDecimal128(Decimal128 value)
Parameters
value
Decimal128The Decimal128 value.
WriteDouble(double)
Writes a BSON Double to the writer.
public override void WriteDouble(double value)
Parameters
value
doubleThe 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
value
intThe Int32 value.
WriteInt64(long)
Writes a BSON Int64 to the writer.
public override void WriteInt64(long value)
Parameters
value
longThe Int64 value.
WriteJavaScript(string)
Writes a BSON JavaScript to the writer.
public override void WriteJavaScript(string code)
Parameters
code
stringThe 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
code
stringThe 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()
WriteName(string)
Writes the name of an element to the writer.
public override void WriteName(string name)
Parameters
name
stringThe name of the element.
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
objectId
ObjectIdThe ObjectId.
WriteRegularExpression(BsonRegularExpression)
Writes a BSON regular expression to the writer.
public override void WriteRegularExpression(BsonRegularExpression regex)
Parameters
regex
BsonRegularExpressionA 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
value
stringThe String value.
WriteSymbol(string)
Writes a BSON Symbol to the writer.
public override void WriteSymbol(string value)
Parameters
value
stringThe symbol.
WriteTimestamp(long)
Writes a BSON timestamp to the writer.
public override void WriteTimestamp(long value)
Parameters
value
longThe combined timestamp/increment value.
WriteUndefined()
Writes a BSON undefined to the writer.
public override void WriteUndefined()