Fauna v10 .NET/C# Driver
0.2.0-beta
Loading...
Searching...
No Matches
Fauna
Serialization
Serializers
NullableSerializer.cs
Go to the documentation of this file.
1
using
Fauna.Mapping
;
2
3
namespace
Fauna.Serialization
;
4
5
internal
class
NullableSerializer<T> : BaseSerializer<T?>
6
{
7
private
readonly ISerializer<T> _inner;
8
9
public
NullableSerializer(ISerializer<T> inner)
10
{
11
_inner = inner;
12
}
13
14
public
override
T? Deserialize(
MappingContext
context, ref Utf8FaunaReader reader)
15
{
16
if
(reader.CurrentTokenType ==
TokenType
.Null)
17
{
18
return
default
(T);
19
}
20
21
return
_inner.Deserialize(context, ref reader);
22
}
23
24
public
override
void
Serialize(
MappingContext
context, Utf8FaunaWriter writer,
object
? o)
25
{
26
DynamicSerializer.Singleton.Serialize(context, writer, o);
27
}
28
}
Fauna.Mapping.MappingContext
A class representing the mapping context to be used during serialization and deserialization.
Definition
MappingContext.cs:9
Fauna.Mapping
Definition
Attributes.cs:1
Fauna.Serialization
Definition
ISerializer.cs:3
Fauna.Serialization.TokenType
TokenType
Enumerates the types of tokens used in Fauna serialization.
Definition
TokenType.cs:7
Generated by
1.12.0