Skip to content

Commit 3dadb07

Browse files
committed
Test with multiple interfaces
1 parent 8b14426 commit 3dadb07

File tree

1 file changed

+115
-102
lines changed

1 file changed

+115
-102
lines changed

src/MongoDB.Bson/Serialization/IBsonSerializationDomain.cs

Lines changed: 115 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,84 @@
66

77
namespace MongoDB.Bson.Serialization
88
{
9+
910
/// <summary>
1011
/// //TODO
1112
/// </summary>
12-
public interface IBsonSerializationDomain
13+
public interface ISerializerConfigurator
1314
{
1415
/// <summary>
15-
/// Gets the serializer registry.
16+
/// Registers the discriminator for a type.
1617
/// </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);
1821

1922
/// <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.
2124
/// </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);
2328

2429
/// <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.
2631
/// </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);
2857

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+
{
2987
/// <summary>
3088
/// Deserializes an object from a BsonDocument.
3189
/// </summary>
@@ -146,6 +204,56 @@ object Deserialize(string json, Type nominalType,
146204
object Deserialize(TextReader textReader, Type nominalType,
147205
Action<BsonDeserializationContext.Builder> configurator = null);
148206

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+
149257
/// <summary>
150258
/// Returns whether the given type has any discriminators registered for any of its subclasses.
151259
/// </summary>
@@ -188,101 +296,6 @@ object Deserialize(TextReader textReader, Type nominalType,
188296
/// <param name="type">The Type.</param>
189297
/// <returns>A serializer for the Type.</returns>
190298
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);
286299
}
287300

288301
internal interface IBsonSerializationDomainInternal : IBsonSerializationDomain

0 commit comments

Comments
 (0)