Ao gerar minha classe, obtenho os erros:
unit UPedido;
interface
uses
Pkg.Json.DTO, System.Generics.Collections, REST.Json.Types;
{$M+}
type
TProdutos = class
private
FDescricao: string;
FId: Integer;
FQtde: Integer;
FUnitario: Double;
published
property Descricao: string read FDescricao write FDescricao;
property Id: Integer read FId write FId;
property Qtde: Integer read FQtde write FQtde;
property Unitario: Double read FUnitario write FUnitario;
end;
TPedido = class(TJsonDTO)
private
FCliente: string;
FId: Integer;
[JSONName('produtos'), JSONMarshalled(False)]
FProdutosArray: TArray;
[GenericListReflect]
FProdutos: TObjectList;
function GetProdutos: TObjectList;
protected
function GetAsJson: string; override;
published
property Cliente: string read FCliente write FCliente;
property Id: Integer read FId write FId;
property Produtos: TObjectList read GetProdutos;
public
destructor Destroy; override;
end;
implementation
{ TPedido }
destructor TPedido.Destroy;
begin
GetProdutos.Free;
inherited;
end;
function TPedido.GetProdutos: TObjectList;
begin
Result := ObjectList(FProdutos, FProdutosArray);
end;
function TPedido.GetAsJson: string;
begin
RefreshArray(FProdutos, FProdutosArray);
Result := inherited;
end;
end.
Ao gerar minha classe, obtenho os erros:
[dcc32 Error] UPedido.pas(34): E2137 Method 'GetAsJson' not found in base class
[dcc32 Error] UPedido.pas(60): E2003 Undeclared identifier: 'RefreshArray'
Classe Gerada:
unit UPedido;
interface
uses
Pkg.Json.DTO, System.Generics.Collections, REST.Json.Types;
{$M+}
type
TProdutos = class
private
FDescricao: string;
FId: Integer;
FQtde: Integer;
FUnitario: Double;
published
property Descricao: string read FDescricao write FDescricao;
property Id: Integer read FId write FId;
property Qtde: Integer read FQtde write FQtde;
property Unitario: Double read FUnitario write FUnitario;
end;
TPedido = class(TJsonDTO)
private
FCliente: string;
FId: Integer;
[JSONName('produtos'), JSONMarshalled(False)]
FProdutosArray: TArray;
[GenericListReflect]
FProdutos: TObjectList;
function GetProdutos: TObjectList;
protected
function GetAsJson: string; override;
published
property Cliente: string read FCliente write FCliente;
property Id: Integer read FId write FId;
property Produtos: TObjectList read GetProdutos;
public
destructor Destroy; override;
end;
implementation
{ TPedido }
destructor TPedido.Destroy;
begin
GetProdutos.Free;
inherited;
end;
function TPedido.GetProdutos: TObjectList;
begin
Result := ObjectList(FProdutos, FProdutosArray);
end;
function TPedido.GetAsJson: string;
begin
RefreshArray(FProdutos, FProdutosArray);
Result := inherited;
end;
end.