14
14
*/
15
15
16
16
using System ;
17
- using System . Collections . Generic ;
18
- using System . Linq ;
19
- using System . Text ;
20
- using System . Threading . Tasks ;
21
- using MongoDB . Bson ;
22
17
23
18
namespace MongoDB . Driver
24
19
{
@@ -28,6 +23,7 @@ namespace MongoDB.Driver
28
23
public class TransactionOptions
29
24
{
30
25
// private fields
26
+ private readonly TimeSpan ? _maxCommitTime ;
31
27
private readonly ReadConcern _readConcern ;
32
28
private readonly ReadPreference _readPreference ;
33
29
private readonly WriteConcern _writeConcern ;
@@ -39,17 +35,28 @@ public class TransactionOptions
39
35
/// <param name="readConcern">The read concern.</param>
40
36
/// <param name="readPreference">The read preference.</param>
41
37
/// <param name="writeConcern">The write concern.</param>
38
+ /// <param name="maxCommitTime">The max commit time.</param>
42
39
public TransactionOptions (
43
40
Optional < ReadConcern > readConcern = default ( Optional < ReadConcern > ) ,
44
41
Optional < ReadPreference > readPreference = default ( Optional < ReadPreference > ) ,
45
- Optional < WriteConcern > writeConcern = default ( Optional < WriteConcern > ) )
42
+ Optional < WriteConcern > writeConcern = default ( Optional < WriteConcern > ) ,
43
+ Optional < TimeSpan ? > maxCommitTime = default ( Optional < TimeSpan ? > ) )
46
44
{
47
45
_readConcern = readConcern . WithDefault ( null ) ;
48
46
_readPreference = readPreference . WithDefault ( null ) ;
49
47
_writeConcern = writeConcern . WithDefault ( null ) ;
48
+ _maxCommitTime = maxCommitTime . WithDefault ( null ) ;
50
49
}
51
50
52
51
// public properties
52
+ /// <summary>
53
+ /// Gets the max commit time.
54
+ /// </summary>
55
+ /// <value>
56
+ /// The max commit time.
57
+ /// </value>
58
+ public TimeSpan ? MaxCommitTime => _maxCommitTime ;
59
+
53
60
/// <summary>
54
61
/// Gets the read concern.
55
62
/// </summary>
@@ -81,18 +88,21 @@ public TransactionOptions(
81
88
/// <param name="readConcern">The new read concern.</param>
82
89
/// <param name="readPreference">The read preference.</param>
83
90
/// <param name="writeConcern">The new write concern.</param>
91
+ /// <param name="maxCommitTime">The max commit time.</param>
84
92
/// <returns>
85
93
/// The new TransactionOptions.
86
94
/// </returns>
87
95
public TransactionOptions With (
88
96
Optional < ReadConcern > readConcern = default ( Optional < ReadConcern > ) ,
89
97
Optional < ReadPreference > readPreference = default ( Optional < ReadPreference > ) ,
90
- Optional < WriteConcern > writeConcern = default ( Optional < WriteConcern > ) )
98
+ Optional < WriteConcern > writeConcern = default ( Optional < WriteConcern > ) ,
99
+ Optional < TimeSpan ? > maxCommitTime = default ( Optional < TimeSpan ? > ) )
91
100
{
92
101
return new TransactionOptions (
93
102
readConcern : readConcern . WithDefault ( _readConcern ) ,
94
103
readPreference : readPreference . WithDefault ( _readPreference ) ,
95
- writeConcern : writeConcern . WithDefault ( _writeConcern ) ) ;
104
+ writeConcern : writeConcern . WithDefault ( _writeConcern ) ,
105
+ maxCommitTime : maxCommitTime . WithDefault ( _maxCommitTime ) ) ;
96
106
}
97
107
}
98
108
}
0 commit comments