string , , , GetStrProp SetStrProp TypInfo. GetObjectProp SetObjectProp.
if Supports(GetObjectProp(Obj, 'data'), IMyInterface, Intf) then
Intf.Go;
, , data TMyClass, :
(GetObjectProp(Obj, 'data') as TMyClass).Go;
, .
, TypInfo . , , , , IMyInterface; Go .
procedure GoAllProperties(Other: TObject);
var
Properties: PPropList;
nProperties: Integer;
Info: PPropInfo;
Obj: TObject;
Intf: IMyInterface;
Unk: IUnknown;
begin
nProperties := GetPropList(Other.ClassInfo, Properties);
if nProperties > 0 then try
SortPropList(Properties, nProperties);
for i := 0 to Pred(nProperties) do begin
Info := Properties^[i];
if not Assigned(Info.GetProc) then
continue;
case Info.PropType^^.Kind of
tkClass: begin
Obj := GetObjectProp(Other, Info);
if Supports(Obj, IMyInterface, Intf) then
Intf.Go;
end;
tkInterface: begin
Unk := GetInterfaceProp(Obj, Info);
if Supports(Unk, IMyInterface, Intf) then
Intf.Go;
end;
end;
end;
finally
FreeMem(Properties);
end;
end;