Class MongoUrl
Represents an immutable URL style connection string. See also MongoUrlBuilder.
[Serializable]
[TypeConverter(typeof(MongoUrlTypeConverter))]
public class MongoUrl : IEquatable<MongoUrl>
- Inheritance
-
MongoUrl
- Implements
- Inherited Members
Constructors
MongoUrl(string)
Creates a new instance of MongoUrl.
public MongoUrl(string url)
Parameters
url
stringThe URL containing the settings.
Properties
AllowInsecureTls
Gets whether to relax TLS constraints as much as possible.
public bool AllowInsecureTls { get; }
Property Value
ApplicationName
Gets the application name.
public string ApplicationName { get; }
Property Value
AuthenticationMechanism
Gets the authentication mechanism.
public string AuthenticationMechanism { get; }
Property Value
AuthenticationMechanismProperties
Gets the authentication mechanism properties.
public IEnumerable<KeyValuePair<string, string>> AuthenticationMechanismProperties { get; }
Property Value
AuthenticationSource
Gets the authentication source.
public string AuthenticationSource { get; }
Property Value
Compressors
Gets the compressors.
public IReadOnlyList<CompressorConfiguration> Compressors { get; }
Property Value
ComputedWaitQueueSize
Gets the actual wait queue size (either WaitQueueSize or WaitQueueMultiple x MaxConnectionPoolSize).
[Obsolete("This property will be removed in a later release.")]
public int ComputedWaitQueueSize { get; }
Property Value
ConnectTimeout
Gets the connect timeout.
public TimeSpan ConnectTimeout { get; }
Property Value
ConnectionMode
Gets the connection mode.
[Obsolete("Use DirectConnection instead.")]
public ConnectionMode ConnectionMode { get; }
Property Value
ConnectionModeSwitch
Gets the connection mode switch.
[Obsolete("This property will be removed in a later release.")]
public ConnectionModeSwitch ConnectionModeSwitch { get; }
Property Value
DatabaseName
Gets the optional database name.
public string DatabaseName { get; }
Property Value
DirectConnection
Gets the direct connection.
public bool? DirectConnection { get; }
Property Value
- bool?
FSync
Gets the FSync component of the write concern.
public bool? FSync { get; }
Property Value
- bool?
GuidRepresentation
Gets the representation to use for Guids.
[Obsolete("Configure serializers instead.")]
public GuidRepresentation GuidRepresentation { get; }
Property Value
HasAuthenticationSettings
Gets a value indicating whether this instance has authentication settings.
public bool HasAuthenticationSettings { get; }
Property Value
HeartbeatInterval
Gets the heartbeat interval.
public TimeSpan HeartbeatInterval { get; }
Property Value
HeartbeatTimeout
Gets the heartbeat timeout.
public TimeSpan HeartbeatTimeout { get; }
Property Value
IPv6
Gets a value indicating whether to use IPv6.
public bool IPv6 { get; }
Property Value
IsResolved
Gets a value indicating whether a connection string with scheme MongoDBPlusSrv has been resolved.
public bool IsResolved { get; }
Property Value
Journal
Gets the Journal component of the write concern.
public bool? Journal { get; }
Property Value
- bool?
LoadBalanced
Gets or sets whether load balanced mode is used.
public bool LoadBalanced { get; }
Property Value
LocalThreshold
Gets the local threshold.
public TimeSpan LocalThreshold { get; }
Property Value
MaxConnecting
Gets the maximum concurrently connecting connections.
public int MaxConnecting { get; }
Property Value
MaxConnectionIdleTime
Gets the max connection idle time.
public TimeSpan MaxConnectionIdleTime { get; }
Property Value
MaxConnectionLifeTime
Gets the max connection life time.
public TimeSpan MaxConnectionLifeTime { get; }
Property Value
MaxConnectionPoolSize
Gets the max connection pool size.
public int MaxConnectionPoolSize { get; }
Property Value
MinConnectionPoolSize
Gets the min connection pool size.
public int MinConnectionPoolSize { get; }
Property Value
Password
Gets the password.
public string Password { get; }
Property Value
ReadConcernLevel
Gets the read concern level.
public ReadConcernLevel? ReadConcernLevel { get; }
Property Value
ReadPreference
Gets the read preference.
public ReadPreference ReadPreference { get; }
Property Value
ReplicaSetName
Gets the name of the replica set.
public string ReplicaSetName { get; }
Property Value
RetryReads
Gets whether reads will be retried.
public bool? RetryReads { get; }
Property Value
- bool?
RetryWrites
Gets whether writes will be retried.
public bool? RetryWrites { get; }
Property Value
- bool?
Scheme
Gets the connection string scheme.
public ConnectionStringScheme Scheme { get; }
Property Value
Server
Gets the address of the server (see also Servers if using more than one address).
public MongoServerAddress Server { get; }
Property Value
ServerSelectionTimeout
Gets the server selection timeout.
public TimeSpan ServerSelectionTimeout { get; }
Property Value
Servers
Gets the list of server addresses (see also Server if using only one address).
public IEnumerable<MongoServerAddress> Servers { get; }
Property Value
SocketTimeout
Gets the socket timeout.
public TimeSpan SocketTimeout { get; }
Property Value
SrvMaxHosts
Limits the number of SRV records used to populate the seedlist during initial discovery, as well as the number of additional hosts that may be added during SRV polling.
public int? SrvMaxHosts { get; }
Property Value
- int?
TlsDisableCertificateRevocationCheck
Gets whether or not to disable checking certificate revocation status during the TLS handshake.
public bool TlsDisableCertificateRevocationCheck { get; }
Property Value
Url
Gets the URL (in canonical form).
public string Url { get; }
Property Value
UseSsl
Gets a value indicating whether to use SSL.
[Obsolete("Use UseTls instead.")]
public bool UseSsl { get; }
Property Value
UseTls
Gets a value indicating whether to use TLS.
public bool UseTls { get; }
Property Value
Username
Gets the username.
public string Username { get; }
Property Value
VerifySslCertificate
Gets a value indicating whether to verify an SSL certificate.
[Obsolete("Use AllowInsecureTls instead.")]
public bool VerifySslCertificate { get; }
Property Value
W
Gets the W component of the write concern.
public WriteConcern.WValue W { get; }
Property Value
WTimeout
Gets the WTimeout component of the write concern.
public TimeSpan? WTimeout { get; }
Property Value
WaitQueueMultiple
Gets the wait queue multiple (the actual wait queue size will be WaitQueueMultiple x MaxConnectionPoolSize).
[Obsolete("This property will be removed in a later release.")]
public double WaitQueueMultiple { get; }
Property Value
WaitQueueSize
Gets the wait queue size.
[Obsolete("This property will be removed in a later release.")]
public int WaitQueueSize { get; }
Property Value
WaitQueueTimeout
Gets the wait queue timeout.
public TimeSpan WaitQueueTimeout { get; }
Property Value
Methods
ClearCache()
Clears the URL cache. When a URL is parsed it is stored in the cache so that it doesn't have to be parsed again. There is rarely a need to call this method.
public static void ClearCache()
Create(string)
Creates an instance of MongoUrl (might be an existing existence if the same URL has been used before).
public static MongoUrl Create(string url)
Parameters
url
stringThe URL containing the settings.
Returns
- MongoUrl
An instance of MongoUrl.
Equals(MongoUrl)
Compares two MongoUrls.
public bool Equals(MongoUrl rhs)
Parameters
rhs
MongoUrlThe other URL.
Returns
- bool
True if the two URLs are equal.
Equals(object)
Compares two MongoUrls.
public override bool Equals(object obj)
Parameters
obj
objectThe other URL.
Returns
- bool
True if the two URLs are equal.
GetCredential()
Gets the credential.
public MongoCredential GetCredential()
Returns
- MongoCredential
The credential (or null if the URL has not authentication settings).
GetHashCode()
Gets the hash code.
public override int GetHashCode()
Returns
- int
The hash code.
GetWriteConcern(bool)
Returns a WriteConcern value based on this instance's settings and a default enabled value.
public WriteConcern GetWriteConcern(bool enabledDefault)
Parameters
enabledDefault
boolThe default enabled value.
Returns
- WriteConcern
A WriteConcern.
Resolve(bool, CancellationToken)
Resolves a connection string. If the connection string indicates more information is available in the DNS system, it will acquire that information as well.
public MongoUrl Resolve(bool resolveHosts, CancellationToken cancellationToken = default)
Parameters
resolveHosts
boolWhether to resolve hosts.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- MongoUrl
A resolved MongoURL.
Resolve(CancellationToken)
Resolves a connection string. If the connection string indicates more information is available in the DNS system, it will acquire that information as well.
public MongoUrl Resolve(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
- MongoUrl
A resolved MongoURL.
ResolveAsync(bool, CancellationToken)
Resolves a connection string. If the connection string indicates more information is available in the DNS system, it will acquire that information as well.
public Task<MongoUrl> ResolveAsync(bool resolveHosts, CancellationToken cancellationToken = default)
Parameters
resolveHosts
boolWhether to resolve hosts.
cancellationToken
CancellationTokenThe cancellation token.
Returns
ResolveAsync(CancellationToken)
Resolves a connection string. If the connection string indicates more information is available in the DNS system, it will acquire that information as well.
public Task<MongoUrl> ResolveAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
ToString()
Returns the canonical URL based on the settings in this MongoUrlBuilder.
public override string ToString()
Returns
- string
The canonical URL.
Operators
operator ==(MongoUrl, MongoUrl)
Compares two MongoUrls.
public static bool operator ==(MongoUrl lhs, MongoUrl rhs)
Parameters
Returns
- bool
True if the two URLs are equal (or both null).
operator !=(MongoUrl, MongoUrl)
Compares two MongoUrls.
public static bool operator !=(MongoUrl lhs, MongoUrl rhs)
Parameters
Returns
- bool
True if the two URLs are not equal (or one is null and the other is not).