Einzelnen Beitrag anzeigen

exon

Registriert seit: 12. Mär 2010
8 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#3

AW: Klonen eines Interfaces

  Alt 22. Dez 2022, 08:05
hm, zusätzliche Variable InCloning, also so:


Code:
   TMyClass = class(TInterfacedObject, IMyInt)
   strict private
                fA: Boolean;
                fB: String;
      fChanged: Boolean;
      fInCloning: Boolean;
   private
      procedure SetA(AValue: Boolean);
      function GetA: Boolean;
      function GetB: String;
   public
      constructor Create;
      destructor Destroy(); override;
      function Clone: IMyInt;
      function Save: Boolean;
      property A: Boolean read GetA write SetA;
      property B: String read GetB;
   end;
....
procedure TMyClass.SetA(AValue: Boolean);
begin
   if fA <> AValue then
   begin
      if not fInCloning then
        fChanged := True;
      fA := AValue;
   end;
end;

function TMyClass.Clone: IMyInt;
begin
   fInCloning := True;
   try
      <bisheriger Clone-Code>
   finally
     fInCloning := False;
   end;
end;
  Mit Zitat antworten Zitat