@@ -25,7 +25,7 @@ namespace MongoDB.Bson
25
25
/// </summary>
26
26
public static class BsonExtensionMethods
27
27
{
28
- //DOMAIN-API We should remove this and use the version with the domain.
28
+ //DOMAIN-API We should remove all the methods that do not take a serialization domain.
29
29
//QUESTION: Do we want to do something now about this...? It's used also internally, but it seems in most cases it's used for "default serialization", so it should be ok.
30
30
/// <summary>
31
31
/// Serializes an object to a BSON byte array.
@@ -43,29 +43,23 @@ public static byte[] ToBson<TNominalType>(
43
43
IBsonSerializer < TNominalType > serializer = null ,
44
44
BsonBinaryWriterSettings writerSettings = null ,
45
45
Action < BsonSerializationContext . Builder > configurator = null ,
46
- BsonSerializationArgs args = default ( BsonSerializationArgs ) ,
47
- int estimatedBsonSize = 0 )
48
- {
49
- args . SetOrValidateNominalType ( typeof ( TNominalType ) , "<TNominalType>" ) ;
50
-
51
- return ToBson ( obj , typeof ( TNominalType ) , writerSettings , serializer , configurator , args , estimatedBsonSize ) ;
52
- }
46
+ BsonSerializationArgs args = default ,
47
+ int estimatedBsonSize = 0 ) => ToBson ( obj , BsonSerializer . DefaultSerializationDomain , serializer , writerSettings , configurator , args , estimatedBsonSize ) ;
53
48
54
- internal static byte [ ] ToBson < TNominalType > (
49
+ private static byte [ ] ToBson < TNominalType > (
55
50
this TNominalType obj ,
56
51
IBsonSerializationDomain serializationDomain ,
57
52
IBsonSerializer < TNominalType > serializer = null ,
58
53
BsonBinaryWriterSettings writerSettings = null ,
59
54
Action < BsonSerializationContext . Builder > configurator = null ,
60
- BsonSerializationArgs args = default ( BsonSerializationArgs ) ,
55
+ BsonSerializationArgs args = default ,
61
56
int estimatedBsonSize = 0 )
62
57
{
63
58
args . SetOrValidateNominalType ( typeof ( TNominalType ) , "<TNominalType>" ) ;
64
59
65
60
return ToBson ( obj , typeof ( TNominalType ) , serializationDomain , writerSettings , serializer , configurator , args , estimatedBsonSize ) ;
66
61
}
67
62
68
- //DOMAIN-API We should remove this and use the version with the domain.
69
63
/// <summary>
70
64
/// Serializes an object to a BSON byte array.
71
65
/// </summary>
@@ -89,14 +83,14 @@ public static byte[] ToBson(
89
83
int estimatedBsonSize = 0 ) => ToBson ( obj , nominalType , BsonSerializer . DefaultSerializationDomain , writerSettings ,
90
84
serializer , configurator , args , estimatedBsonSize ) ;
91
85
92
- internal static byte [ ] ToBson (
86
+ private static byte [ ] ToBson (
93
87
this object obj ,
94
88
Type nominalType ,
95
89
IBsonSerializationDomain serializationDomain ,
96
90
BsonBinaryWriterSettings writerSettings = null ,
97
91
IBsonSerializer serializer = null ,
98
92
Action < BsonSerializationContext . Builder > configurator = null ,
99
- BsonSerializationArgs args = default ( BsonSerializationArgs ) ,
93
+ BsonSerializationArgs args = default ,
100
94
int estimatedBsonSize = 0 )
101
95
{
102
96
if ( estimatedBsonSize < 0 )
@@ -144,7 +138,7 @@ public static BsonDocument ToBsonDocument<TNominalType>(
144
138
this TNominalType obj ,
145
139
IBsonSerializer < TNominalType > serializer = null ,
146
140
Action < BsonSerializationContext . Builder > configurator = null ,
147
- BsonSerializationArgs args = default ( BsonSerializationArgs ) )
141
+ BsonSerializationArgs args = default )
148
142
{
149
143
args . SetOrValidateNominalType ( typeof ( TNominalType ) , "<TNominalType>" ) ;
150
144
return ToBsonDocument ( obj , typeof ( TNominalType ) , serializer , configurator , args ) ;
@@ -169,7 +163,7 @@ public static BsonDocument ToBsonDocument(
169
163
BsonSerializationArgs args = default ) => ToBsonDocument ( obj , nominalType ,
170
164
BsonSerializer . DefaultSerializationDomain , serializer , configurator , args ) ;
171
165
172
- internal static BsonDocument ToBsonDocument (
166
+ private static BsonDocument ToBsonDocument (
173
167
this object obj ,
174
168
Type nominalType ,
175
169
IBsonSerializationDomain serializationDomain ,
@@ -237,7 +231,7 @@ public static string ToJson<TNominalType>(
237
231
JsonWriterSettings writerSettings = null ,
238
232
IBsonSerializer < TNominalType > serializer = null ,
239
233
Action < BsonSerializationContext . Builder > configurator = null ,
240
- BsonSerializationArgs args = default ( BsonSerializationArgs ) )
234
+ BsonSerializationArgs args = default )
241
235
{
242
236
args . SetOrValidateNominalType ( typeof ( TNominalType ) , "<TNominalType>" ) ;
243
237
return ToJson ( obj , typeof ( TNominalType ) , writerSettings , serializer , configurator , args ) ;
@@ -266,14 +260,14 @@ public static string ToJson(
266
260
BsonSerializationArgs args = default )
267
261
=> ToJson ( obj , nominalType , BsonSerializer . DefaultSerializationDomain , writerSettings , serializer , configurator , args ) ;
268
262
269
- internal static string ToJson (
263
+ private static string ToJson (
270
264
this object obj ,
271
265
Type nominalType ,
272
266
IBsonSerializationDomain domain ,
273
267
JsonWriterSettings writerSettings = null ,
274
268
IBsonSerializer serializer = null ,
275
269
Action < BsonSerializationContext . Builder > configurator = null ,
276
- BsonSerializationArgs args = default ( BsonSerializationArgs ) )
270
+ BsonSerializationArgs args = default )
277
271
{
278
272
if ( nominalType == null )
279
273
{
0 commit comments