-
Notifications
You must be signed in to change notification settings - Fork 0
/
ISerializationDriver.cs
70 lines (61 loc) · 2.69 KB
/
ISerializationDriver.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using CK.BinarySerialization.Serialization;
using CK.Core;
using System;
using System.Collections.Generic;
using System.Text;
namespace CK.BinarySerialization;
/// <summary>
/// Serialization driver that knows how to serialize a null or not null instance
/// of one or more type.
/// </summary>
public interface ISerializationDriver
{
/// <summary>
/// Gets the driver's name that will be serialized.
/// </summary>
string DriverName { get; }
/// <summary>
/// Gets the serialization version. This driver can directly hard codes its version or
/// uses the <see cref="SerializationVersionAttribute"/> on the type.
/// This can be -1 when no version is defined.
/// </summary>
int SerializationVersion { get; }
/// <summary>
/// Gets the writer <see cref="BinarySerialization.UntypedWriter"/> that accepts a an untyped object that will be down-casted to the actual type.
/// If this is a non nullable serialization driver, the writer will throw if the
/// object to write is null.
/// </summary>
Delegate UntypedWriter { get; }
/// <summary>
/// Gets a strongly typed <see cref="TypedWriter{T}"/> function for this type and nullability.
/// If this is a non nullable serialization driver, the writer will throw if the
/// object to write is null.
/// </summary>
Delegate TypedWriter { get; }
/// <summary>
/// Gets the nullable driver.
/// </summary>
ISerializationDriver ToNullable { get; }
/// <summary>
/// Gets the non nullable driver.
/// </summary>
ISerializationDriver ToNonNullable { get; }
/// <summary>
/// Gets whether this serialization driver can be cached.
/// <para>
/// The huge majority of serialization drivers can be cached at the <see cref="SharedBinarySerializerContext"/>
/// level since they depend on the serialized (concrete) type. However some of them may rely on stable information
/// available in the <see cref="BinarySerializerContext.Services"/> (this is the case for IPoco serialization
/// that uses the PocoDirectory): these ones must use <see cref="SerializationDriverCacheLevel.Context"/>.
/// </para>
/// <para>
/// If the serialization driver relies on transient/unstable information <see cref="SerializationDriverCacheLevel.Never"/> should
/// be used. (This latter case should be quite exceptional.)
/// </para>
/// <para>
/// A serialization driver that relies on other drivers must combine the levels:
/// see <see cref="SerializationDriverCacheLevelExtensions.Combine(SerializationDriverCacheLevel, SerializationDriverCacheLevel)"/>.
/// </para>
/// </summary>
SerializationDriverCacheLevel CacheLevel { get; }
}