Table of Contents

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
KeyValuePairSerializer<TKey, TValue>
Implements
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 BsonType

The representation.

KeyValuePairSerializer(BsonType, IBsonSerializerRegistry)

Initializes a new instance of the KeyValuePairSerializer<TKey, TValue> class.

public KeyValuePairSerializer(BsonType representation, IBsonSerializerRegistry serializerRegistry)

Parameters

representation BsonType

The representation.

serializerRegistry IBsonSerializerRegistry

The 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 BsonType

The 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 BsonDeserializationContext

The deserialization context.

args BsonDeserializationArgs

The 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 BsonSerializationContext

The serialization context.

args BsonSerializationArgs

The 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 string

Name of the member.

serializationInfo BsonSerializationInfo

The serialization information.

Returns

bool

true if the serialization info exists; otherwise false.