Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
IListConverter.cs
Go to the documentation of this file.
4
6
7internal sealed class IListConverter<TCollection> : JsonCollectionConverter<TCollection, object> where TCollection : IList
8{
9 internal override Type RuntimeType
10 {
11 get
12 {
13 if (TypeToConvert.IsAbstract || TypeToConvert.IsInterface)
14 {
15 return typeof(List<object>);
16 }
17 return TypeToConvert;
18 }
19 }
20
21 protected override void Add(in object value, ref ReadStack state)
22 {
23 TCollection val = (TCollection)state.Current.ReturnValue;
24 val.Add(value);
25 if (base.IsValueType)
26 {
28 }
29 }
30
32 {
33 JsonTypeInfo jsonTypeInfo = state.Current.JsonTypeInfo;
34 if (TypeToConvert.IsInterface || TypeToConvert.IsAbstract)
35 {
36 if (!TypeToConvert.IsAssignableFrom(RuntimeType))
37 {
39 }
41 return;
42 }
43 if (jsonTypeInfo.CreateObject == null)
44 {
46 }
47 TCollection val = (TCollection)jsonTypeInfo.CreateObject();
48 if (val.IsReadOnly)
49 {
51 }
53 }
54
56 {
58 int i = state.Current.EnumeratorIndex;
60 if (elementConverter.CanUseDirectReadOrWrite && !state.Current.NumberHandling.HasValue)
61 {
62 for (; i < list.Count; i++)
63 {
65 }
66 }
67 else
68 {
69 for (; i < list.Count; i++)
70 {
71 object value2 = list[i];
73 {
75 return false;
76 }
77 if (ShouldFlush(writer, ref state))
78 {
80 return false;
81 }
82 }
83 }
84 return true;
85 }
86}
bool ICollection< KeyValuePair< TKey, TValue > >. IsReadOnly
void Add(TKey key, TValue value)
override void Add(in object value, ref ReadStack state)
override void CreateCollection(ref Utf8JsonReader reader, ref ReadStack state, JsonSerializerOptions options)
override bool OnWriteResume(Utf8JsonWriter writer, TCollection value, JsonSerializerOptions options, ref WriteStack 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)