GroupConfig.pas 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. unit GroupConfig;
  2. interface
  3. uses
  4. BaseConfig, InterfaceConfig, TypInfo;
  5. type
  6. TGroupConfig = class(TBaseConfig, IGroupConfig)
  7. private
  8. public
  9. constructor Create(); override;
  10. function GetGatewayEnable: Boolean;
  11. function GetImageHost: string;
  12. function GetSocketHost: string;
  13. function GetGroupVersion: TGroupVersion;
  14. function GetGatewayHost: string;
  15. property SocketHost: string read GetSocketHost;
  16. property ImageHost: string read GetImageHost;
  17. property GatewayHost: string read GetGatewayHost;
  18. property Version: TGroupVersion read GetGroupVersion;
  19. property GatewayEnable: Boolean read GetGatewayEnable;
  20. end;
  21. implementation
  22. { TGroupConfig }
  23. constructor TGroupConfig.Create;
  24. begin
  25. ConfigType := ctPublic;
  26. FileName := 'group.json';
  27. inherited;
  28. end;
  29. function TGroupConfig.GetGatewayEnable: Boolean;
  30. begin
  31. if GetGroupVersion <> gvIndependent then
  32. Result := False;
  33. Result := Data.B['gatewayEnable'];
  34. end;
  35. function TGroupConfig.GetGatewayHost: string;
  36. begin
  37. if GetGroupVersion <> gvIndependent then
  38. Result := '';
  39. Result := Data.S['gatewayHost'];
  40. end;
  41. function TGroupConfig.GetGroupVersion: TGroupVersion;
  42. begin
  43. Result := TGroupVersion(GetEnumValue(TypeInfo(TGroupVersion), Data.S['version']));
  44. end;
  45. function TGroupConfig.GetImageHost: string;
  46. begin
  47. if GetGroupVersion <> gvIndependent then
  48. Result := '';
  49. Result := Data.S['imageHost'];
  50. end;
  51. function TGroupConfig.GetSocketHost: string;
  52. begin
  53. if GetGroupVersion <> gvIndependent then
  54. Result := '';
  55. Result := Data.S['socketHost'];
  56. end;
  57. end.