mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
- Some cleanup, added first call to the sample project about the jsonrpc support for record types
This commit is contained in:
parent
66211feb75
commit
08bf440713
@ -330,6 +330,7 @@ type
|
|||||||
TMyEnum = (EnumItem1, EnumItem2, EnumItem3);
|
TMyEnum = (EnumItem1, EnumItem2, EnumItem3);
|
||||||
TMySet = set of TMyEnum;
|
TMySet = set of TMyEnum;
|
||||||
|
|
||||||
|
[MVCNameCase(ncCamelCase)]
|
||||||
TSimpleRecord = record
|
TSimpleRecord = record
|
||||||
StringProperty: String;
|
StringProperty: String;
|
||||||
IntegerProperty: Integer;
|
IntegerProperty: Integer;
|
||||||
@ -343,6 +344,7 @@ type
|
|||||||
SetProperty: TMySet;
|
SetProperty: TMySet;
|
||||||
class function Create: TSimpleRecord; overload; static;
|
class function Create: TSimpleRecord; overload; static;
|
||||||
class function Create(Value: Integer): TSimpleRecord; overload; static;
|
class function Create(Value: Integer): TSimpleRecord; overload; static;
|
||||||
|
function ToString: String;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TSimpleRecordDynArray = TArray<TSimpleRecord>;
|
TSimpleRecordDynArray = TArray<TSimpleRecord>;
|
||||||
@ -371,7 +373,7 @@ implementation
|
|||||||
uses
|
uses
|
||||||
System.SysUtils,
|
System.SysUtils,
|
||||||
System.Math,
|
System.Math,
|
||||||
RandomUtilsU, FireDAC.Comp.Client;
|
RandomUtilsU, FireDAC.Comp.Client, System.TypInfo;
|
||||||
|
|
||||||
{ TPerson }
|
{ TPerson }
|
||||||
|
|
||||||
@ -786,6 +788,31 @@ begin
|
|||||||
Result.CurrencyProperty := Value + Value div 1000;
|
Result.CurrencyProperty := Value + Value div 1000;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSimpleRecord.ToString: String;
|
||||||
|
function SetToString: String;
|
||||||
|
var
|
||||||
|
lEl: TMyEnum;
|
||||||
|
begin
|
||||||
|
for lEl in SetProperty do
|
||||||
|
begin
|
||||||
|
Result := Result + GetEnumName(typeinfo(TMyEnum), Ord(Self.EnumProperty)) + ',';
|
||||||
|
end;
|
||||||
|
Result := Result.Trim([',']);
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
Result :=
|
||||||
|
'StringProperty = ' + Self.StringProperty + sLineBreak +
|
||||||
|
'IntegerProperty = ' + Self.IntegerProperty.ToString + sLineBreak +
|
||||||
|
'FloatProperty = ' + Self.FloatProperty.ToString + sLineBreak +
|
||||||
|
'CurrencyProperty = ' + Self.CurrencyProperty.ToString + sLineBreak +
|
||||||
|
'DateProperty = ' + DateToStr(Self.DateProperty) + sLineBreak +
|
||||||
|
'TimeProperty = ' + TimeToStr(Self.TimeProperty) + sLineBreak +
|
||||||
|
'DateTimeProperty = ' + FormatDateTime('yyyy-mm-dd hh:nn:ss', Self.DateTimeProperty) + sLineBreak +
|
||||||
|
'BooleanProperty = ' + BoolToStr(Self.BooleanProperty, True) + sLineBreak +
|
||||||
|
'EnumProperty = ' + GetEnumName(typeinfo(TMyEnum), Ord(Self.EnumProperty)) + sLineBreak +
|
||||||
|
'SetProperty = ' + SetToString + sLineBreak;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TComplexRecord }
|
{ TComplexRecord }
|
||||||
|
|
||||||
class function TComplexRecord.Create: TComplexRecord;
|
class function TComplexRecord.Create: TComplexRecord;
|
||||||
|
@ -17,7 +17,7 @@ object MainForm: TMainForm
|
|||||||
Top = 0
|
Top = 0
|
||||||
Width = 842
|
Width = 842
|
||||||
Height = 604
|
Height = 604
|
||||||
ActivePage = TabSheet1
|
ActivePage = TabSheet6
|
||||||
Align = alClient
|
Align = alClient
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object TabSheet1: TTabSheet
|
object TabSheet1: TTabSheet
|
||||||
@ -523,6 +523,31 @@ object MainForm: TMainForm
|
|||||||
OnClick = btnGenericExcWithoutCustomHandlingClick
|
OnClick = btnGenericExcWithoutCustomHandlingClick
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
object TabSheet6: TTabSheet
|
||||||
|
Caption = 'Using record as parameters'
|
||||||
|
ImageIndex = 3
|
||||||
|
DesignSize = (
|
||||||
|
834
|
||||||
|
576)
|
||||||
|
object btnSingleRec: TButton
|
||||||
|
Left = 16
|
||||||
|
Top = 16
|
||||||
|
Width = 185
|
||||||
|
Height = 41
|
||||||
|
Caption = 'Returning Single Record'
|
||||||
|
TabOrder = 0
|
||||||
|
OnClick = btnSingleRecClick
|
||||||
|
end
|
||||||
|
object lbLogRec: TListBox
|
||||||
|
Left = 216
|
||||||
|
Top = 16
|
||||||
|
Width = 601
|
||||||
|
Height = 545
|
||||||
|
Anchors = [akLeft, akTop, akRight, akBottom]
|
||||||
|
ItemHeight = 13
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object DataSource1: TDataSource
|
object DataSource1: TDataSource
|
||||||
DataSet = FDMemTable1
|
DataSet = FDMemTable1
|
||||||
|
@ -92,6 +92,9 @@ type
|
|||||||
btnGenericExcWithCustomHandling: TButton;
|
btnGenericExcWithCustomHandling: TButton;
|
||||||
btnGenericExcWithCustomHAndling2: TButton;
|
btnGenericExcWithCustomHAndling2: TButton;
|
||||||
btnGenericExcWithoutCustomHandling: TButton;
|
btnGenericExcWithoutCustomHandling: TButton;
|
||||||
|
TabSheet6: TTabSheet;
|
||||||
|
btnSingleRec: TButton;
|
||||||
|
lbLogRec: TListBox;
|
||||||
procedure btnSubstractClick(Sender: TObject);
|
procedure btnSubstractClick(Sender: TObject);
|
||||||
procedure btnReverseStringClick(Sender: TObject);
|
procedure btnReverseStringClick(Sender: TObject);
|
||||||
procedure edtGetCustomersClick(Sender: TObject);
|
procedure edtGetCustomersClick(Sender: TObject);
|
||||||
@ -116,6 +119,7 @@ type
|
|||||||
procedure btnGenericExcWithCustomHandlingClick(Sender: TObject);
|
procedure btnGenericExcWithCustomHandlingClick(Sender: TObject);
|
||||||
procedure btnGenericExcWithCustomHAndling2Click(Sender: TObject);
|
procedure btnGenericExcWithCustomHAndling2Click(Sender: TObject);
|
||||||
procedure btnGenericExcWithoutCustomHandlingClick(Sender: TObject);
|
procedure btnGenericExcWithoutCustomHandlingClick(Sender: TObject);
|
||||||
|
procedure btnSingleRecClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
FExecutor: IMVCJSONRPCExecutor;
|
FExecutor: IMVCJSONRPCExecutor;
|
||||||
// FExecutor2: IMVCJSONRPCExecutor;
|
// FExecutor2: IMVCJSONRPCExecutor;
|
||||||
@ -140,7 +144,7 @@ uses
|
|||||||
MVCFramework.DataSet.Utils,
|
MVCFramework.DataSet.Utils,
|
||||||
BusinessObjectsU,
|
BusinessObjectsU,
|
||||||
System.Math,
|
System.Math,
|
||||||
System.Rtti;
|
System.Rtti, CommonTypesU;
|
||||||
|
|
||||||
{$R *.dfm}
|
{$R *.dfm}
|
||||||
|
|
||||||
@ -371,6 +375,22 @@ begin
|
|||||||
// lbPerson.Items.Add('DOB:'.PadRight(15) + DateToStr(lJSON.D['dob']));
|
// lbPerson.Items.Add('DOB:'.PadRight(15) + DateToStr(lJSON.D['dob']));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainForm.btnSingleRecClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
lReq: IJSONRPCRequest;
|
||||||
|
lResp: IJSONRPCResponse;
|
||||||
|
lPersonRec: TPersonRec;
|
||||||
|
begin
|
||||||
|
lReq := TJSONRPCRequest.Create;
|
||||||
|
lReq.Method := 'GetPersonRec';
|
||||||
|
lReq.RequestID := Random(1000);
|
||||||
|
lResp := FExecutor.ExecuteRequest('/jsonrpc', lReq);
|
||||||
|
lPersonRec := TMVCRecordUtils.JSONObjectToRecord<TPersonRec>(lResp.ResultAsJSONObject);
|
||||||
|
lbLogRec.Items.Add('** TPersonRec **');
|
||||||
|
lbLogRec.Items.Add(lResp.ResultAsJSONObject.ToJSON());
|
||||||
|
lbLogRec.Items.Add(lPersonRec.ToString);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainForm.btnSubstractClick(Sender: TObject);
|
procedure TMainForm.btnSubstractClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
lReq: IJSONRPCRequest;
|
lReq: IJSONRPCRequest;
|
||||||
|
@ -33,54 +33,9 @@ uses
|
|||||||
BusinessObjectsU,
|
BusinessObjectsU,
|
||||||
FireDAC.Comp.Client,
|
FireDAC.Comp.Client,
|
||||||
MVCFramework.Serializer.Commons,
|
MVCFramework.Serializer.Commons,
|
||||||
MVCFramework.Commons, MVCFramework, MVCFramework.JSONRPC;
|
MVCFramework.Commons, MVCFramework, MVCFramework.JSONRPC, CommonTypesU;
|
||||||
|
|
||||||
type
|
type
|
||||||
TPersonType = (ptFamily, ptFriend, ptColleague, ptAcquaintance);
|
|
||||||
TPersonTypes = set of TPersonType;
|
|
||||||
[MVCNameCase(ncCamelCase)]
|
|
||||||
TChildRec = record
|
|
||||||
ChildName: String;
|
|
||||||
PersonType: TPersonType;
|
|
||||||
ChildSurname: String;
|
|
||||||
end;
|
|
||||||
|
|
||||||
[MVCNameCase(ncCamelCase)]
|
|
||||||
TPersonRec = record
|
|
||||||
Name: String;
|
|
||||||
Surname: String;
|
|
||||||
// [MVCNameAs('personAge')]
|
|
||||||
Age: Integer;
|
|
||||||
Child: TChildRec;
|
|
||||||
PersonType: TPersonType;
|
|
||||||
InitialTypes: TPersonTypes;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPeopleList = TArray<TPersonRec>;
|
|
||||||
|
|
||||||
TPeopleArray = array [0..1] of TPersonRec;
|
|
||||||
|
|
||||||
TVendorProxy = record
|
|
||||||
Code: String;
|
|
||||||
FileAs: String;
|
|
||||||
IsDefault: Boolean;
|
|
||||||
InActive: Boolean;
|
|
||||||
Name: String;
|
|
||||||
OID: Integer;
|
|
||||||
UsageNotes: String;
|
|
||||||
end;
|
|
||||||
TVendorProxyList = TArray<TVendorProxy>;
|
|
||||||
|
|
||||||
TVendorPersonLink = record
|
|
||||||
PersonOID: Integer;
|
|
||||||
DefaultVendorOID: Integer;
|
|
||||||
LinkedVendorList: TArray<Integer>;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TVendorProxiesAndLinks = record
|
|
||||||
VendorList: TArray<TVendorProxy>;
|
|
||||||
PersonLinkList: TArray<TVendorPersonLink>;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TMyObject = class
|
TMyObject = class
|
||||||
private
|
private
|
||||||
@ -322,6 +277,8 @@ begin
|
|||||||
Result.Age := 42;
|
Result.Age := 42;
|
||||||
Result.Child.ChildName := 'Mattia';
|
Result.Child.ChildName := 'Mattia';
|
||||||
Result.Child.ChildSurname := 'Teti';
|
Result.Child.ChildSurname := 'Teti';
|
||||||
|
Result.PersonType := ptFriend;
|
||||||
|
Result.InitialTypes := [ptFriend, ptColleague];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// function TMyObject.GetPeopleDataset: TFDMemTable;
|
// function TMyObject.GetPeopleDataset: TFDMemTable;
|
||||||
|
@ -5,7 +5,8 @@ uses
|
|||||||
MainClientFormU in 'MainClientFormU.pas' {MainForm},
|
MainClientFormU in 'MainClientFormU.pas' {MainForm},
|
||||||
MVCFramework.JSONRPC.Client in '..\..\sources\MVCFramework.JSONRPC.Client.pas',
|
MVCFramework.JSONRPC.Client in '..\..\sources\MVCFramework.JSONRPC.Client.pas',
|
||||||
RandomUtilsU in '..\commons\RandomUtilsU.pas',
|
RandomUtilsU in '..\commons\RandomUtilsU.pas',
|
||||||
BusinessObjectsU in '..\commons\BusinessObjectsU.pas';
|
BusinessObjectsU in '..\commons\BusinessObjectsU.pas',
|
||||||
|
CommonTypesU in 'CommonTypesU.pas';
|
||||||
|
|
||||||
{$R *.res}
|
{$R *.res}
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@ uses
|
|||||||
MVCFramework.JSONRPC in '..\..\sources\MVCFramework.JSONRPC.pas',
|
MVCFramework.JSONRPC in '..\..\sources\MVCFramework.JSONRPC.pas',
|
||||||
BusinessObjectsU in '..\commons\BusinessObjectsU.pas',
|
BusinessObjectsU in '..\commons\BusinessObjectsU.pas',
|
||||||
RandomUtilsU in '..\commons\RandomUtilsU.pas',
|
RandomUtilsU in '..\commons\RandomUtilsU.pas',
|
||||||
MainDM in '..\articles_crud_server\MainDM.pas' {dmMain: TDataModule};
|
MainDM in '..\articles_crud_server\MainDM.pas' {dmMain: TDataModule},
|
||||||
|
CommonTypesU in 'CommonTypesU.pas';
|
||||||
|
|
||||||
{$R *.res}
|
{$R *.res}
|
||||||
|
|
||||||
|
@ -1701,10 +1701,8 @@ var
|
|||||||
lOutInteger: Integer;
|
lOutInteger: Integer;
|
||||||
lInt: Integer;
|
lInt: Integer;
|
||||||
lOutInteger64: Int64;
|
lOutInteger64: Int64;
|
||||||
ChildObject: TObject;
|
lChildObject: TObject;
|
||||||
lRef: PByte;
|
lRef: PByte;
|
||||||
I: Integer;
|
|
||||||
lInnerName: String;
|
|
||||||
lInnerType: TRttiType;
|
lInnerType: TRttiType;
|
||||||
lCtx: TRttiContext;
|
lCtx: TRttiContext;
|
||||||
lArr: TArray<TValue>;
|
lArr: TArray<TValue>;
|
||||||
@ -1733,6 +1731,7 @@ var
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
begin
|
begin
|
||||||
|
lChildObject := nil;
|
||||||
case AJsonObject[APropertyName].Typ of
|
case AJsonObject[APropertyName].Typ of
|
||||||
jdtNone:
|
jdtNone:
|
||||||
Exit;
|
Exit;
|
||||||
@ -1920,13 +1919,13 @@ begin
|
|||||||
case AValue.Kind of
|
case AValue.Kind of
|
||||||
tkInterface:
|
tkInterface:
|
||||||
begin
|
begin
|
||||||
JsonObjectToObject(AJsonObject.O[APropertyName], ChildObject,
|
JsonObjectToObject(AJsonObject.O[APropertyName], lChildObject,
|
||||||
GetSerializationType(ChildObject, AType), AIgnored);
|
GetSerializationType(lChildObject, AType), AIgnored);
|
||||||
end;
|
end;
|
||||||
tkClass:
|
tkClass:
|
||||||
begin
|
begin
|
||||||
JsonObjectToObject(AJsonObject.O[APropertyName], ChildObject, GetSerializationType(ChildObject, AType),
|
JsonObjectToObject(AJsonObject.O[APropertyName], lChildObject,
|
||||||
AIgnored);
|
GetSerializationType(lChildObject, AType), AIgnored);
|
||||||
end;
|
end;
|
||||||
tkString, tkUString:
|
tkString, tkUString:
|
||||||
begin
|
begin
|
||||||
@ -1971,23 +1970,8 @@ begin
|
|||||||
Format('Wrong array size, expected %d, got %d',
|
Format('Wrong array size, expected %d, got %d',
|
||||||
[AValue.GetArrayLength, AJSONObject.A[APropertyName].Count]));
|
[AValue.GetArrayLength, AJSONObject.A[APropertyName].Count]));
|
||||||
end;
|
end;
|
||||||
var lt := ARTTIField.FieldType.Handle;
|
|
||||||
SetLength(lArr, AJSONObject.A[APropertyName].Count);
|
SetLength(lArr, AJSONObject.A[APropertyName].Count);
|
||||||
BuildATValueArrayFromJSONArrayOfJSONObject;
|
BuildATValueArrayFromJSONArrayOfJSONObject;
|
||||||
// lInnerType := lCtx.GetType(AValue.GetArrayElement(0).TypeInfo);
|
|
||||||
// lInnerTypeAsRecord := lInnerType.AsRecord;
|
|
||||||
// for I := 0 to Length(lArr) - 1 do
|
|
||||||
// begin
|
|
||||||
// lBuff := AValue.GetReferenceToRawArrayElement(I);
|
|
||||||
// lJItem := AJSONObject.A[APropertyName].Items[I].ObjectValue;
|
|
||||||
// JSONObjectToRecord(
|
|
||||||
// lJItem,
|
|
||||||
// lInnerTypeAsRecord,
|
|
||||||
// lBuff
|
|
||||||
// );
|
|
||||||
// TValue.MakeWithoutCopy(lBuff, lInnerType.Handle, lArr[I]);
|
|
||||||
// FreeMem(lBuff, lInnerType.TypeSize);
|
|
||||||
// end;
|
|
||||||
AValue := TValue.FromArray(ARTTIField.FieldType.Handle, lArr);
|
AValue := TValue.FromArray(ARTTIField.FieldType.Handle, lArr);
|
||||||
end
|
end
|
||||||
else if AValue.Kind = tkDynArray then
|
else if AValue.Kind = tkDynArray then
|
||||||
@ -1995,24 +1979,12 @@ begin
|
|||||||
SetLength(lArr, AJSONObject.A[APropertyName].Count);
|
SetLength(lArr, AJSONObject.A[APropertyName].Count);
|
||||||
if Length(lArr) > 0 then
|
if Length(lArr) > 0 then
|
||||||
begin
|
begin
|
||||||
//DT: This code is required to know the typeinfo of an element of the dynamic array
|
//DT: This line is required to know the typeinfo of an element of the dynamic array
|
||||||
//still not created. This is required because the dynamic array is still
|
//still not created (see BuildATValueArrayFromJSONArrayOfJSONObject).
|
||||||
//not dimensioned, for a static array this is not necessary.
|
//This is required because the dynamic array is still
|
||||||
|
//not dimensioned here, for a static array this is not necessary.
|
||||||
AValue := TValue.FromArray(ARTTIField.FieldType.Handle, [TValue.Empty]);
|
AValue := TValue.FromArray(ARTTIField.FieldType.Handle, [TValue.Empty]);
|
||||||
BuildATValueArrayFromJSONArrayOfJSONObject;
|
BuildATValueArrayFromJSONArrayOfJSONObject;
|
||||||
// lInnerType := lCtx.GetType(AValue.GetArrayElement(0).TypeInfo);
|
|
||||||
// lInnerTypeAsRecord := lInnerType.AsRecord;
|
|
||||||
// for I := 0 to Length(lArr) - 1 do
|
|
||||||
// begin
|
|
||||||
// lJItem := AJSONObject.A[APropertyName].Items[I].ObjectValue;
|
|
||||||
// JSONObjectToRecord(
|
|
||||||
// lJItem,
|
|
||||||
// lInnerTypeAsRecord,
|
|
||||||
// lBuff
|
|
||||||
// );
|
|
||||||
// TValue.MakeWithoutCopy(lBuff, lInnerType.Handle, lArr[I]);
|
|
||||||
// FreeMem(lBuff, lInnerType.TypeSize);
|
|
||||||
// end;
|
|
||||||
end;
|
end;
|
||||||
AValue := TValue.FromArray(ARTTIField.FieldType.Handle, lArr);
|
AValue := TValue.FromArray(ARTTIField.FieldType.Handle, lArr);
|
||||||
end
|
end
|
||||||
@ -2047,12 +2019,6 @@ begin
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
lName := TMVCSerializerHelper.ApplyNameCase(GetNameCase(ADataSet, ANameCase), lName { Field.FieldName } );
|
lName := TMVCSerializerHelper.ApplyNameCase(GetNameCase(ADataSet, ANameCase), lName { Field.FieldName } );
|
||||||
// case GetNameCase(ADataSet, ANameCase) of
|
|
||||||
// ncLowerCase:
|
|
||||||
// name := LowerCase(Field.FieldName);
|
|
||||||
// ncUpperCase:
|
|
||||||
// name := UpperCase(Field.FieldName);
|
|
||||||
// end;
|
|
||||||
|
|
||||||
if not AJsonObject.Contains(lName) then
|
if not AJsonObject.Contains(lName) then
|
||||||
continue;
|
continue;
|
||||||
@ -2384,25 +2350,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TMVCJsonDataObjectsSerializer.JSONObjectToNestedRecordfield(
|
procedure TMVCJsonDataObjectsSerializer.JSONObjectToNestedRecordField(
|
||||||
const JSONObject: TJsonObject; RecordFieldRTTIType: TRttiField; const TypeOffset: Integer; var Buffer: PByte);
|
const JSONObject: TJsonObject; RecordFieldRTTIType: TRttiField; const TypeOffset: Integer; var Buffer: PByte);
|
||||||
var
|
var
|
||||||
lChildType: TRttiType;
|
lChildType: TRttiType;
|
||||||
lChildFieldOffset: Integer;
|
lChildFieldOffset: Integer;
|
||||||
lKeyName: String;
|
lKeyName: String;
|
||||||
lValue: TValue;
|
lValue: TValue;
|
||||||
|
lField: TRttiField;
|
||||||
begin
|
begin
|
||||||
if RecordFieldRTTIType.FieldType.TypeKind <> tkRecord then
|
if RecordFieldRTTIType.FieldType.TypeKind <> tkRecord then
|
||||||
begin
|
begin
|
||||||
raise EMVCDeserializationException.Create('Only record type allowed');
|
raise EMVCDeserializationException.Create('Only record type allowed');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//Recupero il tipo e l'offset
|
|
||||||
lChildType := RecordFieldRTTIType.FieldType;
|
lChildType := RecordFieldRTTIType.FieldType;
|
||||||
lChildFieldOffset := RecordFieldRTTIType.Offset + TypeOffset;
|
lChildFieldOffset := RecordFieldRTTIType.Offset + TypeOffset;
|
||||||
|
|
||||||
//recupero i campi
|
for lField in lChildType.GetFields do
|
||||||
for var lField in lChildType.GetFields do
|
|
||||||
begin
|
begin
|
||||||
lKeyName := TMVCSerializerHelper.GetKeyName(lField, lChildType);
|
lKeyName := TMVCSerializerHelper.GetKeyName(lField, lChildType);
|
||||||
lValue := lField.GetValue(Buffer + lChildFieldOffset);
|
lValue := lField.GetValue(Buffer + lChildFieldOffset);
|
||||||
@ -2417,9 +2382,9 @@ procedure TMVCJsonDataObjectsSerializer.JSONObjectToNestedRecordFieldStatic(
|
|||||||
const TypeOffset: Integer; var Buffer: PByte);
|
const TypeOffset: Integer; var Buffer: PByte);
|
||||||
var
|
var
|
||||||
lChildType: TRttiType;
|
lChildType: TRttiType;
|
||||||
// lChildFieldOffset: Integer;
|
|
||||||
lKeyName: String;
|
lKeyName: String;
|
||||||
lValue: TValue;
|
lValue: TValue;
|
||||||
|
lField: TRttiField;
|
||||||
begin
|
begin
|
||||||
if RecordFieldRTTIType.FieldType.TypeKind <> tkRecord then
|
if RecordFieldRTTIType.FieldType.TypeKind <> tkRecord then
|
||||||
begin
|
begin
|
||||||
@ -2431,7 +2396,7 @@ begin
|
|||||||
// lChildFieldOffset := RecordFieldRTTIType.Offset + TypeOffset;
|
// lChildFieldOffset := RecordFieldRTTIType.Offset + TypeOffset;
|
||||||
|
|
||||||
//recupero i campi
|
//recupero i campi
|
||||||
for var lField in lChildType.GetFields do
|
for lField in lChildType.GetFields do
|
||||||
begin
|
begin
|
||||||
lKeyName := TMVCSerializerHelper.GetKeyName(lField, lChildType);
|
lKeyName := TMVCSerializerHelper.GetKeyName(lField, lChildType);
|
||||||
lValue := lField.GetValue(Buffer); // + lChildFieldOffset);
|
lValue := lField.GetValue(Buffer); // + lChildFieldOffset);
|
||||||
|
Loading…
Reference in New Issue
Block a user