Method ToBsonDocument
ToBsonDocument<TNominalType>(TNominalType, IBsonSerializer<TNominalType>, Action<Builder>, BsonSerializationArgs)
Serializes an object to a BsonDocument.
public static BsonDocument ToBsonDocument<TNominalType>(this TNominalType obj, IBsonSerializer<TNominalType> serializer = null, Action<BsonSerializationContext.Builder> configurator = null, BsonSerializationArgs args = default)
Parameters
obj
TNominalTypeThe object.
serializer
IBsonSerializer<TNominalType>The serializer.
configurator
Action<BsonSerializationContext.Builder>The serialization context configurator.
args
BsonSerializationArgsThe serialization args.
Returns
- BsonDocument
A BsonDocument.
Type Parameters
TNominalType
The nominal type of the object.
ToBsonDocument(object, Type, IBsonSerializer, Action<Builder>, BsonSerializationArgs)
Serializes an object to a BsonDocument.
public static BsonDocument ToBsonDocument(this object obj, Type nominalType, IBsonSerializer serializer = null, Action<BsonSerializationContext.Builder> configurator = null, BsonSerializationArgs args = default)
Parameters
obj
objectThe object.
nominalType
TypeThe nominal type of the object.
serializer
IBsonSerializerThe serializer.
configurator
Action<BsonSerializationContext.Builder>The serialization context configurator.
args
BsonSerializationArgsThe serialization args.
Returns
- BsonDocument
A BsonDocument.
Exceptions
- ArgumentNullException
nominalType
- ArgumentException
serializer