Martin Schreiber wrote:
On Thursday 11 February 2016 17:17:32 Graeme Geldenhuys wrote:
Now the other thing that surprised be, I thought TPersistent.Assign()
automatically handles protected properties (via RTTI) - thinking that
descendants automatically get such functionality for free. But reviewing
the RTL code, I see Assign() and AssignTo() really has no functionality
implemented by default.

Correct, it depends much on the actual classes what should happen by
calling "assign()". So "tpersistent" does nothing by default.

Martin

Is there any sample codes to copy published properties (via RTTI) ?
e.g. psuedo code below

  for i := 0 to properties.count -1 do begin
     case properties[i].type of
vtInteger : properties[i].AsInteger := Source.PropertiesByName(Properties[i].Name).AsInteger;
       vtdouble : ....
       vtString : ...
     end;
  end;

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to