Does anyone have an idea how I can make TValue using the link to the source data? In my serialization project, I use (as suggested in XML-Serialization ) a generic serializer that stores TValues ββin an internal tree structure (similar to MemberMap in the example).
This tree of elements should also be used to create a form of dynamic configuration and data management. My idea was to define a property for the data:
TDataModel <T> = class {...} private FData : TValue; function GetData : T; procedure SetData (Value : T); public property Data : T read GetData write SetData; end;
Implementation of GetData, SetData methods:
procedure TDataModel <T>.SetData (Value : T); begin FData := TValue.From <T> (Value); end; procedure TDataModel <T>.GetData : T; begin Result := FData.AsType <T>; end;
Unfortunately, the TValue.From method always makes a copy of the source data. Therefore, whenever the application makes changes to the data, the DataModel is not updated, and vice versa, if I change my DataModel in a dynamic form, the original data will not be affected. Of course, I could always use the Data property before and after changing something, but since I use a lot of Rtti inside my DataModel, I donβt want to do this at any time.
Maybe someone has a better deal?
rtti delphi delphi-2010 tvalue
Christian metzler
source share