5internal class DictionaryDeserializer<T> : BaseDeserializer<Dictionary<string, T>>
7 private IDeserializer<T> _elemDeserializer;
9 public DictionaryDeserializer(IDeserializer<T> elemDeserializer)
11 _elemDeserializer = elemDeserializer;
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, _elemDeserializer.Deserialize(context, ref reader));
T Deserialize(MappingContext context, ref Utf8FaunaReader reader)
TokenType
Enumerates the types of tokens used in Fauna serialization.