Please, help me.
I looked for exists questions and no found how i can get all published property of items (declared as Class) in dynamic array in delphi class (i use Delphi 7 IDE (i can’t use other version))
I have this code:
TObjectList = array of TObject;
TSubClass = class(TObject)
private
FFirstName: string;
FLastName: string;
FDOB: TDateTime;
FArray : TObjectList;
published
property FirstName: string read FFirstName write FFirstName;
property LastName: string read FLastName write FLastName;
property DOB: TDateTime read FDOB write FDOB;
property MyArray : TObjectList read FArray write FArray ;
end;
TListSubClass = array of TSubClass;
TPersonList = class(TObject)
private
FSubClasses: TListSubClass;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property SubClasses: TListSubClass read FSubClasses write FSubClasses;
end;
I have link to Elem of TPersonList class (MyVariable : TPersonList).
How i can using RTTI get all published property’s data of my FSubClasses and FArray array items?
How i can set new data to FSubClasses using RTTI?
Thank you,
Sergey.
Have a look at
GetDynArrayPropandGetPropListof unitTypInfo.GetDynArrayPropreturns a pointer to the underlying array, you can then cast it to the correct array type.GetPropListreturns a pointer to an array of property information to all properties of the class you pass in.The
TPropInforecord that you get back fromGetPropListhas information on the address of the getter and setter methods associated with a property, you can use them to call the getter or setter respectively.In general you should have a deeper look on the
TypInfounit in your Delphi help or at the online documentation:http://docwiki.embarcadero.com/VCL/en/TypInfo