80 lines
3.2 KiB
C#
80 lines
3.2 KiB
C#
using System;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Questionable.Model.Questing.Converter;
|
|
|
|
public sealed class ElementIdConverter : JsonConverter<ElementId>
|
|
{
|
|
public override ElementId Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
int num = ((reader.TokenType != JsonTokenType.Number) ? 937296843 : 937296840);
|
|
while (true)
|
|
{
|
|
int num2 = num;
|
|
int num3 = 937296842;
|
|
int num4 = num2;
|
|
int num5 = num4 + num3;
|
|
int num6 = num4 & num3;
|
|
switch (num5 - (num6 + num6))
|
|
{
|
|
case 0:
|
|
goto IL_0049;
|
|
case 1:
|
|
return ElementId.FromString(reader.GetString() ?? throw _200F_200C_200C_202B_202D_206A_200F_206B_200D_206D_202B_202C_206D_206F_202E_206C_206A_200B_200B_206B_206C_202B_206F_206D_200B_206B_202C_200C_202E_200D_200C_200D_202B_202B_200C_202C_200F_202A_202C_202C_202E());
|
|
case 2:
|
|
return new QuestId(reader.GetUInt16());
|
|
}
|
|
continue;
|
|
IL_0049:
|
|
num = 937296840;
|
|
}
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, ElementId value, JsonSerializerOptions options)
|
|
{
|
|
int num = ((!(value is QuestId)) ? (-1636085642) : (-1636085643));
|
|
while (true)
|
|
{
|
|
int num2 = num;
|
|
int num3 = -1636085641;
|
|
int num4 = num2;
|
|
int num5 = num4 + num3;
|
|
int num6 = num4 & num3;
|
|
switch (num5 - (num6 + num6))
|
|
{
|
|
case 0:
|
|
goto IL_0048;
|
|
case 1:
|
|
_206D_202E_202D_200B_202D_200B_206B_200E_200D_206F_202D_200D_206A_200F_202D_200F_200E_202E_202D_206C_200F_206E_200F_202C_206F_206B_200B_200F_200B_200C_206C_200B_206F_206B_202D_202B_202C_200D_202B_202E_202E(writer, _200E_202C_206D_200B_200D_206A_206F_206D_200B_200F_200D_200D_206E_206A_202D_200B_202A_202E_206D_202B_202E_200E_200E_200D_200D_200E_202D_200C_206A_202D_202E_200E_202E_202E_202C_206F_202B_200D_206B_202E((object)value));
|
|
return;
|
|
case 2:
|
|
_202D_200D_206A_202D_206A_202E_202D_202D_202C_202B_202C_202E_202B_202B_200F_206C_206E_202C_206A_202A_200C_206E_202E_206E_200E_202E_202B_206A_200B_206E_202E_206B_206C_206B_200F_202E_202D_200C_202A_202E(writer, (int)value.Value);
|
|
return;
|
|
}
|
|
continue;
|
|
IL_0048:
|
|
num = -1636085643;
|
|
}
|
|
}
|
|
|
|
static JsonException _200F_200C_200C_202B_202D_206A_200F_206B_200D_206D_202B_202C_206D_206F_202E_206C_206A_200B_200B_206B_206C_202B_206F_206D_200B_206B_202C_200C_202E_200D_200C_200D_202B_202B_200C_202C_200F_202A_202C_202C_202E()
|
|
{
|
|
return new JsonException();
|
|
}
|
|
|
|
static void _202D_200D_206A_202D_206A_202E_202D_202D_202C_202B_202C_202E_202B_202B_200F_206C_206E_202C_206A_202A_200C_206E_202E_206E_200E_202E_202B_206A_200B_206E_202E_206B_206C_206B_200F_202E_202D_200C_202A_202E(Utf8JsonWriter P_0, int P_1)
|
|
{
|
|
P_0.WriteNumberValue(P_1);
|
|
}
|
|
|
|
static string _200E_202C_206D_200B_200D_206A_206F_206D_200B_200F_200D_200D_206E_206A_202D_200B_202A_202E_206D_202B_202E_200E_200E_200D_200D_200E_202D_200C_206A_202D_202E_200E_202E_202E_202C_206F_202B_200D_206B_202E(object P_0)
|
|
{
|
|
return P_0.ToString();
|
|
}
|
|
|
|
static void _206D_202E_202D_200B_202D_200B_206B_200E_200D_206F_202D_200D_206A_200F_202D_200F_200E_202E_202D_206C_200F_206E_200F_202C_206F_206B_200B_200F_200B_200C_206C_200B_206F_206B_202D_202B_202C_200D_202B_202E_202E(Utf8JsonWriter P_0, string P_1)
|
|
{
|
|
P_0.WriteStringValue(P_1);
|
|
}
|
|
}
|