The settings for a MongoDB client.
Beispiel #1
8
        MongoClientSettings GetSettings()
        {
            if (String.IsNullOrEmpty(MongoSettings.ConnectionString))
             {
                 throw new ArgumentNullException("Connection string not found.");
             }

             if (String.IsNullOrEmpty(MongoSettings.Database))
             {
                 throw new ArgumentNullException("Database string not found.");
             }

             var ips = MongoSettings.ConnectionString.Split(';');
             var servicesList = new List<MongoServerAddress>();

             foreach (var ip in ips)
             {
                 var host = ip.Split(':')[0];
                 var port = Convert.ToInt32(ip.Split(':')[1]);

                 servicesList.Add(new MongoServerAddress(host, port));
             }

             var setting = new MongoClientSettings();
             setting.ReplicaSetName = MongoSettings.ReplicaSetName;

             //集群中的服务器列表
             setting.Servers = servicesList;

             return setting;
        }
        public void GetOrCreateCluster_should_return_a_cluster_with_the_correct_settings()
        {
            var credentials = new[] { MongoCredential.CreateMongoCRCredential("source", "username", "password") };
            var servers = new[] { new MongoServerAddress("localhost"), new MongoServerAddress("127.0.0.1", 30000), new MongoServerAddress("[::1]", 27018) };

            var sslSettings = new SslSettings
            {
                CheckCertificateRevocation = true,
                EnabledSslProtocols = SslProtocols.Tls
            };

            var clientSettings = new MongoClientSettings
            {
                ApplicationName = "app1",
                ConnectionMode = ConnectionMode.ReplicaSet,
                ConnectTimeout = TimeSpan.FromSeconds(1),
                Credentials = credentials,
                GuidRepresentation = GuidRepresentation.Standard,
                HeartbeatInterval = TimeSpan.FromSeconds(7),
                HeartbeatTimeout = TimeSpan.FromSeconds(8),
                IPv6 = true,
                MaxConnectionIdleTime = TimeSpan.FromSeconds(2),
                MaxConnectionLifeTime = TimeSpan.FromSeconds(3),
                MaxConnectionPoolSize = 10,
                MinConnectionPoolSize = 5,
                ReplicaSetName = "rs",
                LocalThreshold = TimeSpan.FromMilliseconds(20),
                Servers = servers,
                ServerSelectionTimeout = TimeSpan.FromSeconds(5),
                SocketTimeout = TimeSpan.FromSeconds(4),
                SslSettings = sslSettings,
                UseSsl = true,
                VerifySslCertificate = true,
                WaitQueueSize = 20,
                WaitQueueTimeout = TimeSpan.FromSeconds(6)
            };

            var subject = new ClusterRegistry();

            using (var cluster = subject.GetOrCreateCluster(clientSettings.ToClusterKey()))
            {
                var endPoints = new EndPoint[]
                {
                    new DnsEndPoint("localhost", 27017),
                    new IPEndPoint(IPAddress.Parse("127.0.0.1"), 30000),
                    new IPEndPoint(IPAddress.Parse("[::1]"), 27018)
                };
                cluster.Settings.ConnectionMode.Should().Be(ClusterConnectionMode.ReplicaSet);
                cluster.Settings.EndPoints.Equals(endPoints);
                cluster.Settings.ReplicaSetName.Should().Be("rs");
                cluster.Settings.ServerSelectionTimeout.Should().Be(clientSettings.ServerSelectionTimeout);
                cluster.Settings.PostServerSelector.Should().NotBeNull().And.Subject.Should().BeOfType<LatencyLimitingServerSelector>();
                cluster.Settings.MaxServerSelectionWaitQueueSize.Should().Be(20);

                cluster.Description.Servers.Select(s => s.EndPoint).Should().Contain(endPoints);

                // TODO: don't know how to test the rest of the settings because they are all private to the cluster
            }
        }
		protected void parse_from_connection_string( string connection_string ) {
			var mongo_url = MongoUrl.Create( connection_string );
			
			ConnectionString = connection_string;
			DatabaseName = mongo_url.DatabaseName;
			
			MongoClientSettings = MongoClientSettings.FromUrl( mongo_url );
		}
		public IMongoDatabase GetDatabase(string user, string password, string db = defaultDB) {
            var credential = MongoCredential.CreateMongoCRCredential(db, user, password);
            var settings = new MongoClientSettings { Credentials = new[] { credential } };
            var mongoClient = new MongoClient(settings);

			return GetDatabase(mongoClient, db);
		}
Beispiel #5
0
        /// <summary>
        /// Dispose(bool disposing) executes in two distinct scenarios.
        /// If disposing equals true, the method has been called directly
        /// or indirectly by a user's code. Managed and unmanaged resources
        /// can be disposed.
        /// If disposing equals false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference
        /// other objects. Only unmanaged resources can be disposed.
        /// </summary>
        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this._disposed)
            {
                // Note disposing has been done.
                _disposed = true;

                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    if (_server != null)
                    {
                        try
                        {
                            // Disconnect from the server.
                            _server.Disconnect();
                        }
                        catch { }
                    }
                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                _server         = null;
                _client         = null;
                _serverAddress  = null;
                _clientSettings = null;
            }
        }
        public ActionResult TestRealMongo()
        {
            //Connect to MongoDB in C# with Credentials

            var credential = MongoCredential.CreateMongoCRCredential("alertsmd", "rangle", "m3anstack");
            //Server settings
            var settings = new MongoClientSettings
            {
                Credentials = new[] { credential },
                Server = new MongoServerAddress("ds033757.mongolab.com",33757)
            };

            //Get a Reference to the Client Object
            var mongoClient = new MongoClient(settings);
            var mongoServer = mongoClient.GetServer();
            var database = mongoServer.GetDatabase("alertsmd");

            var collections = database.GetCollectionNames();

            var usersCollection = database.GetCollection("users");

            var mconditions = database.GetCollection("conditions").FindAll();
            var mfeedbacks = database.GetCollection("feedbacks").FindAll();
            var mprofiles = database.GetCollection("profiles").FindAll();
            var msessions = database.GetCollection("sessions").FindAll();
            var msymptoms = database.GetCollection("symptoms").FindAll();
            var msystem_indexes = database.GetCollection("system.indexes").FindAll();
            var msystem_users = database.GetCollection("system.users").FindAll();
            var muserDatas = database.GetCollection("userDatas").FindAll();
            var musers = database.GetCollection("users").FindAll();

            return View();
        }
Beispiel #7
0
        public MongoDBCache(IOptions <MongoDBCacheOptions> settings)
        {
            var mongoSetttings = new Mongo.MongoClientSettings()
            {
                Server = new Mongo.MongoServerAddress(settings.Value.Hostname)
            };

            if (settings.Value.Username != null)
            {
                mongoSetttings.Credential = MongoCredential.CreateCredential(settings.Value.Database, settings.Value.Username, settings.Value.Password);
            }

            Client = new Mongo.MongoClient(mongoSetttings);

            Database = Client.GetDatabase(settings.Value.Database);

            ImageMetadatas = Database.GetCollection <ImageMetadataModel>("ImageMetadata");
            ImageBuffer    = new GridFSBucket(Database, new GridFSBucketOptions()
            {
                BucketName = "ImageBuffer"
            });

            //create index
            ImageMetadatas.Indexes.CreateOne(new CreateIndexModel <ImageMetadataModel>(new IndexKeysDefinitionBuilder <ImageMetadataModel>().Ascending(x => x.Key)));
            ImageMetadatas.Indexes.CreateOne(new CreateIndexModel <ImageMetadataModel>(new IndexKeysDefinitionBuilder <ImageMetadataModel>().Ascending(x => x.Created)));
            ImageMetadatas.Indexes.CreateOne(new CreateIndexModel <ImageMetadataModel>(new IndexKeysDefinitionBuilder <ImageMetadataModel>().Ascending(x => x.MimeType)));
            ImageMetadatas.Indexes.CreateOne(new CreateIndexModel <ImageMetadataModel>(new IndexKeysDefinitionBuilder <ImageMetadataModel>().Ascending(x => x.DPR)));
            ImageMetadatas.Indexes.CreateOne(new CreateIndexModel <ImageMetadataModel>(new IndexKeysDefinitionBuilder <ImageMetadataModel>().Ascending(x => x.Width)));
            ImageMetadatas.Indexes.CreateOne(new CreateIndexModel <ImageMetadataModel>(new IndexKeysDefinitionBuilder <ImageMetadataModel>().Ascending(x => x.Height)));
        }
        /// <summary>
        /// Converts the current instance to a <see cref="MongoClientSettings"/>.
        /// </summary>
        /// <returns>The current instance as a <see cref="MongoClientSettings"/>.</returns>
        public virtual MongoClientSettings ToMongoClientSettings()
        {
            MongoClientSettings settings;
            if (this.Servers == null || !this.Servers.Any())
            {
                settings = new MongoClientSettings
                {
                    Server = new MongoServerAddress(this.Host, this.Port)
                };
            }
            else
            {
                // Support multiple servers if needed (e.g. replication)
                settings = new MongoClientSettings
                {
                    Servers = this.Servers.Select(s => new MongoServerAddress(s.Host, s.Port))
                };
            }

            // Set replica set
            settings.ReplicaSetName = this.ReplicaSet;

            if (this.Authenticate)
            {
                settings.Credentials = new[] { MongoCredential.CreateMongoCRCredential(this.Database, this.Username, this.Password) };
            }

            return settings;
        }
Beispiel #9
0
        public override bool Connect() {
            bool opened = true;

            if (this.Client == null) {
                try {
                    MongoClientSettings settings = new MongoClientSettings();

                    if (this.Settings.Hostname != null && this.Settings.Port.HasValue == true) {
                        settings.Server = new MongoServerAddress(this.Settings.Hostname, (int)this.Settings.Port.Value);
                    }
                    else if (this.Settings.Hostname != null) {
                        settings.Server = new MongoServerAddress(this.Settings.Hostname);
                    }

                    if (this.Database != null && this.Settings.Username != null && this.Settings.Password != null) {
                        settings.Credentials = new List<MongoCredential>() {
                        MongoCredential.CreateMongoCRCredential(this.Settings.Database, this.Settings.Username, this.Settings.Password)
                    };
                    }

                    this.Client = new MongoClient(settings);

                    this.Database = this.Client.GetServer().GetDatabase(this.Settings.Database);
                }
                catch {
                    opened = false;
                }
            }

            return opened;
        }
Beispiel #10
0
 protected static MongoDatabase GetTestDatabase()
 {
     var settings = new MongoClientSettings
     {
         Server = new MongoServerAddress("localhost")
     };
     return new MongoClient(settings).GetServer().GetDatabase("mongo-learning");
 }
Beispiel #11
0
 public MongoStore(string db)
 {
     var clientSettings = new MongoClientSettings();
     //clientSettings.Server = new MongoServerAddress("mongodb://host:22666");
     var mongo = new MongoClient("mongodb://localhost:22666");
     var l = mongo.ListDatabasesAsync().Result;
     _mongodb = mongo.GetDatabase(db);
 }
Beispiel #12
0
 public LocalContext()
 {
     MongoClientSettings settings = new MongoClientSettings();
     settings.Server = new MongoServerAddress("localhost", 27017);
     //settings.Server = new MongoServerAddress("192.168.0.103", 27017);
     var client = new MongoClient(settings);
     Database = client.GetDatabase("admin");
 }
 public MongoDashboardContext()
 {
     var settings = new MongoClientSettings();
     settings.Server = new MongoServerAddress("127.0.0.1");
     var client = new MongoClient(settings);
     var database = client.GetDatabase("Workspaces");
     Dashboards = database.GetCollection<Dashboard>("Dashboard");
 }
 public MongoOptimisticDataStore(MongoClientSettings settings, string databaseName, string collectionName)
 {
     MongoClient client = new MongoClient(settings);
     this.Server = client.GetServer();
     this.CollectionName = collectionName;
     this.Database = this.Server.GetDatabase(databaseName);
     SetCollection();
     this.IsConnected = true;
 }
Beispiel #15
0
        public IMongoDatabase Create()
        {
            MongoClientSettings setting = new MongoClientSettings();
            setting.Server = new MongoServerAddress(_serverAddress, 27017);
            var mongoClient = new MongoClient(setting);
            var db = mongoClient.GetDatabase(_databaseName);

            return db;
        }
		public static MongoStorage UseMongoStorage(this IBootstrapperConfiguration configuration,
			MongoClientSettings mongoClientSettings,
			string databaseName)
		{
			MongoStorage storage = new MongoStorage(mongoClientSettings, databaseName);

			configuration.UseStorage(storage);

			return storage;
		}
		/// <summary>
		/// Constructs context with Mongo client settings and database name
		/// </summary>
		/// <param name="mongoClientSettings">Client settings for MongoDB</param>
		/// <param name="databaseName">Database name</param>
		/// <param name="prefix">Collections prefix</param>
		public HangfireDbContext(MongoClientSettings mongoClientSettings, string databaseName, string prefix = "hangfire")
		{
			_prefix = prefix;

			MongoClient client = new MongoClient(mongoClientSettings);

			Database = client.GetDatabase(databaseName);

			ConnectionId = Guid.NewGuid().ToString();
		}
Beispiel #18
0
 public BookController()
 {
     _repo = new Repository();
     string connectionString = "mongodb://localhost:27017/";
     var mongoClientSettings = new MongoClientSettings();
     mongoClientSettings.Server = new MongoServerAddress(connectionString);
     var client = new MongoClient();
     var db = client.GetDatabase("BookMVC");
     var collection = db.GetCollection<Book>("Book");
 }
Beispiel #19
0
 public MongoContext()
 {
     var credentials = MongoCredential.CreateMongoCRCredential("TestDB", "admin", "123456");
     var settings = new MongoClientSettings
     {
         Credentials = new [] {credentials}
     };
     var client = new MongoClient(settings);
     database = client.GetDatabase("TestDB");
     //database = server.GetDatabase("TestDB");
 }
        public static MongoDatabase GetMongoDatabase()
        {
            string connectionString = "mongodb://localhost:27017/";
            var mongoClientSettings = new MongoClientSettings();
            mongoClientSettings.Server = new MongoServerAddress(connectionString);
            var client = new MongoClient();
            var db = client.GetDatabase("BookMVC");
            var collection = db.GetCollection<Book>("Book");

            return client.GetServer().GetDatabase("BookMVC");
        }
 public static MongoDbAuditStoreProvider Start(this MongoDbAuditStoreProvider @mongoDbAuditStoreProvider)
 {
     var settings = new MongoClientSettings
     {
         ClusterConfigurator = cb => cb.ConfigureCluster(c => c.With(serverSelectionTimeout:
             TimeSpan.FromMilliseconds(@mongoDbAuditStoreProvider.TimeoutMilliseconds))),
         Server = new MongoServerAddress(@mongoDbAuditStoreProvider.ServerName)
     };
     @mongoDbAuditStoreProvider.Client = new MongoClient(settings);
     return @mongoDbAuditStoreProvider;
 }
        public void Constructor_with_MongoClientSettings_parameter_should_copy_relevant_values()
        {
            var credentials = new[] { MongoCredential.CreateMongoCRCredential("source", "username", "password") };
            var servers = new[] { new MongoServerAddress("localhost") };

            var certificates = new[] { new X509Certificate() };
            var sslSettings = new SslSettings
            {
                CheckCertificateRevocation = true,
                ClientCertificates = certificates,
                EnabledSslProtocols = SslProtocols.Tls12
            };

            var clientSettings = new MongoClientSettings
            {
                ConnectionMode = ConnectionMode.Direct,
                ConnectTimeout = TimeSpan.FromSeconds(1),
                Credentials = credentials,
                GuidRepresentation = GuidRepresentation.Standard,
                IPv6 = true,
                MaxConnectionIdleTime = TimeSpan.FromSeconds(2),
                MaxConnectionLifeTime = TimeSpan.FromSeconds(3),
                MaxConnectionPoolSize = 10,
                MinConnectionPoolSize = 5,
                ReplicaSetName = "rs",
                Servers = servers,
                SocketTimeout = TimeSpan.FromSeconds(4),
                SslSettings = sslSettings,
                UseSsl = true,
                VerifySslCertificate = true,
                WaitQueueSize = 20,
                WaitQueueTimeout = TimeSpan.FromSeconds(5)
            };

            var subject = new ClusterKey(clientSettings);

            subject.ConnectionMode.Should().Be(clientSettings.ConnectionMode);
            subject.ConnectTimeout.Should().Be(clientSettings.ConnectTimeout);
            subject.Credentials.Should().Equal(clientSettings.Credentials);
            subject.IPv6.Should().Be(clientSettings.IPv6);
            subject.MaxConnectionIdleTime.Should().Be(clientSettings.MaxConnectionIdleTime);
            subject.MaxConnectionLifeTime.Should().Be(clientSettings.MaxConnectionLifeTime);
            subject.MaxConnectionPoolSize.Should().Be(clientSettings.MaxConnectionPoolSize);
            subject.MinConnectionPoolSize.Should().Be(clientSettings.MinConnectionPoolSize);
            subject.ReplicaSetName.Should().Be(clientSettings.ReplicaSetName);
            subject.Servers.Should().Equal(clientSettings.Servers);
            subject.SocketTimeout.Should().Be(clientSettings.SocketTimeout);
            subject.SslSettings.Should().Be(clientSettings.SslSettings);
            subject.UseSsl.Should().Be(clientSettings.UseSsl);
            subject.VerifySslCertificate.Should().Be(clientSettings.VerifySslCertificate);
            subject.WaitQueueSize.Should().Be(clientSettings.WaitQueueSize);
            subject.WaitQueueTimeout.Should().Be(clientSettings.WaitQueueTimeout);
        }
 public DocumentsController()
 {
     var settings = new MongoClientSettings
     {
         Credentials = new[] { MongoCredential.CreateMongoCRCredential("admin", "siteRootAdmin", "password") },
         ConnectTimeout = TimeSpan.FromSeconds(5),
         Server = new MongoServerAddress("mdb0.cloudapp.net", 5000)
     };
     var client = new MongoClient(settings);
     _database = client.GetDatabase("Documents");
     _documents = _database.GetCollection<Document>("documents");
 }
 private static void initMongoDB(string ip, int port)
 {
     MongoClientSettings mongoSettings = new MongoClientSettings();
     mongoSettings.Servers = new List<MongoServerAddress>()
     {
     new MongoServerAddress (ip,port)
     };
     mongoClient = new MongoClient(mongoSettings);
     MongoServer mongoServer = mongoClient.GetServer();
     MongoDatabase mongoDB = mongoServer.GetDatabase("V5");
     dataCollection = mongoDB.GetCollection("MessagePack");
 }
        private DatabaseFactory()
        {
            var servers = new List<MongoServerAddress>();
            servers.Add(new MongoServerAddress("localhost", 11233));
            servers.Add(new MongoServerAddress("localhost", 22344));
            servers.Add(new MongoServerAddress("localhost", 33455));
            
            var settings = new MongoClientSettings();

            settings.Servers = servers;
            _client = new MongoClient(settings);
            _database = CreateDatabase();
        }
        public void TestConnectionMode()
        {
            var settings = new MongoClientSettings();
            Assert.AreEqual(ConnectionMode.Automatic, settings.ConnectionMode);

            var connectionMode = ConnectionMode.Direct;
            settings.ConnectionMode = connectionMode;
            Assert.AreEqual(connectionMode, settings.ConnectionMode);

            settings.Freeze();
            Assert.AreEqual(connectionMode, settings.ConnectionMode);
            Assert.Throws<InvalidOperationException>(() => { settings.ConnectionMode = connectionMode; });
        }
        public void TestConnectTimeout()
        {
            var settings = new MongoClientSettings();
            Assert.AreEqual(MongoDefaults.ConnectTimeout, settings.ConnectTimeout);

            var connectTimeout = new TimeSpan(1, 2, 3);
            settings.ConnectTimeout = connectTimeout;
            Assert.AreEqual(connectTimeout, settings.ConnectTimeout);

            settings.Freeze();
            Assert.AreEqual(connectTimeout, settings.ConnectTimeout);
            Assert.Throws<InvalidOperationException>(() => { settings.ConnectTimeout = connectTimeout; });
        }
        public void GetOrCreateCluster_should_return_a_cluster_with_the_correct_settings()
        {
            var credentials = new[] { MongoCredential.CreateMongoCRCredential("source", "username", "password") };
            var servers = new[] { new MongoServerAddress("localhost") };

            var certificates = new[] { new X509Certificate() };
            var sslSettings = new SslSettings
            {
                CheckCertificateRevocation = true,
                ClientCertificates = certificates,
                EnabledSslProtocols = SslProtocols.Tls12
            };

            var clientSettings = new MongoClientSettings
            {
                ConnectionMode = ConnectionMode.ReplicaSet,
                ConnectTimeout = TimeSpan.FromSeconds(1),
                Credentials = credentials,
                GuidRepresentation = GuidRepresentation.Standard,
                IPv6 = true,
                MaxConnectionIdleTime = TimeSpan.FromSeconds(2),
                MaxConnectionLifeTime = TimeSpan.FromSeconds(3),
                MaxConnectionPoolSize = 10,
                MinConnectionPoolSize = 5,
                ReplicaSetName = "rs",
                Servers = servers,
                SocketTimeout = TimeSpan.FromSeconds(4),
                SslSettings = sslSettings,
                UseSsl = true,
                VerifySslCertificate = true,
                WaitQueueSize = 20,
                WaitQueueTimeout = TimeSpan.FromSeconds(5)
            };

            var subject = new ClusterRegistry();

            using (var cluster = subject.GetOrCreateCluster(clientSettings))
            {
                var address = clientSettings.Servers.Single();
                var endPoints = new[] { new DnsEndPoint(address.Host, address.Port) };
                cluster.Settings.ConnectionMode.Should().Be(ClusterConnectionMode.ReplicaSet);
                cluster.Settings.EndPoints.Equals(endPoints);
                cluster.Settings.ReplicaSetName.Should().Be("rs");

                var serverDescription = cluster.Description.Servers.Single(s => s.EndPoint.Equals(endPoints[0]));
                serverDescription.EndPoint.Should().Be(endPoints[0]);

                // TODO: don't know how to test the rest of the settings because they are all private to the cluster
            }
        }
Beispiel #29
0
        private IMongoCollection<Task> GetCollection() {
            var mongoCredential = MongoCredential.CreateMongoCRCredential(databaseName, mongoToken.Key, mongoToken.Secret);
            var serverAddress = new MongoServerAddress(serverName, serverPort);

            var mongoClientSettings = new MongoClientSettings {
                Credentials = new[] { mongoCredential },
                Server = serverAddress
            };

            var client = new MongoClient(mongoClientSettings);
            var database = client.GetDatabase(databaseName);
            var collection = database.GetCollection<Task>(collectionName);
            return collection;
        }
Beispiel #30
0
        public void Connect()
        {
            MongoClientSettings settings = new MongoClientSettings();
            settings.Server = new MongoServerAddress(_ServerAddress);

            if(_TimeoutMilliseconds != -1)
            {
                settings.ConnectTimeout = new TimeSpan(TimeSpan.TicksPerMillisecond * _TimeoutMilliseconds);
            }
            
            _Client = new MongoClient(settings);

            _Database = _Client.GetDatabase(_DatabaseName);
        }
        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; });
        }
        //
        // GET: /WellCast/
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var credential = MongoCredential.CreateMongoCRCredential("alertsmd", "rangle", "m3anstack");
            //Server settings
            var settings = new MongoClientSettings
            {
                Credentials = new[] { credential },
                Server = new MongoServerAddress("ds033757.mongolab.com", 33757)
            };

            //Get a Reference to the Client Object
            var mongoClient = new MongoClient(settings);
            var mongoServer = mongoClient.GetServer();
            mdb = mongoServer.GetDatabase("alertsmd");
        }
 /// <summary>
 /// Initializes a new instance of the MongoClient class.
 /// </summary>
 /// <param name="settings">The settings.</param>
 public MongoClient(MongoClientSettings settings)
 {
     _settings = settings.FrozenCopy();
 }
        // private static methods
        private static MongoClientSettings ParseConnectionString(string connectionString)
        {
            var url = new MongoUrl(connectionString);

            return(MongoClientSettings.FromUrl(url));
        }
 /// <summary>
 /// Initializes a new instance of the MongoClient class.
 /// </summary>
 /// <param name="settings">The settings.</param>
 public MongoClient(MongoClientSettings settings)
 {
     _settings          = settings.FrozenCopy();
     _cluster           = ClusterRegistry.Instance.GetOrCreateCluster(_settings);
     _operationExecutor = new OperationExecutor();
 }
 /// <summary>
 /// Initializes a new instance of the MongoClient class.
 /// </summary>
 /// <param name="url">The URL.</param>
 public MongoClient(MongoUrl url)
     : this(MongoClientSettings.FromUrl(url))
 {
 }