Fauna .NET Driver 0.1.0-beta
 
Loading...
Searching...
No Matches
NullableDeserializer.cs
Go to the documentation of this file.
1using Fauna.Mapping;
2
3namespace Fauna.Serialization;
4
5internal class NullableDeserializer<T> : BaseDeserializer<T?>
6{
7 private readonly IDeserializer<T> _inner;
8
9 public NullableDeserializer(IDeserializer<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}
T Deserialize(MappingContext context, ref Utf8FaunaReader reader)
TokenType
Enumerates the types of tokens used in Fauna serialization.
Definition TokenType.cs:7