7internal class StringSerializer : BaseSerializer<string?>
9 public override string? Deserialize(
MappingContext ctx, ref Utf8FaunaReader reader) =>
10 reader.CurrentTokenType
switch
12 TokenType.Null =>
null,
13 TokenType.String => reader.GetString(),
17 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
22 writer.WriteNullValue();
25 writer.WriteStringValue(s);
33internal class ByteSerializer : BaseSerializer<byte>
35 public override byte Deserialize(
MappingContext context, ref Utf8FaunaReader reader) =>
36 reader.CurrentTokenType
switch
38 TokenType.Int => reader.GetByte(),
42 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
47 writer.WriteNullValue();
50 writer.WriteIntValue(i);
58internal class SByteSerializer : BaseSerializer<sbyte>
60 public override sbyte Deserialize(
MappingContext context, ref Utf8FaunaReader reader) =>
61 reader.CurrentTokenType
switch
63 TokenType.Int => reader.GetUnsignedByte(),
67 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
72 writer.WriteNullValue();
75 writer.WriteIntValue(i);
84internal class ShortSerializer : BaseSerializer<short>
86 public override short Deserialize(
MappingContext context, ref Utf8FaunaReader reader) =>
87 reader.CurrentTokenType
switch
89 TokenType.Int => reader.GetShort(),
93 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
98 writer.WriteNullValue();
101 writer.WriteIntValue(i);
109internal class UShortSerializer : BaseSerializer<ushort>
111 public override ushort Deserialize(
MappingContext context, ref Utf8FaunaReader reader) =>
112 reader.CurrentTokenType
switch
114 TokenType.Int => reader.GetUnsignedShort(),
118 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
123 writer.WriteNullValue();
126 writer.WriteIntValue(i);
134internal class IntSerializer : BaseSerializer<int>
136 public override int Deserialize(
MappingContext context, ref Utf8FaunaReader reader) =>
137 reader.CurrentTokenType
switch
139 TokenType.Int => reader.GetInt(),
143 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
148 writer.WriteNullValue();
151 writer.WriteIntValue(i);
159internal class UIntSerializer : BaseSerializer<uint>
161 public override uint Deserialize(
MappingContext context, ref Utf8FaunaReader reader) =>
162 reader.CurrentTokenType
switch
164 TokenType.Int or TokenType.Long => reader.GetUnsignedInt(),
168 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
173 writer.WriteNullValue();
176 writer.WriteLongValue(i);
184internal class LongSerializer : BaseSerializer<long>
186 public override long Deserialize(
MappingContext context, ref Utf8FaunaReader reader) =>
187 reader.CurrentTokenType
switch
189 TokenType.Int or TokenType.Long => reader.GetLong(),
193 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
198 writer.WriteNullValue();
201 writer.WriteLongValue(i);
209internal class FloatSerializer : BaseSerializer<float>
211 public override float Deserialize(
MappingContext context, ref Utf8FaunaReader reader) =>
212 reader.CurrentTokenType
switch
214 TokenType.Int or TokenType.Long or TokenType.Double => reader.GetFloat(),
218 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
223 writer.WriteNullValue();
226 writer.WriteDoubleValue(i);
234internal class DoubleSerializer : BaseSerializer<double>
236 public override double Deserialize(
MappingContext context, ref Utf8FaunaReader reader) =>
237 reader.CurrentTokenType
switch
239 TokenType.Int or TokenType.Long or TokenType.Double => reader.GetDouble(),
243 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
248 writer.WriteNullValue();
251 writer.WriteDoubleValue(i);
259internal class BooleanSerializer : BaseSerializer<bool>
261 public override bool Deserialize(
MappingContext context, ref Utf8FaunaReader reader) =>
262 reader.CurrentTokenType
switch
264 TokenType.True or TokenType.False => reader.GetBoolean(),
268 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
273 writer.WriteNullValue();
276 writer.WriteBooleanValue(i);
284internal class DateOnlySerializer : BaseSerializer<DateOnly>
286 public override DateOnly Deserialize(
MappingContext context, ref Utf8FaunaReader reader) =>
287 reader.CurrentTokenType
switch
289 TokenType.Date => reader.GetDate(),
293 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
298 writer.WriteNullValue();
301 writer.WriteDateValue(i);
309internal class DateTimeSerializer : BaseSerializer<DateTime>
311 public override DateTime Deserialize(
MappingContext context, ref Utf8FaunaReader reader) =>
312 reader.CurrentTokenType
switch
314 TokenType.Time => reader.GetTime(),
318 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
323 writer.WriteNullValue();
326 writer.WriteTimeValue(i);
334internal class DateTimeOffsetSerializer : BaseSerializer<DateTimeOffset>
336 public override DateTimeOffset Deserialize(
MappingContext context, ref Utf8FaunaReader reader) =>
337 reader.CurrentTokenType
switch
339 TokenType.Time => reader.GetTime(),
343 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
348 writer.WriteNullValue();
350 case DateTimeOffset i:
351 writer.WriteTimeValue(i);
A class representing the mapping context to be used during serialization and deserialization.
string UnsupportedSerializationTypeMessage(Type type)
string UnexpectedTokenExceptionMessage(TokenType token)