Skip to content

Commit

Permalink
New template language: TemplatePro
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Aug 7, 2024
1 parent 7e28bc9 commit 21bdc7c
Show file tree
Hide file tree
Showing 3 changed files with 1,240 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ interface
[MVCPath('/api/customers')]
TCustomersController = class(TMVCController)
public
[MVCPath]
[MVCHTTPMethods([httpGET])]
procedure GetCustomers([MVCFromQueryString('rql','')] RQLFilter: String);

[MVCPath('/($ID)')]
[MVCHTTPMethods([httpGET])]
procedure GetCustomerByID(const ID: Integer);

[MVCPath]
[MVCHTTPMethods([httpGET])]
procedure GetCustomers([MVCFromQueryString('rql','')] RQLFilter: String);

[MVCPath]
[MVCHTTPMethods([httpPOST])]
procedure CreateCustomer([MVCFromBody] const Customer: TCustomer);
Expand Down Expand Up @@ -74,6 +74,7 @@ procedure TCustomersController.BulkCreateCustomers(const Customers: TObjectList<
Render201Created();
except
TMVCActiveRecord.CurrentConnection.Rollback;
raise;
end;
end;

Expand Down
11 changes: 5 additions & 6 deletions sources/MVCFramework.DuckTyping.pas
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ***************************************************************************
// ***************************************************************************
//
// Delphi MVC Framework
//
Expand Down Expand Up @@ -90,13 +90,10 @@ TDuckTypedList = class(TInterfacedObject, IMVCList)
FGetItemMethod: TRttiMethod;
FGetCountMethod: TRttiMethod;
protected
procedure GetItemAsTValue(const AIndex: Integer; out AValue: TValue);
function GetItem(const AIndex: Integer): TObject;
function GetEnumerator: TDuckListEnumerator;
function GetOwnsObjects: Boolean;
procedure SetOwnsObjects(const AValue: Boolean);
procedure Add(const AObject: TObject);
function Count: Integer;
procedure Clear;

function WrappedObject: TObject;
Expand All @@ -112,6 +109,9 @@ TDuckTypedList = class(TInterfacedObject, IMVCList)
destructor Destroy; override;

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; out AMVCList: IMVCList): Boolean; overload; static;
class function CanBeWrappedAsList(const AInterfaceAsDuck: IInterface): Boolean; overload; static;
Expand Down Expand Up @@ -292,7 +292,6 @@ function TDuckTypedList.GetItem(const AIndex: Integer): TObject;
raise EMVCDuckTypingException.Create
('Cannot find method Indexed property "Items" or method "GetItem" or method "GetElement" in the Duck Object.');
GetItemAsTValue(AIndex, lValue);
// lValue := FGetItemMethod.Invoke(FObjectAsDuck, [AIndex]);

if lValue.Kind = tkInterface then
begin
Expand Down Expand Up @@ -431,7 +430,7 @@ class function TDuckTypedList.Wrap(const AObjectAsDuck: TObject; const AOwnsObje
List: IMVCList;
begin
if AObjectAsDuck is TDuckTypedList then
Exit(AObjectAsDuck as TDuckTypedList);
Exit(TDuckTypedList(AObjectAsDuck));
Result := nil;
List := TDuckTypedList.Create(AObjectAsDuck, AOwnsObject);
if List.IsWrappedList then
Expand Down
Loading

0 comments on commit 21bdc7c

Please sign in to comment.