// *** before: ***
uses
TypInfo;
// type information existed only for published members of a class, and
// only for properties: fields, methods and parameters were invisible
var
PropList: PPropList;
Count, I: Integer;
begin
Count := GetPropList(Person.ClassInfo, PropList);
for I := 0 to Count - 1 do
Writeln(PropList^[I]^.Name, ' = ', GetStrProp(Person, PropList^[I]));
end;
// *** in version 2010: ***
uses
Rtti;
var
Ctx: TRttiContext;
T: TRttiType;
F: TRttiField;
M: TRttiMethod;
P: TRttiProperty;
begin
Ctx := TRttiContext.Create;
T := Ctx.GetType(TPerson);
for F in T.GetFields do // fields of any visibility
Writeln(F.Name, ': ', F.FieldType.Name);
for P in T.GetProperties do
Writeln(P.Name, ' = ', P.GetValue(Person).ToString);
for M in T.GetMethods do // methods with their parameters
Writeln(M.Name, ' takes ', Length(M.GetParameters), ' parameters');
end;