-
Notifications
You must be signed in to change notification settings - Fork 0
/
IDeserializationDriver.cs
53 lines (47 loc) · 2.06 KB
/
IDeserializationDriver.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
using System;
using System.Collections.Generic;
using System.Text;
namespace CK.BinarySerialization;
/// <summary>
/// Deserialization driver that knows how to instantiate an instance of a <see cref="ResolvedType"/>
/// and initializes it from a <see cref="IBinaryDeserializer"/> or handles null thanks to its 2 drivers.
/// </summary>
public interface IDeserializationDriver
{
/// <summary>
/// Gets the type that this drivers is able to resolve.
/// </summary>
Type ResolvedType { get; }
/// <summary>
/// Gets a <see cref="TypedReader{T}"/> for this type and nullability.
/// </summary>
Delegate TypedReader { get; }
/// <summary>
/// Gets whether this driver is cached and reused.
/// <para>
/// Note that this caching is not done at the <see cref="BinaryDeserializerContext"/> level nor at
/// the <see cref="SharedBinaryDeserializerContext"/>: this can only be done by resolvers. (Ultimately,
/// the deserializer is always cached in the <see cref="ITypeReadInfo"/> per deserialization session instance).
/// </para>
/// <para>
/// A driver that relies on other drivers can only be cached and reused if
/// all the drivers it relies on are cached (this is a necessary and but not a sufficient condition
/// to actually be cached).
/// </para>
/// <para>
/// Resolvers should use <see cref="SharedBinaryDeserializerContext.PureLocalTypeDependentDrivers"/> concurrent
/// dictionary to cache drivers that can be cached and when the deserializer depends only on the local type to
/// deserialize. For more complex cache condition (typically when the deserialization uses the <see cref="BinaryDeserializerContext.Services"/>),
/// it is up to the resolver to handle its caching if it can.
/// </para>
/// </summary>
bool IsCached { get; }
/// <summary>
/// Gets the nullable driver.
/// </summary>
IDeserializationDriver ToNullable { get; }
/// <summary>
/// Gets the non nullable driver.
/// </summary>
IDeserializationDriver ToNonNullable { get; }
}