CodeRush Is Your Best Friend for XPO
Recently Gary Short burnt a little too much midnight oil and ended up posting a blog with some incorrect property patterns for XPO. These have been corrected but it did make me wonder how many people are actually using the CodeRush templates for XPO.
So I decided to do up a quick blog to highlight some of the “cool” features of CodeRush with XPO. First thing to remember is that CodeRush is language independent, it is smart and knows how to code as a C# or VB.NET programmer, so if you enjoy your hieroglyphic bracket hell {C#} or prefer to program in English (VB.NET) CodeRush will provide the code that you need.
Note: CodeRush will automatically put in the project reference to DevExpress libraries as well as a using/Imports statement as well :)
xc – XPO Persistent Class
Firstly you can declare a Persistent Class (inheriting XPObject) by using the template “xc”,
xp?type? – XPO Persistent Property
Declaring persistent properties are a breeze, for this example I have expanded a “xps” template
xr?type? - XPO ReadOnly Persistent Property
These can be "tricky" to remember, the basic idea is you persist a private variable and only expose a readonly property which is "alias'd" to the persisted private variable. Using this template makes it very easy to setup a readonly persistent property, for an example here is a readonly String property
xpa - XP Associated Persistent Property
Although not as "handy" as the others this will create a persistent property of type Object with the AssocationAttribute already on it. Note: this template hasn't got the ?type? style, so you can't do xpas for a string for example, it will create a property with the type set to Object, however CodeRush has linked types so if you change the type it will change the private variable, setter and property type all in one go.
xpcl - XPO Associated Collection
Need an associated collection for a 1-to-Many or Many-to-Many, just expand xpcl and it will provide you with what you need
Background: Developer Express created CodeRush for Visual Studio® .NET to help developers and managers meet these increased demands for quality and functionality, by boosting productivity while eliminating the repetition that erodes precious creativity.
For Developers, CodeRush for Visual Studio® .NET will help you create sophisticated code blocks in seconds and extend code templates instantly. CodeRush will complete identifiers as you type and expand or contract selections logically. With CodeRush, you will be able to instantly place selected code inside Try/Catch blocks, Regions and your own custom wrappers with ease. You can even reverse the logic of selected code and revisit important points within your code instantly (and effortlessly swap between locations). http://www.devexpress.com/Products/Visual_Studio_Add-in/Coding_Assistance/index.xml

Should AussieALF stay bald?
Latest Comments
- How to make XPO only...
Hi Sean, Very true ;) however keep in mi... More...
09-Apr-10 - How to make XPO only...
True, but it's worth noting that DX do ... More...
09-Apr-10 - How to make XPO only...
I would have to check with Gary, as alth... More...
09-Apr-10 - How to make XPO only...
Hi, I agree it seems like a "normal" thi... More...
09-Apr-10 - How to make XPO only...
Another question, how does it work with ... More...
09-Apr-10






Comments
I didn't know about xc or xr
I reckon xr is one of the handiest one as it can be "tricky" to setup a readonly Persistent Property, this just sets it up for you ready to "manipulate" into what you need.
Glad you found it informative. Spent a bit of time on my blog site over the last month, so now hopefully it means I can pump out these little blogs whenever I see something. you'll notice I also display VB.NET and C# to keep everyone happy ;)
Have a Merry Christmas.
RSS feed for comments to this post.