Advertisement
filhotecmail

Abstract Factory

Aug 17th, 2017
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.33 KB | None | 0 0
  1. unit CargadeTabelas.Factory;
  2.  
  3. interface
  4.  
  5. uses CargaTabelas.Controller, ServerCadProd;
  6.  
  7. type
  8.   IAbstractCargaProduto = interface
  9.   ['{3DEA3773-00B1-43A9-A76F-D22EAF6D0A20}']
  10.   end;
  11.  
  12.   IAbstractFactoryCargaProd = interface
  13.   ['{0168A492-7D0E-4C13-A3C0-FBE5EB0FEDAF}']
  14.   function CreateInterfaceCargaProd: TCargaTabelasController;
  15.   function CreateIAbstractProduct: IAbstractCargaProduto;
  16.   end;
  17.  
  18.   TConcreteCargaProduto = class(TInterfacedObject, IAbstractCargaProduto)
  19.   end;
  20.  
  21.   TConcreteCarga = class(TInterfacedObject, IAbstractFactoryCargaProd)
  22.  
  23.  
  24.    function CreateInterfaceCargaProd: TCargaTabelasController;
  25.    function CreateIAbstractProduct: IAbstractCargaProduto;
  26.    function CreateServerCadProd:TServerCadProd;
  27.   end;
  28.  
  29.    var CargaProdGeneric: TConcreteCarga;
  30.    var CargaController: TCargaTabelasController;
  31.    var CdsServerProd: TServerCadProd;
  32.  
  33. implementation
  34.  
  35.  
  36. function TConcreteCarga.CreateIAbstractProduct: IAbstractCargaProduto;
  37. begin
  38.   Result := TConcreteCargaProduto.Create();
  39. end;
  40.  
  41.  function TConcreteCarga.CreateInterfaceCargaProd: TCargaTabelasController;
  42. begin
  43.          result := TCargaTabelasController.Create;
  44.          CargaController := Result;
  45. end;
  46.  
  47. function TConcreteCarga.CreateServerCadProd: TServerCadProd;
  48. begin
  49.   result:= TServerCadProd.Create;
  50.   CdsServerProd:= result;
  51. end;
  52.  
  53. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement