@@ -39,7 +39,6 @@ public class MongoConnectionStringBuilder : DbConnectionStringBuilder
3939 { "connecttimeout" , "connectTimeout" } ,
4040 { "connecttimeoutms" , "connectTimeout" } ,
4141 { "database" , "database" } ,
42- { "fireandforget" , "fireAndForget" } ,
4342 { "fsync" , "fsync" } ,
4443 { "guids" , "uuidRepresentation" } ,
4544 { "ipv6" , "ipv6" } ,
@@ -81,7 +80,6 @@ public class MongoConnectionStringBuilder : DbConnectionStringBuilder
8180 private ConnectionMode _connectionMode ;
8281 private TimeSpan _connectTimeout ;
8382 private string _databaseName ;
84- private bool ? _fireAndForget ;
8583 private bool ? _fsync ;
8684 private GuidRepresentation _guidRepresentation ;
8785 private bool _ipv6 ;
@@ -187,30 +185,6 @@ public string DatabaseName
187185 }
188186 }
189187
190- /// <summary>
191- /// Gets or sets the fireAndForget value.
192- /// </summary>
193- public bool ? FireAndForget
194- {
195- get { return _fireAndForget ; }
196- set
197- {
198- if ( value != null )
199- {
200- if ( _safe != null )
201- {
202- throw new InvalidOperationException ( "FireAndForget and Safe are mutually exclusive." ) ;
203- }
204- if ( value . Value && AnyWriteConcernSettingsAreSet ( ) )
205- {
206- throw new InvalidOperationException ( "FireAndForget cannot be set to true if any other write concern values have been set." ) ;
207- }
208- }
209- _fireAndForget = value ;
210- base [ "fireAndForget" ] = ( value == null ) ? null : XmlConvert . ToString ( value . Value ) ;
211- }
212- }
213-
214188 /// <summary>
215189 /// Gets or sets the FSync component of the write concern.
216190 /// </summary>
@@ -219,7 +193,6 @@ public bool? FSync
219193 get { return _fsync ; }
220194 set
221195 {
222- if ( value != null ) { EnsureFireAndForgetIsNotTrue ( "FSync" ) ; }
223196 _fsync = value ;
224197 base [ "fsync" ] = ( value == null ) ? null : XmlConvert . ToString ( value . Value ) ;
225198 }
@@ -259,7 +232,6 @@ public bool? Journal
259232 get { return _journal ; }
260233 set
261234 {
262- if ( value != null ) { EnsureFireAndForgetIsNotTrue ( "Journal" ) ; }
263235 _journal = value ;
264236 base [ "journal" ] = ( value == null ) ? null : XmlConvert . ToString ( value . Value ) ;
265237 }
@@ -407,18 +379,14 @@ public string ReplicaSetName
407379 /// <summary>
408380 /// Gets or sets the safe value.
409381 /// </summary>
410- [ Obsolete ( "Use FireAndForget instead." ) ]
382+ [ Obsolete ( "Use W=0 or W=1 instead." ) ]
411383 public bool ? Safe
412384 {
413385 get { return _safe ; }
414386 set
415387 {
416388 if ( value != null )
417389 {
418- if ( _fireAndForget != null )
419- {
420- throw new InvalidOperationException ( "FireAndForget and Safe are mutually exclusive." ) ;
421- }
422390 if ( ! value . Value && AnyWriteConcernSettingsAreSet ( ) )
423391 {
424392 throw new InvalidOperationException ( "Safe cannot be set to false if any other write concern values have been set." ) ;
@@ -432,12 +400,12 @@ public bool? Safe
432400 /// <summary>
433401 /// Gets or sets the SafeMode to use.
434402 /// </summary>
435- [ Obsolete ( "Use FireAndForget, FSync, Journal, W and WTimeout instead." ) ]
403+ [ Obsolete ( "Use FSync, Journal, W and WTimeout instead." ) ]
436404 public SafeMode SafeMode
437405 {
438406 get
439407 {
440- if ( _fireAndForget != null || _safe != null || AnyWriteConcernSettingsAreSet ( ) )
408+ if ( _safe != null || AnyWriteConcernSettingsAreSet ( ) )
441409 {
442410#pragma warning disable 618
443411 return new SafeMode ( GetWriteConcern ( false ) ) ;
@@ -450,7 +418,6 @@ public SafeMode SafeMode
450418 }
451419 set
452420 {
453- FireAndForget = null ;
454421 Safe = null ;
455422 FSync = null ;
456423 Journal = null ;
@@ -607,7 +574,6 @@ public WriteConcern.WValue W
607574 get { return _w ; }
608575 set
609576 {
610- if ( value != null ) { EnsureFireAndForgetIsNotTrue ( "W" ) ; }
611577 _w = value ;
612578 base [ "w" ] = ( value == null ) ? null : value . ToString ( ) ;
613579 }
@@ -676,7 +642,6 @@ public TimeSpan? WTimeout
676642 get { return _wTimeout ; }
677643 set
678644 {
679- if ( value != null ) { EnsureFireAndForgetIsNotTrue ( "WTimeout" ) ; }
680645 if ( value != null && value . Value < TimeSpan . Zero )
681646 {
682647 throw new ArgumentOutOfRangeException ( "value" , "WTimeout must be greater than or equal to zero." ) ;
@@ -722,9 +687,6 @@ public override object this[string keyword]
722687 case "database" :
723688 DatabaseName = ( string ) value ;
724689 break ;
725- case "fireandforget" :
726- FireAndForget = Convert . ToBoolean ( value ) ;
727- break ;
728690 case "fsync" :
729691 FSync = Convert . ToBoolean ( value ) ;
730692 break ;
@@ -870,23 +832,13 @@ public override bool ContainsKey(string keyword)
870832 }
871833
872834 /// <summary>
873- /// Returns a WriteConcern value based on this instance's settings and a fire and forget default .
835+ /// Returns a WriteConcern value based on this instance's settings and a default enabled value .
874836 /// </summary>
875- /// <param name="fireAndForgetDefault ">The fire and forget default .</param>
837+ /// <param name="enabledDefault ">The default enabled value .</param>
876838 /// <returns>A WriteConcern.</returns>
877- public WriteConcern GetWriteConcern ( bool fireAndForgetDefault )
839+ public WriteConcern GetWriteConcern ( bool enabledDefault )
878840 {
879- var fireAndForget = fireAndForgetDefault ;
880- if ( _fireAndForget != null ) { fireAndForget = _fireAndForget . Value ; }
881- else if ( _safe != null ) { fireAndForget = ! _safe . Value ; }
882- else if ( AnyWriteConcernSettingsAreSet ( ) ) { fireAndForget = false ; }
883-
884- var writeConcern = new WriteConcern { FireAndForget = fireAndForget } ;
885- if ( _fsync != null ) { writeConcern . FSync = _fsync . Value ; }
886- if ( _journal != null ) { writeConcern . Journal = _journal . Value ; }
887- if ( _w != null ) { writeConcern . W = _w ; }
888- if ( _wTimeout != null ) { writeConcern . WTimeout = _wTimeout . Value ; }
889- return writeConcern ;
841+ return WriteConcern . Create ( enabledDefault , _safe , _fsync , _journal , _w , _wTimeout ) ;
890842 }
891843
892844 /// <summary>
@@ -905,20 +857,6 @@ private bool AnyWriteConcernSettingsAreSet()
905857 return _fsync != null || _journal != null || _w != null || _wTimeout != null ;
906858 }
907859
908- private void EnsureFireAndForgetIsNotTrue ( string propertyName )
909- {
910- if ( _fireAndForget != null && _fireAndForget . Value )
911- {
912- var message = string . Format ( "{0} cannot be set when FireAndForget is true." , propertyName ) ;
913- throw new InvalidOperationException ( message ) ;
914- }
915- if ( _safe != null && ! _safe . Value )
916- {
917- var message = string . Format ( "{0} cannot be set when Safe is false." , propertyName ) ;
918- throw new InvalidOperationException ( message ) ;
919- }
920- }
921-
922860 private string GetServersString ( IEnumerable < MongoServerAddress > servers )
923861 {
924862 var sb = new StringBuilder ( ) ;
@@ -990,7 +928,6 @@ private void ResetValues()
990928 _connectionMode = ConnectionMode . Automatic ;
991929 _connectTimeout = MongoDefaults . ConnectTimeout ;
992930 _databaseName = null ;
993- _fireAndForget = null ;
994931 _fsync = null ;
995932 _guidRepresentation = MongoDefaults . GuidRepresentation ;
996933 _ipv6 = false ;
0 commit comments