Delphi 2010 - 属性向导或类似的东西,以避免手动编码 getters/setters
是否有任何内置或外部工具(向导)可以使用 getter/setter 轻松添加类成员(已发布字段)?
添加每个字段需要我编写大量代码。假设我需要添加 Foo: Bar;
属性。
我需要编写
FFoo: TBar;
procedure SetFoo(const AValue: TBar);
function GetFoo: TBar;
...
property Foo: TBar read GetFoo write SetFoo
任何工具来使其快速而简单吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
输入:
或:
然后按 CTRL-SHIFT-C
编辑:后者(设置器和字段组合)可以通过仅写入来更快地完成以下内容,后跟 CTRL-SHIFT-C:
如果您在类中编写方法,此快捷方式也适用并且您希望创建匹配的实现。
Type:
or:
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:
This shortcut also works if you write a method in your class and you wish to create the matching implementation.
只需编写属性声明:
然后将光标放在属性上(或类声明中的任何位置),按 Ctrl-Shft-C,IDE 将自动为您完成声明,包括实现存根。
请注意,您可能必须确保选中“完成不完整的属性”选项。您可以在“工具”|“工具”下找到它。选项|环境选项 |探险家。
Just write the property declarataion:
then with your cursor on the property (or anywhere within the class declaration), press Ctrl-Shft-C and the IDE will autocomplete the declarations for you, including the implementation stubbs.
Please note that you may have to make sure that the "Finish incomplete properties" option is checked. You can find that under Tools | Options | Environment Options | Explorer.
您应该查看ModelMaker Code Explorer。它将使您的编码速度显着加快。
You should have a look at ModelMaker Code Explorer. It will make your coding significantly faster.