Mega Code Archive

 
Categories / Delphi / Examples
 

Rtti - determining property information

Question: A RTTI question - it is possible to determine if a certain property is Read-Only, Write-Only or stored? Answer: The following code checks whether a property can be written to, read or whether it is stored. function IsWriteProp(Info: PPropInfo) : Boolean; begin Result := Assigned(Info) and (Info^.SetProc<>nil) end; function IsReadProp : Boolean; begin Result := Assigned(Info) and (Info^.GetProc<>nil) end; function IsStoredProp : Boolean; begin Result := Assigned(Info) and TYPINFO.IsStoredProp(FObj, Info) end;