DBManagerComponentSystem.cs 896 B

123456789101112131415161718192021222324252627
  1. using System;
  2. namespace ET.Server
  3. {
  4. [FriendOf(typeof(DBManagerComponent))]
  5. public static partial class DBManagerComponentSystem
  6. {
  7. public static DBComponent GetZoneDB(this DBManagerComponent self, int zone)
  8. {
  9. DBComponent dbComponent = self.DBComponents[zone];
  10. if (dbComponent != null)
  11. {
  12. return dbComponent;
  13. }
  14. StartZoneConfig startZoneConfig = StartZoneConfigCategory.Instance.Get(zone);
  15. if (startZoneConfig.DBConnection == "")
  16. {
  17. throw new Exception($"zone: {zone} not found mongo connect string");
  18. }
  19. dbComponent = self.AddChild<DBComponent, string, string, int>(startZoneConfig.DBConnection, startZoneConfig.DBName, zone);
  20. self.DBComponents[zone] = dbComponent;
  21. return dbComponent;
  22. }
  23. }
  24. }