5internal class DictionarySerializer<T> : BaseSerializer<Dictionary<string, T>>
 
    7    private readonly ISerializer<T> _elemSerializer;
 
    9    public DictionarySerializer(ISerializer<T> elemSerializer)
 
   11        _elemSerializer = elemSerializer;
 
   14    public override Dictionary<string, T> Deserialize(
MappingContext context, ref Utf8FaunaReader reader)
 
   16        if (reader.CurrentTokenType != 
TokenType.StartObject)
 
   17            throw new SerializationException(
 
   18                $
"Unexpected token while deserializing into {typeof(Dictionary<string, T>)}: {reader.CurrentTokenType}");
 
   20        var dict = 
new Dictionary<string, T>();
 
   22        while (reader.Read() && reader.CurrentTokenType != 
TokenType.EndObject)
 
   24            if (reader.CurrentTokenType != 
TokenType.FieldName)
 
   25                throw new SerializationException(
 
   26                    $
"Unexpected token while deserializing field of {typeof(Dictionary<string, T>)}: {reader.CurrentTokenType}");
 
   28            var fieldName = reader.GetString()!;
 
   30            dict.Add(fieldName, _elemSerializer.Deserialize(context, ref reader));
 
   36    public override void Serialize(
MappingContext context, Utf8FaunaWriter writer, 
object? o)
 
   38        DynamicSerializer.Singleton.Serialize(context, writer, o);
 
A class representing the mapping context to be used during serialization and deserialization.
 
TokenType
Enumerates the types of tokens used in Fauna serialization.