Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ObjectConverterFactory.cs
Go to the documentation of this file.
5
7
9{
11
12 [RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
17
18 public override bool CanConvert(Type typeToConvert)
19 {
20 return true;
21 }
22
23 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor is marked RequiresUnreferencedCode.")]
24 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2067:UnrecognizedReflectionPattern", Justification = "The ctor is marked RequiresUnreferencedCode.")]
26 {
27 if (typeToConvert.IsKeyValuePair())
28 {
30 }
32 {
34 }
35 ParameterInfo[] array = deserializationCtor?.GetParameters();
36 Type type;
37 if (deserializationCtor == null || typeToConvert.IsAbstract || array.Length == 0)
38 {
40 }
41 else
42 {
43 int num = array.Length;
44 if (num <= 4)
45 {
47 Type[] array2 = new Type[5] { typeToConvert, null, null, null, null };
48 for (int i = 0; i < 4; i++)
49 {
50 if (i < num)
51 {
52 array2[i + 1] = array[i].ParameterType;
53 }
54 else
55 {
56 array2[i + 1] = objectType;
57 }
58 }
60 }
61 else
62 {
64 }
65 }
68 return jsonConverter;
69 }
70
79}
static ? object CreateInstance([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, BindingFlags bindingAttr, Binder? binder, object?[]? args, CultureInfo? culture)
Definition Activator.cs:17
ObjectConverterFactory(bool useDefaultConstructorInUnannotatedStructs=true)
override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
JsonConverter CreateKeyValuePairConverter(Type type, JsonSerializerOptions options)
static void ThrowInvalidOperationException_SerializationDuplicateTypeAttribute(Type classType, Type attribute)
virtual Type[] GetGenericArguments()
Definition Type.cs:500
virtual Type MakeGenericType(params Type[] typeArguments)
Definition Type.cs:1074