Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
JsonEnumDataContract.cs
Go to the documentation of this file.
2
4
6{
8 {
9 private readonly bool _isULong;
10
11 public bool IsULong => _isULong;
12
13 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
19 }
20
22
23 public bool IsULong => _helper.IsULong;
24
25 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
31
32 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
34 {
35 object obj = ((!IsULong) ? Enum.ToObject(base.TraditionalDataContract.UnderlyingType, jsonReader.ReadElementContentAsLong()) : Enum.ToObject(base.TraditionalDataContract.UnderlyingType, jsonReader.ReadElementContentAsUnsignedLong()));
36 context?.AddNewObject(obj);
37 return obj;
38 }
39
40 [RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
42 {
43 if (IsULong)
44 {
45 jsonWriter.WriteUnsignedLong(Convert.ToUInt64(obj));
46 }
47 else
48 {
49 jsonWriter.WriteLong(Convert.ToInt64(obj));
50 }
51 }
52}
static long ToInt64(object? value)
Definition Convert.cs:1623
static ulong ToUInt64(object? value)
Definition Convert.cs:1738
static object ToObject(Type enumType, object value)
Definition Enum.cs:874
JsonEnumDataContract(EnumDataContract traditionalDataContract)
override void WriteJsonValueCore(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
readonly JsonEnumDataContractCriticalHelper _helper