testproperties.out

来自「格式化源码的最新板」· OUT 代码 · 共 83 行

OUT
83
字号
unit testproperties;

interface

uses types;

type
  tfoo = class(TObject)
  private
    fibar, fibaz, fiwibble, fifish, fiquux: integer;
    function getarray(piindex: integer): integer;
    procedure setarray(piindex: integer; pivalue: integer);
    function getconstarray(const piindex: integer): integer;
    procedure setconstarray(const piindex: integer; pivalue: integer);
    function getcomplexarrayprop(const piindex: integer; var pcstring: string): boolean;
  public
    property arrayval[piindex: integer]: integer Read getarray Write setarray; default;
    property constarrayval[const piindex: integer]: integer
      Read getconstarray Write setconstarray;
    property complexarrayprop[const piindex: integer;var pcsstring: string]: boolean
      Read getcomplexarrayprop;
  published
    property bar: integer Read fibar Write fibar;
    property baz: integer index 3 Read fibaz Write fibaz;
    property wibble: integer Read fiwibble Write fiwibble stored False;
    property fish: integer index 5 Read fifish Write fifish default 6;
    property quux: integer index 5 Read fiquux Write fiquux nodefault;
  end;

type
  tbar = class(TObject)
    function getarray(piindex: integer): integer;
    procedure setarray(piindex: integer; pivalue: integer);
  public
    property arrayval[piindex: integer]: integer Read getarray Write setarray; default;
  end;

type
  thasapoint = class(TObject)
  private
    fpoint: tpoint;
  public
    property x: integer Read fpoint.x;
    property y: integer Read fpoint.y Write fpoint.y;
  end;

implementation

function tfoo.getarray(piindex: integer): integer;
begin
  Result := piindex * 3;
end;

function tfoo.getcomplexarrayprop(const piindex: integer; var pcstring: string): boolean;
begin
  Result   := False;
  pcstring := pcstring + 'aa';
end;

function tfoo.getconstarray(const piindex: integer): integer;
begin
  Result := piindex * 3;
end;

procedure tfoo.setarray(piindex, pivalue: integer);
begin
end;

procedure tfoo.setconstarray(const piindex: integer; pivalue: integer);
begin
end;

function tbar.getarray(piindex: integer): integer;
begin
  Result := piindex * 4;
end;

procedure tbar.setarray(piindex, pivalue: integer);
begin
end;

end.
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?