Einzelnen Beitrag anzeigen

Benutzerbild von Stevie
Stevie

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

AW: Kann man den Typ vererbter Properties oder Methoden ändern

  Alt 19. Okt 2011, 12:48
Du meinst in etwa so?

Delphi-Quellcode:
type
  TBaseDataModule = class

  end;

  TBaseDataForm = class
  private
    FDataModule: TBaseDataModule;
  protected
    function GetDataModule: TBaseDataModule;
    procedure SetDataModule(const Value: TBaseDataModule);
  public
    property DataModule: TBaseDataModule read GetDataModule write SetDataModule;
  end;

  TCustomerDataModule = class(TBaseDataModule)

  end;

  TCustomerDataForm = class(TBaseDataForm)
  protected
    function GetDataModule: TCustomerDataModule;
    procedure SetDataModule(const Value: TCustomerDataModule);
  public
    property DataModule: TCustomerDataModule read GetDataModule write SetDataModule;
  end;

{ TBaseDataForm }

function TBaseDataForm.GetDataModule: TBaseDataModule;
begin
  Result := FDataModule
end;

procedure TBaseDataForm.SetDataModule(const Value: TBaseDataModule);
begin
  FDataModule := Value;
end;

{ TCustomerDataForm }

function TCustomerDataForm.GetDataModule: TCustomerDataModule;
begin
  Result := inherited GetDataModule as TCustomerDataModule;
end;

procedure TCustomerDataForm.SetDataModule(const Value: TCustomerDataModule);
begin
  inherited SetDataModule(Value);
end;
Stefan
“Simplicity, carried to the extreme, becomes elegance.” Jon Franklin

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