Gracias Neftali, justamente estaba viendo las funciones que propones, les dejo un pequeño resumen de como lo estoy resolviendo, por si a alguno le interesa. Por ahora para ir tomando la idea estoy guardando los datos obtenidos en un array dinamico. Y con el procedimiento recursivo.
Código Delphi
[-]
GetPropertyList(Producto, tkProperties, 0);
procedure GetPropertyList(Obj: TObject; Filter: TTypeKinds; Counter: integer);
var
Names, Value, Tipo: string;
PInfo: PPropInfo;
PropList: PPropList;
Count, i, j: integer;
Ob: TObject;
begin
Count := GetPropList(Obj.ClassInfo, Filter, nil);
GetMem(PropList, Count * SizeOf(PPropInfo));
GetPropList(Obj.ClassInfo, Filter, PropList);
for i := 0 to Count -1 do
begin
Value := GetPropValue(Obj, Proplist[i].Name); PInfo := GetPropInfo(Obj, Proplist[i].Name); Names := UpperCase(Proplist[i].Name);
if PInfo <> nil then
begin
case PInfo^.PropType^.Kind of
tkUnknown: Tipo := 'Unknown';
tkInteger: Tipo := 'Integer';
tkChar: Tipo := 'Char';
tkEnumeration: Tipo := 'Enumeration';
tkFloat: Tipo := 'Float';
tkString: Tipo := 'String';
tkSet: Tipo := 'Set';
tkClass: Tipo := 'Class';
tkMethod: Tipo := 'Method';
tkWChar: Tipo := 'WChar';
tkLString: Tipo := 'LString';
tkWString: Tipo := 'WString';
tkVariant: Tipo := 'Variant';
tkArray: Tipo := 'Array';
tkRecord: Tipo := 'Record';
tkInterface: Tipo := 'Interface';
tkInt64: Tipo := 'Int64';
tkDynArray: Tipo := 'DynArray';
end;
end;
if Tipo = 'Class' then
begin
j := High(xmlArray) + 1;
SetLength(xmlArray, j + 1);
SetLength(xmlArray[j], 1);
xmlArray[j][0] := '<' + Names + '>';
Ob := GetObjectProp(Obj, Proplist[i].Name);
GetPropertyList(Ob, tkProperties, Counter + 1);
j := High(xmlArray) + 1;
SetLength(xmlArray, j + 1);
SetLength(xmlArray[j], 1);
xmlArray[j][0] := + '< /' + Names + '>';
end
else
begin
j := High(xmlArray) + 1;
SetLength(xmlArray, j + 1);
SetLength(xmlArray[j], 1);
xmlArray[j][0] := '<' + Names + '>' + Value + '< /' + Names + '>';
end;
end;
end;