Represents a credentials store that contains credentials for different databases.
コード例 #1
0
        /// <summary>
        /// Compares this credentials store to another credentials store.
        /// </summary>
        /// <param name="rhs">The other credentials store.</param>
        /// <returns>True if the two credentials stores are equal.</returns>
        public bool Equals(MongoCredentialsStore rhs)
        {
            if (object.ReferenceEquals(rhs, null) || GetType() != rhs.GetType()) {
                return false;
            }

            if (_credentialsStore.Count != rhs._credentialsStore.Count)
            {
                return false;
            }

            foreach (var key in _credentialsStore.Keys)
            {
                if (!rhs._credentialsStore.ContainsKey(key))
                {
                    return false;
                }
                if (!_credentialsStore[key].Equals(rhs._credentialsStore[key]))
                {
                    return false;
                }
            }

            return true;
        }
コード例 #2
0
        // constructors
        /// <summary>
        /// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
        /// </summary>
        public MongoServerSettings()
        {
            _connectionMode = ConnectionMode.Automatic;
            _connectTimeout = MongoDefaults.ConnectTimeout;
            _credentialsStore = new MongoCredentialsStore();
            _defaultCredentials = null;
            _guidRepresentation = MongoDefaults.GuidRepresentation;
            _ipv6 = false;
            _maxConnectionIdleTime = MongoDefaults.MaxConnectionIdleTime;
            _maxConnectionLifeTime = MongoDefaults.MaxConnectionLifeTime;
            _maxConnectionPoolSize = MongoDefaults.MaxConnectionPoolSize;
            _minConnectionPoolSize = MongoDefaults.MinConnectionPoolSize;
            _readPreference = ReadPreference.Primary;
            _replicaSetName = null;
            _secondaryAcceptableLatency = MongoDefaults.SecondaryAcceptableLatency;
            _servers = new List<MongoServerAddress> { new MongoServerAddress("localhost") };
            _socketTimeout = MongoDefaults.SocketTimeout;
            _useSsl = false;
            _verifySslCertificate = true;
            _waitQueueSize = MongoDefaults.ComputedWaitQueueSize;
            _waitQueueTimeout = MongoDefaults.WaitQueueTimeout;
#pragma warning disable 612, 618
            _writeConcern = MongoDefaults.SafeMode.WriteConcern;
#pragma warning restore
        }
コード例 #3
0
        // constructors
        /// <summary>
        /// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
        /// </summary>
        public MongoServerSettings()
        {
            _connectionMode     = ConnectionMode.Automatic;
            _connectTimeout     = MongoDefaults.ConnectTimeout;
            _credentialsStore   = new MongoCredentialsStore();
            _defaultCredentials = null;
            _guidRepresentation = MongoDefaults.GuidRepresentation;
            _ipv6 = false;
            _maxConnectionIdleTime      = MongoDefaults.MaxConnectionIdleTime;
            _maxConnectionLifeTime      = MongoDefaults.MaxConnectionLifeTime;
            _maxConnectionPoolSize      = MongoDefaults.MaxConnectionPoolSize;
            _minConnectionPoolSize      = MongoDefaults.MinConnectionPoolSize;
            _readPreference             = ReadPreference.Primary;
            _replicaSetName             = null;
            _secondaryAcceptableLatency = MongoDefaults.SecondaryAcceptableLatency;
            _servers = new List <MongoServerAddress> {
                new MongoServerAddress("localhost")
            };
            _socketTimeout        = MongoDefaults.SocketTimeout;
            _useSsl               = false;
            _verifySslCertificate = true;
            _waitQueueSize        = MongoDefaults.ComputedWaitQueueSize;
            _waitQueueTimeout     = MongoDefaults.WaitQueueTimeout;
#pragma warning disable 612, 618
            _writeConcern = MongoDefaults.SafeMode.WriteConcern;
#pragma warning restore
        }
コード例 #4
0
 // constructors
 /// <summary>
 /// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
 /// </summary>
 public MongoServerSettings()
 {
     _connectionMode     = ConnectionMode.Direct;
     _connectTimeout     = MongoDefaults.ConnectTimeout;
     _credentialsStore   = new MongoCredentialsStore();
     _defaultCredentials = null;
     _guidRepresentation = MongoDefaults.GuidRepresentation;
     _ipv6 = false;
     _maxConnectionIdleTime = MongoDefaults.MaxConnectionIdleTime;
     _maxConnectionLifeTime = MongoDefaults.MaxConnectionLifeTime;
     _maxConnectionPoolSize = MongoDefaults.MaxConnectionPoolSize;
     _minConnectionPoolSize = MongoDefaults.MinConnectionPoolSize;
     _readPreference        = ReadPreference.Primary;
     _replicaSetName        = null;
     _safeMode = MongoDefaults.SafeMode;
     _servers  = new List <MongoServerAddress> {
         new MongoServerAddress("localhost")
     };
     _serversReadOnly      = new ReadOnlyCollection <MongoServerAddress>(_servers);
     _socketTimeout        = MongoDefaults.SocketTimeout;
     _useSsl               = false;
     _verifySslCertificate = true;
     _waitQueueSize        = MongoDefaults.ComputedWaitQueueSize;
     _waitQueueTimeout     = MongoDefaults.WaitQueueTimeout;
 }
コード例 #5
0
        /// <summary>
        /// Compares this credentials store to another credentials store.
        /// </summary>
        /// <param name="rhs">The other credentials store.</param>
        /// <returns>True if the two credentials stores are equal.</returns>
        public bool Equals(MongoCredentialsStore rhs)
        {
            if (object.ReferenceEquals(rhs, null) || GetType() != rhs.GetType())
            {
                return(false);
            }

            if (_credentialsStore.Count != rhs._credentialsStore.Count)
            {
                return(false);
            }

            foreach (var key in _credentialsStore.Keys)
            {
                if (!rhs._credentialsStore.ContainsKey(key))
                {
                    return(false);
                }
                if (!_credentialsStore[key].Equals(rhs._credentialsStore[key]))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #6
0
        /// <summary>
        /// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
        /// </summary>
        /// <param name="connectionMode">The connection mode (Direct or ReplicaSet).</param>
        /// <param name="connectTimeout">The connect timeout.</param>
        /// <param name="credentialsStore">The credentials store.</param>
        /// <param name="defaultCredentials">The default credentials.</param>
        /// <param name="guidRepresentation">The representation for Guids.</param>
        /// <param name="ipv6">Whether to use IPv6.</param>
        /// <param name="maxConnectionIdleTime">The max connection idle time.</param>
        /// <param name="maxConnectionLifeTime">The max connection life time.</param>
        /// <param name="maxConnectionPoolSize">The max connection pool size.</param>
        /// <param name="minConnectionPoolSize">The min connection pool size.</param>
        /// <param name="readPreference">The default read preference.</param>
        /// <param name="replicaSetName">The name of the replica set.</param>
        /// <param name="safeMode">The safe mode.</param>
        /// <param name="secondaryAcceptableLatency">The secondary acceptable latency.</param>
        /// <param name="servers">The server addresses (normally one unless it is the seed list for connecting to a replica set).</param>
        /// <param name="socketTimeout">The socket timeout.</param>
        /// <param name="useSsl">Whether to use SSL.</param>
        /// <param name="verifySslCertificate">Whether to verify an SSL certificate.</param>
        /// <param name="waitQueueSize">The wait queue size.</param>
        /// <param name="waitQueueTimeout">The wait queue timeout.</param>
        /// <exception cref="System.ArgumentNullException"></exception>
        public MongoServerSettings(
            ConnectionMode connectionMode,
            TimeSpan connectTimeout,
            MongoCredentialsStore credentialsStore,
            MongoCredentials defaultCredentials,
            GuidRepresentation guidRepresentation,
            bool ipv6,
            TimeSpan maxConnectionIdleTime,
            TimeSpan maxConnectionLifeTime,
            int maxConnectionPoolSize,
            int minConnectionPoolSize,
            ReadPreference readPreference,
            string replicaSetName,
            SafeMode safeMode,
            TimeSpan secondaryAcceptableLatency,
            IEnumerable<MongoServerAddress> servers,
            TimeSpan socketTimeout,
            bool useSsl,
            bool verifySslCertificate,
            int waitQueueSize,
            TimeSpan waitQueueTimeout)
        {
            if (servers == null)
            {
                throw new ArgumentNullException("servers");
            }
            if (readPreference == null)
            {
                throw new ArgumentNullException("readPreference");
            }
            if (safeMode == null)
            {
                throw new ArgumentNullException("safeMode");
            }

            _connectionMode = connectionMode;
            _connectTimeout = connectTimeout;
            _credentialsStore = credentialsStore ?? new MongoCredentialsStore();
            _defaultCredentials = defaultCredentials;
            _guidRepresentation = guidRepresentation;
            _ipv6 = ipv6;
            _maxConnectionIdleTime = maxConnectionIdleTime;
            _maxConnectionLifeTime = maxConnectionLifeTime;
            _maxConnectionPoolSize = maxConnectionPoolSize;
            _minConnectionPoolSize = minConnectionPoolSize;
            _readPreference = readPreference;
            _replicaSetName = replicaSetName;
            _safeMode = safeMode;
            _secondaryAcceptableLatency = secondaryAcceptableLatency;
            _servers = new List<MongoServerAddress>(servers);
            _serversReadOnly = new ReadOnlyCollection<MongoServerAddress>(_servers);
            _socketTimeout = socketTimeout;
            _useSsl = useSsl;
            _verifySslCertificate = verifySslCertificate;
            _waitQueueSize = waitQueueSize;
            _waitQueueTimeout = waitQueueTimeout;
        }
コード例 #7
0
 /// <summary>
 /// Creates a clone of the credentials store.
 /// </summary>
 /// <returns>A clone of the credentials store.</returns>
 public MongoCredentialsStore Clone()
 {
     var clone = new MongoCredentialsStore();
     foreach (var item in _credentialsStore)
     {
         clone.AddCredentials(item.Key, item.Value);
     }
     return clone;
 }
コード例 #8
0
        /// <summary>
        /// Creates a clone of the credentials store.
        /// </summary>
        /// <returns>A clone of the credentials store.</returns>
        public MongoCredentialsStore Clone()
        {
            var clone = new MongoCredentialsStore();

            foreach (var item in _credentialsStore)
            {
                clone.AddCredentials(item.Key, item.Value);
            }
            return(clone);
        }
コード例 #9
0
        public void TestCredentialsStore()
        {
            var settings = new MongoClientSettings();
            Assert.AreEqual("{}", settings.CredentialsStore.ToString());

            var credentialsStore = new MongoCredentialsStore();
            settings.CredentialsStore = credentialsStore;
            Assert.AreSame(credentialsStore, settings.CredentialsStore);
            Assert.IsFalse(settings.CredentialsStore.IsFrozen);

            settings.Freeze();
            Assert.AreSame(credentialsStore, settings.CredentialsStore);
            Assert.IsTrue(settings.CredentialsStore.IsFrozen);
            Assert.Throws<InvalidOperationException>(() => { settings.CredentialsStore = credentialsStore; });
        }
コード例 #10
0
 // constructors
 /// <summary>
 /// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
 /// </summary>
 public MongoServerSettings()
 {
     _connectionMode = ConnectionMode.Direct;
     _connectTimeout = MongoDefaults.ConnectTimeout;
     _credentialsStore = new MongoCredentialsStore();
     _defaultCredentials = null;
     _guidRepresentation = MongoDefaults.GuidRepresentation;
     _ipv6 = false;
     _maxConnectionIdleTime = MongoDefaults.MaxConnectionIdleTime;
     _maxConnectionLifeTime = MongoDefaults.MaxConnectionLifeTime;
     _maxConnectionPoolSize = MongoDefaults.MaxConnectionPoolSize;
     _minConnectionPoolSize = MongoDefaults.MinConnectionPoolSize;
     _replicaSetName = null;
     _safeMode = MongoDefaults.SafeMode;
     _servers = null;
     _slaveOk = false;
     _socketTimeout = MongoDefaults.SocketTimeout;
     _waitQueueSize = MongoDefaults.ComputedWaitQueueSize;
     _waitQueueTimeout = MongoDefaults.WaitQueueTimeout;
 }
コード例 #11
0
 // constructors
 /// <summary>
 /// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
 /// </summary>
 public MongoServerSettings()
 {
     _connectionMode     = ConnectionMode.Direct;
     _connectTimeout     = MongoDefaults.ConnectTimeout;
     _credentialsStore   = new MongoCredentialsStore();
     _defaultCredentials = null;
     _guidRepresentation = MongoDefaults.GuidRepresentation;
     _ipv6 = false;
     _maxConnectionIdleTime = MongoDefaults.MaxConnectionIdleTime;
     _maxConnectionLifeTime = MongoDefaults.MaxConnectionLifeTime;
     _maxConnectionPoolSize = MongoDefaults.MaxConnectionPoolSize;
     _minConnectionPoolSize = MongoDefaults.MinConnectionPoolSize;
     _replicaSetName        = null;
     _safeMode         = MongoDefaults.SafeMode;
     _servers          = null;
     _slaveOk          = false;
     _socketTimeout    = MongoDefaults.SocketTimeout;
     _waitQueueSize    = MongoDefaults.ComputedWaitQueueSize;
     _waitQueueTimeout = MongoDefaults.WaitQueueTimeout;
 }
コード例 #12
0
 // constructors
 /// <summary>
 /// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
 /// </summary>
 public MongoServerSettings()
 {
     _connectionMode = ConnectionMode.Direct;
     _connectTimeout = MongoDefaults.ConnectTimeout;
     _credentialsStore = new MongoCredentialsStore();
     _defaultCredentials = null;
     _guidRepresentation = MongoDefaults.GuidRepresentation;
     _ipv6 = false;
     _maxConnectionIdleTime = MongoDefaults.MaxConnectionIdleTime;
     _maxConnectionLifeTime = MongoDefaults.MaxConnectionLifeTime;
     _maxConnectionPoolSize = MongoDefaults.MaxConnectionPoolSize;
     _minConnectionPoolSize = MongoDefaults.MinConnectionPoolSize;
     _readPreference = ReadPreference.Primary;
     _replicaSetName = null;
     _safeMode = MongoDefaults.SafeMode;
     _servers = new List<MongoServerAddress> { new MongoServerAddress("localhost") };
     _serversReadOnly = new ReadOnlyCollection<MongoServerAddress>(_servers);
     _socketTimeout = MongoDefaults.SocketTimeout;
     _waitQueueSize = MongoDefaults.ComputedWaitQueueSize;
     _waitQueueTimeout = MongoDefaults.WaitQueueTimeout;
 }
コード例 #13
0
 /// <summary>
 /// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
 /// </summary>
 /// <param name="connectionMode">The connection mode (Direct or ReplicaSet).</param>
 /// <param name="connectTimeout">The connect timeout.</param>
 /// <param name="credentialsStore">The credentials store.</param>
 /// <param name="defaultCredentials">The default credentials.</param>
 /// <param name="guidRepresentation">The representation for Guids.</param>
 /// <param name="ipv6">Whether to use IPv6.</param>
 /// <param name="maxConnectionIdleTime">The max connection idle time.</param>
 /// <param name="maxConnectionLifeTime">The max connection life time.</param>
 /// <param name="maxConnectionPoolSize">The max connection pool size.</param>
 /// <param name="minConnectionPoolSize">The min connection pool size.</param>
 /// <param name="replicaSetName">The name of the replica set.</param>
 /// <param name="safeMode">The safe mode.</param>
 /// <param name="servers">The server addresses (normally one unless it is the seed list for connecting to a replica set).</param>
 /// <param name="slaveOk">Whether queries should be sent to secondary servers.</param>
 /// <param name="socketTimeout">The socket timeout.</param>
 /// <param name="waitQueueSize">The wait queue size.</param>
 /// <param name="waitQueueTimeout">The wait queue timeout.</param>
 public MongoServerSettings(
     ConnectionMode connectionMode,
     TimeSpan connectTimeout,
     MongoCredentialsStore credentialsStore,
     MongoCredentials defaultCredentials,
     GuidRepresentation guidRepresentation,
     bool ipv6,
     TimeSpan maxConnectionIdleTime,
     TimeSpan maxConnectionLifeTime,
     int maxConnectionPoolSize,
     int minConnectionPoolSize,
     string replicaSetName,
     SafeMode safeMode,
     IEnumerable <MongoServerAddress> servers,
     bool slaveOk,
     TimeSpan socketTimeout,
     int waitQueueSize,
     TimeSpan waitQueueTimeout)
 {
     _connectionMode     = connectionMode;
     _connectTimeout     = connectTimeout;
     _credentialsStore   = credentialsStore ?? new MongoCredentialsStore();
     _defaultCredentials = defaultCredentials;
     _guidRepresentation = guidRepresentation;
     _ipv6 = ipv6;
     _maxConnectionIdleTime = maxConnectionIdleTime;
     _maxConnectionLifeTime = maxConnectionLifeTime;
     _maxConnectionPoolSize = maxConnectionPoolSize;
     _minConnectionPoolSize = minConnectionPoolSize;
     _replicaSetName        = replicaSetName;
     _safeMode         = safeMode;
     _servers          = servers;
     _slaveOk          = slaveOk;
     _socketTimeout    = socketTimeout;
     _waitQueueSize    = waitQueueSize;
     _waitQueueTimeout = waitQueueTimeout;
 }
コード例 #14
0
        public MongoServerSettings(
            ConnectionMode connectionMode,
            TimeSpan connectTimeout,
            MongoCredentialsStore credentialsStore,
            MongoCredentials defaultCredentials,
            GuidRepresentation guidRepresentation,
            bool ipv6,
            TimeSpan maxConnectionIdleTime,
            TimeSpan maxConnectionLifeTime,
            int maxConnectionPoolSize,
            int minConnectionPoolSize,
            ReadPreference readPreference,
            string replicaSetName,
            SafeMode safeMode,
            TimeSpan secondaryAcceptableLatency,
            IEnumerable<MongoServerAddress> servers,
            TimeSpan socketTimeout,
            bool useSsl,
            bool verifySslCertificate,
            int waitQueueSize,
            TimeSpan waitQueueTimeout)
        {
            if (servers == null)
            {
                throw new ArgumentNullException("servers");
            }
            if (readPreference == null)
            {
                throw new ArgumentNullException("readPreference");
            }
            if (safeMode == null)
            {
                throw new ArgumentNullException("safeMode");
            }

            _connectionMode = connectionMode;
            _connectTimeout = connectTimeout;
            _credentialsStore = credentialsStore ?? new MongoCredentialsStore();
            _defaultCredentials = defaultCredentials;
            _guidRepresentation = guidRepresentation;
            _ipv6 = ipv6;
            _maxConnectionIdleTime = maxConnectionIdleTime;
            _maxConnectionLifeTime = maxConnectionLifeTime;
            _maxConnectionPoolSize = maxConnectionPoolSize;
            _minConnectionPoolSize = minConnectionPoolSize;
            _readPreference = readPreference;
            _replicaSetName = replicaSetName;
            _secondaryAcceptableLatency = secondaryAcceptableLatency;
            _servers = new List<MongoServerAddress>(servers);
            _socketTimeout = socketTimeout;
            _useSsl = useSsl;
            _verifySslCertificate = verifySslCertificate;
            _waitQueueSize = waitQueueSize;
            _waitQueueTimeout = waitQueueTimeout;
            _writeConcern = safeMode;
        }
コード例 #15
0
 /// <summary>
 /// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
 /// </summary>
 /// <param name="connectionMode">The connection mode (Direct or ReplicaSet).</param>
 /// <param name="connectTimeout">The connect timeout.</param>
 /// <param name="credentialsStore">The credentials store.</param>
 /// <param name="defaultCredentials">The default credentials.</param>
 /// <param name="guidRepresentation">The representation for Guids.</param>
 /// <param name="ipv6">Whether to use IPv6.</param>
 /// <param name="maxConnectionIdleTime">The max connection idle time.</param>
 /// <param name="maxConnectionLifeTime">The max connection life time.</param>
 /// <param name="maxConnectionPoolSize">The max connection pool size.</param>
 /// <param name="minConnectionPoolSize">The min connection pool size.</param>
 /// <param name="replicaSetName">The name of the replica set.</param>
 /// <param name="safeMode">The safe mode.</param>
 /// <param name="servers">The server addresses (normally one unless it is the seed list for connecting to a replica set).</param>
 /// <param name="slaveOk">Whether queries should be sent to secondary servers.</param>
 /// <param name="socketTimeout">The socket timeout.</param>
 /// <param name="waitQueueSize">The wait queue size.</param>
 /// <param name="waitQueueTimeout">The wait queue timeout.</param>
 public MongoServerSettings(
     ConnectionMode connectionMode,
     TimeSpan connectTimeout,
     MongoCredentialsStore credentialsStore,
     MongoCredentials defaultCredentials,
     GuidRepresentation guidRepresentation,
     bool ipv6,
     TimeSpan maxConnectionIdleTime,
     TimeSpan maxConnectionLifeTime,
     int maxConnectionPoolSize,
     int minConnectionPoolSize,
     string replicaSetName,
     SafeMode safeMode,
     IEnumerable<MongoServerAddress> servers,
     bool slaveOk,
     TimeSpan socketTimeout,
     int waitQueueSize,
     TimeSpan waitQueueTimeout)
 {
     _connectionMode = connectionMode;
     _connectTimeout = connectTimeout;
     _credentialsStore = credentialsStore ?? new MongoCredentialsStore();
     _defaultCredentials = defaultCredentials;
     _guidRepresentation = guidRepresentation;
     _ipv6 = ipv6;
     _maxConnectionIdleTime = maxConnectionIdleTime;
     _maxConnectionLifeTime = maxConnectionLifeTime;
     _maxConnectionPoolSize = maxConnectionPoolSize;
     _minConnectionPoolSize = minConnectionPoolSize;
     _replicaSetName = replicaSetName;
     _safeMode = safeMode;
     _servers = servers;
     _slaveOk = slaveOk;
     _socketTimeout = socketTimeout;
     _waitQueueSize = waitQueueSize;
     _waitQueueTimeout = waitQueueTimeout;
 }
コード例 #16
0
        public void TestGetCredentials()
        {
            var settings = new MongoServerSettings();
            var credentialsStore = new MongoCredentialsStore();
            credentialsStore.AddCredentials("db1", new MongoCredentials("user1", "password1"));
            credentialsStore.AddCredentials("db2", new MongoCredentials("user2", "password2"));
            settings.CredentialsStore = credentialsStore;

            Assert.AreEqual(new MongoCredentials("user1", "password1"), settings.GetCredentials("db1"));
            Assert.AreEqual(new MongoCredentials("user2", "password2"), settings.GetCredentials("db2"));
            Assert.AreEqual(null, settings.GetCredentials("db3"));
            Assert.AreEqual(null, settings.GetCredentials("admin"));

            var defaultCredentials = new MongoCredentials("defaultuser", "defaultpassword");
            settings.DefaultCredentials = defaultCredentials;
            Assert.AreEqual(defaultCredentials, settings.GetCredentials("db3"));
            Assert.AreEqual(null, settings.GetCredentials("admin")); // default credentials aren't admin credentials

            defaultCredentials = new MongoCredentials("defaultuser", "defaultpassword", true);
            settings.DefaultCredentials = defaultCredentials;
            Assert.AreEqual(defaultCredentials, settings.GetCredentials("db3"));
            Assert.AreEqual(defaultCredentials, settings.GetCredentials("admin")); // default credentials are admin credentials
        }
コード例 #17
0
        /// <summary>
        /// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
        /// </summary>
        /// <param name="connectionMode">The connection mode (Direct or ReplicaSet).</param>
        /// <param name="connectTimeout">The connect timeout.</param>
        /// <param name="credentialsStore">The credentials store.</param>
        /// <param name="defaultCredentials">The default credentials.</param>
        /// <param name="guidRepresentation">The representation for Guids.</param>
        /// <param name="ipv6">Whether to use IPv6.</param>
        /// <param name="maxConnectionIdleTime">The max connection idle time.</param>
        /// <param name="maxConnectionLifeTime">The max connection life time.</param>
        /// <param name="maxConnectionPoolSize">The max connection pool size.</param>
        /// <param name="minConnectionPoolSize">The min connection pool size.</param>
        /// <param name="readPreference">The default read preference.</param>
        /// <param name="replicaSetName">The name of the replica set.</param>
        /// <param name="safeMode">The safe mode.</param>
        /// <param name="servers">The server addresses (normally one unless it is the seed list for connecting to a replica set).</param>
        /// <param name="socketTimeout">The socket timeout.</param>
        /// <param name="waitQueueSize">The wait queue size.</param>
        /// <param name="waitQueueTimeout">The wait queue timeout.</param>
        public MongoServerSettings(
            ConnectionMode connectionMode,
            TimeSpan connectTimeout,
            MongoCredentialsStore credentialsStore,
            MongoCredentials defaultCredentials,
            GuidRepresentation guidRepresentation,
            bool ipv6,
            TimeSpan maxConnectionIdleTime,
            TimeSpan maxConnectionLifeTime,
            int maxConnectionPoolSize,
            int minConnectionPoolSize,
            ReadPreference readPreference,
            string replicaSetName,
            SafeMode safeMode,
            IEnumerable<MongoServerAddress> servers,
            TimeSpan socketTimeout,
            int waitQueueSize,
            TimeSpan waitQueueTimeout)
        {
            if (servers == null)
            {
                throw new ArgumentNullException("servers");
            }
            if (readPreference == null)
            {
                throw new ArgumentNullException("readPreference");
            }
            if (safeMode == null)
            {
                throw new ArgumentNullException("safeMode");
            }

            _connectionMode = connectionMode;
            _connectTimeout = connectTimeout;
            _credentialsStore = credentialsStore ?? new MongoCredentialsStore();
            _defaultCredentials = defaultCredentials;
            _guidRepresentation = guidRepresentation;
            _ipv6 = ipv6;
            _maxConnectionIdleTime = maxConnectionIdleTime;
            _maxConnectionLifeTime = maxConnectionLifeTime;
            _maxConnectionPoolSize = maxConnectionPoolSize;
            _minConnectionPoolSize = minConnectionPoolSize;
            _readPreference = readPreference;
            _replicaSetName = replicaSetName;
            _safeMode = safeMode;
            _servers = new List<MongoServerAddress>(servers);
            _serversReadOnly = new ReadOnlyCollection<MongoServerAddress>(_servers);
            _socketTimeout = socketTimeout;
            _waitQueueSize = waitQueueSize;
            _waitQueueTimeout = waitQueueTimeout;
        }