Esempio n. 1
0
 public void Init(BaseConfig config = null)
 {
     lock (_lock)
     {
         if (_logClient == null)
         {
             if (config != null)
             {
                 _noSqlDbConfig = (NoSqlDBConfig)config;
             }
             else
             {
                 _noSqlDbConfig = ConfigUtil.GetConfig <NoSqlDBConfig>("");
             }
             if (_noSqlDbConfig != null)
             {
                 string text = _noSqlDbConfig.Provider.ToLower();
                 if (text != null)
                 {
                     if (text == "mongodb")
                     {
                         INoSqlDBClient noSqlDBClient = new MongoDBClient();
                         _logClient = noSqlDBClient.Connect(_noSqlDbConfig);
                         goto IL_C8;
                     }
                 }
                 throw new Exception(string.Format("没有可提供的{0}调用", _noSqlDbConfig.Provider));
             }
             throw new Exception("缺少本地MongoDBConfig配置节点");
         }
         IL_C8 :;
     }
 }
Esempio n. 2
0
        public INoSqlDBClient Connect(NoSqlDBConfig config)
        {
            this.config = config;
            MongoClient mongoClient = new MongoClient(config.ConnectionString);

            this.client = mongoClient.GetDatabase(config.DBName, null);
            return(this);
        }