You are not logged in.
Pages: 1
Hi all,
I'm trying to serialize some UI for several forms, for example Font settings, ListView columns (order, widths) and several string properties. Here is the record:
TFrmSerializerRec = packed record
Font: TFont;
LV: TListView;
Param1: string;
Param2: string;
end;
I'm writing record with ASerializer.AddRecordJSON and loading with RecordLoadJSON, problem is that I cannot register TFrmSerializerRec with RegisterCustomJSONSerializerFromText, I get error for TFont and TListView, I've tried registering both of them with RegisterClassForJSON, RegisterCustomJSONSerializerFromTextSimpleType and RegisterCustomSerializer but it all fails.
If I call ObjectToJson individually on Font and ListView it works.
I know I can write a custom serializer for this record but I'm wondering is there a way to use existing, system ones, since all those classes already work if called one by one (as opposed when called as a group in a record).
Thanks,
Igor
Offline
Class instance within records are not supported.
Records are not meant to host class instances!
How would you free them?
Use a TSynAutoCreateField class instead.
BTW, I think that serializing VCL objects is not very safe, since they would be created outside the application context.
Use it at your own risk!
Offline
>> So I'll use it same way as this record with these values I want to store?
Yes.
It will create the sub class instances for you, and release them within Destroy.
Nice and easy.
Offline
Pages: 1