Skip to content

Update Quick.ORM.RestClient.pas #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions Quick.ORM.RestClient.pas
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{ ***************************************************************************

Copyright (c) 2016-2019 Kike P�rez
Copyright (c) 2016-2019 Kike Pérez

Unit : Quick.ORM.RestClient
Description : Rest ORM Client access by http, httpapi or websockets
Author : Kike P�rez
Author : Kike Pérez
Version : 1.6
Created : 02/06/2017
Modified : 26/09/2019
Expand Down Expand Up @@ -100,20 +100,23 @@ TORMDataBaseConnection = class
constructor Create;
destructor Destroy; override;
end;

TGUIDArray = array of TGUID;

TORMServiceClient = class
private
fORMClient : TORMClient;
fMethodInterface : TGUID;
fMethodInterface : TGUIDArray;
fInstanceImplementation : TServiceInstanceImplementation;
fEnabled : Boolean;
public
constructor Create;
property MethodInterface : TGUID read fMethodInterface write fMethodInterface;
property MethodInterface : TGUIDArray read fMethodInterface write fMethodInterface;
property InstanceImplementation : TServiceInstanceImplementation read fInstanceImplementation write fInstanceImplementation;
property Enabled : Boolean read fEnabled write fEnabled;
procedure SetORM(fORM : TORMClient);
function SetRestMethod(out Obj) : Boolean;
function SetRestMethod(out Obj) : Boolean; overload;
function SetRestMethod(const aObjs: array of pointer) : Boolean; overload;
end;

TConnectEvent = procedure of object;
Expand Down Expand Up @@ -204,9 +207,21 @@ procedure TORMServiceClient.SetORM(fORM : TORMClient);
fORMClient := fORM;
end;

function TORMServiceClient.SetRestMethod(const aObjs: array of pointer): Boolean;
begin
try
result := true;
fORMClient.Services.Resolve(fMethodInterface, aObjs, false);
except
result := false;
end;

end;

function TORMServiceClient.SetRestMethod(out Obj) : Boolean;
begin
Result := fORMClient.Services.Resolve(fMethodInterface, obj);
if length(fMethodInterface) > 0 then
Result := fORMClient.Services.Resolve(fMethodInterface[0], obj);
end;


Expand Down Expand Up @@ -352,7 +367,7 @@ function TORMRestClient.Connect : Boolean;
if fService.Enabled then
begin
fService.SetORM(ORM);
ORM.ServiceDefine([fService.fMethodInterface],fService.fInstanceImplementation);
ORM.ServiceDefine(fService.fMethodInterface,fService.fInstanceImplementation);
end;

//get Auth Group
Expand Down