<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://idevelopwith.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Joe's Blog</title><link>http://idevelopwith.net/blogs/joe/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.2)</generator><item><title>Extend Yourself</title><link>http://idevelopwith.net/blogs/joe/archive/2009/08/11/extend-yourself.aspx</link><pubDate>Wed, 12 Aug 2009 01:53:46 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:50</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/50.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=50</wfw:commentRss><description>&lt;p&gt;I tend to have a fairly long list of things I want to investigate in .NET development. Extension methods have been on my list for a long time. I finally got around to looking into them and wish I had done so much sooner. They are a handy little feature available in .NET 3.0 and later. &lt;/p&gt;  &lt;p&gt;So what are extension methods? I’m glad you asked. Suppose you want to add some functionality to an existing class but you don’t have the source code. One way is to derive a class and add the new functionality there. That works, but if you are using the base class in lots of places in your application, you have to go to each instance and replace the base class with the derived class. This doesn’t give me a warm, fuzzy feeling and makes me think there must be a better way. This is where extension methods come in. They provide a way to extend the functionality of a class without subclassing.&lt;/p&gt;  &lt;p&gt;Let’s see how it works. Suppose you want to be able to log exceptions in your application. It would be nice to be able to write something like&lt;/p&gt;  &lt;pre&gt;catch (Exception ex) 
{ 
   ex.Log(); 
}&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;That would be very cool, and as it turns out, is exactly what extension methods do for you.&lt;/p&gt;

&lt;p&gt;Declare your extension methods in a common project that will be referenced from any project that needs access to the extension method. Extension methods must be static methods declared in a static class. &lt;/p&gt;

&lt;pre&gt;using System; 
using System.Diagnostics; 

namespace Common 
{ 
    public static class ExceptionExtensions 
    { 
        public static void Log(this Exception ex) 
        { 
            Debug.WriteLine(ex.Message + 
                Environment.NewLine + 
                ex.StackTrace); 
        } 

        public static void Log(this Exception ex, string msg) 
        { 
            Debug.WriteLine(msg + 
                Environment.NewLine + 
                ex.Message + 
                Environment.NewLine + 
                ex.StackTrace); 
        } 
    } 
}&lt;/pre&gt;

&lt;p&gt;The strange syntax of the first argument means you want to extend the Exception class (and any class derived from it) with the extension method. The second and later arguments are passed to the extension method when you call it. You are free to put whatever code you want in your extension methods. Log to SQL Server if you want, or use your favorite logger.&lt;/p&gt;

&lt;p&gt;Now that you have your extension methods written, you can do this in your application code.&lt;/p&gt;

&lt;pre&gt;catch (Exception ex) 
{ 
   ex.Log(); 
    // or
   ex.Log(&amp;quot;some more info to log&amp;quot;); 
}&lt;/pre&gt;

&lt;p&gt;You even have IntelliSense available and it tells you the method is an extension method.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://idevelopwith.net/blogs/images/ExtensionMethod.jpg" /&gt; &lt;/p&gt;

&lt;pre&gt;Now, throw new InvalidOperationException(&amp;quot;Don't do that.&amp;quot;);&lt;/pre&gt;
produces the following output with the two overloaded calls to Log. 

&lt;p&gt;A first chance exception of type 'System.InvalidOperationException' occurred in Common.dll 
  &lt;br /&gt;Don't do that. 

  &lt;br /&gt;at Common.ViewHelper.RegisterView(IRegionManager regionManager, String regionName, Type viewType) in C:\Users\jbennett\Documents\Visual Studio 2008\Projects\PrismFontViewer\Common\ViewHelper.cs:line 25 &lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;some more info to log 

  &lt;br /&gt;Don't do that. 

  &lt;br /&gt;at Common.ViewHelper.RegisterView(IRegionManager regionManager, String regionName, Type viewType) in C:\Users\jbennett\Documents\Visual Studio 2008\Projects\PrismFontViewer\Common\ViewHelper.cs:line 25&lt;/p&gt;

&lt;p&gt;That’s all there is to it. Enjoy and extend!&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=50" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/.NET/default.aspx">.NET</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Cool+Stuff/default.aspx">Cool Stuff</category></item><item><title>Windows 7 RTM</title><link>http://idevelopwith.net/blogs/joe/archive/2009/07/27/windows-7-rtm.aspx</link><pubDate>Mon, 27 Jul 2009 21:27:45 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:49</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/49.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=49</wfw:commentRss><description>&lt;p&gt;Windows 7 has been released to manufacturing!&amp;#160; The official bits are getting very close.&amp;#160; You can still get the RC until August 20, but laying down your cash at the local Best Buy will have to wait until October 22.&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=49" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Windows/default.aspx">Windows</category></item><item><title>Raleigh Code Camp</title><link>http://idevelopwith.net/blogs/joe/archive/2009/07/20/raleigh-code-camp.aspx</link><pubDate>Tue, 21 Jul 2009 00:48:31 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:48</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/48.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=48</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://www.trinug.org/" target="_blank"&gt;TRINUG&lt;/a&gt; will be holding a &lt;a href="http://www.codecamp.org/" target="_blank"&gt;Code Camp in Raleigh&lt;/a&gt; on September 19, 2009.&amp;#160; If you are interested in attending, registration will begin near the end of August.&amp;#160; If you are interested in presenting, get your session info submitted as soon as possible.&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=48" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/.NET/default.aspx">.NET</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Code+Camp/default.aspx">Code Camp</category></item><item><title>Hangin’ with the Big Dogs</title><link>http://idevelopwith.net/blogs/joe/archive/2009/07/20/hangin-with-the-big-dogs.aspx</link><pubDate>Tue, 21 Jul 2009 00:37:37 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:47</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/47.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=47</wfw:commentRss><description>&lt;p&gt;I spent this past Saturday at the annual Community Leaders Summit in Summerfield, NC.&amp;#160; Thanks for the invitation, Brian.&amp;#160; It’s an event for folks involved in the developer community to get together, eat some burgers and dogs, and see what the user groups in the area are doing.&amp;#160; There are some cool things happening in Charlotte at the &lt;a href="http://www.developersguild.org/" target="_blank"&gt;Enterprise Developers Guild&lt;/a&gt;.&amp;#160; Let me just say “Carolina Mega Code Camp” and “October 10, 2009” in the same sentence.&amp;#160; Watch their site for more info.&amp;#160; I hope to see everyone again next year.&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=47" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/.NET/default.aspx">.NET</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Code+Camp/default.aspx">Code Camp</category></item><item><title>Prism Demo</title><link>http://idevelopwith.net/blogs/joe/archive/2009/07/02/prism-demo.aspx</link><pubDate>Thu, 02 Jul 2009 22:17:59 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:46</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/46.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=46</wfw:commentRss><description>&lt;p&gt;I’ll be speaking July 22 about building a simple WPF application using Prism (Composite Application Guidance or CAG just doesn’t roll off your tongue like Prism) for the TRINUG Design Patterns group.&amp;#160; If you’ve never seen Prism and what it can do for you, you should come see it.&amp;#160; It’s very cool stuff.&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=46" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/.NET/default.aspx">.NET</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/TRINUG/default.aspx">TRINUG</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Design/default.aspx">Design</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Prism/default.aspx">Prism</category></item><item><title>Code Contracts and Pex</title><link>http://idevelopwith.net/blogs/joe/archive/2009/06/10/code-contracts-and-pex.aspx</link><pubDate>Thu, 11 Jun 2009 02:42:53 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:45</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/45.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=45</wfw:commentRss><description>&lt;p&gt;I’ll be presenting on &lt;a href="http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx" target="_blank"&gt;Code Contracts&lt;/a&gt; and &lt;a href="http://research.microsoft.com/en-us/projects/pex/" target="_blank"&gt;Pex&lt;/a&gt; at the June 17th meeting of the TRINUG .NET in Depth SIG.&amp;#160; If you haven’t used these two products from Microsoft Research, you have missed a treat!&amp;#160; Code Contracts allow you to express pre and post-condition coding assumptions as well as object invariants in .NET source code.&amp;#160; Pex is automated white box parameterized unit testing with very high levels of code coverage.&amp;#160; Both products are very cool and together they are awesome!&amp;#160; Code Contracts has been released as a separate .NET library and will be a part of .NET 4.0 when it’s released.&amp;#160; Pex is still pre-release software but has been very stable for me and is definitely worth getting for some eye-popping demos at the next geekathon.&amp;#160; Get yourself some Code Contracts and Pex bits and have some fun.&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=45" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/.NET/default.aspx">.NET</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Cool+Stuff/default.aspx">Cool Stuff</category></item><item><title>Windows 7 RC1</title><link>http://idevelopwith.net/blogs/joe/archive/2009/05/05/windows-7-rc1.aspx</link><pubDate>Tue, 05 May 2009 21:03:01 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:43</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/43.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=43</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://www.microsoft.com/windows/windows-7/download.aspx" target="_blank"&gt;Windows 7 RC1&lt;/a&gt; has been released to the public.&amp;#160; This is the replacement for Vista that so many have been waiting for.&amp;#160; This version is available through July 2009 and expires June 1, 2010.&amp;#160; You will want to get some new bits though before March 1, 2010, because that is when your PC starts shutting down every two hours as a friendly reminder.&amp;#160; So, dig out a PC that isn’t used for production and install the bits.&amp;#160; &lt;a href="http://www.microsoft.com/windows/windows-7/download.aspx" target="_blank"&gt;Get them&lt;/a&gt; while they are hot.&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=43" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Windows/default.aspx">Windows</category></item><item><title>Richmond Code Camp</title><link>http://idevelopwith.net/blogs/joe/archive/2009/04/28/richmond-codecamp.aspx</link><pubDate>Tue, 28 Apr 2009 18:00:56 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:42</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/42.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=42</wfw:commentRss><description>&lt;p&gt;I went to the &lt;a href="http://richmondcodecamp.org/" target="_blank"&gt;Richmond Code Camp 2009.1&lt;/a&gt; event this past weekend.&amp;#160; It was a last-minute decision to go and I’m glad I was able to attend.&amp;#160; It was an excellent event, well organized, plenty of good speakers, and pizza for lunch.&amp;#160; What more could you possibly want?&amp;#160; I spent the day immersed in WPF and Silverlight sessions.&amp;#160; They make me want to write code!&amp;#160; I really enjoyed it and will definitely go back again.&amp;#160; Thanks to Andy and the rest of the gang in Richmond.&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=42" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/.NET/default.aspx">.NET</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Training/default.aspx">Training</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Code+Camp/default.aspx">Code Camp</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Free/default.aspx">Free</category></item><item><title>Good Free Stuff</title><link>http://idevelopwith.net/blogs/joe/archive/2009/04/16/good-free-stuff.aspx</link><pubDate>Thu, 16 Apr 2009 12:18:09 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:41</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/41.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=41</wfw:commentRss><description>&lt;p&gt;I may have mentioned before that I love free stuff.&amp;#160; If someone is giving away a free T-Shirt or coffee cup, I’m in line.&amp;#160; I also like to learn about different technologies.&amp;#160; Now, if I could just find a way to combine the free and the learning I’d be a happy man.&lt;/p&gt;  &lt;p&gt;As it turns out, our friends at Microsoft created &lt;a href="http://msdn.microsoft.com/en-us/rampup/default.aspx" target="_blank"&gt;Ramp Up&lt;/a&gt; for guys just like me.&amp;#160; So if you want some free basic technical training, head on over and take a look.&amp;#160; You may not get a free coffee cup, but you do get some good things to put in your head.&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=41" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Training/default.aspx">Training</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Free/default.aspx">Free</category></item><item><title>Sentient DSLs</title><link>http://idevelopwith.net/blogs/joe/archive/2009/04/01/sentient-dsls.aspx</link><pubDate>Thu, 02 Apr 2009 03:49:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:40</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/40.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=40</wfw:commentRss><description>&lt;p&gt;The Channel 9 guys made my day today!&amp;#160; Check it out.&amp;#160; &lt;a title="http://channel9.msdn.com/shows/10-4/10-4-Episode-14-Sentient-DSLs/" href="http://channel9.msdn.com/shows/10-4/10-4-Episode-14-Sentient-DSLs/"&gt;http://channel9.msdn.com/shows/10-4/10-4-Episode-14-Sentient-DSLs/&lt;/a&gt;&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=40" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Cool+Stuff/default.aspx">Cool Stuff</category></item><item><title>Back by Popular Demand</title><link>http://idevelopwith.net/blogs/joe/archive/2009/03/25/back-by-popular-demand.aspx</link><pubDate>Wed, 25 Mar 2009 19:43:04 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:39</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/39.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=39</wfw:commentRss><description>&lt;p&gt;Last month I spoke with the TRINUG Design Patterns group about Dependency Injection with the Unity framework.&amp;#160; There was a lot of interest and some of the folks wanted more.&amp;#160; So, this month I will be speaking there again and demonstrating the interception capabilities of Unity.&amp;#160; I'm also going to demo the Validation application block from the Enterprise Library.&amp;#160; EntLib and Unity together offer some interesting possibilities.&amp;#160; &lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=39" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/.NET/default.aspx">.NET</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/TRINUG/default.aspx">TRINUG</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Unity/default.aspx">Unity</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Enterprise+Library/default.aspx">Enterprise Library</category></item><item><title>Intercept Something</title><link>http://idevelopwith.net/blogs/joe/archive/2009/03/17/intercept-something.aspx</link><pubDate>Tue, 17 Mar 2009 16:18:40 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:38</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/38.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=38</wfw:commentRss><description>&lt;p&gt;I've been working with the Unity DI framework lately.&amp;#160; The guys at P&amp;amp;P have created a piece of work you really should get to know.&amp;#160; Unity encourages developing highly cohesive and loosely coupled modules for use in your application.&amp;#160; That's great, but there are some cross-cutting concerns that tend to muddy up our code.&amp;#160; For example, logging various kinds of information at runtime is a common task.&amp;#160; Sometimes it seems as if we have as much logging code in our applications as we have code that actually does what our application was intended to do.&amp;#160; Including that logging code just kicks our cohesiveness out the door.&amp;#160; We are no longer focused on just one task.&amp;#160; We now are focused on one task and logging.&amp;#160; It can make a method hard to understand just because the logging code tends to mask what the method is actually doing.&amp;#160; Unity provides a solution to that problem.&lt;/p&gt;  &lt;p&gt;The Interception Extension for Unity provides the capability to intercept a method call, do something before the call and after the call.&amp;#160; That sounds like it's ideal for logging doesn't it?&amp;#160; As it turns out, it actually works very well for handling that kind of cross-cutting concern without muddying up our code.&amp;#160; An easy way (but not the only way) to accomplish interception is to create a new LogAttribute and override its CreateHandler method.&lt;/p&gt;  &lt;p&gt;Make sure you have references to Microsoft.Practices.ObjectBuilder2, Microsoft.Practices.Unity, and Microsoft.Practices.Unity.Interception in your project and a using Microsoft.Practices.Unity.Interception directive at the top of your source file.&lt;/p&gt;  &lt;p&gt;public class LogAttribute : HandlerAttribute&lt;/p&gt;  &lt;p&gt;{&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public override ICallHandler CreateHandler(Microsoft.Practices.Unity.IUnityContainer container)&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return new LogCallHandler();&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;}&lt;/p&gt;  &lt;p&gt;Now create the LogCallHandler class like this:&lt;/p&gt;  &lt;p&gt;public class LogCallHandler : ICallHandler&lt;/p&gt;  &lt;p&gt;{&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; private int order;&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public LogCallHandler() : this(0) {}&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public LogCallHandler(int order)&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Order = order;&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public int Order&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return order; }&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set { order = value; }&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ILogger logger = container.Resolve&amp;lt;ILogger&amp;gt;();&amp;#160;&amp;#160;&amp;#160; // get your logger&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; logger.Write(&amp;quot;Precall logging&amp;quot;);&amp;#160;&amp;#160;&amp;#160; // log whatever you want before the call&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var result = getNext().Invoke(input, getNext);&amp;#160; // this invokes the method you called&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; logger.Write(&amp;quot;Postcall logging&amp;quot;);&amp;#160;&amp;#160;&amp;#160; // log whatever you want after the call&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return result;&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;}&lt;/p&gt;  &lt;p&gt;Now, add the Interception Extension to the container and configure it to use the InterfaceInterceptor.&lt;/p&gt;  &lt;p&gt;container.AddNewExtension&amp;lt;Interception&amp;gt;();&lt;/p&gt;  &lt;p&gt;container.Configure&amp;lt;Interception&amp;gt;().SetInterceptorFor&amp;lt;IMessenger&amp;gt;(new InterfaceInterceptor());&lt;/p&gt;  &lt;p&gt;You have the container configured so that any class that implements the IMessenger interface can have its methods intercepted.&amp;#160; To wire everything together, use the LogAttribute&amp;#160; you created on the methods of IMessenger you want logged.&amp;#160; In the concrete class, when you call a method of the IMessenger interface that has the LogAttribute on it, it will be intercepted and the Invoke method above will be called instead.&amp;#160; The information you wanted logged before the call is logged, then the call is made to the method you called, then the information you wanted logged after the call is logged.&lt;/p&gt;  &lt;p&gt;Enjoy!&amp;#160; More information is available on using &lt;a href="http://msdn.microsoft.com/en-us/library/dd140045.aspx" target="_blank"&gt;Interception with Unity&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=38" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/.NET/default.aspx">.NET</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Unity/default.aspx">Unity</category></item><item><title>Object Responsibility</title><link>http://idevelopwith.net/blogs/joe/archive/2009/01/31/object-responsibility.aspx</link><pubDate>Sat, 31 Jan 2009 17:32:16 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:37</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/37.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=37</wfw:commentRss><description>&lt;p&gt;One of the most basic concepts of object oriented design is the class.&amp;#160; A class is one of those things that we know when we see one, but describing what it is, is a little harder.&amp;#160; More importantly, how do we know when we are through creating one in code?&amp;#160; What should be included in it and what should not?&amp;#160; One definition could be when we quit typing, and that is a definition I have unfortunately seen too often in code.&amp;#160; Designing a class correctly is more than looking at a source file and saying &amp;quot;This Widget doesn't have too much stuff in it, I think I'll put the code for the new Zinger in here.&amp;quot;&amp;#160; An object should be responsible for maintaining its own state and behaving in a way that is reasonable.&lt;/p&gt;  &lt;p&gt;I like to think of a class as a model of something real.&amp;#160; Suppose I had a class named Apple.&amp;#160; What is an Apple and how do I represent it in code?&amp;#160; Well, it probably has a name and depending on your point of view it might be &amp;quot;Fuji&amp;quot; or &amp;quot;Mac.&amp;quot;&amp;#160; Let's take the fruit and think of other things that might help describe it.&amp;#160; Size and weight are possibilities, and so is color.&amp;#160; We might even need some indication of whether it is ripe or a measure of its sweetness.&amp;#160; All those things are the state of an Apple.&amp;#160; They represent a particular instance of an Apple with variables that contain values at a particular point in time.&amp;#160; &lt;/p&gt;  &lt;p&gt;An object is more than just state, it also includes behaviors.&amp;#160; Behaviors are represented by methods in our classes.&amp;#160; What kind of behaviors can an Apple have?&amp;#160; Watch one for a while and see what it does.&amp;#160; If you actually did that exercise, your list of behaviors is probably pretty short.&amp;#160; This is characteristic of a category of objects called Entities.&amp;#160; Entities have very few behaviors.&amp;#160; When you describe what software should do, they are some of the nouns in the description.&amp;#160; They are typically inanimate, have very few of their own behaviors, and are acted upon by other objects.&amp;#160; While that description is not always accurate, if you find something that fits that description you have probably found an entity.&amp;#160; Examples of entity objects might be a Book in a library application or a DVD in video store software.&amp;#160; &lt;/p&gt;  &lt;p&gt;Should an Apple have a Find method that locates a particular Apple in a Basket of Apples?&amp;#160; No, it is not the responsibility of an Apple to find other Apples.&amp;#160; An Apple should be unaware of other Apples or even the Basket instance that is its container.&amp;#160; So how is a particular Apple found in a Basket of Apples?&amp;#160; Should the Basket class have a method named FindApple?&amp;#160; No, have you ever seen a basket search for anything?&amp;#160; I haven't.&amp;#160; The way you model an object in code should be as close to the object in the real world as possible.&amp;#160; It is the responsibility of a Basket to hold things, not search for them.&amp;#160; A Person might be interested in a particular Apple.&amp;#160; So, should a Person have a FindApple method?&amp;#160; Probably not, but people use tools to help them do things.&amp;#160; A type of object called a Collection knows how to manipulate multiple instances of some class.&amp;#160; So a person would use an instance of a Collection as a tool to find a particular instance of an Apple in a collection of Apples.&lt;/p&gt;  &lt;p&gt;To define an object we need to understand exactly what it looks like and how it behaves.&amp;#160; We describe an object in code by the internal variables (and externally visible properties) used to store its state, other variables used to store values required by one or more of its behaviors, and only the behaviors that are required for that object.&amp;#160; What else should go into a class?&amp;#160; NOTHING!&lt;/p&gt;  &lt;p&gt;While this is not meant to be the last word on object responsibility it is meant to be a guideline on how to create well-designed objects.&amp;#160; Understanding what an object's responsibilities are helps in knowing when to stop adding things to your classes.&amp;#160; Use common sense and good judgement and don't add unnecessary things to your classes, it just clutters up your code and makes maintaining your software harder and more time consuming.&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=37" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/.NET/default.aspx">.NET</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Design/default.aspx">Design</category></item><item><title>Design Patterns</title><link>http://idevelopwith.net/blogs/joe/archive/2009/01/12/design-patterns.aspx</link><pubDate>Mon, 12 Jan 2009 15:30:43 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:36</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/36.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=36</wfw:commentRss><description>&lt;p&gt;I'll be speaking to the &lt;a href="http://trinug.pbwiki.com/Design+Patterns" target="_blank"&gt;TRINUG&lt;/a&gt; Design Patterns group on February 25, 2009 about creating highly cohesive and loosely coupled applications using the Unity Dependency Injection framework.&amp;#160; Come check it out.&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=36" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/.NET/default.aspx">.NET</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Unity/default.aspx">Unity</category></item><item><title>Loosely Coupled Applications</title><link>http://idevelopwith.net/blogs/joe/archive/2009/01/09/loosely-coupled-applications.aspx</link><pubDate>Fri, 09 Jan 2009 17:23:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:35</guid><dc:creator>jbennett</dc:creator><slash:comments>0</slash:comments><comments>http://idevelopwith.net/blogs/joe/comments/35.aspx</comments><wfw:commentRss>http://idevelopwith.net/blogs/joe/commentrss.aspx?PostID=35</wfw:commentRss><description>&lt;p&gt;I've been working with the Unity Dependency Injection Application Block lately.&amp;nbsp; It is part of the Enterprise Library beginning with version 4.0.&amp;nbsp; You can also get it as a separate download without EntLib.&amp;nbsp; Pick your flavor at &lt;a href="http://www.CodePlex.com/Unity"&gt;www.CodePlex.com/Unity&lt;/a&gt;.&amp;nbsp; &lt;/p&gt;    &lt;p&gt;The benefits of using Unity (other than the cool factor) are from the way it encourages developing your software as loosely coupled modules.&amp;nbsp; Anyone who has ever worked with a tangled mess of spaghetti code will understand the advantages of loose coupling.&amp;nbsp; &lt;/p&gt;    &lt;p&gt;Although it's great as is, there are a few shortcomings in version 1.2 I'd like to see addressed.&amp;nbsp; I'd like to see MS throw some more complete extensions into the mix.&amp;nbsp; Currently, you get a simple event broker extension.&amp;nbsp; It's very cool and easy to use.&amp;nbsp; Limitations on the type of the event and event handler are a bit of an annoyance, but you can work around that.&lt;/p&gt;    &lt;p&gt;Overall, for a version 1.x product the guys at Patterns and Practices have produced some very cool and very useful software in Unity.&amp;nbsp; You should get it now and use it in your projects.&amp;nbsp; Thanks P&amp;amp;P guys!&amp;nbsp; I look forward to future versions of Unity.&lt;/p&gt;&lt;img src="http://idevelopwith.net/aggbug.aspx?PostID=35" width="1" height="1"&gt;</description><category domain="http://idevelopwith.net/blogs/joe/archive/tags/.NET/default.aspx">.NET</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Cool+Stuff/default.aspx">Cool Stuff</category><category domain="http://idevelopwith.net/blogs/joe/archive/tags/Unity/default.aspx">Unity</category></item></channel></rss>