6
6
7
7
namespace MongoDB . Bson . Serialization
8
8
{
9
-
10
9
/// <summary>
11
10
/// //TODO
12
11
/// </summary>
13
- public interface IBsonSerializationConfigurator
12
+ public interface IBsonSerializationDomain : IBsonCoreSerializerConfigurator , IBsonCoreSerializerConfiguration , IBsonCoreSerializer
14
13
{
15
- /// <summary>
16
- /// Registers the discriminator for a type.
17
- /// </summary>
18
- /// <param name="type">The type.</param>
19
- /// <param name="discriminator">The discriminator.</param>
20
- void RegisterDiscriminator ( Type type , BsonValue discriminator ) ;
21
-
22
- /// <summary>
23
- /// Registers the discriminator convention for a type.
24
- /// </summary>
25
- /// <param name="type">Type type.</param>
26
- /// <param name="convention">The discriminator convention.</param>
27
- void RegisterDiscriminatorConvention ( Type type , IDiscriminatorConvention convention ) ;
28
-
29
- /// <summary>
30
- /// Registers a generic serializer definition for a generic type.
31
- /// </summary>
32
- /// <param name="genericTypeDefinition">The generic type.</param>
33
- /// <param name="genericSerializerDefinition">The generic serializer definition.</param>
34
- void RegisterGenericSerializerDefinition (
35
- Type genericTypeDefinition ,
36
- Type genericSerializerDefinition ) ;
37
-
38
- /// <summary>
39
- /// Registers an IdGenerator for an Id Type.
40
- /// </summary>
41
- /// <param name="type">The Id Type.</param>
42
- /// <param name="idGenerator">The IdGenerator for the Id Type.</param>
43
- void RegisterIdGenerator ( Type type , IIdGenerator idGenerator ) ;
44
-
45
- /// <summary>
46
- /// Registers a serialization provider.
47
- /// </summary>
48
- /// <param name="provider">The serialization provider.</param>
49
- void RegisterSerializationProvider ( IBsonSerializationProvider provider ) ;
50
-
51
- /// <summary>
52
- /// Registers a serializer for a type.
53
- /// </summary>
54
- /// <typeparam name="T">The type.</typeparam>
55
- /// <param name="serializer">The serializer.</param>
56
- void RegisterSerializer < T > ( IBsonSerializer < T > serializer ) ;
57
-
58
- /// <summary>
59
- /// Registers a serializer for a type.
60
- /// </summary>
61
- /// <param name="type">The type.</param>
62
- /// <param name="serializer">The serializer.</param>
63
- void RegisterSerializer ( Type type , IBsonSerializer serializer ) ;
64
-
65
- /// <summary>
66
- /// Tries to register a serializer for a type.
67
- /// </summary>
68
- /// <param name="serializer">The serializer.</param>
69
- /// <param name="type">The type.</param>
70
- /// <returns>True if the serializer was registered on this call, false if the same serializer was already registered on a previous call, throws an exception if a different serializer was already registered.</returns>
71
- bool TryRegisterSerializer ( Type type , IBsonSerializer serializer ) ;
14
+ }
72
15
73
- /// <summary>
74
- /// Tries to register a serializer for a type.
75
- /// </summary>
76
- /// <typeparam name="T">The type.</typeparam>
77
- /// <param name="serializer">The serializer.</param>
78
- /// <returns>True if the serializer was registered on this call, false if the same serializer was already registered on a previous call, throws an exception if a different serializer was already registered.</returns>
79
- bool TryRegisterSerializer < T > ( IBsonSerializer < T > serializer ) ;
16
+ internal interface IBsonSerializationDomainInternal : IBsonSerializationDomain
17
+ {
18
+ ReaderWriterLockSlim ConfigLock { get ; }
80
19
81
- /// <summary>
82
- /// Gets or sets whether to use the NullIdChecker on reference Id types that don't have an IdGenerator registered.
83
- /// </summary>
84
- bool UseNullIdChecker { get ; set ; } //TODO It would be nice if this became a method (SetUseNullIdChecker) and the configuration would have only a getter
20
+ void EnsureKnownTypesAreRegistered ( Type nominalType ) ;
85
21
86
- /// <summary>
87
- /// Gets or sets whether to use the ZeroIdChecker on value Id types that don't have an IdGenerator registered.
88
- /// </summary>
89
- bool UseZeroIdChecker { get ; set ; }
22
+ IDiscriminatorConvention GetOrRegisterDiscriminatorConvention ( Type type ,
23
+ IDiscriminatorConvention discriminatorConvention ) ;
90
24
91
- /// <summary>
92
- /// //TODO
93
- /// </summary>
94
- /// <returns></returns>
95
- IBsonCoreSerializer BuildCoreSerializer ( ) ;
25
+ bool IsDiscriminatorConventionRegisteredAtThisLevel ( Type type ) ;
96
26
}
97
27
98
28
/// <summary>
@@ -103,7 +33,7 @@ public interface IBsonCoreSerializer //TODO Don't like the name but have no bett
103
33
/// <summary>
104
34
/// //TODO
105
35
/// </summary>
106
- IBsonSerializationConfiguration SerializationConfiguration { get ; }
36
+ IBsonCoreSerializerConfiguration SerializationConfiguration { get ; }
107
37
108
38
/// <summary>
109
39
/// Deserializes an object from a BsonDocument.
@@ -258,7 +188,95 @@ void Serialize(
258
188
/// <summary>
259
189
/// //TODO
260
190
/// </summary>
261
- public interface IBsonSerializationConfiguration
191
+ public interface IBsonCoreSerializerConfigurator
192
+ {
193
+ /// <summary>
194
+ /// Registers the discriminator for a type.
195
+ /// </summary>
196
+ /// <param name="type">The type.</param>
197
+ /// <param name="discriminator">The discriminator.</param>
198
+ void RegisterDiscriminator ( Type type , BsonValue discriminator ) ;
199
+
200
+ /// <summary>
201
+ /// Registers the discriminator convention for a type.
202
+ /// </summary>
203
+ /// <param name="type">Type type.</param>
204
+ /// <param name="convention">The discriminator convention.</param>
205
+ void RegisterDiscriminatorConvention ( Type type , IDiscriminatorConvention convention ) ;
206
+
207
+ /// <summary>
208
+ /// Registers a generic serializer definition for a generic type.
209
+ /// </summary>
210
+ /// <param name="genericTypeDefinition">The generic type.</param>
211
+ /// <param name="genericSerializerDefinition">The generic serializer definition.</param>
212
+ void RegisterGenericSerializerDefinition (
213
+ Type genericTypeDefinition ,
214
+ Type genericSerializerDefinition ) ;
215
+
216
+ /// <summary>
217
+ /// Registers an IdGenerator for an Id Type.
218
+ /// </summary>
219
+ /// <param name="type">The Id Type.</param>
220
+ /// <param name="idGenerator">The IdGenerator for the Id Type.</param>
221
+ void RegisterIdGenerator ( Type type , IIdGenerator idGenerator ) ;
222
+
223
+ /// <summary>
224
+ /// Registers a serialization provider.
225
+ /// </summary>
226
+ /// <param name="provider">The serialization provider.</param>
227
+ void RegisterSerializationProvider ( IBsonSerializationProvider provider ) ;
228
+
229
+ /// <summary>
230
+ /// Registers a serializer for a type.
231
+ /// </summary>
232
+ /// <typeparam name="T">The type.</typeparam>
233
+ /// <param name="serializer">The serializer.</param>
234
+ void RegisterSerializer < T > ( IBsonSerializer < T > serializer ) ;
235
+
236
+ /// <summary>
237
+ /// Registers a serializer for a type.
238
+ /// </summary>
239
+ /// <param name="type">The type.</param>
240
+ /// <param name="serializer">The serializer.</param>
241
+ void RegisterSerializer ( Type type , IBsonSerializer serializer ) ;
242
+
243
+ /// <summary>
244
+ /// Tries to register a serializer for a type.
245
+ /// </summary>
246
+ /// <param name="serializer">The serializer.</param>
247
+ /// <param name="type">The type.</param>
248
+ /// <returns>True if the serializer was registered on this call, false if the same serializer was already registered on a previous call, throws an exception if a different serializer was already registered.</returns>
249
+ bool TryRegisterSerializer ( Type type , IBsonSerializer serializer ) ;
250
+
251
+ /// <summary>
252
+ /// Tries to register a serializer for a type.
253
+ /// </summary>
254
+ /// <typeparam name="T">The type.</typeparam>
255
+ /// <param name="serializer">The serializer.</param>
256
+ /// <returns>True if the serializer was registered on this call, false if the same serializer was already registered on a previous call, throws an exception if a different serializer was already registered.</returns>
257
+ bool TryRegisterSerializer < T > ( IBsonSerializer < T > serializer ) ;
258
+
259
+ /// <summary>
260
+ /// Gets or sets whether to use the NullIdChecker on reference Id types that don't have an IdGenerator registered.
261
+ /// </summary>
262
+ bool UseNullIdChecker { get ; set ; } //TODO It would be nice if this became a method (SetUseNullIdChecker) and the configuration would have only a getter
263
+
264
+ /// <summary>
265
+ /// Gets or sets whether to use the ZeroIdChecker on value Id types that don't have an IdGenerator registered.
266
+ /// </summary>
267
+ bool UseZeroIdChecker { get ; set ; }
268
+
269
+ /// <summary>
270
+ /// //TODO
271
+ /// </summary>
272
+ /// <returns></returns>
273
+ IBsonCoreSerializer BuildCoreSerializer ( ) ;
274
+ }
275
+
276
+ /// <summary>
277
+ /// //TODO
278
+ /// </summary>
279
+ public interface IBsonCoreSerializerConfiguration
262
280
{
263
281
/// <summary>
264
282
/// Returns whether the given type has any discriminators registered for any of its subclasses.
@@ -318,23 +336,4 @@ public interface IBsonSerializationConfiguration
318
336
/// </summary>
319
337
bool UseZeroIdCheckerEnabled { get ; }
320
338
}
321
-
322
- /// <summary>
323
- /// //TODO
324
- /// </summary>
325
- public interface IBsonSerializationDomain : IBsonSerializationConfigurator , IBsonSerializationConfiguration , IBsonCoreSerializer
326
- {
327
- }
328
-
329
- internal interface IBsonSerializationDomainInternal : IBsonSerializationDomain
330
- {
331
- ReaderWriterLockSlim ConfigLock { get ; }
332
-
333
- void EnsureKnownTypesAreRegistered ( Type nominalType ) ;
334
-
335
- IDiscriminatorConvention GetOrRegisterDiscriminatorConvention ( Type type ,
336
- IDiscriminatorConvention discriminatorConvention ) ;
337
-
338
- bool IsDiscriminatorConventionRegisteredAtThisLevel ( Type type ) ;
339
- }
340
339
}
0 commit comments