Class BsonTypeMapper
A static class that maps between .NET objects and BsonValues.
public static class BsonTypeMapper
- Inheritance
-
BsonTypeMapper
- Inherited Members
Methods
MapToBsonValue(object)
Maps an object to an instance of the closest BsonValue class.
public static BsonValue MapToBsonValue(object value)
Parameters
value
objectAn object.
Returns
- BsonValue
A BsonValue.
MapToBsonValue(object, BsonType)
Maps an object to a specific BsonValue type.
public static BsonValue MapToBsonValue(object value, BsonType bsonType)
Parameters
Returns
- BsonValue
A BsonValue of the desired type (or BsonNull.Value if value is null and bsonType is Null).
MapToDotNetValue(BsonValue)
Maps a BsonValue to a .NET value using the default BsonTypeMapperOptions.
public static object MapToDotNetValue(BsonValue bsonValue)
Parameters
bsonValue
BsonValueThe BsonValue.
Returns
- object
The mapped .NET value.
MapToDotNetValue(BsonValue, BsonTypeMapperOptions)
Maps a BsonValue to a .NET value.
public static object MapToDotNetValue(BsonValue bsonValue, BsonTypeMapperOptions options)
Parameters
bsonValue
BsonValueThe BsonValue.
options
BsonTypeMapperOptionsThe BsonTypeMapperOptions.
Returns
- object
The mapped .NET value.
RegisterCustomTypeMapper(Type, ICustomBsonTypeMapper)
Registers a custom type mapper.
public static void RegisterCustomTypeMapper(Type type, ICustomBsonTypeMapper customTypeMapper)
Parameters
type
TypeThe type.
customTypeMapper
ICustomBsonTypeMapperA custom type mapper.
TryMapToBsonValue(object, out BsonValue)
Tries to map an object to an instance of the closest BsonValue class.
public static bool TryMapToBsonValue(object value, out BsonValue bsonValue)
Parameters
Returns
- bool
True if the mapping was successfull.