Table of Contents

Class MongoServerSettings

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.Legacy.dll

The settings used to access a MongoDB server.

public class MongoServerSettings : IEquatable<MongoServerSettings>
Inheritance
MongoServerSettings
Implements
Inherited Members
Extension Methods

Constructors

MongoServerSettings()

Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.

public MongoServerSettings()

Properties

AddressFamily

Gets the AddressFamily for the IPEndPoint (derived from the IPv6 setting).

[Obsolete("Use IPv6 instead.")]
public AddressFamily AddressFamily { get; }

Property Value

AddressFamily

AllowInsecureTls

Gets or sets whether to relax TLS constraints as much as possible. Setting this variable to true will also set SslSettings.CheckCertificateRevocation to false.

public bool AllowInsecureTls { get; set; }

Property Value

bool

ApplicationName

Gets or sets the application name.

public string ApplicationName { get; set; }

Property Value

string

ClusterConfigurator

Gets or sets the cluster configurator.

public Action<ClusterBuilder> ClusterConfigurator { get; set; }

Property Value

Action<ClusterBuilder>

Compressors

Gets or sets the compressors.

public IReadOnlyList<CompressorConfiguration> Compressors { get; set; }

Property Value

IReadOnlyList<CompressorConfiguration>

ConnectTimeout

Gets or sets the connect timeout.

public TimeSpan ConnectTimeout { get; set; }

Property Value

TimeSpan

ConnectionMode

Gets or sets the connection mode.

[Obsolete("Use DirectConnection instead.")]
public ConnectionMode ConnectionMode { get; set; }

Property Value

ConnectionMode

ConnectionModeSwitch

Gets the connection mode switch.

[Obsolete("This property will be removed in a later release.")]
public ConnectionModeSwitch ConnectionModeSwitch { get; }

Property Value

ConnectionModeSwitch

Credential

Gets or sets the credential.

public MongoCredential Credential { get; set; }

Property Value

MongoCredential

Credentials

Gets or sets the credentials.

[Obsolete("Use Credential instead. Using multiple credentials is deprecated.")]
public IEnumerable<MongoCredential> Credentials { get; set; }

Property Value

IEnumerable<MongoCredential>

DirectConnection

Gets ot sets DirectConnection.

public bool? DirectConnection { get; set; }

Property Value

bool?

GuidRepresentation

Gets or sets the representation to use for Guids.

[Obsolete("Configure serializers instead.")]
public GuidRepresentation GuidRepresentation { get; set; }

Property Value

GuidRepresentation

HeartbeatInterval

Gets or sets the heartbeat interval.

public TimeSpan HeartbeatInterval { get; set; }

Property Value

TimeSpan

HeartbeatTimeout

Gets or sets the heartbeat timeout.

public TimeSpan HeartbeatTimeout { get; set; }

Property Value

TimeSpan

IPv6

Gets or sets a value indicating whether to use IPv6.

public bool IPv6 { get; set; }

Property Value

bool

IsFrozen

Gets a value indicating whether the settings have been frozen to prevent further changes.

public bool IsFrozen { get; }

Property Value

bool

LocalThreshold

Gets or sets the local threshold.

public TimeSpan LocalThreshold { get; set; }

Property Value

TimeSpan

MaxConnectionIdleTime

Gets or sets the max connection idle time.

public TimeSpan MaxConnectionIdleTime { get; set; }

Property Value

TimeSpan

MaxConnectionLifeTime

Gets or sets the max connection life time.

public TimeSpan MaxConnectionLifeTime { get; set; }

Property Value

TimeSpan

MaxConnectionPoolSize

Gets or sets the max connection pool size.

public int MaxConnectionPoolSize { get; set; }

Property Value

int

MinConnectionPoolSize

Gets or sets the min connection pool size.

public int MinConnectionPoolSize { get; set; }

Property Value

int

OperationTimeout

Gets or sets the operation timeout.

public TimeSpan OperationTimeout { get; set; }

Property Value

TimeSpan

ReadConcern

Gets or sets the read concern.

public ReadConcern ReadConcern { get; set; }

Property Value

ReadConcern

ReadEncoding

Gets or sets the Read Encoding.

public UTF8Encoding ReadEncoding { get; set; }

Property Value

UTF8Encoding

ReadPreference

Gets or sets the read preferences.

public ReadPreference ReadPreference { get; set; }

Property Value

ReadPreference

ReplicaSetName

Gets or sets the name of the replica set.

public string ReplicaSetName { get; set; }

Property Value

string

RetryReads

Gets or sets whether to retry reads.

public bool RetryReads { get; set; }

Property Value

bool

RetryWrites

Gets or sets whether to retry writes.

public bool RetryWrites { get; set; }

Property Value

bool

The default value is true.

Scheme

Gets or sets the connection string scheme.

public ConnectionStringScheme Scheme { get; set; }

Property Value

ConnectionStringScheme

SdamLogFilename

Gets or set the name of the SDAM log file. Null turns logging off. stdout will log to console.

[Obsolete("Use MongoClientSettings.LoggerFactory instead.")]
public string SdamLogFilename { get; set; }

Property Value

string

Server

Gets or sets the address of the server (see also Servers if using more than one address).

public MongoServerAddress Server { get; set; }

Property Value

MongoServerAddress

ServerSelectionTimeout

Gets or sets the server selection timeout.

public TimeSpan ServerSelectionTimeout { get; set; }

Property Value

TimeSpan

Exceptions

InvalidOperationException

MongoServerSettings is frozen.

Servers

Gets or sets the list of server addresses (see also Server if using only one address).

public IEnumerable<MongoServerAddress> Servers { get; set; }

Property Value

IEnumerable<MongoServerAddress>

SocketTimeout

Gets or sets the socket timeout.

public TimeSpan SocketTimeout { get; set; }

Property Value

TimeSpan

SslSettings

Gets or sets the SSL settings.

public SslSettings SslSettings { get; set; }

Property Value

SslSettings

UseSsl

Gets or sets a value indicating whether to use SSL.

[Obsolete("Use UseTls instead.")]
public bool UseSsl { get; set; }

Property Value

bool

UseTls

Gets or sets a value indicating whether to use TLS.

public bool UseTls { get; set; }

Property Value

bool

VerifySslCertificate

Gets or sets a value indicating whether to verify an SSL certificate.

[Obsolete("Use AllowInsecureTls instead.")]
public bool VerifySslCertificate { get; set; }

Property Value

bool

WaitQueueSize

Gets or sets the wait queue size.

[Obsolete("This property will be removed in a later release.")]
public int WaitQueueSize { get; set; }

Property Value

int

WaitQueueTimeout

Gets or sets the wait queue timeout.

public TimeSpan WaitQueueTimeout { get; set; }

Property Value

TimeSpan

WriteConcern

Gets or sets the WriteConcern to use.

public WriteConcern WriteConcern { get; set; }

Property Value

WriteConcern

WriteEncoding

Gets or sets the Write Encoding.

public UTF8Encoding WriteEncoding { get; set; }

Property Value

UTF8Encoding

Methods

Clone()

Creates a clone of the settings.

public MongoServerSettings Clone()

Returns

MongoServerSettings

A clone of the settings.

Equals(MongoServerSettings)

Determines whether the specified MongoServerSettings is equal to this instance.

public bool Equals(MongoServerSettings obj)

Parameters

obj MongoServerSettings

The MongoServerSettings to compare with this instance.

Returns

bool

true if the specified MongoServerSettings is equal to this instance; otherwise, false.

Equals(object)

Determines whether the specified object is equal to this instance.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with this instance.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

Freeze()

Freezes the settings.

public MongoServerSettings Freeze()

Returns

MongoServerSettings

The frozen settings.

FromClientSettings(MongoClientSettings)

Creates a new MongoServerSettings object from a MongoClientSettings object.

public static MongoServerSettings FromClientSettings(MongoClientSettings clientSettings)

Parameters

clientSettings MongoClientSettings

The MongoClientSettings.

Returns

MongoServerSettings

A MongoServerSettings.

FromUrl(MongoUrl)

Gets a MongoServerSettings object intialized with values from a MongoUrl.

public static MongoServerSettings FromUrl(MongoUrl url)

Parameters

url MongoUrl

The MongoUrl.

Returns

MongoServerSettings

A MongoServerSettings.

FrozenCopy()

Returns a frozen copy of the settings.

public MongoServerSettings FrozenCopy()

Returns

MongoServerSettings

A frozen copy of the settings.

GetHashCode()

Gets the hash code.

public override int GetHashCode()

Returns

int

The hash code.

ToString()

Returns a string representation of the settings.

public override string ToString()

Returns

string

A string representation of the settings.

Operators

operator ==(MongoServerSettings, MongoServerSettings)

Determines whether two MongoServerSettings instances are equal.

public static bool operator ==(MongoServerSettings lhs, MongoServerSettings rhs)

Parameters

lhs MongoServerSettings

The LHS.

rhs MongoServerSettings

The RHS.

Returns

bool

true if the left hand side is equal to the right hand side; otherwise, false.

operator !=(MongoServerSettings, MongoServerSettings)

Determines whether two MongoServerSettings instances are not equal.

public static bool operator !=(MongoServerSettings lhs, MongoServerSettings rhs)

Parameters

lhs MongoServerSettings

The LHS.

rhs MongoServerSettings

The RHS.

Returns

bool

true if the left hand side is not equal to the right hand side; otherwise, false.