// public constructors /// <summary> /// Initializes a new instance of the <see cref="TransactionOptions" /> class. /// </summary> /// <param name="readConcern">The read concern.</param> /// <param name="writeConcern">The write concern.</param> public TransactionOptions( Optional <ReadConcern> readConcern = default(Optional <ReadConcern>), Optional <WriteConcern> writeConcern = default(Optional <WriteConcern>)) { _readConcern = readConcern.WithDefault(null); _writeConcern = writeConcern.WithDefault(null); }
/// <summary> /// Returns a new instance of ReadPreference with some values changed. /// </summary> /// <param name="mode">The read preference mode.</param> /// <param name="tagSets">The tag sets.</param> /// <returns>A new instance of ReadPreference.</returns> public ReadPreference With( Optional <ReadPreferenceMode> mode = default(Optional <ReadPreferenceMode>), Optional <IEnumerable <TagSet> > tagSets = default(Optional <IEnumerable <TagSet> >)) { return(new ReadPreference( mode.WithDefault(_mode), Optional.Create(tagSets.WithDefault(_tagSets)))); }
// public methods /// <summary> /// Returns a new TransactionOptions with some values changed. /// </summary> /// <param name="readConcern">The new read concern.</param> /// <param name="writeConcern">The new write concern.</param> /// <returns>The new TransactionOptions.</returns> public TransactionOptions With( Optional <ReadConcern> readConcern = default(Optional <ReadConcern>), Optional <WriteConcern> writeConcern = default(Optional <WriteConcern>)) { return(new TransactionOptions( readConcern: readConcern.WithDefault(_readConcern), writeConcern: writeConcern.WithDefault(_writeConcern))); }
/// <summary> /// Initializes a new instance of the <see cref="WriteConcern"/> class. /// </summary> /// <param name="w">The w value.</param> /// <param name="wTimeout">The wtimeout value.</param> /// <param name="fsync">The fsync value .</param> /// <param name="journal">The journal value.</param> public WriteConcern( Optional <WValue> w = default(Optional <WValue>), Optional <TimeSpan?> wTimeout = default(Optional <TimeSpan?>), Optional <bool?> fsync = default(Optional <bool?>), Optional <bool?> journal = default(Optional <bool?>)) { _w = w.WithDefault(null); _wTimeout = Ensure.IsNullOrGreaterThanZero(wTimeout.WithDefault(null), "wTimeout"); _fsync = fsync.WithDefault(null); _journal = journal.WithDefault(null); }
/// <summary> /// Returns a new instance of ReadConcern with some values changed. /// </summary> /// <param name="level">The level.</param> /// <returns> /// A ReadConcern. /// </returns> public ReadConcern With(Optional <ReadConcernLevel?> level = default(Optional <ReadConcernLevel?>)) { if (level.Replaces(_level)) { return(new ReadConcern(level.WithDefault(_level))); } else { return(this); } }
// public constructors /// <summary> /// Initializes a new instance of the <see cref="TransactionOptions" /> class. /// </summary> /// <param name="readConcern">The read concern.</param> /// <param name="readPreference">The read preference.</param> /// <param name="writeConcern">The write concern.</param> /// <param name="maxCommitTime">The max commit time.</param> public TransactionOptions( Optional <ReadConcern> readConcern = default(Optional <ReadConcern>), Optional <ReadPreference> readPreference = default(Optional <ReadPreference>), Optional <WriteConcern> writeConcern = default(Optional <WriteConcern>), Optional <TimeSpan?> maxCommitTime = default(Optional <TimeSpan?>)) { _readConcern = readConcern.WithDefault(null); _readPreference = readPreference.WithDefault(null); _writeConcern = writeConcern.WithDefault(null); _maxCommitTime = maxCommitTime.WithDefault(null); }
// constructors /// <summary> /// Initializes a new instance of the <see cref="ReadPreference"/> class. /// </summary> /// <param name="mode">The read preference mode.</param> /// <param name="tagSets">The tag sets.</param> public ReadPreference( Optional <ReadPreferenceMode> mode = default(Optional <ReadPreferenceMode>), Optional <IEnumerable <TagSet> > tagSets = default(Optional <IEnumerable <TagSet> >)) { _mode = mode.WithDefault(ReadPreferenceMode.Primary); _tagSets = Ensure.IsNotNull(tagSets.WithDefault(Enumerable.Empty <TagSet>()), "tagSets").ToList(); if (_mode == ReadPreferenceMode.Primary && _tagSets.Count() > 0) { throw new ArgumentException("TagSets cannot be used with ReadPreferenceMode Primary.", "tagSets"); } }
// public methods /// <summary> /// Returns a new TransactionOptions with some values changed. /// </summary> /// <param name="readConcern">The new read concern.</param> /// <param name="readPreference">The read preference.</param> /// <param name="writeConcern">The new write concern.</param> /// <param name="maxCommitTime">The max commit time.</param> /// <returns> /// The new TransactionOptions. /// </returns> public TransactionOptions With( Optional <ReadConcern> readConcern = default(Optional <ReadConcern>), Optional <ReadPreference> readPreference = default(Optional <ReadPreference>), Optional <WriteConcern> writeConcern = default(Optional <WriteConcern>), Optional <TimeSpan?> maxCommitTime = default(Optional <TimeSpan?>)) { return(new TransactionOptions( readConcern: readConcern.WithDefault(_readConcern), readPreference: readPreference.WithDefault(_readPreference), writeConcern: writeConcern.WithDefault(_writeConcern), maxCommitTime: maxCommitTime.WithDefault(_maxCommitTime))); }
/// <summary> /// Initializes a new instance of the <see cref="WriteConcern"/> class. /// </summary> /// <param name="w">The w value.</param> /// <param name="wTimeout">The wtimeout value.</param> /// <param name="fsync">The fsync value .</param> /// <param name="journal">The journal value.</param> public WriteConcern( Optional <WValue> w = default(Optional <WValue>), Optional <TimeSpan?> wTimeout = default(Optional <TimeSpan?>), Optional <bool?> fsync = default(Optional <bool?>), Optional <bool?> journal = default(Optional <bool?>)) { _w = w.WithDefault(null); _wTimeout = Ensure.IsNullOrGreaterThanZero(wTimeout.WithDefault(null), "wTimeout"); _fsync = fsync.WithDefault(null); _journal = journal.WithDefault(null); if (_w != null && w.Value.Equals(0) && _journal.HasValue && journal.Value.Equals(true)) { throw new MongoConfigurationException("This write concern is not valid."); } }
// constructors /// <summary> /// Initializes a new instance of the <see cref="Collation" /> class. /// </summary> /// <param name="locale">The locale.</param> /// <param name="caseLevel">The case level.</param> /// <param name="caseFirst">The case that is ordered first.</param> /// <param name="strength">The strength.</param> /// <param name="numericOrdering">Whether numbers are ordered numerically.</param> /// <param name="alternate">The alternate.</param> /// <param name="maxVariable">The maximum variable.</param> /// <param name="normalization">The normalization.</param> /// <param name="backwards">Whether secondary differences are to be considered in reverse order.</param> public Collation( string locale, Optional <bool?> caseLevel = default(Optional <bool?>), Optional <CollationCaseFirst?> caseFirst = default(Optional <CollationCaseFirst?>), Optional <CollationStrength?> strength = default(Optional <CollationStrength?>), Optional <bool?> numericOrdering = default(Optional <bool?>), Optional <CollationAlternate?> alternate = default(Optional <CollationAlternate?>), Optional <CollationMaxVariable?> maxVariable = default(Optional <CollationMaxVariable?>), Optional <bool?> normalization = default(Optional <bool?>), Optional <bool?> backwards = default(Optional <bool?>)) { _locale = Ensure.IsNotNull(locale, nameof(locale)); _caseLevel = caseLevel.WithDefault(null); _caseFirst = caseFirst.WithDefault(null); _strength = strength.WithDefault(null); _numericOrdering = numericOrdering.WithDefault(null); _alternate = alternate.WithDefault(null); _maxVariable = maxVariable.WithDefault(null); _normalization = normalization.WithDefault(null); _backwards = backwards.WithDefault(null); }
/// <summary> /// Returns a new instance of WriteConcern with some values changed. /// </summary> /// <param name="w">The w value.</param> /// <param name="wTimeout">The wtimeout value.</param> /// <param name="fsync">The fsync value.</param> /// <param name="journal">The journal value.</param> /// <returns>A WriteConcern.</returns> public WriteConcern With( Optional <WValue> w = default(Optional <WValue>), Optional <TimeSpan?> wTimeout = default(Optional <TimeSpan?>), Optional <bool?> fsync = default(Optional <bool?>), Optional <bool?> journal = default(Optional <bool?>)) { if (w.Replaces(_w) || wTimeout.Replaces(_wTimeout) || fsync.Replaces(_fsync) || journal.Replaces(_journal)) { return(new WriteConcern( w: w.WithDefault(_w), wTimeout: wTimeout.WithDefault(_wTimeout), fsync: fsync.WithDefault(_fsync), journal: journal.WithDefault(_journal))); } else { return(this); } }
/// <summary> /// Creates a new Collation instance with some properties changed. /// </summary> /// <param name="locale">The new locale.</param> /// <param name="caseLevel">The new case level.</param> /// <param name="caseFirst">The new case first.</param> /// <param name="strength">The new strength.</param> /// <param name="numericOrdering">The new numeric ordering.</param> /// <param name="alternate">The new alternate.</param> /// <param name="maxVariable">The new maximum variable.</param> /// <param name="normalization">The new normalization.</param> /// <param name="backwards">The new backwards.</param> /// <returns>A new Collation instance.</returns> public Collation With( Optional <string> locale = default(Optional <string>), Optional <bool?> caseLevel = default(Optional <bool?>), Optional <CollationCaseFirst?> caseFirst = default(Optional <CollationCaseFirst?>), Optional <CollationStrength?> strength = default(Optional <CollationStrength?>), Optional <bool?> numericOrdering = default(Optional <bool?>), Optional <CollationAlternate?> alternate = default(Optional <CollationAlternate?>), Optional <CollationMaxVariable?> maxVariable = default(Optional <CollationMaxVariable?>), Optional <bool?> normalization = default(Optional <bool?>), Optional <bool?> backwards = default(Optional <bool?>)) { return(new Collation( locale.WithDefault(_locale), caseLevel.WithDefault(_caseLevel), caseFirst.WithDefault(_caseFirst), strength.WithDefault(_strength), numericOrdering.WithDefault(_numericOrdering), alternate.WithDefault(_alternate), maxVariable.WithDefault(_maxVariable), normalization.WithDefault(_normalization), backwards.WithDefault(_backwards))); }
/// <summary> /// Initializes a new instance of the <see cref="TimeSeriesOptions"/> class. /// </summary> /// <param name="timeField">The name of the top-level field to be used for time.</param> /// <param name="metaField">The name of the top-level field describing the series upon which related data will be grouped.</param> /// <param name="granularity">The <see cref="TimeSeriesGranularity"/> for the time series.</param> public TimeSeriesOptions(string timeField, Optional <string> metaField = default, Optional <TimeSeriesGranularity?> granularity = default) { _timeField = Ensure.IsNotNullOrEmpty(timeField, nameof(timeField)); _metaField = metaField.WithDefault(null); _granularity = granularity.WithDefault(null); }
/// <summary> /// Initializes a new instance of the <see cref="ReadConcern" /> class. /// </summary> /// <param name="level">The level.</param> public ReadConcern(Optional <ReadConcernLevel?> level = default(Optional <ReadConcernLevel?>)) { _level = level.WithDefault(null); }
// constructors /// <summary> /// Initializes a new instance of the <see cref="ServerApi" /> class. /// </summary> /// <param name="version">The server API version.</param> /// <param name="strict">The flag for strict server API version enforcement.</param> /// <param name="deprecationErrors">The flag for treating deprecated server APIs as errors.</param> public ServerApi(ServerApiVersion version, Optional <bool?> strict = default, Optional <bool?> deprecationErrors = default) { _version = Ensure.IsNotNull(version, nameof(version)); _strict = strict.WithDefault(null); _deprecationErrors = deprecationErrors.WithDefault(null); }