3
3
4
4
namespace Codehard . Common . DomainModel . Converters ;
5
5
6
- public class EntityKeyJsonConverter : JsonConverter < IEntityKey >
6
+ public class IntegerKeyJsonConverter : JsonConverter < IntegerKey >
7
7
{
8
- public override IEntityKey ? Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
8
+ public override IntegerKey Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
9
9
{
10
- throw new NotImplementedException ( ) ;
10
+ return new IntegerKey ( reader . GetInt32 ( ) ) ;
11
11
}
12
12
13
- public override void Write ( Utf8JsonWriter writer , IEntityKey value , JsonSerializerOptions options )
13
+ public override void Write ( Utf8JsonWriter writer , IntegerKey value , JsonSerializerOptions options )
14
14
{
15
- throw new NotImplementedException ( ) ;
15
+ writer . WriteNumberValue ( value . Value ) ;
16
+ }
17
+ }
18
+
19
+ public class LongKeyJsonConverter : JsonConverter < LongKey >
20
+ {
21
+ public override LongKey Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
22
+ {
23
+ return new LongKey ( reader . GetInt64 ( ) ) ;
24
+ }
25
+
26
+ public override void Write ( Utf8JsonWriter writer , LongKey value , JsonSerializerOptions options )
27
+ {
28
+ writer . WriteNumberValue ( value . Value ) ;
29
+ }
30
+ }
31
+
32
+ public class StringKeyJsonConverter : JsonConverter < StringKey >
33
+ {
34
+ public override StringKey Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
35
+ {
36
+ return new StringKey ( reader . GetString ( ) ! ) ;
37
+ }
38
+
39
+ public override void Write ( Utf8JsonWriter writer , StringKey value , JsonSerializerOptions options )
40
+ {
41
+ writer . WriteStringValue ( value . Value ) ;
42
+ }
43
+ }
44
+
45
+ public class GuidKeyJsonConverter : JsonConverter < GuidKey >
46
+ {
47
+ public override GuidKey Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
48
+ {
49
+ return new GuidKey ( reader . GetGuid ( ) ) ;
50
+ }
51
+
52
+ public override void Write ( Utf8JsonWriter writer , GuidKey value , JsonSerializerOptions options )
53
+ {
54
+ writer . WriteStringValue ( value . Value ) ;
16
55
}
17
56
}
0 commit comments