-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnumToStringConverter.cs
More file actions
33 lines (31 loc) · 982 Bytes
/
EnumToStringConverter.cs
File metadata and controls
33 lines (31 loc) · 982 Bytes
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
using FreeAllegiance.IGCCore.Modules;
using FreeAllegiance.IGCCore.Util;
using System.Collections;
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Metadata;
namespace CoreExporter
{
internal class EnumToStringConverter : JsonConverter<int>
{
public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
throw new NotImplementedException();
}
public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options)
{
try
{
var partType = (PartType)value;
var jsonValue = JsonValue.Create(partType.ToString());
jsonValue.WriteTo(writer, options);
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
}
}
}