<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.southworks.net/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Fernando Antivero</title>
	
	<link>http://blogs.southworks.net/fantivero</link>
	<description />
	<lastBuildDate>Wed, 07 Apr 2010 17:36:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.southworks.net/fantivero" /><feedburner:info uri="fantivero" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>WCSF 2010 Beta source just released for VS2010 RC</title>
		<link>http://blogs.southworks.net/fantivero/2010/04/07/wcsf-2010-beta-source-just-released-for-vs2010-rc/</link>
		<comments>http://blogs.southworks.net/fantivero/2010/04/07/wcsf-2010-beta-source-just-released-for-vs2010-rc/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 17:31:22 +0000</pubDate>
		<dc:creator>Fernando Antivero</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CWAB]]></category>
		<category><![CDATA[Microsoft p&p]]></category>
		<category><![CDATA[Microsoft Patterns & Practices]]></category>
		<category><![CDATA[p&p]]></category>
		<category><![CDATA[Patterns & Practices]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[VS 2010]]></category>
		<category><![CDATA[VS2010]]></category>
		<category><![CDATA[WCSF]]></category>
		<category><![CDATA[WCSF 2010]]></category>
		<category><![CDATA[Web Client Guidance Package]]></category>
		<category><![CDATA[Web Client Software Factory 2010]]></category>
		<category><![CDATA[Web Client Sofware Factory]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/fantivero/?p=30</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/fantivero/2010/04/07/wcsf-2010-beta-source-just-released-for-vs2010-rc/" class="more-link">read more<img src="http://blogs.southworks.net/fantivero/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p> </p>
<p>As just two weeks ago the Smart Client source code has been published in beta version (read more in <a href="http://blogs.southworks.net/fantivero/2010/03/26/smart-client-software-factory-beta-source-for-visual-studio-2010-rc/">my previous post</a>), now it was turn for the release of the Web Client Software Factory source code (beta) for Visual Studio 2010 RC. This was published on <a href="http://www.codeplex.com/">Codeplex</a> by the p&amp;p team (read more about this in the <a href="http://blogs.msdn.com/blaine/archive/2010/04/05/beta-version-of-wcsf-available-on-codeplex.aspx">Blaine’s Post</a>), so it is possible to download it from <a href="http://webclientguidance.codeplex.com/releases/view/43000">here</a>.</p>
<p>It follows the same approach that the SCSF 2010 beta source code, as its blocks are built against .NET 3.5 and the Guidance Package with .NET 4.0 (this project has references to GAX, which was built targeting .NET 4.0 and it is the reason why it was refreshed to this version).</p>
<p><a href="http://blogs.southworks.net/fantivero/files/2010/04/image.png"><img src="http://blogs.southworks.net/fantivero/files/2010/04/image-thumb.png" border="0" alt="image" width="410" height="461" /></a></p>
<p>When SCSF 2010 beta source code was published, the VSIX package was also published in Visual Studio Gallery a week after  (more information in the Damian’s post <a href="http://blogs.southworks.net/dschenkelman/2010/04/04/scsf-gp-beta-for-visual-studio-2010-rc-just-released/">here</a>), so following this trend we will probably see soon the WCSF GP VSIX to be installed on Visual Studio 2010.</p>
<p>If you have any question or feedback about this version, you could post it in the <a href="http://webclientguidance.codeplex.com/Thread/List.aspx">Web Client Codeplex forum</a>.</p>
]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smart Client Software Factory Beta source for Visual Studio 2010 RC</title>
		<link>http://blogs.southworks.net/fantivero/2010/03/26/smart-client-software-factory-beta-source-for-visual-studio-2010-rc/</link>
		<comments>http://blogs.southworks.net/fantivero/2010/03/26/smart-client-software-factory-beta-source-for-visual-studio-2010-rc/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 15:03:50 +0000</pubDate>
		<dc:creator>Fernando Antivero</dc:creator>
				<category><![CDATA[Patterns & Practices]]></category>
		<category><![CDATA[CAB 2010]]></category>
		<category><![CDATA[CAB WCF 2010]]></category>
		<category><![CDATA[DSA 2010]]></category>
		<category><![CDATA[Microsoft p&p]]></category>
		<category><![CDATA[Microsoft Patterns & Practices]]></category>
		<category><![CDATA[SCSF 2010]]></category>
		<category><![CDATA[SCSF GP 2010]]></category>
		<category><![CDATA[Smart Client Guidance Package 2010]]></category>
		<category><![CDATA[Smart Client Software Factory 2010]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[VS 2010]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/fantivero/?p=27</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/fantivero/2010/03/26/smart-client-software-factory-beta-source-for-visual-studio-2010-rc/" class="more-link">read more<img src="http://blogs.southworks.net/fantivero/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>As Visual Studio 2010 RTM is coming soon other products are being released too. For example, the source code of Smart Client Software Factory 2010 was released in beta version on <a href="http://www.codeplex.com/">Codeplex</a> (download it from <a href="http://smartclient.codeplex.com/releases/view/42559">here</a>) by the Microsoft Patterns &amp; Practices team (read more about this in <a href="http://smartclient.codeplex.com/Thread/View.aspx?ThreadId=207355">Don’s post</a> and <a href="http://blogs.msdn.com/blaine/archive/2010/03/26/beta-version-of-scsf-fro-vs2010-available-on-codeplex.aspx">Blaine’s Post</a>).</p>
<p>At first this Beta version is for Visual Studio 2010 RC and requires to install GAX/GAT (find all the requirements to build the source <a href="http://smartclient.codeplex.com/releases/view/42559">here</a>).</p>
<p><a href="http://blogs.southworks.net/fantivero/files/2010/03/image.png"><img src="http://blogs.southworks.net/fantivero/files/2010/03/image-thumb.png" border="0" alt="image" width="461" height="361" /></a></p>
<h3>Features in this version</h3>
<ul>
<li>The Applications Blocks, Quickstarts and Reference Implementation are keeping the 3.5 .NET Framework version, as it was in the 2008 release. This should make migrating to VS 2010, for users that are using the previous version, a straightforward task.</li>
<li>As GAX was built targeting .NET 4.0, the Smart Client Guidance Package is also referencing that framework version.</li>
<li>The <strong>EntLib</strong> version used in this release is 3.1, but this is something that is being analyzed (for further information check the <em>Broad</em> <em>Changes</em> section in <a href="http://blogs.msdn.com/simplifying_patterns_and_practices/archive/2010/03/17/factory-refresh-update-17-mar-2010.aspx">this article</a>) and might change in the final release.</li>
</ul>
<p>If you have any question or feedback about this version, you could post it in the <a href="http://smartclient.codeplex.com/Thread/List.aspx">Smart Client Codeplex forum</a>.</p>
]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Running WCSF on IIS 7 (integrated mode)</title>
		<link>http://blogs.southworks.net/fantivero/2009/12/01/running-wcsf-on-iis-7-integrated-mode/</link>
		<comments>http://blogs.southworks.net/fantivero/2009/12/01/running-wcsf-on-iis-7-integrated-mode/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:13:00 +0000</pubDate>
		<dc:creator>Fernando Antivero</dc:creator>
				<category><![CDATA[CWAB]]></category>
		<category><![CDATA[IIS 7]]></category>
		<category><![CDATA[IIS 7 Integrated Mode]]></category>
		<category><![CDATA[IIS7]]></category>
		<category><![CDATA[IIS7 Integrated Mode]]></category>
		<category><![CDATA[Patterns & Practices]]></category>
		<category><![CDATA[WCSF]]></category>
		<category><![CDATA[Web Client Sofware Factory]]></category>
		<category><![CDATA[p&p]]></category>
		<category><![CDATA[II7]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/fantivero/2009/12/04/running-wcsf-on-iis-7-integrated-mode/</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/fantivero/2009/12/01/running-wcsf-on-iis-7-integrated-mode/" class="more-link">read more<img src="http://blogs.southworks.net/fantivero/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>If you host a WCSF application on IIS 7 (integrated mode), you will notice that the application throws an exception on its first request (System.Web.HttpException: Request is not available in this context).</p>
<p>This is because when the <a href="http://msdn.microsoft.com/en-us/library/bb470252.aspx">Application_Start</a> method of the <b>WebClientApplication</b> class calls the <b>GetConfiguration</b> method of the <a href="http://msdn.microsoft.com/en-us/library/cc304770.aspx">WebConfigModuleInfoStore</a> class, it requires access to the <a href="http://msdn.microsoft.com/en-us/library/system.web.httpcontext.request(VS.71).aspx">HttpContext.Request</a> that is not yet available at this point of the <a href="http://msdn.microsoft.com/en-us/library/ms227435.aspx">application’s life cycle</a>.</p>
<p>That said, I will show you how to workaround it <strong>without rebuilding the <a href="http://msdn.microsoft.com/en-us/library/cc304856.aspx">CWAB</a> and taking advantage of Dependency Injection </strong>in just three simple steps:</p>
<ol>
<li>Copy the class named <a href="http://msdn.microsoft.com/en-us/library/cc304770.aspx">WebConfigModuleInfoStore</a> under the project CompositeWeb into your main Web application, then rename it to WebConfigModuleInfoStoreExtended. </li>
<li>In the method GetConfiguration paste the following code<strong>:</strong>
<pre><span style="color: blue">private static </span>System.Configuration.<span style="color: #2b91af">Configuration </span>GetConfiguration(<span style="color: blue">string </span>configFilePath)
{
    System.Configuration.<span style="color: #2b91af">Configuration </span>configuration;
    <span style="color: #2b91af">HttpContext </span>context = <span style="color: #2b91af">HttpContext</span>.Current;
    <span style="color: blue">if </span>(context == <span style="color: blue">null</span>)
    {
        configuration = GetConfigurationForCustomFile(configFilePath);
    }
    <span style="color: blue">else
    </span>{
        configuration =
        <span style="color: #2b91af">WebConfigurationManager</span>.OpenWebConfiguration(<span style="color: #2b91af">HttpRuntime</span>.AppDomainAppVirtualPath + <span style="color: #a31515">&quot;/&quot; </span>+
                                         configFilePath.Substring(<span style="color: #2b91af">HttpRuntime</span>.AppDomainAppPath.Length));
    }
    <span style="color: blue">return </span>configuration;
}</pre>
<p>    <a href="http://11011.net/software/vspaste"></a></li>
<li>In your main Web application in the Global.asax, override the AddRequiredServices and paste the following code<strong>:</strong>
<pre><span style="color: blue">protected override void </span>AddRequiredServices()
{
    <span style="color: #2b91af">WebClientApplication</span>.AddServiceIfMissing&lt;<span style="color: #2b91af">WebConfigModuleInfoStoreExtended</span>, <span style="color: #2b91af">IModuleInfoStore</span>&gt;(RootContainer);
    <span style="color: blue">base</span>.AddRequiredServices();
}</pre>
<p>    <a href="http://11011.net/software/vspaste"></a></li>
</ol>
<p>Basically, I took inspiration from <a href="http://msmvps.com/blogs/paulomorgado/archive/2008/03/11/wcsf-2-0-and-iis7-integrated-pipeline-mode.aspx">Paulo Morgado’s post</a> to figure out how to replace the calls to the <a href="HttpContext.Request">HttpRequest</a> to use <a href="http://msdn.microsoft.com/en-us/library/system.web.httpruntime.aspx">HttpRuntime</a>.</p>
<p>You can find the complete code implemented in <a href="http://msdn.microsoft.com/en-us/library/cc304865.aspx">one of the quickstarts for CWAB</a> to download from <a href="http://blogs.southworks.net/fantivero/files/2009/12/mvpwithcwab.zip">here</a>.</p>
<p>I hope you can find this post helpful. </p>
]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Why Prism WPF applications closes when a non Shell window is closed?</title>
		<link>http://blogs.southworks.net/fantivero/2009/10/28/why-prism-wpf-applications-closes-when-a-non-shell-window-is-closed/</link>
		<comments>http://blogs.southworks.net/fantivero/2009/10/28/why-prism-wpf-applications-closes-when-a-non-shell-window-is-closed/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 01:54:41 +0000</pubDate>
		<dc:creator>Fernando Antivero</dc:creator>
				<category><![CDATA[Patterns & Practices]]></category>
		<category><![CDATA[Prism v2]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Windows Presentation Foundation]]></category>
		<category><![CDATA[p&p]]></category>
		<category><![CDATA[Patterms & Practices]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/fantivero/2009/10/28/why-prism-wpf-applications-closes-when-a-non-shell-window-is-closed/</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/fantivero/2009/10/28/why-prism-wpf-applications-closes-when-a-non-shell-window-is-closed/" class="more-link">read more<img src="http://blogs.southworks.net/fantivero/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>If you use Prism in your WPF applications, you will notice that the Shell window is usually the application’s main window. If you want to check it just execute in debug time <a href="http://msdn.microsoft.com/en-us/library/system.windows.application.mainwindow.aspx">Application.Current.MainWindow</a> from the immediate window. </p>
<p>In the <a href="http://www.codeplex.com/">Codeplex forum</a> we received an <a href="http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=73137">interesting question</a> that said that an application was being shutdown after its Login window was closed which was instantiated from the OnStartup method. </p>
<p>The reason for this particular behavior is that WPF’s <a href="http://msdn.microsoft.com/en-us/library/system.windows.window.aspx">Window</a> class has a property named <a href="http://msdn.microsoft.com/en-us/library/system.windows.application.shutdownmode.aspx">ShutdownMode</a> with default value <a href="http://msdn.microsoft.com/en-us/library/system.windows.shutdownmode.onlastwindowclose.aspx">OnLastWindowsClose</a>. So if you instantiated a window before&#160; instantiating any other window and close it, WPF implicitly calls <span><a id="ctl00_MTCS_main_ctl42_ctl00_ctl02" href="http://msdn.microsoft.com/en-us/library/system.windows.application.shutdown.aspx"><u><font color="#0066cc">Shutdown</font></u></a>.</span> This is because it is the first and unique window in the application lifetime so far.</p>
<p>What happens if you have a similar scenario?. You can implement the two following approaches:</p>
<ul>
<li>Instantiate the Login window after the Shell window, because in this way the Shell will be the last window and main windows at once, so the <a href="http://msdn.microsoft.com/en-us/library/system.windows.application.shutdown.aspx">Shutdown</a> method doesn’t be called after closes the Login window. </li>
<li>Choose to close the application explicitly. To do this, you must set the <a href="http://msdn.microsoft.com/en-us/library/system.windows.application.shutdownmode.aspx">ShutdownMode</a> with the value&#160; <span><a id="ctl00_MTCS_main_ctl42_ctl00_ctl07" href="http://msdn.microsoft.com/en-us/library/system.windows.shutdownmode.onexplicitshutdown.aspx"><font color="#0033cc">OnExplicitShutdown</font></a>, which requires an explicit <a href="http://msdn.microsoft.com/en-us/library/system.windows.application.shutdown.aspx">Shutdown</a> method call to stop the application.</span> </li>
</ul>
<h4><span>Demonstration</span></h4>
<p>You can find in this <a href="http://blogs.southworks.net/fantivero/files/2009/10/sampleshutdownmode.zip">zip file </a>the following two applications which shows how it works:</p>
<ul>
<li>ClosingSolution: The application closes after closing the Login window. </li>
<li>NotClosingSolution: The application closes explicitly. </li>
</ul>
<p>Note: The code I provided doest not follow the best practices, it’s just for demo purposes.</p>
<p>I hope you can find this post useful.</p>
]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to change the ASP.NET Page theme programmatically in CWAB</title>
		<link>http://blogs.southworks.net/fantivero/2009/10/03/how-to-change-the-aspnet-page-theme-programmatically-in-cwab-2/</link>
		<comments>http://blogs.southworks.net/fantivero/2009/10/03/how-to-change-the-aspnet-page-theme-programmatically-in-cwab-2/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 04:25:27 +0000</pubDate>
		<dc:creator>Fernando Antivero</dc:creator>
				<category><![CDATA[CWAB]]></category>
		<category><![CDATA[Patterns & Practices]]></category>
		<category><![CDATA[Theming]]></category>
		<category><![CDATA[WCSF]]></category>
		<category><![CDATA[p&p]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/fantivero/2009/10/03/how-to-change-the-aspnet-page-theme-programmatically-in-cwab-2/</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/fantivero/2009/10/03/how-to-change-the-aspnet-page-theme-programmatically-in-cwab-2/" class="more-link">read more<img src="http://blogs.southworks.net/fantivero/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[</p>
<p>&#160;</p>
<p>One of things that we may need in a CWAB application is changing the ASP.Net page theme programmatically based on some logic.</p>
<p>If we want to achieve this, probably we will quickly be aware which it presents some design challenges for us: </p>
<ul>
<li>What is the best place to put your logic? </li>
<li>How should we expose the artifact which retrieves the theme name? </li>
<li>When and where must we set the theme in the ASP.Net page? </li>
</ul>
<p>That said, I think that a good idea could be creating a global service in the Shell Module to retrieve the theme. Because in this way we will consume this service from a page to set the theme programmatically. </p>
<p>Inspired by this <a href="http://websf.codeplex.com/Thread/View.aspx?ThreadId=70556">forum thread</a>, the logic to determine that ThemeName is retrieved based on the name of site. in the sample explain below. </p>
<p>If your not familiar with the topics listed below, consider taking a look to the links before starting with the steps I listed.:</p>
<ul>
<li>Register a new service as <a href="http://msdn.microsoft.com/en-us/library/cc304836.aspx">Global Service</a>. </li>
<li><a href="http://msdn.microsoft.com/en-us/library/cc304811.aspx">Dependency Injection</a> to access the service from the page. </li>
</ul>
<p>The steps to implement one of the possible solutions are the following: </p>
<h4>Creating the ThemeResolutionProvider service</h4>
<ol>
<li>Create a new folder named <strong>Services</strong> under the Shell Module. </li>
<li>Add a new interface named <strong>IThemeProvider </strong>in the Services folder and a new class named ThemeResolutionProvier in the Services folder.       <br /><a href="http://blogs.southworks.net/fantivero/files/2009/10/solutionexplorer.png"><img border="0" alt="solutionexplorer" src="http://blogs.southworks.net/fantivero/files/2009/10/solutionexplorer-thumb.png" width="244" height="220" /></a> </li>
<li>Update the <strong>IThemeProvider.cs</strong> with the following code:
<pre><span style="color: blue">public interface </span><span style="color: #2b91af">IThemeProvider
</span>{
    <span style="color: blue">string </span>GetThemeName();
} </pre>
</li>
<li>Implement <strong>ThemeResolutionProvider.cs</strong> like this:
<pre><span style="color: blue">public class </span><span style="color: #2b91af">ThemeResolutionProvider </span>: <span style="color: #2b91af">IThemeProvider </span>
{
    <span style="color: blue">private </span><span style="color: #2b91af">IHttpContextLocatorService </span>_httpContextLocatorService;
    <span style="color: blue">public </span>ThemeResolutionProvider([<span style="color: #2b91af">ServiceDependency</span>] <span style="color: #2b91af">IHttpContextLocatorService</span> httpContextLocatorService)
    {
        <span style="color: blue">this</span>._httpContextLocatorService = httpContextLocatorService;
    }
    <span style="color: blue">public string </span>GetThemeName()
    {
        <span style="color: blue">string </span>themeName = <span style="color: blue">string</span>.Empty;
        <span style="color: blue">var </span>request = <span style="color: blue">this</span>._httpContextLocatorService.GetCurrentContext().Request;
        <span style="color: blue">switch </span>(request.Url.Authority)
        {
            <span style="color: blue">case </span><span style="color: #a31515">&quot;YourSite&quot;</span>:
                {
                    themeName = <span style="color: #a31515">&quot;YourCustomeTheme&quot;</span>;
                    <span style="color: blue">break</span>;
                }
            <span style="color: blue">default</span>:
                {
                    themeName = <span style="color: #a31515">&quot;Default&quot;</span>;
                    <span style="color: blue">break</span>;
                }
        }
        <span style="color: blue">return </span>themeName;
    }
}</pre>
<p>    <a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
<p><strong>Note:</strong> if you examine this code you will notice that the constructor has an argument with an attribute ServiceDependecy. This is necessary to notify ObjectBuilder to inject the object (for further information visit <a href="http://msdn.microsoft.com/en-us/library/cc304811.aspx">Dependency Injection</a>). Also notice that the <a href="http://msdn.microsoft.com/en-us/library/cc304770.aspx">IHttpContextLocatorService</a> helps you to access the HttpContext (to obtain the name of the site from the module). </p>
</li>
</ol>
<h4>Using the ThemeResolutionProvider service.</h4>
<ol>
<li>Once you have created the service, you should register it as a <a href="http://msdn.microsoft.com/en-us/library/cc304836.aspx">Global Service</a> in the ShellModuleInitializer class under the Shell project. So in this class, locate <strong>AddGlobalServices</strong> method and add the following code to the method body to register the theme service.
<pre><span style="color: blue">protected virtual void </span>AddGlobalServices(<span style="color: #2b91af">IServiceCollection </span>globalServices)
{
     <span style="color: green">//more code here
     </span>globalServices.AddNew&lt;ThemeResolutionProvider, IThemeProvider&gt;();
}&#160; </pre>
</li>
<li>Finally you just need to programmatically set the <strong>ThemeName</strong> in your page, by adding the following property to your page:
<pre>[<span style="color: #2b91af">ServiceDependency</span>]
<span style="color: blue">public </span><span style="color: #2b91af">IThemeProvider </span>ThemeResolutionProvider
{
     <span style="color: blue">set
     </span>{
          <span style="color: blue">this</span>.Theme = value.GetThemeName();
     }
}</pre>
<p>    <a href="http://11011.net/software/vspaste"></a></p>
<p><strong>Note:&#160; </strong>Here the property has the ServiceDependency attribute, to notify ObjectBuilder that in the Page PreInit it has to inject an instance of the IThemeProvider. As the IThemeProvider is injected OnPreInit it is possible to set the theme. <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.page.theme.aspx">You can read more about that</a>.</p>
</li>
</ol>
<p><strong>Important:</strong> If you have just a few pages where you have to apply this behavior, this is a good approach. But take in account that you can create a base class which inherits from Microsoft.Practices.CompositeWeb.Web.UI.<strong>Page </strong>to implement this behavior for an entire website. </p>
<p>I hope that this post helps you. As always your feedback is really appreciated.</p>
]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How CWAB takes advantage of ObjectBuilder</title>
		<link>http://blogs.southworks.net/fantivero/2009/09/25/how-cwab-takes-advantage-of-objectbuilder/</link>
		<comments>http://blogs.southworks.net/fantivero/2009/09/25/how-cwab-takes-advantage-of-objectbuilder/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 21:43:32 +0000</pubDate>
		<dc:creator>Fernando Antivero</dc:creator>
				<category><![CDATA[CWAB]]></category>
		<category><![CDATA[ObjectBuilder]]></category>
		<category><![CDATA[Patterns & Practices]]></category>
		<category><![CDATA[WCSF]]></category>
		<category><![CDATA[p&p]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/fantivero/?p=11</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/fantivero/2009/09/25/how-cwab-takes-advantage-of-objectbuilder/" class="more-link">read more<img src="http://blogs.southworks.net/fantivero/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p><font color="#000000" size="3" face="Calibri"></font></p>
<p><span><font face="Calibri"><font size="3"><font color="#000000"></font></font></font></span></p>
<p>As you may know <a href="http://www.codeplex.com/websf/Wiki/View.aspx?title=Composite%20Web%20Application%20Block">Composite Web Application Block</a> (a.k.a. CWAB) is part of a compendium of application blocks which are included into <a href="http://websf.codeplex.com/">Web Client Software Factory</a> (a.k.a. WCSF). </p>
<p>CWAB helps architects and developers create web applications obtaining the following benefits: </p>
<ul>
<li>Separation of Concerns </li>
<li>Modularity </li>
<li>Extensibility </li>
<li>Testability </li>
<li>Maintainability </li>
</ul>
<p> <font color="#000000" size="3" face="Calibri"><span></span></font><span><font size="3"><font color="#000000" face="Calibri"></font></font></span><font color="#000000"></font><font color="#000000"></font><font color="#000000"></font><font color="#000000"></font><font color="#000000"></font><font color="#000000"></font>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal">When I started researching WCSF, one of the most interesting things I noticed was how CWAB takes advantage of <a href="http://www.codeplex.com/ObjectBuilder">ObjectBuilder</a> and I want to share with you some highlights about it. </p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal"><font color="#000000" size="3" face="Calibri"></font></p>
<h4>ObjectBuilder Introduction</h4>
</p>
<p>ObjectBuilder is a framework for creating <a href="http://en.wikipedia.org/wiki/Dependency_injection">dependency injection</a> systems that uses the <a href="http://msdn.microsoft.com/en-us/library/ms954600.aspx">factory pattern</a> to create object instances. So, basically it creates and injects instances of objects of the appropriate type into the application at run time. </p>
<p>That is why, when you inspect the source code for a CWAB application, you will notice that the application does not always create instances of another component by directly constructing an object (using new). Instead, the source code contains attributes such as CreateNew and ServiceDependency which are in charge of supporting the injection of objects at run time.</p>
<p> <span><br />
<h4>ObjectBuilder with CWAB</h4>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal">
<p> </span>
<p>One might wonder, how does ObjectBuilder work when a property has the CreateNew attribute in a CWAB page?</p>
<p>By default in a CWAB application, its pages inherit from <strong>Microsoft.Practices.CompositeWeb.Web.UI.Page</strong> which overloads the <strong>OnPreInit</strong> method where calls to ObjectBuilder are made in order to iterate through the page properties which contain a CreateNew attribute and allow the creation of all needed instances for the page.</p>
<p>To show this more clearly you can find below a piece of code.</p>
<table border="0" cellspacing="0" cellpadding="2" width="682">
<tbody>
<tr>
<td valign="top" width="680">
<pre><span style="color: blue">public partial class </span><span style="color: #2b91af">MyPage </span>: <strong>Microsoft.Practices.CompositeWeb.Web.UI.<span style="color: #2b91af">Page</span></strong>, <span style="color: #2b91af">IContactsListView</span>
{
    <strong>[<span style="color: #2b91af">CreateNew</span>]</strong>
    <span style="color: blue">public </span>MyPagePresenter Presenter
    {
        <span style="color: blue">set
        </span>{
            <span style="color: blue">this</span>._presenter = <span style="color: blue">value</span>;
            <span style="color: blue">if </span>(<span style="color: blue">value </span>!= <span style="color: blue">null</span>)
            {
                <span style="color: blue">this</span>._presenter.View = <span style="color: blue">this</span>;
            }
        }
        <span style="color: blue">get
        </span>{
            <span style="color: blue">return this</span>._presenter;
        }
    }
<span style="color: green"><font color="#333333">    </font>// more code here</span>
}</pre>
</td>
</tr>
</tbody>
</table>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal"><span><font color="#000000" size="3" face="Calibri"></font></span></p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal"><span><font color="#000000" size="3" face="Calibri"></font></span></p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal"><font size="3"><font face="Calibri"></font></font></p>
<p>So far, we&#8217;ve explained how ObjectBuilder and a CWAB page work together, but how does ObjectBuilder work with a CWAB Presenter or Controller from a module?</p>
<p>In some cases in order to decouple your components in a CWAB Module, you might use interfaces unlike CWAB Page which uses concrete types, so the CWAB Module has to find the way to notify ObjectBuilder how to determine the type of object that it creates.</p>
<p>To do this, CWAB exposes a container where developers can indicate how to match interfaces with concrete object types in the “Initializer Module”.</p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal"><font color="#000000" size="3" face="Calibri"></font></p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal"><font size="3" face="Calibri"></font></p>
<table border="0" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td valign="top" width="400">
<pre><span style="color: blue">public class </span><span style="color: #2b91af">ContactsModuleInitializer </span>: ModuleInitializer
{
    <span style="color: blue">public override void </span>Load(CompositionContainer container)
    {
        <span style="color: blue">base</span>.Load(container);

        AddGlobalServices(container.Parent.Services);
        AddModuleServices(container.Services);
        RegisterSiteMapInformation(container.Services.Get&lt;ISiteMapBuilderService&gt;(<span style="color: blue">true</span>));

        <strong>container.RegisterTypeMapping&lt;</strong><span style="color: #2b91af">IMyPageController</span><strong>, </strong><span style="color: #2b91af">MyPageController</span><strong>&gt;();</strong>
    }
    <span style="color: green">//more code here
</span>}</pre>
</td>
</tr>
</tbody>
</table>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal">&#160;</p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal">Once the developer adds the mappings between interfaces and concrete types, they will be able to use interfaces inside CWAB Modules. </p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal">&#160;</p>
<table border="0" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td valign="top" width="400">
<pre><span style="color: blue">public class </span><span style="color: #2b91af">MyPageViewPresenter </span>: Presenter&lt;<span style="color: #2b91af">IMyPageView</span>&gt;
{
    <span style="color: blue">private <span style="color: #2b91af">IMyPageController </span></span>_controller;

    <span style="color: blue">public </span>DefaultViewPresenter([<span style="color: #2b91af"><strong>CreateNew</strong></span>] <span style="color: #2b91af">IMyPageController </span>controller)
    {
        <span style="color: blue">this</span>._controller = controller;
    }
    <span style="color: green">//more code here
</span>}</pre>
<pre><span style="color: blue">public class </span><span style="color: #2b91af">MyPageController
</span>{
    <span style="color: blue">private <span style="color: #2b91af">IService </span></span>_service;

    <span style="color: blue">public </span>MyPageController
        <strong>([<span style="color: #2b91af">ServiceDependency</span>]</strong> <span style="color: #2b91af">IService</span> service)
    {
        _service = service;
    }
    <span style="color: green">//more code here
</span>}</pre>
</td>
</tr>
</tbody>
</table>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal"><font size="3" face="Calibri"></font></p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal">&#160;</p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal">If you want continue reading more about it, I recommend to visit the following blog post <a href="http://blogs.southworks.net/jdominguez/2007/05/how-to-extend-object-creation-in-the-web-client-software-factory/">How To: about Extend Object Creation in the Web Client Software Factory</a></p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal">&#160;</p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal">I hope the article helps you to understand more about ObjectBuilder with CWAB. As always your feedback is really appreciated.</p>
]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

