tgstation-server
6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
src
Tgstation.Server.Host
Extensions
Converters
BoolConverter.cs
Go to the documentation of this file.
1
using
System;
2
3
using
Newtonsoft.Json;
4
5
namespace
Tgstation.Server.Host.Extensions.Converters
6
{
10
sealed
class
BoolConverter
:
JsonConverter
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
Tgstation.Server.Host.Extensions.Converters.BoolConverter
JsonConverter for decoding bools returned by BYOND.
Definition
BoolConverter.cs:11
Tgstation.Server.Host.Extensions.Converters.BoolConverter.WriteJson
override void WriteJson(JsonWriter? writer, object? value, JsonSerializer serializer)
Definition
BoolConverter.cs:13
Tgstation.Server.Host.Extensions.Converters.BoolConverter.ReadJson
override? object ReadJson(JsonReader? reader, Type? objectType, object? existingValue, JsonSerializer serializer)
Definition
BoolConverter.cs:20
Tgstation.Server.Host.Extensions.Converters.BoolConverter.CanConvert
override bool CanConvert(Type objectType)
Tgstation.Server.Host.Extensions.Converters
Definition
BoolConverter.cs:6
Generated by
1.9.8