Delphi How to get default value for property using RTTI -


if have class this:

tserversettings = class(tsettings) strict private     fhttpport : integer; published     property httpport : integer read fhttpport write fhttpport default 80; end; 

how can default attribute of httpport property using rtti?

like this:

{$apptype console}  uses   system.typinfo;  type   tmyclass = class   strict private     fmyvalue: integer;   published     property myvalue: integer read fmyvalue default 42;   end;  var   obj: tmyclass;   propinfo: ppropinfo;  begin   obj := tmyclass.create;   propinfo := getpropinfo(obj, 'myvalue');   writeln(propinfo.default); end. 

note class stands, in question, broken. system not automatically initialise properties default value when instance created. need add constructor class that.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -