From c55bfea9da676bb94db6c9a28cca3e06c28948fd Mon Sep 17 00:00:00 2001 From: Daniele Teti Date: Mon, 15 Feb 2021 18:28:45 +0100 Subject: [PATCH] [+] Small improvement in custom type serialisers --- ...ework.Serializer.JsonDataObjects.CustomTypes.pas | 8 ++++---- sources/MVCFramework.pas | 8 ++++---- unittests/general/Several/DMVCFrameworkTests.dpr | 3 ++- unittests/general/Several/DMVCFrameworkTests.dproj | 13 +++++++++++++ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/sources/MVCFramework.Serializer.JsonDataObjects.CustomTypes.pas b/sources/MVCFramework.Serializer.JsonDataObjects.CustomTypes.pas index edf03386..7634df63 100644 --- a/sources/MVCFramework.Serializer.JsonDataObjects.CustomTypes.pas +++ b/sources/MVCFramework.Serializer.JsonDataObjects.CustomTypes.pas @@ -600,7 +600,7 @@ var lJsonArray: TJsonArray; i: Integer; begin - lList := AElementValue.AsObject as TList; + lList := TMVCListOfString(AElementValue.AsObject); lList.Clear; lJsonArray := ASerializerObject as TJsonArray; for i := 0 to lJsonArray.Count - 1 do @@ -650,7 +650,7 @@ var lJsonArray: TJsonArray; i: Integer; begin - lList := AElementValue.AsObject as TList; + lList := TMVCListOfInteger(AElementValue.AsObject); lList.Clear; lJsonArray := ASerializerObject as TJsonArray; for i := 0 to lJsonArray.Count - 1 do @@ -701,7 +701,7 @@ var lJsonArray: TJsonArray; i: Integer; begin - lList := AElementValue.AsObject as TList; + lList := TMVCListOfBoolean(AElementValue.AsObject); lList.Clear; lJsonArray := ASerializerObject as TJsonArray; for i := 0 to lJsonArray.Count - 1 do @@ -751,7 +751,7 @@ var lJsonArray: TJsonArray; i: Integer; begin - lList := AElementValue.AsObject as TList; + lList := TMVCListOfDouble(AElementValue.AsObject); lList.Clear; lJsonArray := ASerializerObject as TJsonArray; for i := 0 to lJsonArray.Count - 1 do diff --git a/sources/MVCFramework.pas b/sources/MVCFramework.pas index 3d2851cf..ec95924a 100644 --- a/sources/MVCFramework.pas +++ b/sources/MVCFramework.pas @@ -2766,10 +2766,10 @@ begin begin try AHandled := ExecuteAction(ASender, ARequest, AResponse); -// if not AHandled then -// begin -// AResponse.ContentStream := nil; -// end; + if not AHandled then + begin + AResponse.ContentStream := nil; + end; except on E: Exception do begin diff --git a/unittests/general/Several/DMVCFrameworkTests.dpr b/unittests/general/Several/DMVCFrameworkTests.dpr index db28dfe1..9bcff68b 100644 --- a/unittests/general/Several/DMVCFrameworkTests.dpr +++ b/unittests/general/Several/DMVCFrameworkTests.dpr @@ -50,7 +50,8 @@ uses FDConnectionConfigU in 'webmodules\FDConnectionConfigU.pas', StandaloneServerTestU in '..\StandaloneServer\StandaloneServerTestU.pas', StandAloneServerWebModuleTest in '..\StandaloneServer\StandAloneServerWebModuleTest.pas' {TestWebModule2: TWebModule}, - MVCFramework.Commons in '..\..\..\sources\MVCFramework.Commons.pas'; + MVCFramework.Commons in '..\..\..\sources\MVCFramework.Commons.pas', + MVCFramework.Serializer.JsonDataObjects.CustomTypes in '..\..\..\sources\MVCFramework.Serializer.JsonDataObjects.CustomTypes.pas'; {$R *.RES} diff --git a/unittests/general/Several/DMVCFrameworkTests.dproj b/unittests/general/Several/DMVCFrameworkTests.dproj index 996cd885..857b251e 100644 --- a/unittests/general/Several/DMVCFrameworkTests.dproj +++ b/unittests/general/Several/DMVCFrameworkTests.dproj @@ -219,6 +219,7 @@ TWebModule + Base @@ -333,6 +334,12 @@ true + + + DMVCFrameworkTests.rsm + true + + true @@ -356,6 +363,12 @@ true + + + DMVCFrameworkTests.exe + true + + 1