Ich mach es z. B. so:
Delphi-Quellcode:
TtoTreeNodeAttribute = class(TtoCollectionItem)
private
FData: TtoData;
FName: String;
...
protected
procedure SetName(Value: String);
procedure SetData(Value: TtoData);
...
public
...
procedure AssignTo(Dest: TPersistent); override;
published
property Name: String read FName write SetName;
property Data: TtoData read FData write SetData;
...
end;
...
procedure TtoTreeNodeAttribute.AssignTo(Dest: TPersistent);
var
DestObj: TtoTreeNodeAttribute;
begin
inherited AssignTo(Dest);
if Dest is TtoTreeNodeAttribute then
begin
DestObj := TtoTreeNodeAttribute(Dest);
DestObj.BeginUpdate;
try
DestObj.FData.Assign(FData);
DestObj.FName := FName;
...
finally
DestObj.EndUpdate;
end;
end;
end;
procedure TtoTreeNodeAttribute.SetName(Value: String);
begin
if (FName <> Value) and (Value <> '') then
FName := Value;
end;
procedure TtoTreeNodeAttribute.SetData(Value: TtoData);
begin
FData.Assign(Value);
end;
...
Anmerkung: Die Methoden BeginUpdate() und EndUpdate() habe ich selbst implementiert weil es sie in in TPersistent nicht gibt. (Delphi 2009)