Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* Trabalhando com Propertys e declarando na Interface.
- Quando um Objeto implementa interfaces é comum nos depararmos com a questão de , e agora , como faço para declarar as minhas propertys.
- Segue um exemplo maneiro..
- No model. *)
- uses System.SysUtils,{$ifdef FMX} FMX.Forms,{$else} VCL.Forms,{$endif} System.Classes, MVCBr.Interf, MVCBr.PersistentModel,
- SenMailModel.PersistentModel.Interf, //%Interf,
- MVCBr.Controller;
- Type
- TSenMailModelPersistentModel = class(TPersistentModelFactory,ISenMailModelPersistentModel, IThisAs<TSenMailModelPersistentModel>)
- protected
- private
- FFrom: string;
- FFromName: string;
- FHost: string;
- FUsername: string;
- FPassword: string;
- FPort: integer;
- FSetTLS: Boolean;
- FSetSSL: Boolean;
- function getFrom: string;
- function getFromName: string;
- function getHost: string;
- function getPassword: string;
- function getPorta: Integer;
- function getSetTLS: Boolean;
- function getUserName: string;
- procedure setFrom(const Value: string);
- procedure setFromname(const Value: string);
- procedure SetPassword(const Value: string);
- procedure setPorta(const Value: Integer);
- procedure setSetTLS(const Value: Boolean);
- procedure SetUsername(const Value: string);
- procedure setHost(const Value: string);
- public
- Constructor Create; override;
- Destructor Destroy; override;
- class function new():ISenMailModelPersistentModel; overload;
- class function new(const AController:IController):ISenMailModelPersistentModel; overload;
- function ThisAs:TSenMailModelPersistentModel;
- // implementaçoes
- property From: string read getFrom write setFrom;
- property FromName: string read getFromName write setFromname;
- property Host: string read getHost write setHost;
- Property UserName: string read getUserName write SetUsername;
- property Password: string read getPassword write SetPassword;
- property Porta: Integer read getPorta write setPorta;
- property SetTLS: Boolean read getSetTLS write setSetTLS;
- Na interface..
- uses System.SysUtils,{$ifdef FMX} FMX.Forms,{$else} VCL.Forms,{$endif} System.Classes, MVCBr.Interf, MVCBr.PersistentModel,
- //%Interf,
- MVCBr.Controller;
- Type
- // Interface de acesso ao model
- ISenMailModelPersistentModel = interface( IPersistentModel )
- ['{9BA0B924-6279-4E5A-B0C3-D40306C419B9}']
- // incluir aqui as especializações
- function getFrom: string;
- function getFromName: string;
- function getHost: string;
- function getPassword: string;
- function getPorta: Integer;
- function getSetTLS: Boolean;
- function getUserName: string;
- procedure setFrom(const Value: string);
- procedure setFromname(const Value: string);
- procedure SetPassword(const Value: string);
- procedure setPorta(const Value: Integer);
- procedure setSetTLS(const Value: Boolean);
- procedure SetUsername(const Value: string);
- procedure setHost(const Value: string);
- property From: string read getFrom write setFrom;
- property FromName: string read getFromName write setFromname;
- property Host: string read getHost write setHost;
- Property UserName: string read getUserName write SetUsername;
- property Password: string read getPassword write SetPassword;
- property Porta: Integer read getPorta write setPorta;
- property SetTLS: Boolean read getSetTLS write setSetTLS;
- // 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