ConditionConfig.pas 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. unit ConditionConfig;
  2. interface
  3. uses
  4. Classes, SysUtils;
  5. type
  6. TConditionConfig = class
  7. private
  8. FFaceSize: Int64;
  9. FUserInfoController: Boolean;
  10. FSMSName: string;
  11. FOtherServersDisable: Boolean;
  12. FNewCenterServer: Boolean;
  13. FUserInfoCheck: Boolean;
  14. FGradeSystem: Boolean;
  15. FFirstLoginConfirm: Boolean;
  16. FDev: Boolean;
  17. FRemoteUIHost: string;
  18. FRemoteUI: Boolean;
  19. public
  20. constructor Create;
  21. class function Load: TConditionConfig;
  22. class function GetConfig: TConditionConfig;
  23. property FaceSize: Int64 read FFaceSize;
  24. property UserInfoController: Boolean read FUserInfoController;
  25. property OtherServersDisable: Boolean read FOtherServersDisable;
  26. property NewCenterServer: Boolean read FNewCenterServer;
  27. property UserInfoCheck: Boolean read FUserInfoCheck;
  28. property SMSName: string read FSMSName;
  29. property GradeSystem: Boolean read FGradeSystem;
  30. property FirstLoginConfirm: Boolean read FFirstLoginConfirm;
  31. property Dev: Boolean read FDev;
  32. property RemoteUI: Boolean read FRemoteUI;
  33. property RemoteUIHost: string read FRemoteUIHost;
  34. end;
  35. implementation
  36. uses
  37. superobject, Dialogs, TypInfo, Winsock2, LoggerImport;
  38. const
  39. CONDITION_CONFIG: string = 'Config\condition.config';
  40. var
  41. config: TConditionConfig;
  42. constructor TConditionConfig.Create;
  43. begin
  44. FFaceSize := 20;//µ¥Î»M
  45. end;
  46. class function TConditionConfig.GetConfig: TConditionConfig;
  47. begin
  48. if config <> nil then
  49. Result := config
  50. else
  51. Result := TConditionConfig.Load;
  52. end;
  53. class function TConditionConfig.Load: TConditionConfig;
  54. var
  55. AFullFileName: string;
  56. jo, AServer: ISuperObject;
  57. AGroupServerAddresses: TSuperArray;
  58. iLoop: Integer;
  59. begin
  60. if config <> nil then
  61. FreeAndNil(config);
  62. config := TConditionConfig.Create;
  63. Result := config;
  64. AFullFileName := ExtractFilePath(ParamStr(0)) + CONDITION_CONFIG;
  65. if not FileExists(AFullFileName) then
  66. Exit;
  67. try
  68. jo := TSuperObject.ParseFile(AFullFileName, False);
  69. if jo.O['faceSize'] <> nil then
  70. Result.FFaceSize := jo['faceSize'].AsInteger;
  71. Result.FUserInfoController := jo.B['userInfoController'];
  72. Result.FOtherServersDisable := jo.B['otherServersDisable'];
  73. Result.FNewCenterServer := jo.B['newCenterServer'];
  74. Result.FSMSName := jo.S['smsName'];
  75. Result.FUserInfoCheck := jo.B['userInfoCheck'];
  76. Result.FGradeSystem := jo.B['grade'];
  77. Result.FFirstLoginConfirm := jo.B['firstLoginConfirm'];
  78. Result.FDev := jo.B['dev'];
  79. Result.FRemoteUI := jo.B['remoteUI'];
  80. Result.FRemoteUIHost := jo.S['remoteUIHost'];
  81. except
  82. on E: Exception do
  83. begin
  84. Error(E.Message, 'TConditionConfig.Load');
  85. end;
  86. end;
  87. end;
  88. initialization
  89. finalization
  90. if config <> nil then
  91. FreeAndNil(config);
  92. end.