17
17
using System . Collections . Generic ;
18
18
using System . Linq ;
19
19
using System . Net ;
20
+ using MongoDB . Bson ;
20
21
using MongoDB . Driver . Core . Clusters ;
21
22
using MongoDB . Driver . Core . Clusters . ServerSelectors ;
22
23
using MongoDB . Driver . Core . Misc ;
@@ -36,8 +37,10 @@ public class ClusterSettings
36
37
// fields
37
38
private readonly ClusterConnectionMode _connectionMode ;
38
39
private readonly IReadOnlyList < EndPoint > _endPoints ;
40
+ private readonly IReadOnlyDictionary < string , IReadOnlyDictionary < string , object > > _kmsProviders ;
39
41
private readonly int _maxServerSelectionWaitQueueSize ;
40
42
private readonly string _replicaSetName ;
43
+ private readonly IReadOnlyDictionary < string , BsonDocument > _schemaMap ;
41
44
private readonly ConnectionStringScheme _scheme ;
42
45
private readonly TimeSpan _serverSelectionTimeout ;
43
46
private readonly IServerSelector _preServerSelector ;
@@ -49,30 +52,36 @@ public class ClusterSettings
49
52
/// </summary>
50
53
/// <param name="connectionMode">The connection mode.</param>
51
54
/// <param name="endPoints">The end points.</param>
55
+ /// <param name="kmsProviders">The kms providers.</param>
52
56
/// <param name="maxServerSelectionWaitQueueSize">Maximum size of the server selection wait queue.</param>
53
57
/// <param name="replicaSetName">Name of the replica set.</param>
54
58
/// <param name="serverSelectionTimeout">The server selection timeout.</param>
55
59
/// <param name="preServerSelector">The pre server selector.</param>
56
60
/// <param name="postServerSelector">The post server selector.</param>
61
+ /// <param name="schemaMap">The schema map.</param>
57
62
/// <param name="scheme">The connection string scheme.</param>
58
63
public ClusterSettings (
59
64
Optional < ClusterConnectionMode > connectionMode = default ( Optional < ClusterConnectionMode > ) ,
60
65
Optional < IEnumerable < EndPoint > > endPoints = default ( Optional < IEnumerable < EndPoint > > ) ,
66
+ Optional < IReadOnlyDictionary < string , IReadOnlyDictionary < string , object > > > kmsProviders = default ( Optional < IReadOnlyDictionary < string , IReadOnlyDictionary < string , object > > > ) ,
61
67
Optional < int > maxServerSelectionWaitQueueSize = default ( Optional < int > ) ,
62
68
Optional < string > replicaSetName = default ( Optional < string > ) ,
63
69
Optional < TimeSpan > serverSelectionTimeout = default ( Optional < TimeSpan > ) ,
64
70
Optional < IServerSelector > preServerSelector = default ( Optional < IServerSelector > ) ,
65
71
Optional < IServerSelector > postServerSelector = default ( Optional < IServerSelector > ) ,
72
+ Optional < IReadOnlyDictionary < string , BsonDocument > > schemaMap = default ( Optional < IReadOnlyDictionary < string , BsonDocument > > ) ,
66
73
Optional < ConnectionStringScheme > scheme = default ( Optional < ConnectionStringScheme > ) )
67
74
{
68
75
_connectionMode = connectionMode . WithDefault ( ClusterConnectionMode . Automatic ) ;
69
76
_endPoints = Ensure . IsNotNull ( endPoints . WithDefault ( __defaultEndPoints ) , "endPoints" ) . ToList ( ) ;
77
+ _kmsProviders = kmsProviders . WithDefault ( null ) ;
70
78
_maxServerSelectionWaitQueueSize = Ensure . IsGreaterThanOrEqualToZero ( maxServerSelectionWaitQueueSize . WithDefault ( 500 ) , "maxServerSelectionWaitQueueSize" ) ;
71
79
_replicaSetName = replicaSetName . WithDefault ( null ) ;
72
80
_serverSelectionTimeout = Ensure . IsGreaterThanOrEqualToZero ( serverSelectionTimeout . WithDefault ( TimeSpan . FromSeconds ( 30 ) ) , "serverSelectionTimeout" ) ;
73
81
_preServerSelector = preServerSelector . WithDefault ( null ) ;
74
82
_postServerSelector = postServerSelector . WithDefault ( null ) ;
75
83
_scheme = scheme . WithDefault ( ConnectionStringScheme . MongoDB ) ;
84
+ _schemaMap = schemaMap . WithDefault ( null ) ;
76
85
}
77
86
78
87
// properties
@@ -98,6 +107,17 @@ public IReadOnlyList<EndPoint> EndPoints
98
107
get { return _endPoints ; }
99
108
}
100
109
110
+ /// <summary>
111
+ /// Gets the kms providers.
112
+ /// </summary>
113
+ /// <value>
114
+ /// The kms providers.
115
+ /// </value>
116
+ public IReadOnlyDictionary < string , IReadOnlyDictionary < string , object > > KmsProviders
117
+ {
118
+ get { return _kmsProviders ; }
119
+ }
120
+
101
121
/// <summary>
102
122
/// Gets the maximum size of the server selection wait queue.
103
123
/// </summary>
@@ -120,6 +140,17 @@ public string ReplicaSetName
120
140
get { return _replicaSetName ; }
121
141
}
122
142
143
+ /// <summary>
144
+ /// Gets the schema map.
145
+ /// </summary>
146
+ /// <value>
147
+ /// The schema map.
148
+ /// </value>
149
+ public IReadOnlyDictionary < string , BsonDocument > SchemaMap
150
+ {
151
+ get { return _schemaMap ; }
152
+ }
153
+
123
154
/// <summary>
124
155
/// Gets the connection string scheme.
125
156
/// </summary>
@@ -170,31 +201,37 @@ public IServerSelector PostServerSelector
170
201
/// </summary>
171
202
/// <param name="connectionMode">The connection mode.</param>
172
203
/// <param name="endPoints">The end points.</param>
204
+ /// <param name="kmsProviders">The kms providers.</param>
173
205
/// <param name="maxServerSelectionWaitQueueSize">Maximum size of the server selection wait queue.</param>
174
206
/// <param name="replicaSetName">Name of the replica set.</param>
175
207
/// <param name="serverSelectionTimeout">The server selection timeout.</param>
176
208
/// <param name="preServerSelector">The pre server selector.</param>
177
209
/// <param name="postServerSelector">The post server selector.</param>
210
+ /// <param name="schemaMap">The schema map.</param>
178
211
/// <param name="scheme">The connection string scheme.</param>
179
212
/// <returns>A new ClusterSettings instance.</returns>
180
213
public ClusterSettings With (
181
214
Optional < ClusterConnectionMode > connectionMode = default ( Optional < ClusterConnectionMode > ) ,
182
215
Optional < IEnumerable < EndPoint > > endPoints = default ( Optional < IEnumerable < EndPoint > > ) ,
216
+ Optional < IReadOnlyDictionary < string , IReadOnlyDictionary < string , object > > > kmsProviders = default ( Optional < IReadOnlyDictionary < string , IReadOnlyDictionary < string , object > > > ) ,
183
217
Optional < int > maxServerSelectionWaitQueueSize = default ( Optional < int > ) ,
184
218
Optional < string > replicaSetName = default ( Optional < string > ) ,
185
219
Optional < TimeSpan > serverSelectionTimeout = default ( Optional < TimeSpan > ) ,
186
220
Optional < IServerSelector > preServerSelector = default ( Optional < IServerSelector > ) ,
187
221
Optional < IServerSelector > postServerSelector = default ( Optional < IServerSelector > ) ,
222
+ Optional < IReadOnlyDictionary < string , BsonDocument > > schemaMap = default ( Optional < IReadOnlyDictionary < string , BsonDocument > > ) ,
188
223
Optional < ConnectionStringScheme > scheme = default ( Optional < ConnectionStringScheme > ) )
189
224
{
190
225
return new ClusterSettings (
191
226
connectionMode : connectionMode . WithDefault ( _connectionMode ) ,
192
227
endPoints : Optional . Enumerable ( endPoints . WithDefault ( _endPoints ) ) ,
228
+ kmsProviders : Optional . Create ( kmsProviders . WithDefault ( _kmsProviders ) ) ,
193
229
maxServerSelectionWaitQueueSize : maxServerSelectionWaitQueueSize . WithDefault ( _maxServerSelectionWaitQueueSize ) ,
194
230
replicaSetName : replicaSetName . WithDefault ( _replicaSetName ) ,
195
231
serverSelectionTimeout : serverSelectionTimeout . WithDefault ( _serverSelectionTimeout ) ,
196
232
preServerSelector : Optional . Create ( preServerSelector . WithDefault ( _preServerSelector ) ) ,
197
233
postServerSelector : Optional . Create ( postServerSelector . WithDefault ( _postServerSelector ) ) ,
234
+ schemaMap : Optional . Create ( schemaMap . WithDefault ( _schemaMap ) ) ,
198
235
scheme : scheme . WithDefault ( _scheme ) ) ;
199
236
}
200
237
}
0 commit comments