|
6 | 6 |
|
7 | 7 | namespace MongoDB.Bson.Serialization
|
8 | 8 | {
|
| 9 | + |
9 | 10 | /// <summary>
|
10 | 11 | /// //TODO
|
11 | 12 | /// </summary>
|
12 |
| - public interface IBsonSerializationDomain |
| 13 | + public interface ISerializerConfigurator |
13 | 14 | {
|
14 | 15 | /// <summary>
|
15 |
| - /// Gets the serializer registry. |
| 16 | + /// Registers the discriminator for a type. |
16 | 17 | /// </summary>
|
17 |
| - IBsonSerializerRegistry SerializerRegistry { get; } |
| 18 | + /// <param name="type">The type.</param> |
| 19 | + /// <param name="discriminator">The discriminator.</param> |
| 20 | + void RegisterDiscriminator(Type type, BsonValue discriminator); |
18 | 21 |
|
19 | 22 | /// <summary>
|
20 |
| - /// Gets or sets whether to use the NullIdChecker on reference Id types that don't have an IdGenerator registered. |
| 23 | + /// Registers the discriminator convention for a type. |
21 | 24 | /// </summary>
|
22 |
| - bool UseNullIdChecker { get; set; } |
| 25 | + /// <param name="type">Type type.</param> |
| 26 | + /// <param name="convention">The discriminator convention.</param> |
| 27 | + void RegisterDiscriminatorConvention(Type type, IDiscriminatorConvention convention); |
23 | 28 |
|
24 | 29 | /// <summary>
|
25 |
| - /// Gets or sets whether to use the ZeroIdChecker on value Id types that don't have an IdGenerator registered. |
| 30 | + /// Registers a generic serializer definition for a generic type. |
26 | 31 | /// </summary>
|
27 |
| - bool UseZeroIdChecker { get; set; } |
| 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); |
28 | 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); |
| 72 | + |
| 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); |
| 80 | + } |
| 81 | + |
| 82 | + /// <summary> |
| 83 | + /// //TODO |
| 84 | + /// </summary> |
| 85 | + public interface IMainSerializer |
| 86 | + { |
29 | 87 | /// <summary>
|
30 | 88 | /// Deserializes an object from a BsonDocument.
|
31 | 89 | /// </summary>
|
@@ -146,6 +204,56 @@ object Deserialize(string json, Type nominalType,
|
146 | 204 | object Deserialize(TextReader textReader, Type nominalType,
|
147 | 205 | Action<BsonDeserializationContext.Builder> configurator = null);
|
148 | 206 |
|
| 207 | + /// <summary> |
| 208 | + /// Serializes a value. |
| 209 | + /// </summary> |
| 210 | + /// <typeparam name="TNominalType">The nominal type of the object.</typeparam> |
| 211 | + /// <param name="bsonWriter">The BsonWriter.</param> |
| 212 | + /// <param name="value">The object.</param> |
| 213 | + /// <param name="configurator">The serialization context configurator.</param> |
| 214 | + /// <param name="args">The serialization args.</param> |
| 215 | + void Serialize<TNominalType>( |
| 216 | + IBsonWriter bsonWriter, |
| 217 | + TNominalType value, |
| 218 | + Action<BsonSerializationContext.Builder> configurator = null, |
| 219 | + BsonSerializationArgs args = default(BsonSerializationArgs)); |
| 220 | + |
| 221 | + /// <summary> |
| 222 | + /// Serializes a value. |
| 223 | + /// </summary> |
| 224 | + /// <param name="bsonWriter">The BsonWriter.</param> |
| 225 | + /// <param name="nominalType">The nominal type of the object.</param> |
| 226 | + /// <param name="value">The object.</param> |
| 227 | + /// <param name="configurator">The serialization context configurator.</param> |
| 228 | + /// <param name="args">The serialization args.</param> |
| 229 | + void Serialize( |
| 230 | + IBsonWriter bsonWriter, |
| 231 | + Type nominalType, |
| 232 | + object value, |
| 233 | + Action<BsonSerializationContext.Builder> configurator = null, |
| 234 | + BsonSerializationArgs args = default(BsonSerializationArgs)); |
| 235 | + } |
| 236 | + |
| 237 | + /// <summary> |
| 238 | + /// //TODO |
| 239 | + /// </summary> |
| 240 | + public interface IBsonSerializationDomain : ISerializerConfigurator, IMainSerializer |
| 241 | + { |
| 242 | + /// <summary> |
| 243 | + /// Gets the serializer registry. |
| 244 | + /// </summary> |
| 245 | + IBsonSerializerRegistry SerializerRegistry { get; } |
| 246 | + |
| 247 | + /// <summary> |
| 248 | + /// Gets or sets whether to use the NullIdChecker on reference Id types that don't have an IdGenerator registered. |
| 249 | + /// </summary> |
| 250 | + bool UseNullIdChecker { get; set; } |
| 251 | + |
| 252 | + /// <summary> |
| 253 | + /// Gets or sets whether to use the ZeroIdChecker on value Id types that don't have an IdGenerator registered. |
| 254 | + /// </summary> |
| 255 | + bool UseZeroIdChecker { get; set; } |
| 256 | + |
149 | 257 | /// <summary>
|
150 | 258 | /// Returns whether the given type has any discriminators registered for any of its subclasses.
|
151 | 259 | /// </summary>
|
@@ -188,101 +296,6 @@ object Deserialize(TextReader textReader, Type nominalType,
|
188 | 296 | /// <param name="type">The Type.</param>
|
189 | 297 | /// <returns>A serializer for the Type.</returns>
|
190 | 298 | IBsonSerializer LookupSerializer(Type type);
|
191 |
| - |
192 |
| - /// <summary> |
193 |
| - /// Registers the discriminator for a type. |
194 |
| - /// </summary> |
195 |
| - /// <param name="type">The type.</param> |
196 |
| - /// <param name="discriminator">The discriminator.</param> |
197 |
| - void RegisterDiscriminator(Type type, BsonValue discriminator); |
198 |
| - |
199 |
| - /// <summary> |
200 |
| - /// Registers the discriminator convention for a type. |
201 |
| - /// </summary> |
202 |
| - /// <param name="type">Type type.</param> |
203 |
| - /// <param name="convention">The discriminator convention.</param> |
204 |
| - void RegisterDiscriminatorConvention(Type type, IDiscriminatorConvention convention); |
205 |
| - |
206 |
| - /// <summary> |
207 |
| - /// Registers a generic serializer definition for a generic type. |
208 |
| - /// </summary> |
209 |
| - /// <param name="genericTypeDefinition">The generic type.</param> |
210 |
| - /// <param name="genericSerializerDefinition">The generic serializer definition.</param> |
211 |
| - void RegisterGenericSerializerDefinition( |
212 |
| - Type genericTypeDefinition, |
213 |
| - Type genericSerializerDefinition); |
214 |
| - |
215 |
| - /// <summary> |
216 |
| - /// Registers an IdGenerator for an Id Type. |
217 |
| - /// </summary> |
218 |
| - /// <param name="type">The Id Type.</param> |
219 |
| - /// <param name="idGenerator">The IdGenerator for the Id Type.</param> |
220 |
| - void RegisterIdGenerator(Type type, IIdGenerator idGenerator); |
221 |
| - |
222 |
| - /// <summary> |
223 |
| - /// Registers a serialization provider. |
224 |
| - /// </summary> |
225 |
| - /// <param name="provider">The serialization provider.</param> |
226 |
| - void RegisterSerializationProvider(IBsonSerializationProvider provider); |
227 |
| - |
228 |
| - /// <summary> |
229 |
| - /// Registers a serializer for a type. |
230 |
| - /// </summary> |
231 |
| - /// <typeparam name="T">The type.</typeparam> |
232 |
| - /// <param name="serializer">The serializer.</param> |
233 |
| - void RegisterSerializer<T>(IBsonSerializer<T> serializer); |
234 |
| - |
235 |
| - /// <summary> |
236 |
| - /// Registers a serializer for a type. |
237 |
| - /// </summary> |
238 |
| - /// <param name="type">The type.</param> |
239 |
| - /// <param name="serializer">The serializer.</param> |
240 |
| - void RegisterSerializer(Type type, IBsonSerializer serializer); |
241 |
| - |
242 |
| - /// <summary> |
243 |
| - /// Serializes a value. |
244 |
| - /// </summary> |
245 |
| - /// <typeparam name="TNominalType">The nominal type of the object.</typeparam> |
246 |
| - /// <param name="bsonWriter">The BsonWriter.</param> |
247 |
| - /// <param name="value">The object.</param> |
248 |
| - /// <param name="configurator">The serialization context configurator.</param> |
249 |
| - /// <param name="args">The serialization args.</param> |
250 |
| - void Serialize<TNominalType>( |
251 |
| - IBsonWriter bsonWriter, |
252 |
| - TNominalType value, |
253 |
| - Action<BsonSerializationContext.Builder> configurator = null, |
254 |
| - BsonSerializationArgs args = default(BsonSerializationArgs)); |
255 |
| - |
256 |
| - /// <summary> |
257 |
| - /// Serializes a value. |
258 |
| - /// </summary> |
259 |
| - /// <param name="bsonWriter">The BsonWriter.</param> |
260 |
| - /// <param name="nominalType">The nominal type of the object.</param> |
261 |
| - /// <param name="value">The object.</param> |
262 |
| - /// <param name="configurator">The serialization context configurator.</param> |
263 |
| - /// <param name="args">The serialization args.</param> |
264 |
| - void Serialize( |
265 |
| - IBsonWriter bsonWriter, |
266 |
| - Type nominalType, |
267 |
| - object value, |
268 |
| - Action<BsonSerializationContext.Builder> configurator = null, |
269 |
| - BsonSerializationArgs args = default(BsonSerializationArgs)); |
270 |
| - |
271 |
| - /// <summary> |
272 |
| - /// Tries to register a serializer for a type. |
273 |
| - /// </summary> |
274 |
| - /// <param name="serializer">The serializer.</param> |
275 |
| - /// <param name="type">The type.</param> |
276 |
| - /// <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> |
277 |
| - bool TryRegisterSerializer(Type type, IBsonSerializer serializer); |
278 |
| - |
279 |
| - /// <summary> |
280 |
| - /// Tries to register a serializer for a type. |
281 |
| - /// </summary> |
282 |
| - /// <typeparam name="T">The type.</typeparam> |
283 |
| - /// <param name="serializer">The serializer.</param> |
284 |
| - /// <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> |
285 |
| - bool TryRegisterSerializer<T>(IBsonSerializer<T> serializer); |
286 | 299 | }
|
287 | 300 |
|
288 | 301 | internal interface IBsonSerializationDomainInternal : IBsonSerializationDomain
|
|
0 commit comments