Class SerializerBase<TValue>
- Namespace
- MongoDB.Bson.Serialization.Serializers
- Assembly
- MongoDB.Bson.dll
Represents an abstract base class for serializers.
public abstract class SerializerBase<TValue> : IBsonSerializer<TValue>, IBsonSerializer
Type Parameters
TValue
The type of the value.
- Inheritance
-
SerializerBase<TValue>
- Implements
-
IBsonSerializer<TValue>
- Derived
- Inherited Members
- Extension Methods
Properties
ValueType
Gets the type of the values.
public Type ValueType { get; }
Property Value
- Type
The type of the values.
Methods
CreateCannotBeDeserializedException()
Creates an exception to throw when a type cannot be deserialized.
protected Exception CreateCannotBeDeserializedException()
Returns
- Exception
An exception.
CreateCannotBeSerializedException()
Creates an exception to throw when a type cannot be deserialized.
protected Exception CreateCannotBeSerializedException()
Returns
- Exception
An exception.
CreateCannotDeserializeFromBsonTypeException(BsonType)
Creates an exception to throw when a type cannot be deserialized from a BsonType.
protected Exception CreateCannotDeserializeFromBsonTypeException(BsonType bsonType)
Parameters
bsonType
BsonTypeThe BSON type.
Returns
- Exception
An exception.
Deserialize(BsonDeserializationContext, BsonDeserializationArgs)
Deserializes a value.
public virtual TValue Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
Parameters
context
BsonDeserializationContextThe deserialization context.
args
BsonDeserializationArgsThe deserialization args.
Returns
- TValue
A deserialized value.
EnsureBsonTypeEquals(IBsonReader, BsonType)
Ensures that the BsonType equals the expected type.
protected void EnsureBsonTypeEquals(IBsonReader reader, BsonType bsonType)
Parameters
reader
IBsonReaderThe reader.
bsonType
BsonTypeThe expected type.
Serialize(BsonSerializationContext, BsonSerializationArgs, TValue)
Serializes a value.
public virtual void Serialize(BsonSerializationContext context, BsonSerializationArgs args, TValue value)
Parameters
context
BsonSerializationContextThe serialization context.
args
BsonSerializationArgsThe serialization args.
value
TValueThe value.