Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit LeopardGerenciador.BaseClass.InterfaceModelGenericClass.InterfaceModelGenericBaseClass;
- interface
- uses System.classes,
- System.SysUtils,
- System.Types,
- System.Generics.Collections,
- System.Generics.Defaults, LeopardGerenciador.BaseClass.InjectableBaseclass.InjectableBaseClassModel,
- LeopardDriverDataset;
- type IModelBaseInterface = Interface
- ['{582E9A29-346C-4B73-9B1A-E24E614E3E43}']
- function Inject( InjectDeps: TProc<TObject> ):TInterfacedObject;
- function SetEvents( InjectDeps: TProc<TObject> ):TInterfacedObject;
- function Response( Done: TProc<TObject>; Fail: TProc<Exception> ):TInterfacedObject;
- procedure SetDeps(const Value: TInjectableBaseClassModel);
- function getFDeps: TInjectableBaseClassModel;
- property Deps: TInjectableBaseClassModel read getFDeps write SetDeps;
- function PrintData:TInterfacedObject;
- function ExportToXml:TInterfacedObject;
- function ExportToCsv:TInterfacedObject;
- function ExportToJson:TInterfacedObject;
- function MakeDataset( Done: TProc<TObject,IModelBaseInterface> ):TInterfacedObject; overload;
- function MakeDataset( const GeneratorName,Field: String ;Done: TProc<TObject,IModelBaseInterface> ):TInterfacedObject; overload;
- End;
- type TModelBaseObjConcret = class( TInterfacedObject,IModelBaseInterface )
- protected
- FDeps: TInjectableBaseClassModel;
- procedure SetDeps(const Value: TInjectableBaseClassModel);
- function getFDeps: TInjectableBaseClassModel;
- public
- class function New: IModelBaseInterface;
- procedure AfterConstruction; override;
- procedure BeforeDestruction; override;
- function Inject( InjectDeps: TProc<TObject> ):TInterfacedObject; virtual; abstract;
- function SetEvents( InjectDeps: TProc<TObject> ):TInterfacedObject; virtual; abstract;
- function Response( Done: TProc<TObject>; Fail: TProc<Exception> ):TInterfacedObject; virtual; abstract;
- function PrintData:TInterfacedObject; virtual; abstract;
- function ExportToXml:TInterfacedObject; virtual; abstract;
- function ExportToCsv:TInterfacedObject; virtual; abstract;
- function ExportToJson:TInterfacedObject; virtual; abstract;
- function MakeDataset( Done: TProc<TObject,IModelBaseInterface> ):TInterfacedObject; overload;
- function MakeDataset( const GeneratorName,Field: String ;Done: TProc<TObject,IModelBaseInterface> ):TInterfacedObject; overload;
- published
- property Deps: TInjectableBaseClassModel read getFDeps write SetDeps;
- end;
- (*Aqui um exemplo de um plugin para Herança multipla,
- podendo extender a classe base sem prejudicar as classes filhas*)
- type ICrudBaseClass = Interface
- ['{884927F2-21A0-4BFD-9696-28FB11EEC86F}']
- function AppendData():TInterfacedObject;
- function PostData():TInterfacedObject;
- function EditData():TInterfacedObject;
- function CancelData():TInterfacedObject;
- function DeleteData():TInterfacedObject;
- End;
- implementation
- { TModelBaseObjConcret }
- procedure TModelBaseObjConcret.AfterConstruction;
- begin
- inherited AfterConstruction;
- FDeps := TInjectableBaseClassModel.Create;
- end;
- procedure TModelBaseObjConcret.BeforeDestruction;
- begin
- inherited BeforeDestruction;
- FreeAndNil( FDeps );
- end;
- function TModelBaseObjConcret.MakeDataset(const GeneratorName, Field: String;
- Done: TProc<TObject, IModelBaseInterface>): TInterfacedObject;
- begin
- Insert(TLeopardDriverDataset.Create(nil,aTPFiredac,True,GeneratorName,Field),
- FDeps.Response.DataL,length(FDeps.Response.DataL)+1);
- if Assigned(Done) then
- Done(FDeps,Self);
- Result:= Self;
- end;
- function TModelBaseObjConcret.MakeDataset(Done: TProc<TObject,IModelBaseInterface>): TInterfacedObject;
- begin
- Insert(TLeopardDriverDataset.Create(nil,aTPFiredac),
- FDeps.Response.DataL,length(FDeps.Response.DataL)+1);
- if Assigned(Done) then
- Done( FDeps,Self );
- Result:= Self;
- end;
- function TModelBaseObjConcret.getFDeps: TInjectableBaseClassModel;
- begin
- Result:= FDeps;
- end;
- class function TModelBaseObjConcret.New: IModelBaseInterface;
- begin
- Result:= TModelBaseObjConcret.Create;
- end;
- procedure TModelBaseObjConcret.SetDeps(const Value: TInjectableBaseClassModel);
- begin
- FDeps := Value;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement