static void Main(string[] args) { if (doMongoInsert) { Console.WriteLine($"Listening for events from rabbit :)"); _connectionFactory = new ConnectionFactory { HostName = "localhost" }; _connection = _connectionFactory.CreateConnection(); _mongoSetting = new MongoSetting(); _mongoRepository = new MongoRepository(_mongoSetting); var sub = new Subscriber(_connection, _mongoRepository); } Console.WriteLine($"Mode to process set to : {doMongoInsert}"); Console.Read(); }
public MongoRepository(IMongoSetting mongoSettings) { _mongoSettings = mongoSettings; _mongoClient = new MongoClient(_mongoSettings.ConnectionString); _mongoDatabase = _mongoClient.GetDatabase(_mongoSettings.Database); }
public static bool DropCollection(string databaseName, IMongoSetting setting, string collectionName) { MongoDatabase db = GetDatabase(databaseName, setting); CommandResult result = db.DropCollection(collectionName); return (result.Ok ? true : false); }
public static bool CollectionExists(string databaseName, IMongoSetting setting, string collectionName) { MongoDatabase db = GetDatabase(databaseName, setting); return db.CollectionExists(collectionName); }
public static IEnumerable<string> GetCollectionNames(string databaseName, IMongoSetting setting) { MongoDatabase db = GetDatabase(databaseName, setting); return db.GetCollectionNames(); }
public static void DeleteDatabase(string databaseName, IMongoSetting setting) { MongoDatabase db = GetDatabase(databaseName, setting); db.Drop(); }
public static IEnumerable<string> GetDatabaseNames(IMongoSetting setting) { MongoServer server = GetMongoServer(setting); return server.GetDatabaseNames(); }
public static MongoDatabase GetDatabase(string databaseName, IMongoSetting setting) { MongoDatabase db = GetMongoServer(setting).GetDatabase(databaseName); return db; }
private static MongoServer GetMongoServer(IMongoSetting setting) { var client = new MongoClient(setting.ConnectionString); MongoServer server = client.GetServer(); return server; }