Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ICollectionOfTConverter.cs
Go to the documentation of this file.
3
5
6internal sealed class ICollectionOfTConverter<TCollection, TElement> : IEnumerableDefaultConverter<TCollection, TElement> where TCollection : ICollection<TElement>
7{
8 internal override Type RuntimeType
9 {
10 get
11 {
12 if (TypeToConvert.IsAbstract || TypeToConvert.IsInterface)
13 {
14 return typeof(List<TElement>);
15 }
16 return TypeToConvert;
17 }
18 }
19
20 protected override void Add(in TElement value, ref ReadStack state)
21 {
22 TCollection val = (TCollection)state.Current.ReturnValue;
23 val.Add(value);
24 if (base.IsValueType)
25 {
27 }
28 }
29
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 TCollection val = (TCollection)jsonTypeInfo.CreateObject();
47 if (val.IsReadOnly)
48 {
50 }
52 }
53}
bool ICollection< KeyValuePair< TKey, TValue > >. IsReadOnly
void Add(TKey key, TValue value)
override void Add(in TElement value, ref ReadStack state)
override void CreateCollection(ref Utf8JsonReader reader, ref ReadStack state, JsonSerializerOptions options)
static void ThrowNotSupportedException_CannotPopulateCollection(Type type, ref Utf8JsonReader reader, ref ReadStack state)
static void ThrowNotSupportedException_DeserializeNoConstructor(Type type, ref Utf8JsonReader reader, ref ReadStack state)