Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi 2010 - property wizard or something similar, to avoid manual coding getters / setters

Is there any built in or external tool (wizard) to easily add class member (published field) with getters / setters?

adding each field requires me to write quite lot of code. Let's assume I need to add Foo: Bar; property.

I'll need to write

FFoo: TBar;
procedure SetFoo(const AValue: TBar);
function GetFoo: TBar;

...

property Foo: TBar read GetFoo write SetFoo

any tool to make it quick and easy?

like image 623
migajek Avatar asked May 21 '11 10:05

migajek


1 Answers

Type:

property Foo: TBar read GetFoo write SetFoo;

or:

property Foo: TBar read FFoo write SetFoo;

Then press CTRL-SHIFT-C

EDIT: The latter (setter and field combo) can be done even faster by writing only the following, followed by CTRL-SHIFT-C:

property Foo: TBar;

This shortcut also works if you write a method in your class and you wish to create the matching implementation.

like image 89
Steve Mayne Avatar answered Oct 16 '22 05:10

Steve Mayne