Class BsonSerializerRegistry
- Namespace
- MongoDB.Bson.Serialization
- Assembly
- MongoDB.Bson.dll
Default, global implementation of an IBsonSerializerRegistry.
public sealed class BsonSerializerRegistry : IBsonSerializerRegistry
- Inheritance
-
BsonSerializerRegistry
- Implements
- Inherited Members
- Extension Methods
Constructors
BsonSerializerRegistry()
Initializes a new instance of the BsonSerializerRegistry class.
public BsonSerializerRegistry()
Methods
GetSerializer(Type)
Gets the serializer for the specified type
.
If none is already registered, the serialization providers will be used to create a serializer and it will be automatically registered.
public IBsonSerializer GetSerializer(Type type)
Parameters
type
TypeThe type.
Returns
- IBsonSerializer
The serializer.
GetSerializer<T>()
Gets the serializer for the specified T
.
If none is already registered, the serialization providers will be used to create a serializer and it will be automatically registered.
public IBsonSerializer<T> GetSerializer<T>()
Returns
- IBsonSerializer<T>
The serializer.
Type Parameters
T
The value type of the serializer.
RegisterSerializationProvider(IBsonSerializationProvider)
Registers the serialization provider. This behaves like a stack, so the last provider registered is the first provider consulted.
public void RegisterSerializationProvider(IBsonSerializationProvider serializationProvider)
Parameters
serializationProvider
IBsonSerializationProviderThe serialization provider.
RegisterSerializer(Type, IBsonSerializer)
Registers the serializer.
public void RegisterSerializer(Type type, IBsonSerializer serializer)
Parameters
type
TypeThe type.
serializer
IBsonSerializerThe serializer.
TryRegisterSerializer(Type, IBsonSerializer)
Tries to register the serializer.
public bool TryRegisterSerializer(Type type, IBsonSerializer serializer)
Parameters
type
TypeThe type.
serializer
IBsonSerializerThe serializer.
Returns
- bool
True if the serializer was registered on this call, false if the same serializer was already registered on a previous call, throws an exception if a different serializer was already registered.