Du meinst dein Assign sieht ungefähr so aus?
Delphi-Quellcode:
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.Classes,
System.SysUtils;
type
TMyClass =
class( TPersistent )
private
FData:
string;
public
procedure Assign( Source: TPersistent );
override;
public
property Data:
string read FData
write FData;
end;
procedure TMyClass.Assign( Source: TPersistent );
begin
if ( Source
is TMyClass )
then
begin
FData := TMyClass( Source ).FData;
end
else
inherited;
end;
var
a, b: TMyClass;
begin
try
a :=
nil;
b :=
nil;
try
a := TMyClass.Create();
b := TMyClass.Create();
a.Data := '
Foo';
b.Assign(a);
WriteLn(b.Data);
finally
a.Free;
b.Free;
end;
except
on E:
Exception do
Writeln( E.ClassName, '
: ', E.
Message );
end;
end.