Class KeyValuePairSerializer<TKey, TValue>
- Namespace
- MongoDB.Bson.Serialization.Serializers
- Assembly
- MongoDB.Bson.dll
Represents a serializer for KeyValuePairs.
public class KeyValuePairSerializer<TKey, TValue> : StructSerializerBase<KeyValuePair<TKey, TValue>>, IBsonSerializer<KeyValuePair<TKey, TValue>>, IBsonDocumentSerializer, IBsonSerializer
Type Parameters
TKey
The type of the keys.
TValue
The type of the values.
- Inheritance
-
SerializerBase<KeyValuePair<TKey, TValue>>StructSerializerBase<KeyValuePair<TKey, TValue>>KeyValuePairSerializer<TKey, TValue>
- Implements
-
IBsonSerializer<KeyValuePair<TKey, TValue>>
- Inherited Members
- Extension Methods
Constructors
KeyValuePairSerializer()
Initializes a new instance of the KeyValuePairSerializer<TKey, TValue> class.
public KeyValuePairSerializer()
KeyValuePairSerializer(BsonType)
Initializes a new instance of the KeyValuePairSerializer<TKey, TValue> class.
public KeyValuePairSerializer(BsonType representation)
Parameters
representation
BsonTypeThe representation.
KeyValuePairSerializer(BsonType, IBsonSerializerRegistry)
Initializes a new instance of the KeyValuePairSerializer<TKey, TValue> class.
public KeyValuePairSerializer(BsonType representation, IBsonSerializerRegistry serializerRegistry)
Parameters
representation
BsonTypeThe representation.
serializerRegistry
IBsonSerializerRegistryThe serializer registry.
KeyValuePairSerializer(BsonType, IBsonSerializer<TKey>, IBsonSerializer<TValue>)
Initializes a new instance of the KeyValuePairSerializer<TKey, TValue> class.
public KeyValuePairSerializer(BsonType representation, IBsonSerializer<TKey> keySerializer, IBsonSerializer<TValue> valueSerializer)
Parameters
representation
BsonTypeThe representation.
keySerializer
IBsonSerializer<TKey>The key serializer.
valueSerializer
IBsonSerializer<TValue>The value serializer.
Properties
KeySerializer
Gets the key serializer.
public IBsonSerializer<TKey> KeySerializer { get; }
Property Value
- IBsonSerializer<TKey>
The key serializer.
Representation
Gets the representation.
public BsonType Representation { get; }
Property Value
- BsonType
The representation.
ValueSerializer
Gets the value serializer.
public IBsonSerializer<TValue> ValueSerializer { get; }
Property Value
- IBsonSerializer<TValue>
The value serializer.
Methods
Deserialize(BsonDeserializationContext, BsonDeserializationArgs)
Deserializes a value.
public override KeyValuePair<TKey, TValue> Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
Parameters
context
BsonDeserializationContextThe deserialization context.
args
BsonDeserializationArgsThe deserialization args.
Returns
- KeyValuePair<TKey, TValue>
A deserialized value.
Serialize(BsonSerializationContext, BsonSerializationArgs, KeyValuePair<TKey, TValue>)
Serializes a value.
public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, KeyValuePair<TKey, TValue> value)
Parameters
context
BsonSerializationContextThe serialization context.
args
BsonSerializationArgsThe serialization args.
value
KeyValuePair<TKey, TValue>The object.
TryGetMemberSerializationInfo(string, out BsonSerializationInfo)
Tries to get the serialization info for a member.
public bool TryGetMemberSerializationInfo(string memberName, out BsonSerializationInfo serializationInfo)
Parameters
memberName
stringName of the member.
serializationInfo
BsonSerializationInfoThe serialization information.
Returns
- bool
true
if the serialization info exists; otherwisefalse
.