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(
121121 {
122122 using ( var bsonWriter = new BsonBinaryWriter ( memoryStream , writerSettings ?? BsonBinaryWriterSettings . Defaults ) )
123123 {
124- var context = BsonSerializationContext . CreateRoot ( bsonWriter , configurator ) ;
124+ var context = BsonSerializationContext . CreateRoot ( bsonWriter , configurator ) . With ( c => c . Domain = domain ) ;
125125 serializer . Serialize ( context , args , obj ) ;
126126 }
127127 return memoryStream . ToArray ( ) ;
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ public class MongoCollectionSettings
3434 private Setting < ReadPreference > _readPreference ;
3535 private Setting < WriteConcern > _writeConcern ;
3636 private Setting < UTF8Encoding > _writeEncoding ;
37+ private Setting < IBsonSerializationDomain > _serializationDomain ;
3738
3839 // the following fields are set when Freeze is called
3940 private bool _isFrozen ;
@@ -116,9 +117,26 @@ public ReadPreference ReadPreference
116117 /// <summary>
117118 /// Gets the serializer registry.
118119 /// </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
120129 {
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+ }
122140 }
123141
124142 /// <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
8282 binaryData . Bytes . Should ( ) . Equal ( BsonUtils . ParseHexString ( "00112233445566778899aabbccddeeff" ) ) ;
8383 }
8484
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+
8593 [ Fact ]
8694 public void Implicit_encoding_with_standard_representation_should_work_as_expected ( )
8795 {
You can’t perform that action at this time.
0 commit comments