<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>Erwin van der Valk's blog: Practicing patterns : Prism</title><link>http://blogs.msdn.com/erwinvandervalk/archive/tags/Prism/default.aspx</link><description>Tags: Prism</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>writing applications that target both wpf and silverlight with a single codebase</title><link>http://blogs.msdn.com/erwinvandervalk/archive/2009/09/03/writing-applications-that-target-both-wpf-and-silverlight-with-a-single-codebase.aspx</link><pubDate>Thu, 03 Sep 2009 23:09:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9891066</guid><dc:creator>erwinvandervalk</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/erwinvandervalk/comments/9891066.aspx</comments><wfw:commentRss>http://blogs.msdn.com/erwinvandervalk/commentrss.aspx?PostID=9891066</wfw:commentRss><description>&lt;p&gt;A while back, I wrote an MSDN article on writing multi-targeted programs with Prism.&lt;/p&gt;  &lt;p&gt;&lt;a title="http://msdn.microsoft.com/en-us/magazine/ee321573.aspx" href="http://msdn.microsoft.com/en-us/magazine/ee321573.aspx"&gt;http://msdn.microsoft.com/en-us/magazine/ee321573.aspx&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Hope you like it!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9891066" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/patterns+_2600_amp_3B00_+practices/default.aspx">patterns &amp;amp; practices</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Prism/default.aspx">Prism</category></item><item><title>what do you think of prism?</title><link>http://blogs.msdn.com/erwinvandervalk/archive/2009/04/01/what-do-you-think-of-prism.aspx</link><pubDate>Wed, 01 Apr 2009 20:40:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9527405</guid><dc:creator>erwinvandervalk</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/erwinvandervalk/comments/9527405.aspx</comments><wfw:commentRss>http://blogs.msdn.com/erwinvandervalk/commentrss.aspx?PostID=9527405</wfw:commentRss><description>&lt;p&gt;Prism has been out for quite a while now. I hope you had some time to play with it, read the docs, look at the code and build apps with it. So, what do &lt;strong&gt;&lt;u&gt;YOU&lt;/u&gt;&lt;/strong&gt; think of prism? Did you like it? Did it help solve your composite application problems? Was it easy to use or very hard? Please let us know by filling out this survey:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.zoomerang.com/Survey/survey-intro.zgi?p=WEB228YSYYRK4A" href="http://www.zoomerang.com/Survey/survey-intro.zgi?p=WEB228YSYYRK4A"&gt;http://www.zoomerang.com/Survey/survey-intro.zgi?p=WEB228YSYYRK4A&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Of course, you don’t have to.. but this is your chance. If you really liked prism, then tell us. That way, we know we have to invest more in future versions of Prism ;)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9527405" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/CAL/default.aspx">CAL</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/patterns+_2600_amp_3B00_+practices/default.aspx">patterns &amp;amp; practices</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Prism/default.aspx">Prism</category></item><item><title>Test if classes are registered in unity</title><link>http://blogs.msdn.com/erwinvandervalk/archive/2009/02/13/test-if-classes-are-registered-in-unity.aspx</link><pubDate>Sat, 14 Feb 2009 01:45:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9420210</guid><dc:creator>erwinvandervalk</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/erwinvandervalk/comments/9420210.aspx</comments><wfw:commentRss>http://blogs.msdn.com/erwinvandervalk/commentrss.aspx?PostID=9420210</wfw:commentRss><description>&lt;p&gt;While writing some sample applications for the upcoming release of Prism (Composite Application Guidance for WPF and Silverlight) I ran into a small challenge. &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;“How do you verify (with unit tests) that the right classes are registered in your DI-container?”&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In my case, the container is Unity, but Unity does not have any ‘IsTypeRegistered’ methods (Apparently there are good reasons for it not to have these methods). So that posses an interesting challenge. At first I thought of 2 solutions:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Manually create a mock of your container.        &lt;br /&gt;&lt;/strong&gt;Certainly possible but a lot of work for my small demo app. A mocking framework can help with this, but i don’t want to rely on a mocking framework for a small demo app.       &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;See if the components are registered by resolving the type.        &lt;br /&gt;&lt;/strong&gt;This will work initially, but it will actually instantiate the object. So if the object can’t be created for some reason, your test will fail. Now if the type you have just registered has a lot of dependencies, you will need to satisfy all those dependencies in the container before you can even begin to create the object. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;But neither of these options were really satisfying. Then I asked Chris Tavarez, and he mentioned: Why don’t you build a Unity Extension. So I did and that solved the problem quite nicely:&lt;/p&gt;  &lt;p&gt;So this is the Extension I’ve created:&lt;/p&gt;  &lt;div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px"&gt;   &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;     &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; QueryableContainerExtension : UnityContainerExtension&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; List&amp;lt;RegisterEventArgs&amp;gt; Registrations = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;RegisterEventArgs&amp;gt;();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Initialize()&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Context.Registering += &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventHandler&amp;lt;RegisterEventArgs&amp;gt;(Context_Registering);&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Context_Registering(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, RegisterEventArgs e)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Registrations.Add(e);&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; IsTypeRegistered&amp;lt;TFrom, TTo&amp;gt;()&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  17:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Registrations.FirstOrDefault((e) =&amp;gt; e.TypeFrom == &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(TFrom) &amp;amp;&amp;amp; e.TypeTo == &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(TTo)) != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  18:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  19:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  20:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; IsTypeRegisteredAsSingleton&amp;lt;TFrom, TTo&amp;gt;()&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  21:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  22:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Registrations.FirstOrDefault(&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  23:&lt;/span&gt;             (e) =&amp;gt; e.TypeFrom == &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(TFrom)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  24:&lt;/span&gt;                 &amp;amp;&amp;amp; e.TypeTo == &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(TTo)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  25:&lt;/span&gt;                 &amp;amp;&amp;amp; &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(ContainerControlledLifetimeManager).IsInstanceOfType(e.LifetimeManager)) != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  26:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  27:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;And this is how you’d use it:&lt;/p&gt;

&lt;div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; height: 301px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; [TestMethod]&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; TestRegistration()&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// Create the container and add the extension method&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     var container = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; UnityContainer();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     var registeredTypes = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; QueryableContainerExtension();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;     container.AddExtension(registeredTypes);&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// Register the classes to the container&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;     container.Register&amp;lt;IMyInterface, MyClass&amp;gt;();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// See if the type is registered&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;     Assert.IsTrue(registeredTypes.IsTypeRegistered&amp;lt;IMyInterface, MyClass&amp;gt;());&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Hope you find this as useful as I did :)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9420210" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/patterns+_2600_amp_3B00_+practices/default.aspx">patterns &amp;amp; practices</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Prism/default.aspx">Prism</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Unity/default.aspx">Unity</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Dependency+Injection/default.aspx">Dependency Injection</category></item><item><title>prism v2 – drop 10 (composite application guidance)</title><link>http://blogs.msdn.com/erwinvandervalk/archive/2009/01/30/prism-v2-drop-10-composite-application-guidance.aspx</link><pubDate>Sat, 31 Jan 2009 02:41:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9385502</guid><dc:creator>erwinvandervalk</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/erwinvandervalk/comments/9385502.aspx</comments><wfw:commentRss>http://blogs.msdn.com/erwinvandervalk/commentrss.aspx?PostID=9385502</wfw:commentRss><description>&lt;p&gt;Today, we have released what’s likely going to be the last drop of Prism before the final release. You can get the release from:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=22566" href="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=22566"&gt;http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=22566&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;During this iteration, we have mostly worked on documentation, implementing a new UI for the Stock Trader Reference Implementation and fixing some last important bugs. &lt;/p&gt;  &lt;p&gt;The most important changes are:&lt;/p&gt;  &lt;li&gt;Removed .Silverlight and .Desktop extensions from the Assembly names, both in the Library and in all the Quickstarts. &lt;/li&gt;  &lt;li&gt;Renamed RegionExtensions class to RegionContext and RegionExtensions.GetRegionContext() method to RegionContext.GetObservableContext() &lt;/li&gt;  &lt;li&gt;Moved RegionExtensions.GetObservableRegion() method from RegionExtensions class to RegionManager class. &lt;/li&gt;  &lt;li&gt;Integrated new UI design for Stock Trader Reference Implementation. &lt;/li&gt;  &lt;li&gt;Many updates to Documentation &lt;/li&gt;  &lt;li&gt;Included API CHM file &lt;/li&gt;  &lt;li&gt;Added shortcut .Bat files to make it easier to open the solutions. &lt;/li&gt;  &lt;li&gt;Bug fixes &lt;/li&gt;  &lt;li&gt;Added missing XML comments to the code of the Composite Application Library.&lt;/li&gt;  &lt;h1&gt;&amp;#160;&lt;/h1&gt;  &lt;h1&gt;New UI for Stock Trader Reference Implementation&lt;/h1&gt;  &lt;p&gt;We felt that the original UI of the Stocktrader RI didn’t give a good impression of the capabilities of WPF and Silverlight. Most of the things we were showing before were also possible with Windows Forms. So for this release, we’ve decided to hire a graphical design company to give our RI a complete makeover, complete with some cool animations. &lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="400"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="200"&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;a href="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/prismv2drop10compositeapplicationguidanc_DCB4/image_2.png"&gt;           &lt;br /&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/prismv2drop10compositeapplicationguidanc_DCB4/image_thumb.png" width="463" height="313" /&gt;&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="200"&gt;After:&lt;a href="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/prismv2drop10compositeapplicationguidanc_DCB4/image_6.png"&gt;           &lt;br /&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/prismv2drop10compositeapplicationguidanc_DCB4/image_thumb_2.png" width="410" height="313" /&gt;&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt; Looks a lot better huh?&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9385502" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/CAL/default.aspx">CAL</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/patterns+_2600_amp_3B00_+practices/default.aspx">patterns &amp;amp; practices</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Prism/default.aspx">Prism</category></item><item><title>prism v2 – drop 9 (composite application guidance for wpf and silverlight)</title><link>http://blogs.msdn.com/erwinvandervalk/archive/2009/01/19/prism-v2-drop-9-composite-application-guidance-for-wpf-and-silverlight.aspx</link><pubDate>Mon, 19 Jan 2009 22:32:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9340600</guid><dc:creator>erwinvandervalk</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/erwinvandervalk/comments/9340600.aspx</comments><wfw:commentRss>http://blogs.msdn.com/erwinvandervalk/commentrss.aspx?PostID=9340600</wfw:commentRss><description>&lt;p&gt;It’s been a while since my last post. Not that the Prism team has been sitting idle though. &lt;/p&gt;  &lt;p&gt;Last Friday, we’ve released drop 9 of Prism. As we are approaching the end of the Prism v2 project, there are a lot less API changes, as we are mostly focussing on finishing the docs and resolving bugs. We have also spent some time trying to build different application styles (for example, an outlook style app, or a master-detail style app) on top of our library. The results of this exercise was very useful. Unfortunately, they were nothing more than spikes, so we can’t deliver them as part Prism, but we are thinking of doing a bunch of blog posts or webcasts, that describe how to build different application styles on top of Prism. &lt;/p&gt;  &lt;p&gt;You can get drop 9 of Prism here: &lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=21912" href="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=21912"&gt;http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=21912&lt;/a&gt;&lt;/p&gt;  &lt;h1&gt;&amp;#160;&lt;/h1&gt;  &lt;h1&gt;What’s in Prism drop 9&lt;/h1&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;New skin for the Stocktrader reference implementation. &lt;/strong&gt;      &lt;br /&gt;We wanted to show a bit more of the power of the WPF and Silverlight platform in our RI, so we have hired an external design bureau to create a new design. It has taken a bit longer to implement than we had hoped. In this drop, we have some of the basic styling in place. Hopefully, we can get the next styling &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Desktop only solutions&lt;/strong&gt;       &lt;br /&gt;Not everybody is interested in developing on both WPF and Silverlight. So that’s why we’ve added ‘WPF’ only solutions. We can’t really add Silverlight only solutions as easily, because the Silverlight projects are linking all the files from the WPF projects. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;New SingleActiveWindowRegionAdapter in the RI        &lt;br /&gt;&lt;/strong&gt;We are demonstrating how to create an adapter in the RI, in this case how to create a popup window and use that as a region. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Several bugs fixed        &lt;br /&gt;&lt;/strong&gt;Lots of testing, prioritizing, bugfixing, retesting, etc.. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Exception stack compression in combination with Unity        &lt;br /&gt;&lt;/strong&gt;Unity is an awesome DI container, but it doesn’t give really clear exception messages if something goes wrong. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The last weeks of a project are always interesting. There are _so_ many ‘little’ things we would have wanted do do, or add to the library. but what seems like a small dev effort, can quickly add up if you also count the test and doc effort. So, we are constantly keeping a critical eye on our prioritized backlog of tasks. Unfortunately, this means there are a bunch of really interesting stuff we would have loved to tackle, but we can’t. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h1&gt;Exception stack compression&lt;/h1&gt;  &lt;p&gt;While building different application styles on top of Prism, we found an interesting problem. &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Suppose the following example: You are creating a simple view. In the Module.Initialize(), you are registering the type of the view against a region that’s displayed in the shell. In the constructor of the view, you have made a small programming error, which causes an exception. &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;So what’s the result?&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;A module initialize error. Ok, that makes sense. But what was the exception message inside that? &lt;em&gt;“Exception occurred at target of invocation.”.&lt;/em&gt; And inside that? A bunch of ServiceLocator, Unity and Objectbuilder errors. Only somewhere at the bottom of the inner exception list you find the exception that caused the problem. &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;All these exceptions are perfectly valid from a technical point of view, but not very useful in understanding what’s going wrong.&amp;#160; Ideally, Unity should return a very clear exception message: “Tried to create object X, but could not because of this error message: ‘xyz’”. Unfortunately, Unity does not do this. (After a discussion with the enterprise library team, it turns out that it’s really hard to build this in Unity). I think that developers who are building applications on top of Prism are rarely interested how exactly the DI container builds up it’s objects.&amp;#160; So all the technical inner exceptions are just clutter to them, that’s obscuring what’s really going wrong. &lt;/p&gt;  &lt;p&gt;So we have built some logic to try and find the error in the stack trace that actually points developers in the right direction. The goal was to be able to get the following exception message: “An exception occurred while initializing module X, in the constructor of View X, with exception message “XYZ”. &lt;/p&gt;  &lt;p&gt;So now in Prism, you can use the extension method exception.GetRootException() to try and find the exception that’s actually causing the problem. It won’t be 100% accurate, but it looks like it really helps in getting to the root of the problem more quickly. &lt;/p&gt;  &lt;p&gt;Hopefully you will find this useful to!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9340600" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/CAL/default.aspx">CAL</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/patterns+_2600_amp_3B00_+practices/default.aspx">patterns &amp;amp; practices</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Prism/default.aspx">Prism</category></item></channel></rss>