In Delphi XE ist Boolean übrigens nicht tkInteger sondern tkEnumeration.
Kleines Codebeispiel (ging übrigens schon vor der neuen
Rtti, genauere Typenbestimmungen von Properties zu machen mit dieser Methode):
Delphi-Quellcode:
type
TFoo = class(TPersistent)
private
FActive: Boolean;
FLastUpdate: TDateTime;
public
property Active: Boolean read FActive write FActive;
property LastUpdate: TDateTime read FLastUpdate write FLastUpdate;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
c: TRttiContext;
p: TRttiProperty;
begin
for p in c.GetType(TFoo).GetProperties do
begin
case p.PropertyType.TypeKind of
tkEnumeration:
begin
if p.PropertyType.Handle = TypeInfo(Boolean) then
begin
ShowMessage('Boolean found!');
end;
end;
tkFloat:
begin
if p.PropertyType.Handle = TypeInfo(TDate) then
ShowMessage('TDate found')
else if p.PropertyType.Handle = TypeInfo(TTime) then
ShowMessage('TTime found')
else if p.PropertyType.Handle = TypeInfo(TDateTime) then
ShowMessage('TDateTime found');
end;
end;
end;
end;