DBComponent.cs 647 B

12345678910111213141516171819202122232425
  1. using MongoDB.Driver;
  2. namespace ET
  3. {
  4. /// <summary>
  5. /// 用来缓存数据
  6. /// </summary>
  7. public class DBComponent: Entity, IAwake<string, string, int>, IDestroy
  8. {
  9. public const int TaskCount = 32;
  10. public MongoClient mongoClient;
  11. public IMongoDatabase database;
  12. public IMongoCollection<T> GetCollection<T>(string collection = null)
  13. {
  14. return this.database.GetCollection<T>(collection ?? typeof (T).Name);
  15. }
  16. public IMongoCollection<Entity> GetCollection(string name)
  17. {
  18. return this.database.GetCollection<Entity>(name);
  19. }
  20. }
  21. }