Method ToBson
ToBson<TNominalType>(TNominalType, IBsonSerializer<TNominalType>, BsonBinaryWriterSettings, Action<Builder>, BsonSerializationArgs, int)
Serializes an object to a BSON byte array.
public static byte[] ToBson<TNominalType>(this TNominalType obj, IBsonSerializer<TNominalType> serializer = null, BsonBinaryWriterSettings writerSettings = null, Action<BsonSerializationContext.Builder> configurator = null, BsonSerializationArgs args = default, int estimatedBsonSize = 0)
Parameters
obj
TNominalTypeThe object.
serializer
IBsonSerializer<TNominalType>The serializer.
writerSettings
BsonBinaryWriterSettingsThe writer settings.
configurator
Action<BsonSerializationContext.Builder>The serialization context configurator.
args
BsonSerializationArgsThe serialization args.
estimatedBsonSize
intThe estimated size of the serialized object
Returns
- byte[]
A BSON byte array.
Type Parameters
TNominalType
The nominal type of the object.
ToBson(object, Type, BsonBinaryWriterSettings, IBsonSerializer, Action<Builder>, BsonSerializationArgs, int)
Serializes an object to a BSON byte array.
public static byte[] ToBson(this object obj, Type nominalType, BsonBinaryWriterSettings writerSettings = null, IBsonSerializer serializer = null, Action<BsonSerializationContext.Builder> configurator = null, BsonSerializationArgs args = default, int estimatedBsonSize = 0)
Parameters
obj
objectThe object.
nominalType
TypeThe nominal type of the object..
writerSettings
BsonBinaryWriterSettingsThe writer settings.
serializer
IBsonSerializerThe serializer.
configurator
Action<BsonSerializationContext.Builder>The serialization context configurator.
args
BsonSerializationArgsThe serialization args.
estimatedBsonSize
intThe estimated size of the serialized object.
Returns
- byte[]
A BSON byte array.
Exceptions
- ArgumentNullException
nominalType
- ArgumentException
serializer