Einzelnen Beitrag anzeigen

Benutzerbild von Stevie
Stevie

Registriert seit: 12. Aug 2003
Ort: Soest
4.012 Beiträge
 
Delphi 10.1 Berlin Enterprise
 
#11

AW: Verständnisfrage zu TValue

  Alt 5. Mär 2020, 09:53
Delphi-Quellcode:
function RestoreProperty(aInstance: TObject; const aPropertyName: string; const aValue: TValue): Boolean;
var
  prop: TRttiProperty;
begin
  prop := TType.GetType(aInstance.ClassType).GetProperty(aPropertyName);
  prop.SetValue(aInstance, aValue.Convert(prop.PropertyType.Handle));
end;
Stefan
“Simplicity, carried to the extreme, becomes elegance.” Jon Franklin

Delphi Sorcery - DSharp - Spring4D - TestInsight
  Mit Zitat antworten Zitat