Fauna v10 .NET/C# Driver 0.2.0-beta
 
Loading...
Searching...
No Matches
ISerializer.cs
Go to the documentation of this file.
1using Fauna.Mapping;
2
4
5public interface ISerializer<out T> : ISerializer
6{
7 new T Deserialize(MappingContext context, ref Utf8FaunaReader reader);
8}
9
10public interface ISerializer
11{
12 object? Deserialize(MappingContext context, ref Utf8FaunaReader reader);
13 void Serialize(MappingContext ctx, Utf8FaunaWriter w, object? o);
14}
15
16public abstract class BaseSerializer<T> : ISerializer<T>
17{
18 protected string UnexpectedTokenExceptionMessage(TokenType token) => $"Unexpected token `{token}` deserializing with `{GetType().Name}`";
19
20 protected string UnsupportedSerializationTypeMessage(Type type) => $"Cannot serialize `{type}` with `{GetType()}`";
21
22 object? ISerializer.Deserialize(MappingContext context, ref Utf8FaunaReader reader) =>
23 Deserialize(context, ref reader);
24
25 public abstract T Deserialize(MappingContext context, ref Utf8FaunaReader reader);
26
27 void ISerializer.Serialize(MappingContext context, Utf8FaunaWriter writer, object? o) =>
28 Serialize(context, writer, o);
29
30 public abstract void Serialize(MappingContext context, Utf8FaunaWriter writer, object? o);
31
33 new($"Unexpected token while deserializing: {token}");
34}
A class representing the mapping context to be used during serialization and deserialization.
string UnsupportedSerializationTypeMessage(Type type)
T Deserialize(MappingContext context, ref Utf8FaunaReader reader)
static SerializationException UnexpectedToken(TokenType token)
void Serialize(MappingContext context, Utf8FaunaWriter writer, object? o)
string UnexpectedTokenExceptionMessage(TokenType token)
Represents error that occur during serialization and deserialization of Fauna data.
Provides functionality for writing data in a streaming manner to a buffer or a stream.
object? Deserialize(MappingContext context, ref Utf8FaunaReader reader)
void Serialize(MappingContext ctx, Utf8FaunaWriter w, object? o)
new T Deserialize(MappingContext context, ref Utf8FaunaReader reader)
TokenType
Enumerates the types of tokens used in Fauna serialization.
Definition TokenType.cs:7
Represents a reader that provides fast, non-cached, forward-only access to serialized data.