New template language: TemplatePro

This commit is contained in:
Daniele Teti 2024-08-07 16:25:08 +02:00
parent 7e28bc959e
commit 21bdc7cee0
3 changed files with 1240 additions and 10 deletions

View File

@ -14,14 +14,14 @@ type
[MVCPath('/api/customers')] [MVCPath('/api/customers')]
TCustomersController = class(TMVCController) TCustomersController = class(TMVCController)
public public
[MVCPath]
[MVCHTTPMethods([httpGET])]
procedure GetCustomers([MVCFromQueryString('rql','')] RQLFilter: String);
[MVCPath('/($ID)')] [MVCPath('/($ID)')]
[MVCHTTPMethods([httpGET])] [MVCHTTPMethods([httpGET])]
procedure GetCustomerByID(const ID: Integer); procedure GetCustomerByID(const ID: Integer);
[MVCPath]
[MVCHTTPMethods([httpGET])]
procedure GetCustomers([MVCFromQueryString('rql','')] RQLFilter: String);
[MVCPath] [MVCPath]
[MVCHTTPMethods([httpPOST])] [MVCHTTPMethods([httpPOST])]
procedure CreateCustomer([MVCFromBody] const Customer: TCustomer); procedure CreateCustomer([MVCFromBody] const Customer: TCustomer);
@ -74,6 +74,7 @@ begin
Render201Created(); Render201Created();
except except
TMVCActiveRecord.CurrentConnection.Rollback; TMVCActiveRecord.CurrentConnection.Rollback;
raise;
end; end;
end; end;

View File

@ -1,4 +1,4 @@
// *************************************************************************** // ***************************************************************************
// //
// Delphi MVC Framework // Delphi MVC Framework
// //
@ -90,13 +90,10 @@ type
FGetItemMethod: TRttiMethod; FGetItemMethod: TRttiMethod;
FGetCountMethod: TRttiMethod; FGetCountMethod: TRttiMethod;
protected protected
procedure GetItemAsTValue(const AIndex: Integer; out AValue: TValue);
function GetItem(const AIndex: Integer): TObject;
function GetEnumerator: TDuckListEnumerator; function GetEnumerator: TDuckListEnumerator;
function GetOwnsObjects: Boolean; function GetOwnsObjects: Boolean;
procedure SetOwnsObjects(const AValue: Boolean); procedure SetOwnsObjects(const AValue: Boolean);
procedure Add(const AObject: TObject); procedure Add(const AObject: TObject);
function Count: Integer;
procedure Clear; procedure Clear;
function WrappedObject: TObject; function WrappedObject: TObject;
@ -112,6 +109,9 @@ type
destructor Destroy; override; destructor Destroy; override;
function IsWrappedList: Boolean; overload; function IsWrappedList: Boolean; overload;
function Count: Integer;
procedure GetItemAsTValue(const AIndex: Integer; out AValue: TValue);
function GetItem(const AIndex: Integer): TObject;
class function CanBeWrappedAsList(const AObjectAsDuck: TObject): Boolean; overload; static; class function CanBeWrappedAsList(const AObjectAsDuck: TObject): Boolean; overload; static;
class function CanBeWrappedAsList(const AObjectAsDuck: TObject; out AMVCList: IMVCList): Boolean; overload; static; class function CanBeWrappedAsList(const AObjectAsDuck: TObject; out AMVCList: IMVCList): Boolean; overload; static;
class function CanBeWrappedAsList(const AInterfaceAsDuck: IInterface): Boolean; overload; static; class function CanBeWrappedAsList(const AInterfaceAsDuck: IInterface): Boolean; overload; static;
@ -292,7 +292,6 @@ begin
raise EMVCDuckTypingException.Create raise EMVCDuckTypingException.Create
('Cannot find method Indexed property "Items" or method "GetItem" or method "GetElement" in the Duck Object.'); ('Cannot find method Indexed property "Items" or method "GetItem" or method "GetElement" in the Duck Object.');
GetItemAsTValue(AIndex, lValue); GetItemAsTValue(AIndex, lValue);
// lValue := FGetItemMethod.Invoke(FObjectAsDuck, [AIndex]);
if lValue.Kind = tkInterface then if lValue.Kind = tkInterface then
begin begin
@ -431,7 +430,7 @@ var
List: IMVCList; List: IMVCList;
begin begin
if AObjectAsDuck is TDuckTypedList then if AObjectAsDuck is TDuckTypedList then
Exit(AObjectAsDuck as TDuckTypedList); Exit(TDuckTypedList(AObjectAsDuck));
Result := nil; Result := nil;
List := TDuckTypedList.Create(AObjectAsDuck, AOwnsObject); List := TDuckTypedList.Create(AObjectAsDuck, AOwnsObject);
if List.IsWrappedList then if List.IsWrappedList then

File diff suppressed because it is too large Load Diff