CodeRush templates for XPO properties

28 April 2006

Prompted by Stefan Renzewitz in the CodeRush newsgroup, I’m making available a number of CodeRush templates, which allow you to create persistent properties of various types, including collections and association properties for “the other side” of the collection property. I guess a variant of these templates will be included in the default distribution of CodeRush in the future, but until that happens, please import the file from the download below. Sorry, C# only for now.

These are the templates:

pp(b|c|d|dt|f|i|o|s):

  private <type> propertyName;
  public <type> PropertyName {
    get {
      return propertyName;
    }
    set {
      if (propertyName != value) {
        <type> oldValue = propertyName;
        propertyName = value;
        OnChanged("PropertyName", oldValue, propertyName);
      }
    }
  }

Depending on the postfix used, the “<type>” in the code is expanded into bool, char, decimal, DateTime, float, int, object or string.

pcoll:

  [Association("PersistentClass-Relations")]
  public XPCollection<RelationType> Relations {
    get {
      return GetCollection<RelationType>("Relations");
    }
  }

ppa (the “a” is for “association”):

  private object propertyName;
  [Association("object-PersistentClasss")]
  public object PropertyName {
    get {
      return propertyName;
    }
    set {
      if (propertyName != value) {
        object oldValue = propertyName;
        propertyName = value;
        OnChanged("PropertyName", oldValue, propertyName);
      }
    }
  }

Of course it’s a little difficult to describe how exactly these templates work, so I suggest you download the file below, import it into CodeRush and try them out! Oh yes, for the import you just enter the CodeRush Options dialog, switch to the Templates page, right-click anywhere in the hierarchical list of templates and click the “Import Templates…” context menu command. Have fun!

File Attachment: CSharp_Oliver_XPO.xml (48 KB)

Tags
2 comment(s)
Stefan Renzewitz
Thanks a lot! Great service Oliver (you are already more American than German ;) and very impressing response time.

Regards,

Stefan
2 May, 2006
Renaud Bompuis
Actually, I found and answer to the issue of not being able to save the template in CodeRush:
https://www.devexpress.com/support/center/Default.aspx?view=ViewIssue&issueid=DB9058

That fixed the problem.
Sorry for posting it here.

Renaud
29 May, 2006

Please login or register to post comments.