From 65c0c4dae636c9707b78b0223f15d5ca633efa66 Mon Sep 17 00:00:00 2001 From: Modest-as Date: Fri, 7 Jan 2022 20:19:11 +0200 Subject: [PATCH] mongo settings support --- EventSauce.MongoDB/MongoDBSauceStoreFactory.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/EventSauce.MongoDB/MongoDBSauceStoreFactory.cs b/EventSauce.MongoDB/MongoDBSauceStoreFactory.cs index 4508ee3..7a294d0 100644 --- a/EventSauce.MongoDB/MongoDBSauceStoreFactory.cs +++ b/EventSauce.MongoDB/MongoDBSauceStoreFactory.cs @@ -12,23 +12,28 @@ namespace EventSauce.MongoDB public class MongoDBSauceStoreFactory { private readonly Assembly[] _assemblies; - private readonly string _connectionString; + private readonly MongoClientSettings _clientSettings; private readonly string _database; private readonly string _collection; public MongoDBSauceStoreFactory( Assembly[] assemblies, string connectionString, - string database) : this(assemblies, connectionString, database, "events") { } + string database) : this(assemblies, MongoClientSettings.FromConnectionString(connectionString), database, "events") { } public MongoDBSauceStoreFactory( Assembly[] assemblies, - string connectionString, + MongoClientSettings clientSettings, + string database) : this(assemblies, clientSettings, database, "events") { } + + public MongoDBSauceStoreFactory( + Assembly[] assemblies, + MongoClientSettings clientSettings, string database, string collection) { _assemblies = assemblies; - _connectionString = connectionString; + _clientSettings = clientSettings; _database = database; _collection = collection; @@ -93,7 +98,7 @@ public ISauceStore Create() private IMongoCollection CreateCollection() { - var client = new MongoClient(_connectionString); + var client = new MongoClient(_clientSettings); var database = client.GetDatabase(_database);