-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPartMaskBitArrayConverter.cs
More file actions
39 lines (31 loc) · 1.14 KB
/
PartMaskBitArrayConverter.cs
File metadata and controls
39 lines (31 loc) · 1.14 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
using FreeAllegiance.IGCCore.Modules;
using FreeAllegiance.IGCCore.Util;
using System.Collections;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Metadata;
namespace CoreExporter
{
internal class PartMaskBitArrayConverter : JsonConverter<System.Collections.BitArray>
{
public override BitArray? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
throw new NotImplementedException();
}
public override void Write(Utf8JsonWriter writer, BitArray value, JsonSerializerOptions options)
{
//writer.WriteStartObject();
//writer.WriteString("_type", value.GetType().AssemblyQualifiedName);
JsonArray array = new JsonArray();
for (int i = 0; i < value.Count; i++)
{
if(value[i] == true)
array.Add(((PartMaskType)i).ToString());
}
//writer.WritePropertyName("PartType");
array.WriteTo(writer);
//writer.WriteEndObject();
}
}
}