Browse Source

Merge branch 'develop'

Unknown 6 years ago
parent
commit
7672e1a107

+ 6 - 3
Quick.Config.Base.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.5
   Version     : 1.5
   Created     : 26/01/2017
   Created     : 26/01/2017
-  Modified    : 25/01/2019
+  Modified    : 12/02/2019
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -65,6 +65,7 @@ type
   private
   private
     fCreateIfNotExists : Boolean;
     fCreateIfNotExists : Boolean;
     fSerializeLevel : TSerializeProperty;
     fSerializeLevel : TSerializeProperty;
+    fUseEnumNames : Boolean;
   protected
   protected
     procedure Load(cConfig : TAppConfig); virtual; abstract;
     procedure Load(cConfig : TAppConfig); virtual; abstract;
     procedure Save(cConfig : TAppConfig); virtual; abstract;
     procedure Save(cConfig : TAppConfig); virtual; abstract;
@@ -72,6 +73,7 @@ type
     constructor Create; virtual;
     constructor Create; virtual;
     property CreateIfNotExists : Boolean read fCreateIfNotExists write fCreateIfNotExists;
     property CreateIfNotExists : Boolean read fCreateIfNotExists write fCreateIfNotExists;
     property SerializeLevel : TSerializeProperty read fSerializeLevel write fSerializeLevel;
     property SerializeLevel : TSerializeProperty read fSerializeLevel write fSerializeLevel;
+    property UseEnumNames : Boolean read fUseEnumNames write fUseEnumNames;
   end;
   end;
 
 
   TApplyConfigEvent = procedure of object;
   TApplyConfigEvent = procedure of object;
@@ -123,6 +125,7 @@ constructor TAppConfigProvider.Create;
 begin
 begin
   fCreateIfNotExists := True;
   fCreateIfNotExists := True;
   fSerializeLevel := spPublished;
   fSerializeLevel := spPublished;
+  fUseEnumNames := True;
 end;
 end;
 
 
 { TAppConfig }
 { TAppConfig }
@@ -158,7 +161,7 @@ var
 begin
 begin
   Result := '';
   Result := '';
   try
   try
-    serializer := TJsonSerializer.Create(slPublishedProperty);
+    serializer := TJsonSerializer.Create(slPublishedProperty,fProvider.UseEnumNames);
     try
     try
       Result := serializer.ObjectToJSON(Self,fJsonIndent);
       Result := serializer.ObjectToJSON(Self,fJsonIndent);
     finally
     finally
@@ -174,7 +177,7 @@ var
   Serializer : TJsonSerializer;
   Serializer : TJsonSerializer;
 begin
 begin
   try
   try
-    serializer := TJsonSerializer.Create(slPublishedProperty);
+    serializer := TJsonSerializer.Create(slPublishedProperty,fProvider.UseEnumNames);
     try
     try
       serializer.JsonToObject(Self,json);
       serializer.JsonToObject(Self,json);
     finally
     finally

+ 4 - 4
Quick.Config.Json.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.5
   Version     : 1.5
   Created     : 21/10/2017
   Created     : 21/10/2017
-  Modified    : 25/01/2019
+  Modified    : 12/02/2019
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -163,7 +163,7 @@ end;
 procedure TAppConfigJsonProvider.Load(cConfig : TAppConfig);
 procedure TAppConfigJsonProvider.Load(cConfig : TAppConfig);
 var
 var
   json : TStrings;
   json : TStrings;
-  Serializer : TJsonSerializer;
+  serializer : TJsonSerializer;
 begin
 begin
   if (not FileExists(fFilename)) and (CreateIfNotExists) then
   if (not FileExists(fFilename)) and (CreateIfNotExists) then
   begin
   begin
@@ -175,7 +175,7 @@ begin
     json := TStringList.Create;
     json := TStringList.Create;
     try
     try
       json.LoadFromFile(fFilename);
       json.LoadFromFile(fFilename);
-      serializer := TJsonSerializer.Create(slPublishedProperty);
+      serializer := TJsonSerializer.Create(slPublishedProperty,UseEnumNames);
       try
       try
         //Streamer.Options := Streamer.Options + [jsoDateTimeAsString ,jsoUseFormatString];
         //Streamer.Options := Streamer.Options + [jsoDateTimeAsString ,jsoUseFormatString];
         //Streamer.DateTimeFormat := 'yyyy-mm-dd"T"hh:mm:ss.zz';
         //Streamer.DateTimeFormat := 'yyyy-mm-dd"T"hh:mm:ss.zz';
@@ -207,7 +207,7 @@ begin
   try
   try
     json := TStringList.Create;
     json := TStringList.Create;
     try
     try
-      serializer := TJsonSerializer.Create(TSerializeLevel.slPublishedProperty);
+      serializer := TJsonSerializer.Create(TSerializeLevel.slPublishedProperty,UseEnumNames);
       try
       try
         //Streamer.Options := Streamer.Options + [jsoDateTimeAsString ,jsoUseFormatString];
         //Streamer.Options := Streamer.Options + [jsoDateTimeAsString ,jsoUseFormatString];
         //Streamer.DateTimeFormat := 'yyyy-mm-dd"T"hh:mm:ss.zz';
         //Streamer.DateTimeFormat := 'yyyy-mm-dd"T"hh:mm:ss.zz';

+ 1 - 1
Quick.FileMonitor.pas

@@ -166,7 +166,7 @@ end;
 
 
 procedure TFileMonitor.SetEnabled(Status : Boolean);
 procedure TFileMonitor.SetEnabled(Status : Boolean);
 begin
 begin
-  if (Status = True) and (Started = False) then Start;
+  if (Status) and {$IFNDEF FPC}(not Started){$ELSE}(Suspended){$ENDIF} then Start;
 
 
   if fEnabled <> Status then
   if fEnabled <> Status then
   begin
   begin

+ 35 - 11
Quick.Json.Serializer.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.5
   Version     : 1.5
   Created     : 21/05/2018
   Created     : 21/05/2018
-  Modified    : 30/01/2019
+  Modified    : 12/02/2019
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -111,7 +111,7 @@ type
     procedure LoadSetProperty(aInstance : TObject; aPropInfo: PPropInfo; const aValue: string);
     procedure LoadSetProperty(aInstance : TObject; aPropInfo: PPropInfo; const aValue: string);
     {$ENDIF}
     {$ENDIF}
   public
   public
-    constructor Create(aSerializeLevel : TSerializeLevel);
+    constructor Create(aSerializeLevel : TSerializeLevel; aUseEnumNames : Boolean = True);
     property UseEnumNames : Boolean read fUseEnumNames write fUseEnumNames;
     property UseEnumNames : Boolean read fUseEnumNames write fUseEnumNames;
     {$IFNDEF FPC}
     {$IFNDEF FPC}
     function DeserializeDynArray(aTypeInfo : PTypeInfo; aObject : TObject; const aJsonArray: TJSONArray) : TValue;
     function DeserializeDynArray(aTypeInfo : PTypeInfo; aObject : TObject; const aJsonArray: TJSONArray) : TValue;
@@ -147,7 +147,7 @@ type
   private
   private
     procedure SetUseEnumNames(const Value: Boolean);
     procedure SetUseEnumNames(const Value: Boolean);
   public
   public
-    constructor Create(aSerializeLevel : TSerializeLevel);
+    constructor Create(aSerializeLevel: TSerializeLevel; aUseEnumNames : Boolean = True);
     destructor Destroy; override;
     destructor Destroy; override;
     property SerializeLevel : TSerializeLevel read fSerializeLevel;
     property SerializeLevel : TSerializeLevel read fSerializeLevel;
     property UseEnumNames : Boolean read fUseEnumNames write SetUseEnumNames;
     property UseEnumNames : Boolean read fUseEnumNames write SetUseEnumNames;
@@ -348,9 +348,30 @@ begin
               end;
               end;
             end
             end
           end;
           end;
+        tkRecord :
+          begin
+            json := TJSONObject.ParseJSONValue(member.ToJson) as TJSONObject;
+            try
+              rValue := DeserializeRecord(rField.GetValue(aRecord.GetReferenceToRawData),aObject,json);
+            finally
+              json.Free;
+            end;
+          end
       else
       else
         begin
         begin
-          rValue := DeserializeType(aObject,rField.FieldType.TypeKind,rField.FieldType.Handle,member.ToString);
+          //rValue := DeserializeType(aObject,rField.FieldType.TypeKind,rField.FieldType.Handle,member.ToJson);
+          {$IFNDEF FPC}
+          //avoid return unicode escaped chars if string
+          if rField.FieldType.TypeKind in [tkString, tkLString, tkWString, tkUString] then
+            {$IFDEF DELPHIRX103_UP}
+            rValue := DeserializeType(aObject,rField.FieldType.TypeKind,rField.FieldType.Handle,TJsonValue(member).value)
+            {$ELSE}
+            rValue := DeserializeType(aObject,rField.FieldType.TypeKind,rField.FieldType.Handle,member.JsonString.ToString)
+            {$ENDIF}
+            else rValue := DeserializeType(aObject,rField.FieldType.TypeKind,rField.FieldType.Handle,member.ToJSON);
+          {$ELSE}
+          rValue := DeserializeType(aObject,rField.FieldType.TypeKind,aName,member.ToJSON);
+          {$ENDIF}
         end;
         end;
       end;
       end;
       if not rValue.IsEmpty then rField.SetValue(aRecord.GetReferenceToRawData,rValue);
       if not rValue.IsEmpty then rField.SetValue(aRecord.GetReferenceToRawData,rValue);
@@ -362,10 +383,10 @@ begin
 end;
 end;
 {$ENDIF}
 {$ENDIF}
 
 
-constructor TRTTIJson.Create(aSerializeLevel: TSerializeLevel);
+constructor TRTTIJson.Create(aSerializeLevel : TSerializeLevel; aUseEnumNames : Boolean = True);
 begin
 begin
   fSerializeLevel := aSerializeLevel;
   fSerializeLevel := aSerializeLevel;
-  fUseEnumNames := True;
+  fUseEnumNames := aUseEnumNames;
 end;
 end;
 
 
 function TRTTIJson.DeserializeClass(aType: TClass; const aJson: TJSONObject): TObject;
 function TRTTIJson.DeserializeClass(aType: TClass; const aJson: TJSONObject): TObject;
@@ -592,7 +613,7 @@ begin
             {$ELSE}
             {$ELSE}
             rValue := DeserializeType(aObject,aProperty.PropertyType.TypeKind,aProperty.GetValue(aObject).TypeInfo,member.JsonString.ToString)
             rValue := DeserializeType(aObject,aProperty.PropertyType.TypeKind,aProperty.GetValue(aObject).TypeInfo,member.JsonString.ToString)
             {$ENDIF}
             {$ENDIF}
-            else rValue := DeserializeType(aObject,aProperty.PropertyType.TypeKind,aProperty.GetValue(aObject).TypeInfo,member.ToJSON);
+          else rValue := DeserializeType(aObject,aProperty.PropertyType.TypeKind,aProperty.GetValue(aObject).TypeInfo,member.ToJSON);
           {$ELSE}
           {$ELSE}
           rValue := DeserializeType(aObject,aProperty.PropertyType.TypeKind,aName,member.ToJSON);
           rValue := DeserializeType(aObject,aProperty.PropertyType.TypeKind,aName,member.ToJSON);
           if not rValue.IsEmpty then SetPropertyValue(aObject,aName,rValue);
           if not rValue.IsEmpty then SetPropertyValue(aObject,aName,rValue);
@@ -659,7 +680,9 @@ begin
           end
           end
           else
           else
           begin
           begin
-            if fUseEnumNames then TValue.Make(GetEnumValue(aTypeInfo,value),aTypeInfo, Result)
+            //if fUseEnumNames then TValue.Make(GetEnumValue(aTypeInfo,value),aTypeInfo, Result)
+            //  else TValue.Make(StrToInt(value),aTypeInfo, Result);
+            if not TryStrToInt(value,i) then TValue.Make(GetEnumValue(aTypeInfo,value),aTypeInfo, Result)
               else TValue.Make(StrToInt(value),aTypeInfo, Result);
               else TValue.Make(StrToInt(value),aTypeInfo, Result);
           end;
           end;
         end;
         end;
@@ -786,6 +809,7 @@ end;
 function TRTTIJson.GetPropertyValue(Instance : TObject; const PropertyName : string) : TValue;
 function TRTTIJson.GetPropertyValue(Instance : TObject; const PropertyName : string) : TValue;
 var
 var
   pinfo : PPropInfo;
   pinfo : PPropInfo;
+  enum : Integer;
 begin
 begin
   Result := nil;
   Result := nil;
   pinfo := GetPropInfo(Instance,PropertyName);
   pinfo := GetPropInfo(Instance,PropertyName);
@@ -1366,15 +1390,15 @@ end;
 
 
 { TJsonSerializer}
 { TJsonSerializer}
 
 
-constructor TJsonSerializer.Create(aSerializeLevel: TSerializeLevel);
+constructor TJsonSerializer.Create(aSerializeLevel: TSerializeLevel; aUseEnumNames : Boolean = True);
 begin
 begin
   {$IFDEF FPC}
   {$IFDEF FPC}
   if aSerializeLevel = TSerializeLevel.slPublicProperty then raise EJsonSerializeError.Create('FreePascal RTTI only supports published properties');
   if aSerializeLevel = TSerializeLevel.slPublicProperty then raise EJsonSerializeError.Create('FreePascal RTTI only supports published properties');
   {$ENDIF}
   {$ENDIF}
   fSerializeLevel := aSerializeLevel;
   fSerializeLevel := aSerializeLevel;
   fUseEnumNames := True;
   fUseEnumNames := True;
-  fRTTIJson := TRTTIJson.Create(aSerializeLevel);
-  fRTTIJson.UseEnumNames := fUseEnumNames;
+  fRTTIJson := TRTTIJson.Create(aSerializeLevel,aUseEnumNames);
+  fRTTIJson.UseEnumNames := aUseEnumNames;
 end;
 end;
 
 
 function TJsonSerializer.JsonToObject(aType: TClass; const aJson: string): TObject;
 function TJsonSerializer.JsonToObject(aType: TClass; const aJson: string): TObject;

+ 3 - 3
samples/delphi/QuickConfig/ConfigToFile/Win64/Debug/config.json

@@ -23,7 +23,7 @@
         31,
         31,
         987
         987
     ],
     ],
-    "LastFilename": "library.txt",
+    "LastFilename": "niño library.txt",
     "WindowPos": {
     "WindowPos": {
         "PosX": 480,
         "PosX": 480,
         "PosY": 0
         "PosY": 0
@@ -111,11 +111,11 @@
         }
         }
     ],
     ],
     "Complex": {
     "Complex": {
-        "Id": 24336464,
+        "Id": 24270928,
         "Priority": "msHigh",
         "Priority": "msHigh",
         "Redundant": false
         "Redundant": false
     },
     },
-    "ModifyDate": "2019-01-26T01:38:10.340Z",
+    "ModifyDate": "2019-01-30T21:24:21.389Z",
     "Title": "a fresh title",
     "Title": "a fresh title",
     "SessionName": "First Session",
     "SessionName": "First Session",
     "WorkList": {
     "WorkList": {

+ 10 - 3
samples/firemonkey/QuickConfig/ConfigToFile/Main.pas

@@ -88,11 +88,18 @@ implementation
 
 
 
 
 procedure TMainForm.btnLoadJsonClick(Sender: TObject);
 procedure TMainForm.btnLoadJsonClick(Sender: TObject);
+var
+  NewConfig : TMyConfig;
 begin
 begin
   meInfo.Lines.Add('Load ConfigReg');
   meInfo.Lines.Add('Load ConfigReg');
-  ConfigJson.Load;
-  meInfo.Lines.Add(ConfigJson.ToJSON);
-  if TestConfig(configtest,ConfigJson) then meInfo.Lines.Add('Test passed successfully!');
+  NewConfig := TMyConfig.Create(ConfigJson.Provider.Filename,ConfigJson.Provider.ReloadIfFileChanged);
+  try
+    NewConfig.Load;
+    meInfo.Lines.Add(NewConfig.ToJSON);
+    if TestConfig(configtest,NewConfig) then meInfo.Lines.Add('Test passed successfully!');
+  finally
+    NewConfig.Free;
+  end;
 end;
 end;
 
 
 procedure TMainForm.btnSaveJsonClick(Sender: TObject);
 procedure TMainForm.btnSaveJsonClick(Sender: TObject);

+ 2 - 358
samples/firemonkey/QuickConfig/ConfigToFile/Win64/Debug/config.json

@@ -29,86 +29,6 @@
         "PosY": 0
         "PosY": 0
     },
     },
     "History": [
     "History": [
-        {
-            "Id": 0,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 1,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 2,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 3,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 4,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 5,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 6,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 7,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 8,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 9,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 10,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 11,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 12,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 13,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 14,
-            "Priority": "msLow",
-            "Redundant": true
-        },
-        {
-            "Id": 15,
-            "Priority": "msLow",
-            "Redundant": true
-        },
         {
         {
             "Id": 0,
             "Id": 0,
             "Priority": "msLow",
             "Priority": "msLow",
@@ -191,291 +111,15 @@
         }
         }
     ],
     ],
     "Complex": {
     "Complex": {
-        "Id": 269991728,
+        "Id": 236568368,
         "Priority": "msHigh",
         "Priority": "msHigh",
         "Redundant": false
         "Redundant": false
     },
     },
-    "ModifyDate": "2019-01-25T23:28:02.895Z",
+    "ModifyDate": "2019-02-13T22:42:52.302Z",
     "Title": "a fresh title",
     "Title": "a fresh title",
     "SessionName": "First Session",
     "SessionName": "First Session",
     "WorkList": {
     "WorkList": {
         "List": [
         "List": [
-            {
-                "Name": "Process 0",
-                "Active": false
-            },
-            {
-                "Name": "Process 1",
-                "Active": false
-            },
-            {
-                "Name": "Process 2",
-                "Active": false
-            },
-            {
-                "Name": "Process 3",
-                "Active": false
-            },
-            {
-                "Name": "Process 4",
-                "Active": false
-            },
-            {
-                "Name": "Process 5",
-                "Active": false
-            },
-            {
-                "Name": "Process 6",
-                "Active": false
-            },
-            {
-                "Name": "Process 7",
-                "Active": false
-            },
-            {
-                "Name": "Process 8",
-                "Active": false
-            },
-            {
-                "Name": "Process 9",
-                "Active": false
-            },
-            {
-                "Name": "Process 10",
-                "Active": false
-            },
-            {
-                "Name": "Process 11",
-                "Active": false
-            },
-            {
-                "Name": "Process 12",
-                "Active": false
-            },
-            {
-                "Name": "Process 13",
-                "Active": false
-            },
-            {
-                "Name": "Process 14",
-                "Active": false
-            },
-            {
-                "Name": "Process 15",
-                "Active": false
-            },
-            {
-                "Name": "Process 16",
-                "Active": false
-            },
-            {
-                "Name": "Process 17",
-                "Active": false
-            },
-            {
-                "Name": "Process 18",
-                "Active": false
-            },
-            {
-                "Name": "Process 19",
-                "Active": false
-            },
-            {
-                "Name": "Process 20",
-                "Active": false
-            },
-            {
-                "Name": "Process 21",
-                "Active": false
-            },
-            {
-                "Name": "Process 22",
-                "Active": false
-            },
-            {
-                "Name": "Process 0",
-                "Active": false
-            },
-            {
-                "Name": "Process 1",
-                "Active": false
-            },
-            {
-                "Name": "Process 2",
-                "Active": false
-            },
-            {
-                "Name": "Process 3",
-                "Active": false
-            },
-            {
-                "Name": "Process 4",
-                "Active": false
-            },
-            {
-                "Name": "Process 5",
-                "Active": false
-            },
-            {
-                "Name": "Process 6",
-                "Active": false
-            },
-            {
-                "Name": "Process 7",
-                "Active": false
-            },
-            {
-                "Name": "Process 8",
-                "Active": false
-            },
-            {
-                "Name": "Process 9",
-                "Active": false
-            },
-            {
-                "Name": "Process 10",
-                "Active": false
-            },
-            {
-                "Name": "Process 11",
-                "Active": false
-            },
-            {
-                "Name": "Process 12",
-                "Active": false
-            },
-            {
-                "Name": "Process 13",
-                "Active": false
-            },
-            {
-                "Name": "Process 14",
-                "Active": false
-            },
-            {
-                "Name": "Process 15",
-                "Active": false
-            },
-            {
-                "Name": "Process 16",
-                "Active": false
-            },
-            {
-                "Name": "Process 17",
-                "Active": false
-            },
-            {
-                "Name": "Process 18",
-                "Active": false
-            },
-            {
-                "Name": "Process 19",
-                "Active": false
-            },
-            {
-                "Name": "Process 20",
-                "Active": false
-            },
-            {
-                "Name": "Process 21",
-                "Active": false
-            },
-            {
-                "Name": "Process 22",
-                "Active": false
-            },
-            {
-                "Name": "Process 0",
-                "Active": false
-            },
-            {
-                "Name": "Process 1",
-                "Active": false
-            },
-            {
-                "Name": "Process 2",
-                "Active": false
-            },
-            {
-                "Name": "Process 3",
-                "Active": false
-            },
-            {
-                "Name": "Process 4",
-                "Active": false
-            },
-            {
-                "Name": "Process 5",
-                "Active": false
-            },
-            {
-                "Name": "Process 6",
-                "Active": false
-            },
-            {
-                "Name": "Process 7",
-                "Active": false
-            },
-            {
-                "Name": "Process 8",
-                "Active": false
-            },
-            {
-                "Name": "Process 9",
-                "Active": false
-            },
-            {
-                "Name": "Process 10",
-                "Active": false
-            },
-            {
-                "Name": "Process 11",
-                "Active": false
-            },
-            {
-                "Name": "Process 12",
-                "Active": false
-            },
-            {
-                "Name": "Process 13",
-                "Active": false
-            },
-            {
-                "Name": "Process 14",
-                "Active": false
-            },
-            {
-                "Name": "Process 15",
-                "Active": false
-            },
-            {
-                "Name": "Process 16",
-                "Active": false
-            },
-            {
-                "Name": "Process 17",
-                "Active": false
-            },
-            {
-                "Name": "Process 18",
-                "Active": false
-            },
-            {
-                "Name": "Process 19",
-                "Active": false
-            },
-            {
-                "Name": "Process 20",
-                "Active": false
-            },
-            {
-                "Name": "Process 21",
-                "Active": false
-            },
-            {
-                "Name": "Process 22",
-                "Active": false
-            },
             {
             {
                 "Name": "Process 0",
                 "Name": "Process 0",
                 "Active": false
                 "Active": false

+ 39 - 0
samples/fpc/QuickConfig/ConfigToRegistry/lib/x86_64-win64/umain.lfm

@@ -0,0 +1,39 @@
+object Form1: TForm1
+  Left = 379
+  Height = 457
+  Top = 208
+  Width = 592
+  Caption = 'Form1'
+  ClientHeight = 457
+  ClientWidth = 592
+  OnClose = FormClose
+  OnCreate = FormCreate
+  LCLVersion = '1.9.0.0'
+  object btnSaveJson: TButton
+    Left = 448
+    Height = 25
+    Top = 424
+    Width = 120
+    Caption = 'Save to Registry'
+    OnClick = btnSaveJsonClick
+    TabOrder = 0
+  end
+  object btnLoadJson: TButton
+    Left = 312
+    Height = 25
+    Top = 424
+    Width = 123
+    Caption = 'Load From Registry'
+    OnClick = btnLoadJsonClick
+    TabOrder = 1
+  end
+  object meInfo: TMemo
+    Left = 19
+    Height = 407
+    Top = 9
+    Width = 549
+    ReadOnly = True
+    ScrollBars = ssAutoBoth
+    TabOrder = 2
+  end
+end

+ 10 - 3
samples/fpc/QuickConfig/ConfigToRegistry/umain.pas

@@ -125,11 +125,18 @@ begin
 end;
 end;
 
 
 procedure TForm1.btnLoadJsonClick(Sender: TObject);
 procedure TForm1.btnLoadJsonClick(Sender: TObject);
+var
+  NewConfig : TMyConfig;
 begin
 begin
   meInfo.Lines.Add('Load ConfigJson');
   meInfo.Lines.Add('Load ConfigJson');
-  ConfigReg.Load;
-  meInfo.Lines.Add(ConfigReg.ToJSON);
-  if TestConfig(ConfigTest,ConfigReg) then meInfo.Lines.Add('Test passed successfully!');
+  NewConfig := TMyConfig.Create(ConfigReg.Provider.HRoot,ConfigReg.Provider.MainKey);
+  try
+    NewConfig.Load;
+    meInfo.Lines.Add(NewConfig.ToJSON);
+    if TestConfig(ConfigTest,NewConfig) then meInfo.Lines.Add('Test passed successfully!');
+  finally
+    NewConfig.Free;
+  end;
 end;
 end;
 
 
 function  TForm1.TestConfig(cConfig1, cConfig2 : TMyConfig) : Boolean;
 function  TForm1.TestConfig(cConfig1, cConfig2 : TMyConfig) : Boolean;