Exemplo n.º 1
0
 /// <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;
 }
Exemplo n.º 2
0
        /// <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));
        }
Exemplo n.º 3
0
 public static DependencyManage UseMongoDBMonitor(this DependencyManage dependencyManage, Func <MonogoDbConfig> func)
 {
     MonogoDbConfig.SetConfig(func);
     return(dependencyManage.RegisterType <IRpcMonitor, MongoMonitor>());
 }