-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.cs
More file actions
43 lines (37 loc) · 1.23 KB
/
Copy pathUser.cs
File metadata and controls
43 lines (37 loc) · 1.23 KB
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
using System;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Domain
{
public class User
{
public byte[] BLOB { get; set; }
public string PASSWORD { get; set; }
public string USER_GROUP { get; set; }
public long USER_ID { get; set; }
public string USER_NAME { get; set; }
public override string ToString()
{
JsonSerializerOptions options = new JsonSerializerOptions
{
WriteIndented = true,
};
options.Converters.Add(new ByteArrayConverter());
return JsonSerializer.Serialize(this, options);
}
}
public class ByteArrayConverter : JsonConverter<byte[]>
{
public override byte[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
throw new NotImplementedException();
}
public override void Write(Utf8JsonWriter writer, byte[] values, JsonSerializerOptions options)
{
writer.WriteStartObject();
writer.WriteStringValue(string.Join(" ", values.Select(v => string.Format("0x{0:X2}", v))));
writer.WriteEndObject();
}
}
}