Folgende Eigenschaften und Felder konnte ich ermitteln:
Code:
=> Todl<odNumerator.TodNumerator>:
*****PROP*****
Items
Items: TObjectList<odNumerator.TodNumerator>
*****PROP*****
OwnsObjects
Capacity
Count
OnNotify
*****VAR*****
FOwnsObjects
FItems
FCount
FComparer
FOnNotify
odName
odClass
odId
odCT
ComponentCount
ComponentIndex
ComponentState
ComponentStyle
DesignInfo
VCLComObject
Name
Tag
*****VAR*****
FItems
FItems: TObjectList<odNumerator.TodNumerator>
FodName
FodClass
FodId
FodCT
FOwner
FName
FTag
FComponents
FFreeNotifies
FFreeNotifies: TList
FDesignInfo
FComponentState
FVCLComObject
FComponentStyle
FSortedComponents
Ich habe jetzt keine Idee, wie ich an die einzelnen Items heran komme und werde in dem Fall doch auf Generics verzichten.
Vielleicht könnte man auf eine Funktion zugreifen, aber das wird mir dann zu kompliziert.
Falls jemand damit herumspielen möchte, hier meine Funktion (schnell gestrickt und etwas unsauber):
Delphi-Quellcode:
function TodProp.GetProps(O: TObject; Deep: Integer):
String;
var
Context: TRttiContext;
RttiType: TRttiType;
PropInfo: TRttiProperty;
FieldInfo: TRttiField;
Attr: TCustomAttribute;
Value: TValue;
SO: TObject;
procedure Write(S:
String);
begin
S := DeepString(Deep) + S;
Result := Result + S + #13#10;
OutputDebugString(PChar(S));
end;
begin
Result := '
';
if (
not Assigned(O))
then
Exit;
if Deep = 0
then
Write('
=> ' + O.ClassName + '
:');
Inc(Deep);
Write('
');
Write('
*****PROP*****');
Context := TRttiContext.Create;
RttiType := Context.GetType(O.ClassType);
if Assigned(RttiType)
then
begin
for PropInfo
in RttiType.GetProperties
do
begin
if PropInfo.
Name = '
ComObject'
then
Continue;
if PropInfo.
Name = '
Owner'
then
Continue;
if PropInfo.
Name = '
Parent'
then
Continue;
if PropInfo.
Name = '
Sport'
then
begin
Beep;
end;
Write(PropInfo.
Name);
case PropInfo.PropertyType.TypeKind
of
tkClass:
begin
Value := PropInfo.GetValue(O);
if (
not Value.IsEmpty)
then
begin
SO := Value.AsObject;
if (Assigned(SO))
and ((
not(SO
is TComponent))
or ((SO
as TComponent).Owner = O))
then
begin
Write(PropInfo.
Name + '
: ' + SO.ClassName);
Result := Result + GetProps(SO, Deep);
end;
end;
end;
end;
end;
end;
Write('
');
Write('
*****VAR*****');
Context := TRttiContext.Create;
RttiType := Context.GetType(O.ClassType);
if Assigned(RttiType)
then
begin
for FieldInfo
in RttiType.GetFields
do
begin
if FieldInfo.
Name = '
ComObject'
then
Continue;
if FieldInfo.
Name = '
Owner'
then
Continue;
if FieldInfo.
Name = '
Parent'
then
Continue;
if FieldInfo.
Name = '
Sport'
then
begin
Beep;
end;
Write(FieldInfo.
Name);
case FieldInfo.FieldType.TypeKind
of
tkClass:
begin
Value := FieldInfo.GetValue(O);
if (
not Value.IsEmpty)
then
begin
SO := Value.AsObject;
if (Assigned(SO))
and ((
not(SO
is TComponent))
or ((SO
as TComponent).Owner = O))
then
begin
Write(FieldInfo.
Name + '
: ' + SO.ClassName);
// Result := Result + GetFields(SO, Deep);
end;
end;
end;
end;
end;
end;
Write('
');
Dec(Deep);
Context.Free;
end;