We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 70678db commit 0b85239Copy full SHA for 0b85239
src/Json/EnumCacheJson.cs
@@ -0,0 +1,18 @@
1
+using System.Text.Json;
2
+using System.Text.Json.Serialization;
3
+
4
+namespace PolyMod.Json
5
+{
6
+ internal class EnumCacheJson<T> : JsonConverter<T> where T : struct, Enum
7
+ {
8
+ public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
9
10
+ return EnumCache<T>.GetType(reader.GetString());
11
+ }
12
13
+ public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
14
15
+ writer.WriteStringValue(EnumCache<T>.GetName(value));
16
17
18
+}
0 commit comments