Advertisement
filhotecmail

Untitled

Apr 20th, 2018
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.21 KB | None | 0 0
  1. (* Trabalhando com Propertys e declarando na Interface.
  2. Quando um Objeto implementa interfaces é comum nos depararmos com a questão de , e agora , como faço para declarar as minhas propertys.
  3. Segue um exemplo maneiro..
  4. No model. *)
  5. uses System.SysUtils,{$ifdef FMX} FMX.Forms,{$else} VCL.Forms,{$endif} System.Classes, MVCBr.Interf, MVCBr.PersistentModel,
  6. SenMailModel.PersistentModel.Interf, //%Interf,
  7. MVCBr.Controller;
  8. Type
  9. TSenMailModelPersistentModel = class(TPersistentModelFactory,ISenMailModelPersistentModel, IThisAs<TSenMailModelPersistentModel>)
  10. protected
  11. private
  12. FFrom: string;
  13. FFromName: string;
  14. FHost: string;
  15. FUsername: string;
  16. FPassword: string;
  17. FPort: integer;
  18. FSetTLS: Boolean;
  19. FSetSSL: Boolean;
  20. function getFrom: string;
  21. function getFromName: string;
  22. function getHost: string;
  23. function getPassword: string;
  24. function getPorta: Integer;
  25. function getSetTLS: Boolean;
  26. function getUserName: string;
  27. procedure setFrom(const Value: string);
  28. procedure setFromname(const Value: string);
  29. procedure SetPassword(const Value: string);
  30. procedure setPorta(const Value: Integer);
  31. procedure setSetTLS(const Value: Boolean);
  32. procedure SetUsername(const Value: string);
  33. procedure setHost(const Value: string);
  34. public
  35. Constructor Create; override;
  36. Destructor Destroy; override;
  37. class function new():ISenMailModelPersistentModel; overload;
  38. class function new(const AController:IController):ISenMailModelPersistentModel; overload;
  39. function ThisAs:TSenMailModelPersistentModel;
  40. // implementaçoes
  41. property From: string read getFrom write setFrom;
  42. property FromName: string read getFromName write setFromname;
  43. property Host: string read getHost write setHost;
  44. Property UserName: string read getUserName write SetUsername;
  45. property Password: string read getPassword write SetPassword;
  46. property Porta: Integer read getPorta write setPorta;
  47. property SetTLS: Boolean read getSetTLS write setSetTLS;
  48. Na interface..
  49. uses System.SysUtils,{$ifdef FMX} FMX.Forms,{$else} VCL.Forms,{$endif} System.Classes, MVCBr.Interf, MVCBr.PersistentModel,
  50. //%Interf,
  51. MVCBr.Controller;
  52. Type
  53. // Interface de acesso ao model
  54. ISenMailModelPersistentModel = interface( IPersistentModel )
  55. ['{9BA0B924-6279-4E5A-B0C3-D40306C419B9}']
  56. // incluir aqui as especializações
  57. function getFrom: string;
  58. function getFromName: string;
  59. function getHost: string;
  60. function getPassword: string;
  61. function getPorta: Integer;
  62. function getSetTLS: Boolean;
  63. function getUserName: string;
  64. procedure setFrom(const Value: string);
  65. procedure setFromname(const Value: string);
  66. procedure SetPassword(const Value: string);
  67. procedure setPorta(const Value: Integer);
  68. procedure setSetTLS(const Value: Boolean);
  69. procedure SetUsername(const Value: string);
  70. procedure setHost(const Value: string);
  71. property From: string read getFrom write setFrom;
  72. property FromName: string read getFromName write setFromname;
  73. property Host: string read getHost write setHost;
  74. Property UserName: string read getUserName write SetUsername;
  75. property Password: string read getPassword write SetPassword;
  76. property Porta: Integer read getPorta write setPorta;
  77. property SetTLS: Boolean read getSetTLS write setSetTLS;
  78. // veja que na Interface, os métodos Get e set e as propertys devem estar juntos..
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement