-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnumModifier.cs
46 lines (37 loc) · 1.19 KB
/
EnumModifier.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Diagnostics;
using System.Runtime;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Metadata;
namespace CoreExporter
{
internal class EnumModifier
{
private readonly string _targetName;
private readonly JsonConverter _converter;
public EnumModifier(string targetName, JsonConverter converter)
{
_targetName = targetName;
_converter = converter;
}
public void ModifyTypeInfo(JsonTypeInfo ti)
{
Debug.WriteLine($"Type: {ti.Type}");
if (ti.Type != typeof(FreeAllegiance.IGCCore.Util.PartType))
return;
//if (ti.Kind != JsonTypeInfoKind.Object)
// return;
//FreeAllegiance.IGCCore.Util
//if (ti.Type != typeof(FreeAllegiance.IGCCore.Modules.IGCCorePart))
// return;
foreach (var prop in ti.Properties)
{
if (prop.Name == _targetName)
{
Debug.WriteLine($"Type: {ti.Type}");
prop.CustomConverter = _converter;
}
}
}
}
}