Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit DictionaryFactory;
- interface
- uses
- System.Generics.Collections, Dialogs;
- type Tproduto = class
- procedure VenderProdutos(aCodeBar: string);
- end;
- type TClientes = class
- procedure cadastrarCliente( NomeCliente: string );
- end;
- type iDicInterface = interface
- ['{F707C788-7886-4D58-A170-5C5609DCA9EC}']
- procedure cadastrarCliente( NomeCliente: string );
- procedure VenderProdutos(aCodeBar: string);
- end;
- type TDicClass = class( TInterfacedObject,iDicInterface )
- private
- FTClientes: TClientes;
- FTproduto: Tproduto;
- function getFTClientes: TClientes;
- procedure setFTClientes(const Value: TClientes);
- function getFTproduto: Tproduto;
- procedure setFTproduto(const Value: Tproduto);
- public
- property Produto: Tproduto read getFTproduto write setFTproduto;
- property Myclass:TClientes read getFTClientes write setFTClientes;
- procedure VenderProdutos(aCodeBar: string);
- procedure cadastrarCliente( NomeCliente: string );
- constructor Create; (*Metodos do Constructor*)
- destructor Destroy; override;
- published
- {Protected declaration}
- end;
- type
- TObj = class function ObjT: TDictionary<TGUID,iDicInterface>;
- end;
- implementation
- { TDicClass }
- procedure TDicClass.cadastrarCliente(NomeCliente: string);
- begin
- FTClientes.cadastrarCliente(NomeCliente);
- end;
- constructor TDicClass.Create;
- begin
- end;
- destructor TDicClass.Destroy;
- begin
- inherited;
- end;
- function TDicClass.getFTClientes: TClientes;
- begin
- if not assigned( FTClientes ) then
- begin
- FTClientes := TClientes.Create;
- end;
- Result := FTClientes;
- end;
- function TDicClass.getFTproduto: Tproduto;
- begin
- if not assigned( FTproduto ) then
- begin
- FTProduto:= Tproduto.Create;
- end;
- Result := FTproduto;
- end;
- procedure TDicClass.setFTClientes(const Value: TClientes);
- begin
- FTClientes := value;
- end;
- procedure TDicClass.setFTproduto(const Value: Tproduto);
- begin
- FTproduto:= value;
- end;
- procedure TDicClass.VenderProdutos(aCodeBar: string);
- begin
- FTproduto.VenderProdutos(aCodeBar);
- end;
- { TObj }
- function TObj.ObjT: TDictionary<TGUID,iDicInterface>;
- var Dic: TDictionary<TGUID,iDicInterface>;
- begin
- dic:= TDictionary<TGUID,iDicInterface>.Create;
- dic.Add(iDicInterface,TDicClass.Create);
- Result:= dic;
- end;
- { TClientes }
- procedure TClientes.cadastrarCliente(NomeCliente: string);
- begin
- showmessage(NomeCliente);
- end;
- { Tproduto }
- procedure Tproduto.VenderProdutos(aCodeBar: string);
- begin
- showMessage(aCodeBar);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement