Advertisement
filhotecmail

Factory exemplo

Nov 22nd, 2017
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.61 KB | None | 0 0
  1. unit Factory;
  2.  
  3. interface
  4.  
  5. uses classes;
  6. (* Declarar aqui todos os forms todas as classes e métodos mais importnates se quiser fazer uma camada mais direta
  7. para acesso aos métodos de outros forms ou classes *)
  8.  
  9.  type iCreator = interface
  10.    ['{6C468335-2AAA-4D9B-B4A6-FEC334781EDC}']
  11.  
  12.   function getFrmUPagammento: TfrmUPagamento;
  13.   procedure setFrmUPagammento(const Value: TfrmUPagamento);
  14.   property FormPagamento: TfrmUPagamento read getFrmUPagammento write setFrmUPagammento;
  15.   procedure CreateFrmPagamento;
  16.  end;
  17.  
  18.  type TCreator = class(TObject)
  19.  private
  20.  {Private declaration}
  21.  FrmUPagammento: TfrmUPagamento;
  22.     function getFrmUPagammento: TfrmUPagamento;
  23.     procedure setFrmUPagammento(const Value: TfrmUPagamento);
  24.  protected
  25.  {Protected declaration}
  26.  public
  27.  {Public declaration declaration}
  28.  
  29.   property FormPagamento: TfrmUPagamento read getFrmUPagammento write setFrmUPagammento;
  30.   procedure CreateFrmPagamento;
  31.    constructor Create; (*Metodos do Constructor*)
  32.    destructor Destroy; override;
  33.  
  34.  published
  35.  {Protected declaration}
  36.  end;
  37.  
  38.   var Fact: iCreator;
  39.  
  40. implementation
  41.  
  42. { TCreator }
  43.  
  44. constructor TCreator.Create;
  45. begin
  46.  
  47. end;
  48.  
  49. procedure TCreator.CreateFrmPagamento;
  50. begin
  51.    if not assigned( FrmUPagammento ) then
  52.   begin
  53.      FrmUPagammento := TformUPagamento.create(Application);
  54.   end;
  55.  
  56. end;
  57.  
  58. destructor TCreator.Destroy;
  59. begin
  60.  
  61.   inherited;
  62. end;
  63.  
  64. function TCreator.getFrmUPagammento: TfrmUPagamento;
  65. begin
  66.  
  67.   Result:= FrmUPagammento;
  68. end;
  69.  
  70. procedure TCreator.setFrmUPagammento(const Value: TfrmUPagamento);
  71. begin
  72.    FrmUPagammento := Value;
  73. end;
  74.  
  75. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement