@@ -24,71 +24,46 @@ namespace MongoDB.Bson
2424 /// </summary>
2525 public static class BsonDefaults
2626 {
27- // private static fields
28- private static bool __dynamicArraySerializerWasSet ;
29- private static IBsonSerializer __dynamicArraySerializer ;
30- private static bool __dynamicDocumentSerializerWasSet ;
31- private static IBsonSerializer __dynamicDocumentSerializer ;
32- private static int __maxDocumentSize = int . MaxValue ;
33- private static int __maxSerializationDepth = 100 ;
34-
3527 // public static properties
3628 /// <summary>
3729 /// Gets or sets the dynamic array serializer.
3830 /// </summary>
3931 public static IBsonSerializer DynamicArraySerializer
4032 {
41- get
42- {
43- if ( ! __dynamicArraySerializerWasSet )
44- {
45- __dynamicArraySerializer = BsonSerializer . LookupSerializer < List < object > > ( ) ;
46- }
47- return __dynamicArraySerializer ;
48- }
49- set
50- {
51- __dynamicArraySerializerWasSet = true ;
52- __dynamicArraySerializer = value ;
53- }
33+ get => BsonSerializationDomain . Default . BsonDefaults . DynamicArraySerializer ;
34+ set => BsonSerializationDomain . Default . BsonDefaults . DynamicArraySerializer = value ;
5435 }
5536
5637 /// <summary>
5738 /// Gets or sets the dynamic document serializer.
5839 /// </summary>
5940 public static IBsonSerializer DynamicDocumentSerializer
6041 {
61- get
62- {
63- if ( ! __dynamicDocumentSerializerWasSet )
64- {
65- __dynamicDocumentSerializer = BsonSerializer . LookupSerializer < ExpandoObject > ( ) ;
66- }
67- return __dynamicDocumentSerializer ;
68- }
69- set
70- {
71- __dynamicDocumentSerializerWasSet = true ;
72- __dynamicDocumentSerializer = value ;
73- }
42+ get => BsonSerializationDomain . Default . BsonDefaults . DynamicDocumentSerializer ;
43+ set => BsonSerializationDomain . Default . BsonDefaults . DynamicDocumentSerializer = value ;
7444 }
7545
46+ /* DOMAIN-API We should modify the API to have those two values (and in the writer/reader settings where they are used) be nullable.
47+ * The problem is that we need to now when these values have been set externally or not. If they have not, then they should
48+ * be retrieved from the closest domain.
49+ */
50+
7651 /// <summary>
7752 /// Gets or sets the default max document size. The default is 4MiB.
7853 /// </summary>
7954 public static int MaxDocumentSize
8055 {
81- get { return __maxDocumentSize ; }
82- set { __maxDocumentSize = value ; }
56+ get => BsonSerializationDomain . Default . BsonDefaults . MaxDocumentSize ;
57+ set => BsonSerializationDomain . Default . BsonDefaults . MaxDocumentSize = value ;
8358 }
8459
8560 /// <summary>
8661 /// Gets or sets the default max serialization depth (used to detect circular references during serialization). The default is 100.
8762 /// </summary>
8863 public static int MaxSerializationDepth
8964 {
90- get { return __maxSerializationDepth ; }
91- set { __maxSerializationDepth = value ; }
65+ get => BsonSerializationDomain . Default . BsonDefaults . MaxSerializationDepth ;
66+ set => BsonSerializationDomain . Default . BsonDefaults . MaxSerializationDepth = value ;
9267 }
9368 }
9469}
0 commit comments