tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
BoolConverter.cs
Go to the documentation of this file.
1using System;
2
3using Newtonsoft.Json;
4
6{
11 {
13 public override void WriteJson(JsonWriter? writer, object? value, JsonSerializer serializer)
14 {
15 ArgumentNullException.ThrowIfNull(writer);
16 writer.WriteValue(((bool)value!) ? 1 : 0);
17 }
18
20 public override object? ReadJson(JsonReader? reader, Type? objectType, object? existingValue, JsonSerializer serializer)
21 {
22 ArgumentNullException.ThrowIfNull(reader);
23 return reader.Value!.ToString() == "1";
24 }
25
27 public override bool CanConvert(Type objectType) => objectType == typeof(bool);
28 }
29}
JsonConverter for decoding bools returned by BYOND.
override void WriteJson(JsonWriter? writer, object? value, JsonSerializer serializer)
override? object ReadJson(JsonReader? reader, Type? objectType, object? existingValue, JsonSerializer serializer)