// factory methods /// <summary> /// Creates a new instance or returns an existing instance of MongoDatabase. Only one instance /// is created for each combination of database settings. Automatically creates an instance /// of MongoServer if needed. /// </summary> /// <param name="builder">Server and database settings in the form of a MongoConnectionStringBuilder.</param> /// <returns> /// A new or existing instance of MongoDatabase. /// </returns> public static MongoDatabase Create(MongoConnectionStringBuilder builder) { var serverSettings = builder.ToServerSettings(); var databaseName = builder.DatabaseName; return(Create(serverSettings, databaseName)); }
internal static MongoServer GetMongoServer() { var serverAddress = (ServerPort != 0) ? new MongoServerAddress(ServerHost, ServerPort) : new MongoServerAddress(ServerHost); var connectionStringBuilder = new MongoConnectionStringBuilder { Server = serverAddress, ConnectTimeout = ConnectTimeout, SocketTimeout = SocketTimeout, WaitQueueTimeout = WaitQueueTimeout, SafeMode = (SafeMode) ? MongoDB.Driver.SafeMode.True : MongoDB.Driver.SafeMode.False }; return MongoServer .Create(connectionStringBuilder.ToServerSettings()); }
/// <summary> /// Creates a new instance or returns an existing instance of MongoServer. Only one instance /// is created for each combination of server settings. /// </summary> /// <param name="builder">Server settings in the form of a MongoConnectionStringBuilder.</param> /// <returns> /// A new or existing instance of MongoServer. /// </returns> public static MongoServer Create( MongoConnectionStringBuilder builder ) { return(Create(builder.ToServerSettings())); }