ClientConfigComponent.cs 620 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System.IO;
  2. using Base;
  3. namespace Model
  4. {
  5. [ObjectEvent]
  6. public class ClientConfigComponentEvent : ObjectEvent<ClientConfigComponent>, IAwake
  7. {
  8. public void Awake()
  9. {
  10. this.GetValue().Awake();
  11. }
  12. }
  13. public class ClientConfigComponent : Component
  14. {
  15. public StartConfig Config { get; private set; }
  16. public void Awake()
  17. {
  18. string s = File.ReadAllText("../Config/StartConfig/ClientConfig.txt");
  19. this.Config = MongoHelper.FromJson<StartConfig>(s);
  20. }
  21. public override void Dispose()
  22. {
  23. if (this.Id == 0)
  24. {
  25. return;
  26. }
  27. base.Dispose();
  28. this.Config.Dispose();
  29. }
  30. }
  31. }