CodeRush Business Property template

CodeRush Business Property template

Old forum URL: forums.lhotka.net/forums/t/807.aspx


xal posted on Thursday, August 03, 2006

For the people who use coderush, I have created a template to generate business properties.
Name the template bp?Type? and paste the following there. From that point you only have to type bps or bpi to create string or integer properties (and so on...). This could be easily ported to c#.


«:#PropertyFieldDeclaration#»
Public Property «BlockAnchor»«:#PropertyName#»
«Caret» As «:#PropertyType#»
    Get
        CanReadProperty("«:#PropertyName#»", True)
        Return «:#PropertyVar#»
    End Get
    Set (ByVal value As «:#PropertyType#»)
        CanWriteProperty("«:#PropertyName#»", True)
        If «:#PropertyVar#» <> value Then
            «:#PropertyVar#» = value
            PropertyHasChanged("«:#PropertyName#»")
        End If
    End Set
End Property




Andrés

PS: don't paste my name in the template!! :P

cmay replied on Thursday, August 03, 2006

Thanks Xal!

This gave me the idea to post my macro for creating properties too:

http://forums.lhotka.net/forums/4185/ShowThread.aspx#4185

 

DogSpots replied on Thursday, August 03, 2006

Here is a C# template that does the same thing.  This also should be named bp?Type?

 

private «Link(«?Get(Type)»)» «Link(PropertyName,FormatFieldName,PropertyNameFromField)»;
public «Link(«?Get(Type)»)» «BlockAnchor»«Link(PropertyName)»«Cursor»
{
 get
 {
  CanReadProperty("«Link(PropertyName)»", True);
  return «Link(PropertyName,FormatFieldName,PropertyNameFromField)»;
 }
 set
 {
  CanWriteProperty("«Link(PropertyName)»", True);
  if («Link(PropertyName,FormatFieldName,PropertyNameFromField)» != value)
  {
   «Link(PropertyName,FormatFieldName,PropertyNameFromField)» = value;
   PropertyHasChanged("«Link(PropertyName)»");
  }
 }
}

Copyright (c) Marimer LLC