File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
tests/MongoDB.Driver.Tests/Specifications/uuid/prose-tests Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ public static byte[] ToBson(
121
121
{
122
122
using ( var bsonWriter = new BsonBinaryWriter ( memoryStream , writerSettings ?? BsonBinaryWriterSettings . Defaults ) )
123
123
{
124
- var context = BsonSerializationContext . CreateRoot ( bsonWriter , configurator ) ;
124
+ var context = BsonSerializationContext . CreateRoot ( bsonWriter , configurator ) . With ( c => c . Domain = domain ) ;
125
125
serializer . Serialize ( context , args , obj ) ;
126
126
}
127
127
return memoryStream . ToArray ( ) ;
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ public class MongoCollectionSettings
34
34
private Setting < ReadPreference > _readPreference ;
35
35
private Setting < WriteConcern > _writeConcern ;
36
36
private Setting < UTF8Encoding > _writeEncoding ;
37
+ private Setting < IBsonSerializationDomain > _serializationDomain ;
37
38
38
39
// the following fields are set when Freeze is called
39
40
private bool _isFrozen ;
@@ -116,9 +117,26 @@ public ReadPreference ReadPreference
116
117
/// <summary>
117
118
/// Gets the serializer registry.
118
119
/// </summary>
119
- public IBsonSerializerRegistry SerializerRegistry
120
+ public IBsonSerializerRegistry SerializerRegistry =>
121
+ _serializationDomain . HasBeenSet
122
+ ? SerializationDomain . SerializerRegistry
123
+ : BsonSerializer . SerializerRegistry ;
124
+
125
+ /// <summary>
126
+ /// //TODO
127
+ /// </summary>
128
+ public IBsonSerializationDomain SerializationDomain
120
129
{
121
- get { return BsonSerializer . SerializerRegistry ; }
130
+ get => _serializationDomain . Value ;
131
+ set
132
+ {
133
+ if ( _isFrozen ) { throw new InvalidOperationException ( "MongoCollectionSettings is frozen." ) ; }
134
+ if ( value == null )
135
+ {
136
+ throw new ArgumentNullException ( "value" ) ;
137
+ }
138
+ _serializationDomain . Value = value ;
139
+ }
122
140
}
123
141
124
142
/// <summary>
Original file line number Diff line number Diff line change @@ -82,6 +82,14 @@ public void Implicit_encoding_with_pyton_legacy_representation_should_work_as_ex
82
82
binaryData . Bytes . Should ( ) . Equal ( BsonUtils . ParseHexString ( "00112233445566778899aabbccddeeff" ) ) ;
83
83
}
84
84
85
+ public class Person
86
+ {
87
+ [ BsonId ]
88
+ public ObjectId Id { get ; set ; }
89
+ public string Name { get ; set ; }
90
+ public int Age { get ; set ; }
91
+ }
92
+
85
93
[ Fact ]
86
94
public void Implicit_encoding_with_standard_representation_should_work_as_expected ( )
87
95
{
You can’t perform that action at this time.
0 commit comments