Table of Contents

Class DictionaryBsonConverter

Namespace
adas_core.Domain.Models.BsonConverters
Assembly
adas-core.Domain.dll

A BSON converter responsible for serializing and deserializing Dictionary<TKey, TValue> instances with string keys and object values, extending the base serializer infrastructure to support BSON format conversion.

public class DictionaryBsonConverter : SerializerBase<Dictionary<string, object>>, IBsonSerializer<Dictionary<string, object>>, IBsonSerializer
Inheritance
SerializerBase<Dictionary<string, object>>
DictionaryBsonConverter
Implements
IBsonSerializer<Dictionary<string, object>>
IBsonSerializer
Inherited Members
SerializerBase<Dictionary<string, object>>.Deserialize(BsonDeserializationContext, BsonDeserializationArgs)
SerializerBase<Dictionary<string, object>>.GetHashCode()
SerializerBase<Dictionary<string, object>>.Serialize(BsonSerializationContext, BsonSerializationArgs, Dictionary<string, object>)
SerializerBase<Dictionary<string, object>>.CreateCannotBeDeserializedException()
SerializerBase<Dictionary<string, object>>.CreateCannotBeSerializedException()
SerializerBase<Dictionary<string, object>>.CreateCannotDeserializeFromBsonTypeException(BsonType)
SerializerBase<Dictionary<string, object>>.EnsureBsonTypeEquals(IBsonReader, BsonType)
SerializerBase<Dictionary<string, object>>.ValueType
Extension Methods

Remarks

This type specializes the generic base serializer for the specific dictionary shape Dictionary<string, object>, providing a focused implementation for BSON-based persistence and data interchange scenarios.

Methods

Deserialize(BsonDeserializationContext, BsonDeserializationArgs)

Deserializes a BSON document into a dictionary where each top-level field name is mapped to its corresponding value. Recognized keys (STEPS, BEACONS, CAMERAS, RELAY) are deserialized into their strongly-typed collections or objects, while unknown keys are deserialized based on the current BSON type (numeric values, strings, booleans, arrays of mixed primitive types, or generic BSON documents). If the current BSON value is not a document, an empty dictionary is returned.

public override Dictionary<string, object> Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)

Parameters

context BsonDeserializationContext

The BSON deserialization context providing the reader used to traverse the BSON payload.

args BsonDeserializationArgs

The BSON deserialization arguments carrying additional configuration for the deserialization process.

Returns

Dictionary<string, object>

A dictionary containing the deserialized key/value pairs extracted from the BSON document.

Serialize(BsonSerializationContext, BsonSerializationArgs, Dictionary<string, object>)

Serializes a dictionary of string keys and object values into a BSON document. When a value's type cannot be handled by the underlying key/value serializer, the corresponding key is written with a null value as a fallback to preserve all dictionary entries.

public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, Dictionary<string, object> value)

Parameters

context BsonSerializationContext

The BSON serialization context that provides the writer used to emit the document.

args BsonSerializationArgs

The BSON serialization arguments associated with the current operation.

value Dictionary<string, object>

The dictionary whose entries are written as fields of the BSON document.