/// <summary> /// /// </summary> /// <param name="databaseProvider"></param> /// <param name="dbConfig"></param> public MongoBaseRepository(IMongoDatabaseProvider databaseProvider, MonogoDbConfig dbConfig) { Ensure.NotNull(databaseProvider, "IMongoDatabaseProvider"); Ensure.NotNull(dbConfig, "MonogoDbConfig"); _databaseProvider = databaseProvider; DbConfig = dbConfig; }
/// <summary> /// 获取 <see cref="IMongoDatabase"/>. /// </summary> /// <param name="config">MongoDb配置</param> /// <exception cref="System.ArgumentNullException">config</exception> /// <returns><see cref="IMongoDatabase"/></returns> public IMongoDatabase GetDatabase(MonogoDbConfig config) { Ensure.NotNull(config, "MonogoDbConfig"); MongoUrl mongoUrl = new MongoUrl(config.ConnectionString); var mongoClient = new MongoClient(mongoUrl); return(mongoClient.GetDatabase(mongoUrl.DatabaseName ?? config.DatabaseName)); }
public static DependencyManage UseMongoDBMonitor(this DependencyManage dependencyManage, Func <MonogoDbConfig> func) { MonogoDbConfig.SetConfig(func); return(dependencyManage.RegisterType <IRpcMonitor, MongoMonitor>()); }