using MongoDB.Driver; namespace ETModel { [ObjectSystem] public class DbComponentSystem : AwakeSystem { public override void Awake(DBComponent self) { self.Awake(); } } /// /// 连接mongodb /// public class DBComponent : Component { public MongoClient mongoClient; public IMongoDatabase database; public void Awake() { //DBConfig config = Game.Scene.GetComponent().StartConfig.GetComponent(); //string connectionString = config.ConnectionString; //mongoClient = new MongoClient(connectionString); //this.database = this.mongoClient.GetDatabase(config.DBName); } public IMongoCollection GetCollection(string name) { return this.database.GetCollection(name); } } }