2010-05-25 20 views
1

在这里和在互联网上搜索没有让我举一个Delphi的实时模板的例子,它使用getter/setter生成一个Property,并生成私有字段并执行复杂操作。 (SHIFT + CTRL + C)德尔福的实时模板,用getter/setter生成属性并创建私人字段?

这可能吗?

+1

如果您需要在Delphi真正的生产力的推动,再考虑MMX(MM代码浏览器)http://bit.ly/9r1qaV - 它是从荷兰vendoer和上衣其他所有德尔福的重构工具。 - jeroen – 2010-05-25 12:50:57

回答

1

题为例子中的“读/写属性”已经提到Delphi Live Templates页面上可以进行修改来产生getter/setter方法,而不是私有字段:

<?xml version="1.0" encoding="utf-8" ?> 
<codetemplate xmlns="http://schemas.borland.com/Delphi/2005/codetemplates" 
       version="1.0.0"> 
    <template name="prop" invoke="manual"> 
     <description> 
      read write property for field 
     </description> 
     <author> 
      twm 
     </author> 
     <point name="ident"> 
      <text>Name</text> 
      <hint>the name for the property</hint> 
     </point> 
     <point name="type"> 
      <text>Integer</text> 
      <hint>the type for the property</hint> 
     </point> 
     <script language="Delphi" onenter="false" onleave="true"> 
      InvokeClassCompletion; 
     </script> 
     <code language="Delphi" delimiter="|"> 
     <![CDATA[property |ident|: |type| read Get|ident| write Set|ident|; 
|end|]]> 
     </code> 
    </template> 
</codetemplate> 

然而,这不会产生私人领域。

+0

Thanks tondrej - 与我现在使用的几乎一样,但正如你所说,它不会生成私人领域。 – 2010-05-25 11:20:10

+0

糟糕。完全错过了您示例中的脚本标记。抱歉! – 2010-05-25 13:11:25