Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
IDictionaryOfTKeyTValueConverter.cs
Go to the documentation of this file.
3
5
6internal sealed class IDictionaryOfTKeyTValueConverter<TDictionary, TKey, TValue> : DictionaryDefaultConverter<TDictionary, TKey, TValue> where TDictionary : IDictionary<TKey, TValue>
7{
8 internal override Type RuntimeType
9 {
10 get
11 {
12 if (TypeToConvert.IsAbstract || TypeToConvert.IsInterface)
13 {
15 }
16 return TypeToConvert;
17 }
18 }
19
20 protected override void Add(TKey key, in TValue value, JsonSerializerOptions options, ref ReadStack state)
21 {
22 TDictionary val = (TDictionary)state.Current.ReturnValue;
23 val[key] = value;
24 if (base.IsValueType)
25 {
27 }
28 }
29
30 protected override void CreateCollection(ref Utf8JsonReader reader, ref ReadStack state)
31 {
32 JsonTypeInfo jsonTypeInfo = state.Current.JsonTypeInfo;
33 if (TypeToConvert.IsInterface || TypeToConvert.IsAbstract)
34 {
35 if (!TypeToConvert.IsAssignableFrom(RuntimeType))
36 {
38 }
40 return;
41 }
42 if (jsonTypeInfo.CreateObject == null)
43 {
45 }
46 TDictionary val = (TDictionary)jsonTypeInfo.CreateObject();
47 if (val.IsReadOnly)
48 {
50 }
52 }
53}
bool ICollection< KeyValuePair< TKey, TValue > >. IsReadOnly
override void CreateCollection(ref Utf8JsonReader reader, ref ReadStack state)
override void Add(TKey key, in TValue value, JsonSerializerOptions options, ref ReadStack state)
static void ThrowNotSupportedException_CannotPopulateCollection(Type type, ref Utf8JsonReader reader, ref ReadStack state)
static void ThrowNotSupportedException_DeserializeNoConstructor(Type type, ref Utf8JsonReader reader, ref ReadStack state)