Skip to content

Commit

Permalink
Updated Neon library to v1.3.0
Browse files Browse the repository at this point in the history
Updated JWT library to 2.5.2
Added 2 new methods to the IWiRLConfigurationNeon interface: AddSerializer & RemoveSerializer
Fixed TArrayDataSetWriter with the new Neon configuration
  • Loading branch information
paolo-rossi committed Jan 23, 2020
1 parent f960d2c commit 460343b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Libs/Neon
Submodule Neon updated 33 files
+0 −1 Demos/Main/Demo.Forms.Main.pas
+0 −1 Demos/Main/Demo.Forms.Serialization.Custom.pas
+35 −4 Demos/Main/Demo.Forms.Serialization.Delphi.dfm
+23 −2 Demos/Main/Demo.Forms.Serialization.Delphi.pas
+0 −1 Demos/Main/Demo.Forms.Serialization.Schema.pas
+10 −1 Demos/Main/Demo.Frame.Configuration.pas
+51 −22 Demos/Main/Demo.Neon.Serializers.pas
+1 −35 Demos/Main/NeonMainDemo.dproj
+1 −1 Source/Neon.Core.DynamicTypes.pas
+14 −93 Source/Neon.Core.Persistence.JSON.pas
+2 −6 Source/Neon.Core.Persistence.Swagger.pas
+116 −40 Source/Neon.Core.Persistence.pas
+39 −21 Source/Neon.Core.Serializers.DB.pas
+148 −0 Source/Neon.Core.Serializers.RTL.pas
+116 −0 Source/Neon.Core.Serializers.VCL.pas
+1 −1 Source/Neon.Core.TypeInfo.pas
+877 −861 Source/Neon.Core.Utils.pas
+1 −0 Tests/Data/TDataTests.Persons.json
+1 −0 Tests/Data/TTestReferenceTypes.TestPersonAnsi.json
+22 −0 Tests/Data/TTestReferenceTypes.TestPersonPretty.json
+1 −0 Tests/Data/TTestReferenceTypes.TestPersonUnicode.json
+27 −17 Tests/Neon.Tests.Framework.dpr
+12 −11 Tests/Neon.Tests.Framework.dproj
+70 −0 Tests/Source/Neon.Data.Tests.dfm
+56 −0 Tests/Source/Neon.Data.Tests.pas
+141 −0 Tests/Source/Neon.Serializers.Tests.pas
+166 −0 Tests/Source/Neon.Tests.CustomSerializers.pas
+122 −0 Tests/Source/Neon.Tests.Entities.pas
+29 −20 Tests/Source/Neon.Tests.Serializer.pas
+120 −0 Tests/Source/Neon.Tests.Types.Reference.pas
+110 −0 Tests/Source/Neon.Tests.Types.Simple.pas
+124 −0 Tests/Source/Neon.Tests.Types.Value.pas
+158 −0 Tests/Source/Neon.Tests.Utils.pas
31 changes: 27 additions & 4 deletions Source/Core/WiRL.Configuration.Neon.pas
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ interface
function SetIgnoreFieldPrefix(AValue: Boolean): IWiRLConfigurationNeon;
function SetUseUTCDate(AValue: Boolean): IWiRLConfigurationNeon;
function SetPrettyPrint(AValue: Boolean): IWiRLConfigurationNeon;
function AddSerializer(ASerializerClass: TCustomSerializerClass): IWiRLConfigurationNeon;
function RemoveSerializer(ASerializerClass: TCustomSerializerClass): IWiRLConfigurationNeon;
end;

[Implements(IWiRLConfigurationNeon)]
Expand Down Expand Up @@ -61,6 +63,9 @@ TWiRLConfigurationNeon = class(TWiRLConfigurationNRef, IWiRLConfigurationNeon)
function SetUseUTCDate(AValue: Boolean): IWiRLConfigurationNeon;
function SetPrettyPrint(AValue: Boolean): IWiRLConfigurationNeon;

function AddSerializer(ASerializerClass: TCustomSerializerClass): IWiRLConfigurationNeon;
function RemoveSerializer(ASerializerClass: TCustomSerializerClass): IWiRLConfigurationNeon;

function GetSerializers: TNeonSerializerRegistry;

function GetNeonConfig: INeonConfiguration;
Expand All @@ -77,7 +82,9 @@ TWiRLConfigurationNeon = class(TWiRLConfigurationNRef, IWiRLConfigurationNeon)
implementation

uses
System.TypInfo;
System.TypInfo,
Neon.Core.Serializers.RTL,
Neon.Core.Serializers.DB;

{ TWiRLConfigurationNeon }

Expand All @@ -104,6 +111,12 @@ class function TWiRLConfigurationNeon.Pretty: IWiRLConfigurationNeon;
Result.SetPrettyPrint(True);
end;

function TWiRLConfigurationNeon.AddSerializer(ASerializerClass: TCustomSerializerClass): IWiRLConfigurationNeon;
begin
FSerializers.RegisterSerializer(ASerializerClass);
Result := Self;
end;

class function TWiRLConfigurationNeon.Snake: IWiRLConfigurationNeon;
begin
Result := TWiRLConfigurationNeon.Create;
Expand All @@ -126,23 +139,33 @@ destructor TWiRLConfigurationNeon.Destroy;
function TWiRLConfigurationNeon.GetNeonConfig: INeonConfiguration;
begin
Result := TNeonConfiguration.Default;
Result.GetSerializers.Assign(FSerializers);
Result
.SetMembers(FMembers)
.SetMemberCase(FMemberCase)
.SetMemberCustomCase(FMemberCustomCase)
.SetVisibility(FVisibility)
.SetIgnoreFieldPrefix(FIgnoreFieldPrefix)
.SetUseUTCDate(FUseUTCDate)
.SetPrettyPrint(FPrettyPrint);

Result.GetSerializers.Assign(FSerializers);
.SetPrettyPrint(FPrettyPrint)
.GetSerializers
.RegisterSerializer(TGUIDSerializer)
.RegisterSerializer(TStreamSerializer)
.RegisterSerializer(TDataSetSerializer)
;
end;

function TWiRLConfigurationNeon.GetSerializers: TNeonSerializerRegistry;
begin
Result := FSerializers;
end;

function TWiRLConfigurationNeon.RemoveSerializer(ASerializerClass: TCustomSerializerClass): IWiRLConfigurationNeon;
begin
FSerializers.UnregisterSerializer(ASerializerClass);
Result := Self;
end;


function TWiRLConfigurationNeon.SetIgnoreFieldPrefix(AValue: Boolean): IWiRLConfigurationNeon;
begin
Expand Down
9 changes: 3 additions & 6 deletions Source/Data/FireDAC/WiRL.Data.FireDAC.Persistence.pas
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ class procedure TFireDACJSONPersistor.Base64Encode(ASource, ADestination: TStrea
{$ENDIF}
end;

class procedure TFireDACJSONPersistor.DataSetsToJSON(ASource: TFireDACDataSets;
ADestination: TJSONObject);
class procedure TFireDACJSONPersistor.DataSetsToJSON(ASource: TFireDACDataSets; ADestination: TJSONObject);
var
LPair: TFireDACDataSetPair;
LActive: Boolean;
Expand Down Expand Up @@ -238,8 +237,7 @@ class function TFireDACJSONPersistor.DataSetToJSON(const AName: string;
end;
end;

class procedure TFireDACJSONPersistor.JSONToDataSet(ASource: TJSONObject;
ADestination: TFDCustomMemTable);
class procedure TFireDACJSONPersistor.JSONToDataSet(ASource: TJSONObject; ADestination: TFDCustomMemTable);
var
LStrStream: TStringStream;
LBinStream: TMemoryStream;
Expand All @@ -258,8 +256,7 @@ class procedure TFireDACJSONPersistor.JSONToDataSet(ASource: TJSONObject;
end;
end;

class procedure TFireDACJSONPersistor.JSONToDataSets(ASource: TJSONObject;
ADestination: TFireDACDataSets);
class procedure TFireDACJSONPersistor.JSONToDataSets(ASource: TJSONObject; ADestination: TFireDACDataSets);
var
LJSONPair: TJSONPair;
LJSONData: TJSONObject;
Expand Down
8 changes: 6 additions & 2 deletions Source/Data/WiRL.Data.MessageBody.Default.pas
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ interface
WiRL.http.Accept.MediaType,
WiRL.Core.MessageBody.Classes,
WiRL.Core.MessageBodyReader,
WiRL.Core.MessageBodyWriter;
WiRL.Core.MessageBodyWriter,
WiRL.Configuration.Neon;

type
[Produces(TMediaType.APPLICATION_JSON)]
TArrayDataSetWriter = class(TMessageBodyWriter)
private
[Context] WiRLConfigurationNeon: TWiRLConfigurationNeon;
public
procedure WriteTo(const AValue: TValue; const AAttributes: TAttributeArray;
AMediaType: TMediaType; AHeaderFields: TWiRLHeaderList; AContentStream: TStream); override;
end;
Expand Down Expand Up @@ -86,7 +90,7 @@ procedure TArrayDataSetWriter.WriteTo(const AValue: TValue; const AAttributes: T
try
{ TODO -opaolo -c : LCurrent.Name can be empty and producing an JSON error 30/05/2017 16:26:09 }
for LCurrent in LData do
LResult.AddPair(LCurrent.Name, TNeon.ObjectToJSON(LCurrent));
LResult.AddPair(LCurrent.Name, TNeon.ObjectToJSON(LCurrent, WiRLConfigurationNeon.GetNeonConfig));

LStreamWriter.Write(TJSONHelper.ToJSON(LResult));
finally
Expand Down

0 comments on commit 460343b

Please sign in to comment.