using MongoDB.Driver; namespace Model { [ObjectSystem] public class DbComponentSystem : ObjectSystem, IAwake { public void Awake() { this.Get().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); } } }