Einzelnen Beitrag anzeigen

Benutzerbild von haentschman
haentschman

Registriert seit: 24. Okt 2006
Ort: Seifhennersdorf / Sachsen
5.297 Beiträge
 
Delphi 12 Athens
 
#2

AW: Superobject und Objekte

  Alt 2. Mai 2017, 05:35
Moin...
Warum steht ihr so auf Records. In Verbindung mit Klassen und Properties gibt es immer Probleme. Imho erst Recht mit Serialisieren. (Sichwort Beispiel: Der linken Seite kann nichts zugewiesen werden.)

Versuch es mal hiermit:
Delphi-Quellcode:
type
  TOptionsOpts = (ooOne, ooTwo, ooThree);

  TOptionsData = class
  private
    FVal1: WideString;
    FVal2: Integer;
    FVal3: Double;
    FVal4: TOptionsOpts;
  public
    property Val1: WideString read FVal1 write FVal1;
    property Val2: Integer read FVal2 write FVal2;
    property Val3: Double read FVal3 write FVal3;
    property Val4: TOptionsOpts read FVal4 write FVal4;
  end;

  TOptions = class
  private
    FData: TOptionsData;
  protected
  public
    procedure ClearData;
    procedure ResetToDefault;
    procedure SaveToJson(Filename: WideString);
    procedure LoadFromJson(Filename: WideString);
  published
    constructor Create;
    destructor Destroy; override;
    property Data: TOptionsData read FData write FData;
  end;

implementation

constructor TOptions.Create;
begin
  FData := TOptionsData.Create;
end;

destructor TOptions.Destroy;
begin
  FData.Free;
  inherited;
end;
...
  Mit Zitat antworten Zitat