Einzelnen Beitrag anzeigen

Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#22

AW: TSQLiteDatabase: A SQLite3 Database Wrapper

  Alt 21. Jul 2016, 16:09
So etwas z.B.
Delphi-Quellcode:
unit Unit2;

interface

uses
  System.IniFiles;

type
  TEinstellungen = class abstract
  private
    procedure SetFoo( const Value: string );
    function GetFoo: string;
  protected
    function GetValue( const Key: string ): string; virtual; abstract;
    procedure SetValue( const Key, Value: string ); virtual; abstract;
  public
    property Foo: string read GetFoo write SetFoo;
  end;

  TIniEinstellungen = class( TEinstellungen )
  private
    FIniFile: TMemIniFile;
  protected
    function GetValue( const Key: string ): string; override;
    procedure SetValue( const Key: string; const Value: string ); override;
  public
    constructor Create( const IniFileName: string );
    destructor Destroy; override;
  end;

implementation

{ TEinstellungen }

function TEinstellungen.GetFoo: string;
begin
  Result := GetValue( 'foo' );
end;

procedure TEinstellungen.SetFoo( const Value: string );
begin
  SetValue( 'foo', Value );
end;

{ TIniEinstellungen }

constructor TIniEinstellungen.Create( const IniFileName: string );
begin
  inherited Create;
  FIniFile := TMemIniFile.Create( IniFileName );
end;

destructor TIniEinstellungen.Destroy;
begin
  FIniFile.Free;
  inherited;
end;

function TIniEinstellungen.GetValue( const Key: string ): string;
begin
  Result := FIniFile.ReadString( 'Default', Key, '' );
end;

procedure TIniEinstellungen.SetValue( const Key, Value: string );
begin
  FIniFile.WriteString( 'Default', Key, Value );
  FIniFile.UpdateFile;
end;

end.
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat