<?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>Southworks Blogs</title>
	
	<link>http://blogs.southworks.net</link>
	<description>Powered by Southworks</description>
	<lastBuildDate>Fri, 03 Feb 2012 23:40:37 +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/master-feed" /><feedburner:info uri="master-feed" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><image><link>http://blogs.southworks.net</link><url>http://static.southworksinc.com/images-v1/sw_logo.png</url><title>Southworks</title></image><item>
		<title>End of Iteration ;)</title>
		<link>http://feeds.southworks.net/~r/master-feed/~3/uFrkAr89tF0/</link>
		<comments>http://blogs.southworks.net/aschapiro/2012/02/03/end-of-iteration/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 23:40:37 +0000</pubDate>
		<dc:creator>aschapiro</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://3.188</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/aschapiro/2012/02/03/end-of-iteration/" class="more-link">read more<img src="http://blogs.southworks.net/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>As some of you know, I’m closing a chapter of my professional life in Southworks today and starting a new one in Microsoft Argentina (DPE) from next week.
<p>It’s been a 6.5 years chapter actually, that started for me in an earlier version of the Southworks that exists today. I think we grew a lot, in part because of the awesome team we helped to build together and also because of the help of very talented and generous people, passionate of getting better every day. I believe the current version of Southworks is the result of that hard work: a well-respected and growing company that earned its place of high quality service, that world-changing agents trust and where many talented engineers find a place to grow and share.
<p>Lots of projects, trips, experiences and people come to my mind now. Ale Jack, <a href="http://blogs.southworks.net/mwoloski/">Mawolo</a>, <a href="http://blogs.southworks.net/fjack/">Fede Jack</a>, Tincho Cacciola, <a href="http://blogs.southworks.net/tosborn/">TimO</a>, <a href="http://blogs.southworks.net/mszklanny/">Mariano S</a>, <a href="http://blogs.southworks.net/pdamiani/">Lito</a>, Beto, <a href="http://blog.salias.com.ar/">Martin Salias</a>, <a href="http://blogs.southworks.net/ejadib/">EZ</a>, <a href="http://johnny.io/">Johnny</a> and <a href="http://blogs.southworks.net/jpgarcia/">JPG</a> are some of the “oldest” <strong>friends</strong> here (in representation of the whole team which includes many, many awesome people that I’ve been interacting with in the last years): well let me thank you for the incredible help, guidance, support and teamwork of these years. I guess I’ll be happy in the future if I get a 1% of what I felt, grew and did at Southworks; and I guess I will because I’ll carry the Southworks flag with me.
<p>I’m simply happy of spending my last 6.5 years working at Southworks but honestly I don’t think that our story together ends here. As I said before, this is just an End of Iteration, and I’m looking forward to keep working and growing together in the following iteration! I’ll be around, you’ll see….and we’ll keep having moments like these:
<p><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="image002" border="0" alt="image002" src="http://blogs.southworks.net/aschapiro/files/2012/02/image002.png" width="561" height="523">
<p>See you soon and keep it up!</p>
<div class="feedflare">
<a href="http://feeds.southworks.net/~ff/master-feed?a=uFrkAr89tF0:aEbUXvpRz7Q:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=uFrkAr89tF0:aEbUXvpRz7Q:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/master-feed?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=uFrkAr89tF0:aEbUXvpRz7Q:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/master-feed?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=uFrkAr89tF0:aEbUXvpRz7Q:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=uFrkAr89tF0:aEbUXvpRz7Q:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/master-feed?i=uFrkAr89tF0:aEbUXvpRz7Q:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=uFrkAr89tF0:aEbUXvpRz7Q:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/master-feed?i=uFrkAr89tF0:aEbUXvpRz7Q:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=uFrkAr89tF0:aEbUXvpRz7Q:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/master-feed?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/master-feed/~4/uFrkAr89tF0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.southworks.net/aschapiro/2012/02/03/end-of-iteration/</feedburner:origLink></item>
		<item>
		<title>How to build a basic fluent interface in 8 steps</title>
		<link>http://feeds.southworks.net/~r/master-feed/~3/cNxUgs6CD5o/</link>
		<comments>http://blogs.southworks.net/jrowies/2012/02/01/how-to-build-a-basic-fluent-interface-in-8-steps/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 17:40:35 +0000</pubDate>
		<dc:creator>Jorge Rowies</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Fluent API]]></category>
		<category><![CDATA[Internal DSL]]></category>

		<guid isPermaLink="false">http://132.133</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/jrowies/2012/02/01/how-to-build-a-basic-fluent-interface-in-8-steps/" class="more-link">read more<img src="http://blogs.southworks.net/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Disclaimer: the aim of this post is not to show a comprehensive list of the different techniques that can be used to write a fluent API, tons of good information is out there on the web and. If you are very interested in the subject, please take a look at Martin Fowler’s <a href="http://www.amazon.com/Domain-Specific-Languages-Addison-Wesley-Signature-Fowler/dp/0321712943/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1327945788&amp;sr=1-1">Domain-Specific Languages</a>.<br />
</strong></p>
<p>Now that I took that load off my back, let’s start writing a fluent interface.</p>
<p>Imagine we are developing an API to publish blog posts to multiple blogging platforms (Blogger, WordPress, TypePad and so on…), chances are that our (super-simplified) domain model will be something similar to this:</p>
<p><a href="http://blogs.southworks.net/jrowies/files/2012/01/ClassDiagram.png"><img class="alignnone size-full wp-image-140" src="http://blogs.southworks.net/jrowies/files/2012/01/ClassDiagram.png" alt="" width="368" height="123" /></a></p>
<p>So, creating a new blog post should be:</p>
<pre class="brush: csharp; title: ; notranslate">
var post = new BlogPost();
post.Title = &quot;How to build a basic fluent interface in 8 steps&quot;;
post.Body = &quot;&lt;html&gt;...&lt;/html&gt;&quot;;

var author = new Author(); // We should check the authors repository
                           // before creating a new one
author.Name = &quot;John Doe&quot;;
author.Email = &quot;johndoe@email.com&quot;;
author.Twitter = &quot;@johndoe&quot;;
post.Author = author;

post.Tags = &quot;Fluent API, Internal DSL&quot;;
</pre>
<p>Our domain model is very simple and the code for creating a blog post is not so bad to read or write, so in this case implementing a fluent interface might be somewhat unnecessary; but… it’s perfect for us to learn how to write a fluent API. Shall we?</p>
<p><strong>Step 1 &#8211; Writing a draft of the interface</strong></p>
<p><strong></strong>Write (in notepad) a draft of the fluent interface showing how you want it to look like (don’t think too much now on <strong>how</strong> you will implement the interface, just play around with the ideas)</p>
<p>This is what I came up with:</p>
<p><code><br />
var post = Post<br />
.Title("How to build a basic fluent interface in 8 steps")<br />
.Body("...")<br />
.Author()<br />
.Name("John Doe")<br />
.Email("johndoe@email.com")<br />
.Twitter("@johndoe")<br />
.Tags("Fluent API, Internal DSL");<br />
</code></p>
<p><strong>Step 2 &#8211; Using a test-first approach</strong></p>
<p><strong></strong>Once you found an option that satisfies you, put it into a test in Visual Studio and add the code you will need to validate the outcome of the fluent interface. Depending on the size of the API, you might want to do this gradually. In this case, we are going to leave the “Author” part out of the scope for now.</p>
<p>In the code below we are creating two BlogPost instances, the first one using the standard API and the second one using our new fluent API. After both instances are created, they are passed to the CheckEquivalence method. This method should check if both instances of BlogPost have the same title, body and tags.</p>
<pre class="brush: csharp; title: ; notranslate">
[TestCase]
public void ConfiguringPostWithoutAuthor()
{
    var expected = new BlogPost();
    expected.Title = &quot;How to build a basic fluent interface in 8 steps&quot;;
    expected.Body = &quot;&lt;html&gt;...&lt;/html&gt;&quot;;
    expected.Tags = &quot;Fluent API, Internal DSL&quot;;

    var post = Post
        .Title(&quot;How to build a basic fluent interface in 8 steps&quot;)
        .Body(&quot;&lt;html&gt;...&lt;/html&gt;&quot;)
        .Tags(&quot;Fluent API, Internal DSL&quot;);
    BlogPost actual = post.Build();

    Assert.IsTrue(TestsHelper.CheckEquivalence(expected, actual));
}
</pre>
<p>This test, of course, won’t even compile.</p>
<p><strong>Step 3 &#8211; Starting to implement the interface</strong></p>
<p><strong></strong>Now, let’s start implementing the Post class. Note that the Title method is static so we can call it without creating a new instance of Post.</p>
<pre class="brush: csharp; title: ; notranslate">
public class Post
{
    public static Post Title(string title)
    {
        var post = new Post();
        post.TitleValue = title;
        return post;
    }
}
</pre>
<p><strong>Step 4 &#8211; Adding more methods to the fluent interface</strong></p>
<p><strong></strong>Once we have our starting point, continue adding the remaining methods (this time as instance methods, not static).</p>
<pre class="brush: csharp; title: ; notranslate">
public class Post
{
    ...

    public Post Body(string body)
    {
        this.BodyValue = body;
        return this;
    }

    public Post Tags(string tags)
    {
        this.TagsValue = tags;
        return this;
    }
}
</pre>
<div style="background-color: #ffffe0;margin: 5px 0 15px;padding: 0 .6em;border: 1px solid #e6db55">Returning the same instance of the object we are building after each method call is one of the most common techniques used to write fluent interfaces, it&#8217;s called <a href="http://en.wikipedia.org/wiki/Method_chaining"><strong>Method Chaining</strong></a>.</div>
<p><strong>Step 5 &#8211; Completing the first iteration and running tests</strong></p>
<p><strong></strong>Now, let’s implement the Build method by creating an instance of BlogPost based on the values provided with the fluent interface.</p>
<pre class="brush: csharp; title: ; notranslate">
public class Post
{
    ...

    public BlogPost Build()
    {
        var blogPost = new BlogPost();

        blogPost.Title = this.TitleValue;
        blogPost.Body = this.BodyValue;
        blogPost.Tags = this.TagsValue;

        return blogPost;
    }
}
</pre>
<p>Our test should be green now!</p>
<p><strong>Step 6 &#8211; Don&#8217;t forget the Author</strong></p>
<p><strong></strong>Here comes the tricky part, let’s add the Author now…</p>
<p>If we continue what we’ve been doing with the Title, Body and Tags methods, we should make Author return an instance of Post; but if we do that, we should put the methods Name, Email and Twitter in the Post class, and we don’t want that. What we want is having those methods in a separate class, so instead of returning an instance of Post we are going to return an instance of a new class (AuthorSpec). Let’s try it.</p>
<pre class="brush: csharp; title: ; notranslate">
public class Post
{
	...

	public AuthorSpec Author()
	{
		var authorSpec = new AuthorSpec();
		return authorSpec;
	}
}

public class AuthorSpec
{
	public AuthorSpec Name(string name)
	{
		this.NameValue = name;
		return this;
	}

	public AuthorSpec Email(string email)
	{
		this.EmailValue = email;
		return this;
	}

	public AuthorSpec Twitter(string twitter)
	{
		this.TwitterValue = twitter;
		return this;
	}
}
</pre>
<p>Now let’s create a new test method, adding the “Author” code:</p>
<pre class="brush: csharp; title: ; notranslate">
public void ConfiguringPostWithAuthor()
{
	var expected = new BlogPost();
	expected.Title = &quot;How to build a basic fluent interface in 8 steps&quot;;
	expected.Body = &quot;&lt;html&gt;...&lt;/html&gt;&quot;;
	expected.Tags = &quot;Fluent API, Internal DSL&quot;;
	var author = new Author();
	author.Name = &quot;John Doe&quot;;
	author.Email = &quot;johndoe@email.com&quot;;
	author.Twitter = &quot;@johndoe&quot;;
	expected.Author = author;

	var post = Post
		.Title(&quot;How to build a basic fluent interface in 8 steps&quot;)
		.Body(&quot;&lt;html&gt;...&lt;/html&gt;&quot;)
		.Author()
			.Name(&quot;John Doe&quot;)
			.Email(&quot;johndoe@email.com&quot;)
			.Twitter(&quot;@johndoe&quot;)
		.Tags(&quot;Fluent API, Internal DSL&quot;);
	BlogPost actual = post.Build();

	Assert.IsTrue(CheckEquivalence(expected, actual));
}
</pre>
<p>But wait! The compiler says that the Tags method is not recognized as a member of the AuthorSpec class. That’s because we are calling Tags over the return value of Twitter, which is an AuthorSpec object instead of a Post object.</p>
<div style="background-color: #ffffe0;margin: 5px 0 15px;padding: 0 .6em;border: 1px solid #e6db55">When writing fluent APIs, it is very common to bump into this kind of problems, the most used solutions for this are ending the Author specification with an “end” method, or passing a nested closure to the Author method.</div>
<p><strong>Step 7 &#8211; Closing the Author specification and running more tests</strong></p>
<p><strong></strong>Option A, using an “End” method.</p>
<pre class="brush: csharp; title: ; notranslate">
public class Post
{
    ...

    public AuthorSpec Author()
    {
        this.authorSpec = new AuthorSpec(this);
        return authorSpec;
    }
}

public class AuthorSpec
{
    public AuthorSpec(Post parent)
    {
        this.parent = parent;
    }

    ...

    public Post End()
    {
        return this.parent;
    }
}
</pre>
<p>How it looks like:</p>
<pre class="brush: csharp; title: ; notranslate">
var post = Post
    .Title(&quot;How to build a basic fluent interface in 8 steps&quot;)
    .Body(&quot;&lt;html&gt;...&lt;/html&gt;&quot;)
    .Author()
        .Name(&quot;John Doe&quot;)
        .Email(&quot;johndoe@email.com&quot;)
        .Twitter(&quot;@johndoe&quot;)
        .End()
    .Tags(&quot;Fluent API, Internal DSL&quot;);
</pre>
<p>Option B, using a nested closure.</p>
<pre class="brush: csharp; title: ; notranslate">
public class Post
{
    ...

    public Post Author(Action&lt;AuthorSpec&gt; spec)
    {
        this.authorSpec = new AuthorSpec();
        spec(authorSpec);
        return this;
    }
}
</pre>
<p>How it looks like:</p>
<pre class="brush: csharp; title: ; notranslate">
var post = Post
    .Title(&quot;How to build a basic fluent interface in 8 steps&quot;)
    .Body(&quot;&lt;html&gt;...&lt;/html&gt;&quot;)
    .Author(a =&gt; a
        .Name(&quot;John Doe&quot;)
        .Email(&quot;johndoe@email.com&quot;)
        .Twitter(&quot;@johndoe&quot;))
    .Tags(&quot;Fluent API, Internal DSL&quot;);
</pre>
<p>I personally prefer option B. I think it’s easier to read and the programmer doesn’t have to remember calling the “End” method.</p>
<p>After implementing one of these options, our test should be green.</p>
<p><strong>Step 8 &#8211; Stepping into dangerous territories</strong></p>
<p><strong></strong>Let’s imagine we want to force people using our API to set the author name first and then configure the email address or the twitter account, but not both (exclusive or). We can make use of interfaces to show only a filtered subset of the methods in the method chain.</p>
<pre class="brush: csharp; title: ; notranslate">
public class Post
{
    ...

    public Post Author(Action&lt;IAuthorSpecAfterCreation&gt; spec)
    {
        this.authorSpec = new AuthorSpec();
        spec(authorSpec);
        return this;
    }
}

public interface IAuthorSpecAfterCreation
{
    IAuthorSpecAfterName Name(string name);
}

public interface IAuthorSpecAfterName
{
    IAuthorSpecAfterEmailOrTwitter Email(string email);
    IAuthorSpecAfterEmailOrTwitter Twitter(string twitter);
}

public interface IAuthorSpecAfterEmailOrTwitter
{
}

public class AuthorSpec : IAuthorSpecAfterCreation,
  IAuthorSpecAfterName, IAuthorSpecAfterEmailOrTwitter
{
    public IAuthorSpecAfterName Name(string name)
    {
        this.NameValue = name;
        return this;
    }

    public IAuthorSpecAfterEmailOrTwitter Email(string email)
    {
        this.EmailValue = email;
        return this;
    }

    public IAuthorSpecAfterEmailOrTwitter Twitter(string twitter)
    {
        this.TwitterValue = twitter;
        return this;
    }
}
</pre>
<div style="background-color: #ffffe0;margin: 5px 0 15px;padding: 0 .6em;border: 1px solid #e6db55">This technique can become very useful, but the complexity of the API can grow quickly with so many interfaces here and there… use it with precaution.</div>
<p><strong>The complete sources can be grabbed from <a href="https://github.com/jrowies/blog-buildfluentapi">here</a>.</strong></p>
<p>That&#8217;s it, I hope this helps <img src='http://blogs.southworks.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="feedflare">
<a href="http://feeds.southworks.net/~ff/master-feed?a=cNxUgs6CD5o:IW33L3vgenA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=cNxUgs6CD5o:IW33L3vgenA:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/master-feed?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=cNxUgs6CD5o:IW33L3vgenA:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/master-feed?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=cNxUgs6CD5o:IW33L3vgenA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=cNxUgs6CD5o:IW33L3vgenA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/master-feed?i=cNxUgs6CD5o:IW33L3vgenA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=cNxUgs6CD5o:IW33L3vgenA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/master-feed?i=cNxUgs6CD5o:IW33L3vgenA:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=cNxUgs6CD5o:IW33L3vgenA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/master-feed?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/master-feed/~4/cNxUgs6CD5o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.southworks.net/jrowies/2012/02/01/how-to-build-a-basic-fluent-interface-in-8-steps/</feedburner:origLink></item>
		<item>
		<title>Fluent API for setting up Windows Azure ACS</title>
		<link>http://feeds.southworks.net/~r/master-feed/~3/SLUJFW7XmJk/</link>
		<comments>http://blogs.southworks.net/jrowies/2012/01/28/fluent-api-for-setting-up-windows-azure-acs/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 16:45:39 +0000</pubDate>
		<dc:creator>Jorge Rowies</dc:creator>
				<category><![CDATA[ACS]]></category>
		<category><![CDATA[Access Control Service]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Fluent API]]></category>
		<category><![CDATA[Windows Azure]]></category>

		<guid isPermaLink="false">http://132.107</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/jrowies/2012/01/28/fluent-api-for-setting-up-windows-azure-acs/" class="more-link">read more<img src="http://blogs.southworks.net/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>During the last couple of months I&#8217;ve been working for the p&amp;p guys at Microsoft, developing the sample application for a new guide around Windows Azure hybrid application integration. </p>
<p>One of the components of the sample solution is a console application that performs all the steps required to have the ACS and Service Bus namespaces properly configured. This application uses a set of wrappers around the ACS Management Service API. </p>
<p>While this is a great step towards simplifying the life of the developer, after I looked at the resulting code I realized that my life could have been simplified even more. That&#8217;s why I decided to spend some of my time developing a fluent API for setting up ACS namespaces. </p>
<p>This is how the API looks like:</p>
<pre class="brush: csharp; title: ; notranslate">
var namespaceDesc = new AcsNamespaceDescription(
	&quot;somenamespace&quot;, &quot;ManagementClient&quot;, &quot;T+bQtqP21BaCLO/8D1hanRdKJF8ZYEV8t32odxP4pYk=&quot;);

var acsNamespace = new AcsNamespace(namespaceDesc);

acsNamespace
	.AddGoogleIdentityProvider()
	.AddServiceIdentity(
		si =&gt; si
			.Name(&quot;Vandelay Industries&quot;)
			.Password(&quot;Passw0rd!&quot;))
	.AddRelyingParty(
		rp =&gt; rp
			.Name(&quot;MyCoolWebsite&quot;)
			.RealmAddress(&quot;http://mycoolwebsite.com/&quot;)
			.ReplyAddress(&quot;http://mycoolwebsite.com/&quot;)
			.AllowGoogleIdentityProvider()
			.SwtToken()
			.TokenLifetime(120)
			.SymmetricKey(
				Convert.FromBase64String(&quot;yMryA5VQVmMwrtuiJBfyjMnAJwoT7//fCuM6NwaHjQ1=&quot;))
			.AddRuleGroup(rg =&gt; rg
				.Name(&quot;Rule Group for MyCoolWebsite Relying Party&quot;)
				.AddRule(
					rule =&gt; rule
						.Description(&quot;Google Passthrough&quot;)
						.IfInputClaimIssuer().Is(&quot;Google&quot;)
						.AndInputClaimType().IsOfType(ClaimTypes.Email)
						.AndInputClaimValue().IsAny()
						.ThenOutputClaimType().ShouldBe(ClaimTypes.Name)
						.AndOutputClaimValue().ShouldPassthroughFirstInputClaimValue())
				.AddRule(
					rule =&gt; rule
						.Description(&quot;ACS rule&quot;)
						.IfInputClaimIssuer().IsAcs()
						.AndInputClaimType().IsAny()
						.AndInputClaimValue().IsAny()
						.ThenOutputClaimType().ShouldPassthroughFirstInputClaimType()
						.AndOutputClaimValue().ShouldPassthroughFirstInputClaimValue())));

acsNamespace.SaveChanges(logInfo =&gt; Console.WriteLine(logInfo.Message));
</pre>
<p>You can find more information in the <a href="https://github.com/jrowies/FluentACS/blob/master/README.markdown">project repository</a> at github. </p>
<p>Oh, and please don&#8217;t forget to take a look at the hybrid application integration guide when it becomes available (a draft can be downloaded from <a href="http://wag.codeplex.com/releases/view/74838">here</a>), these guys have been doing an incredible job !</p>
<p>That’s it, I hope this helps <img src='http://blogs.southworks.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="feedflare">
<a href="http://feeds.southworks.net/~ff/master-feed?a=SLUJFW7XmJk:zAW7gNl2xJg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=SLUJFW7XmJk:zAW7gNl2xJg:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/master-feed?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=SLUJFW7XmJk:zAW7gNl2xJg:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/master-feed?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=SLUJFW7XmJk:zAW7gNl2xJg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=SLUJFW7XmJk:zAW7gNl2xJg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/master-feed?i=SLUJFW7XmJk:zAW7gNl2xJg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=SLUJFW7XmJk:zAW7gNl2xJg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/master-feed?i=SLUJFW7XmJk:zAW7gNl2xJg:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=SLUJFW7XmJk:zAW7gNl2xJg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/master-feed?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/master-feed/~4/SLUJFW7XmJk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.southworks.net/jrowies/2012/01/28/fluent-api-for-setting-up-windows-azure-acs/</feedburner:origLink></item>
		<item>
		<title>Visual Studio 11 Developer Preview Training Kit</title>
		<link>http://feeds.southworks.net/~r/master-feed/~3/PGhOhYC49tk/</link>
		<comments>http://blogs.southworks.net/sdurandeu/2012/01/27/visual-studio-11-developer-preview-training-kit/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 14:37:00 +0000</pubDate>
		<dc:creator>sdurandeu</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://45.123</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/sdurandeu/2012/01/27/visual-studio-11-developer-preview-training-kit/" class="more-link">read more<img src="http://blogs.southworks.net/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.southworks.net/sdurandeu/files/2012/01/image.png"><img style="margin: 0px 10px 0px 0px;float: left" alt="image" align="left" src="http://blogs.southworks.net/sdurandeu/files/2012/01/image_thumb.png" width="354" height="226"></a>If you want to get a sneak peak on what’s coming up in the next version of Visual Studio, the Visual Studio 11 Training Kit is the no brainer choice.&nbsp; The training kit includes hands-on labs to help you understand how to take advantage of the variety of enhancements in Visual Studio 11 and the .NET Framework 4.5. </p>
<p>Some of the topics included are:</p>
<ul>
<li>What’s new in ASP.NET MVC 4 – <em>this lab shows how to use jQuery Mobile together with new MVC 4 features, to make a Web app work great across different mobile devices and desktop web browsers</em> </li>
<li>What’s new in ASP.NET Web Forms </li>
<li>Page Inspector – <em>a new tool that brings browser diagnostics tools to Visual Studio 11 </em></li>
<li>New Visual Studio 11 IDE features – <em>including a whole lab for showing C++ development enhancements</em> </li>
<li>WCF Web API </li>
<li>Async programming in .NET Framework 4.5 – <em>showing the new async and await keywords</em> </li>
<li>Portable Class Libraries support </li>
<li>Application Lifecycle Management features in Visual Studio 11 &#8211; <em>see more of this in </em><a href="http://blogs.msdn.com/b/briankel/"><em>Brian Keller’s Blog</em></a><em> (Microsoft Evangelist)</em></li>
</ul>
<p>You can download the kit here: <a href="http://www.microsoft.com/download/en/details.aspx?id=27738">http://www.microsoft.com/download/en/details.aspx?id=27738</a> or view it online here: <a title="http://msdn.microsoft.com/en-us/VS11TrainingCourse" href="http://msdn.microsoft.com/en-us/VS11TrainingCourse">http://msdn.microsoft.com/en-us/VS11TrainingCourse</a>. </p>
<p>But if you want a quick preview, in this <a href="http://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Visual-Studio-Toolbox-Training-Courses-and-Kits">Channel 9 video</a>, <a href="http://channel9.msdn.com/Niners/rogreen">Robert Green</a> walks through the different flavors of the kit and the content itself.</p>
<div class="feedflare">
<a href="http://feeds.southworks.net/~ff/master-feed?a=PGhOhYC49tk:YfZAf8I_71A:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=PGhOhYC49tk:YfZAf8I_71A:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/master-feed?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=PGhOhYC49tk:YfZAf8I_71A:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/master-feed?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=PGhOhYC49tk:YfZAf8I_71A:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=PGhOhYC49tk:YfZAf8I_71A:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/master-feed?i=PGhOhYC49tk:YfZAf8I_71A:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=PGhOhYC49tk:YfZAf8I_71A:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/master-feed?i=PGhOhYC49tk:YfZAf8I_71A:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=PGhOhYC49tk:YfZAf8I_71A:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/master-feed?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/master-feed/~4/PGhOhYC49tk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.southworks.net/sdurandeu/2012/01/27/visual-studio-11-developer-preview-training-kit/</feedburner:origLink></item>
		<item>
		<title>How to: Use Application Library Caching in Prism modules</title>
		<link>http://feeds.southworks.net/~r/master-feed/~3/dp6c349HhTs/</link>
		<comments>http://blogs.southworks.net/gmaliandi/2012/01/how-to-use-application-library-caching-in-prism-modules/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 20:18:42 +0000</pubDate>
		<dc:creator>Guido Leandro Maliandi</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[MEF]]></category>
		<category><![CDATA[Prism]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Application Library Caching]]></category>

		<guid isPermaLink="false">http://64.130</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/gmaliandi/2012/01/how-to-use-application-library-caching-in-prism-modules/" class="more-link">read more<img src="http://blogs.southworks.net/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>Imagine you have a Silverlight application with functionality that is likely to change over time, but that application depends on some possibly heavyweight libraries that aren’t going to change. Every single change in your code would cause users to download the entire XAP file again, including those heavy libraries that didn’t change.</p>
<p>To address this concern, it’s possible to leverage <a href="http://msdn.microsoft.com/en-us/library/dd833069%28VS.95%29.aspx">Application Library Caching</a>, which involves separating those libraries in ZIP files that are outside the XAP file, and should remain cached in the users’ browsers regardless of changes in the XAP. Prism supports Application Library Caching by, for example, providing the necessary metadata in the Prism assemblies to set them as external libraries.</p>
<p>However, when using Application Library Caching in Prism Modules, this doesn’t work out of the box. Let’s examine why this happens.</p>
<h2>What happens with modules and Application Library Caching?</h2>
<p><a href="http://blogs.southworks.net/aadami/">Agustin Adami</a> and I examined the way Prism loads the content of module’s XAP files and found that the <strong>XapModuleTypeLoader </strong>reads the <strong>AppManifest.xaml</strong> file inside the module&#8217;s XAP file, searches for the <strong>Deployment.Parts</strong> elements and then loads the assemblies corresponding to the ones specified in the <strong>Source </strong>property of the <strong>AssemblyPart </strong>elements in the aforementioned XML element. However, dependencies that have been placed on a ZIP file using Application Library Caching are referenced in <strong>ExtensionPart </strong>elements inside the <strong>Deployment.ExternalParts</strong> element, and the physical file is stored outside the module’s XAP file (which is the only thing downloaded at this point.)</p>
<p>To illustrate this, here&#8217;s how the <strong>AppManifest </strong>for a certain module might look like:</p>
<div class="wlWriterEditableSmartContent" style="margin: 0px;float: none;padding: 0px">
<pre style="width: 576px;height: 161px;background-color: white;overflow: auto">
<div><span style="color: #008080"> 1</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">Deployment </span><span style="color: #ff0000">xmlns</span><span style="color: #0000ff">="http://schemas.microsoft.com/client/2007/deployment"</span><span style="color: #ff0000"> (...)</span><span style="color: #0000ff">&gt;</span><span style="color: #000000">
</span><span style="color: #008080"> 2</span> <span style="color: #000000">  </span><span style="color: #0000ff">&lt;</span><span style="color: #800000">Deployment.Parts</span><span style="color: #0000ff">&gt;</span><span style="color: #000000">
</span><span style="color: #008080"> 3</span> <span style="color: #000000">    </span><span style="color: #0000ff">&lt;</span><span style="color: #800000">AssemblyPart </span><span style="color: #ff0000">x:Name</span><span style="color: #0000ff">="SomeModule"</span><span style="color: #ff0000"> Source</span><span style="color: #0000ff">="SomeModule.dll"</span><span style="color: #ff0000"> </span><span style="color: #0000ff">/&gt;</span><span style="color: #000000">
</span><span style="color: #008080"> 4</span> <span style="color: #000000">    </span><span style="color: #0000ff">&lt;</span><span style="color: #800000">AssemblyPart </span><span style="color: #ff0000">x:Name</span><span style="color: #0000ff">="Infrastructure"</span><span style="color: #ff0000"> Source</span><span style="color: #0000ff">="Infrastructure.dll"</span><span style="color: #ff0000"> </span><span style="color: #0000ff">/&gt;</span><span style="color: #000000">
</span><span style="color: #008080"> 5</span> <span style="color: #000000">  </span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">Deployment.Parts</span><span style="color: #0000ff">&gt;</span><span style="color: #000000">
</span><span style="color: #008080"> 6</span> <span style="color: #000000">  </span><span style="color: #0000ff">&lt;</span><span style="color: #800000">Deployment.ExternalParts</span><span style="color: #0000ff">&gt;</span><span style="color: #000000">
</span><span style="color: #008080"> 7</span> <span style="color: #000000">    </span><span style="color: #0000ff">&lt;</span><span style="color: #800000">ExtensionPart </span><span style="color: #ff0000">Source</span><span style="color: #0000ff">="System.Windows.Controls.Data.Input.zip"</span><span style="color: #ff0000"> </span><span style="color: #0000ff">/&gt;</span><span style="color: #000000">
</span><span style="color: #008080"> 8</span> <span style="color: #000000">    </span><span style="color: #0000ff">&lt;</span><span style="color: #800000">ExtensionPart </span><span style="color: #ff0000">Source</span><span style="color: #0000ff">="System.ComponentModel.DataAnnotations.zip"</span><span style="color: #ff0000"> </span><span style="color: #0000ff">/&gt;</span><span style="color: #000000">
</span><span style="color: #008080"> 9</span> <span style="color: #000000">  </span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">Deployment.ExternalParts</span><span style="color: #0000ff">&gt;</span><span style="color: #000000">
</span><span style="color: #008080">10</span> <span style="color: #000000"> </span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">Deployment</span><span style="color: #0000ff">&gt;</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
</div>
<p>Now, when a module&#8217;s XAP file has been downloaded, the <strong>XapModuleTypeLoader.HandleModuleDownloaded </strong>method is called, which loads in memory the results obtained by calling the <strong>XapModuleTypeLoader.GetParts</strong> method. This method ignores the <strong>Deployment.ExternalParts</strong> element inside the <strong>AppManifest.xaml </strong>file (as seen in the code snippet above):</p>
<div class="wlWriterEditableSmartContent" style="margin: 0px;float: none;padding: 0px">
<pre style="width: 687px;height: 558px;background-color: white;overflow: auto">
<div><span style="color: #008080"> 1</span> <span style="color: #000000">(...)</span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> IEnumerable</span><span style="color: #000000">&lt;</span><span style="color: #000000">AssemblyPart</span><span style="color: #000000">&gt;</span><span style="color: #000000"> GetParts(Stream stream)
</span><span style="color: #008080"> 2</span> <span style="color: #000000">        {
</span><span style="color: #008080"> 3</span> <span style="color: #000000">            List</span><span style="color: #000000">&lt;</span><span style="color: #000000">AssemblyPart</span><span style="color: #000000">&gt;</span><span style="color: #000000"> assemblyParts </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> List</span><span style="color: #000000">&lt;</span><span style="color: #000000">AssemblyPart</span><span style="color: #000000">&gt;</span><span style="color: #000000">();
</span><span style="color: #008080"> 4</span> <span style="color: #000000">
</span><span style="color: #008080"> 5</span> <span style="color: #000000">            var streamReader </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StreamReader(Application.GetResourceStream(</span><span style="color: #0000ff">new</span><span style="color: #000000"> StreamResourceInfo(stream, </span><span style="color: #0000ff">null</span><span style="color: #000000">), </span><span style="color: #0000ff">new</span><span style="color: #000000"> Uri(</span><span style="color: #800000">"</span><span style="color: #800000">AppManifest.xaml</span><span style="color: #800000">"</span><span style="color: #000000">, UriKind.Relative)).Stream);
</span><span style="color: #008080"> 6</span> <span style="color: #000000">            </span><span style="color: #0000ff">using</span><span style="color: #000000"> (XmlReader xmlReader </span><span style="color: #000000">=</span><span style="color: #000000"> XmlReader.Create(streamReader))
</span><span style="color: #008080"> 7</span> <span style="color: #000000">            {
</span><span style="color: #008080"> 8</span> <span style="color: #000000">                xmlReader.MoveToContent();
</span><span style="color: #008080"> 9</span> <span style="color: #000000">                </span><span style="color: #0000ff">while</span><span style="color: #000000"> (xmlReader.Read())
</span><span style="color: #008080">10</span> <span style="color: #000000">                {
</span><span style="color: #008080">11</span> <span style="color: #000000">                    </span><span style="color: #0000ff">if</span><span style="color: #000000"> (xmlReader.NodeType </span><span style="color: #000000">==</span><span style="color: #000000"> XmlNodeType.Element </span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000"> xmlReader.Name </span><span style="color: #000000">==</span><span style="color: #000000"> </span><span style="color: #800000">"</span><span style="color: #800000">Deployment.Parts</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080">12</span> <span style="color: #000000">                    {
</span><span style="color: #008080">13</span> <span style="color: #000000">                    </span><span style="color: #008000">//</span><span style="color: #008000"> Deployment.Parts is examined, but Deployment.ExternalParts isn't</span><span style="color: #008000">
</span><span style="color: #008080">14</span> <span style="color: #008000"> </span><span style="color: #000000">                        </span><span style="color: #0000ff">using</span><span style="color: #000000"> (XmlReader xmlReaderAssemblyParts </span><span style="color: #000000">=</span><span style="color: #000000"> xmlReader.ReadSubtree())
</span><span style="color: #008080">15</span> <span style="color: #000000">                        {
</span><span style="color: #008080">16</span> <span style="color: #000000">                            </span><span style="color: #0000ff">while</span><span style="color: #000000"> (xmlReaderAssemblyParts.Read())
</span><span style="color: #008080">17</span> <span style="color: #000000">                            {
</span><span style="color: #008080">18</span> <span style="color: #000000">                                </span><span style="color: #0000ff">if</span><span style="color: #000000"> (xmlReaderAssemblyParts.NodeType </span><span style="color: #000000">==</span><span style="color: #000000"> XmlNodeType.Element </span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000"> xmlReaderAssemblyParts.Name </span><span style="color: #000000">==</span><span style="color: #000000"> </span><span style="color: #800000">"</span><span style="color: #800000">AssemblyPart</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080">19</span> <span style="color: #000000">                                {
</span><span style="color: #008080">20</span> <span style="color: #000000">                                    AssemblyPart assemblyPart </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> AssemblyPart();
</span><span style="color: #008080">21</span> <span style="color: #000000">                                    assemblyPart.Source </span><span style="color: #000000">=</span><span style="color: #000000"> xmlReaderAssemblyParts.GetAttribute(</span><span style="color: #800000">"</span><span style="color: #800000">Source</span><span style="color: #800000">"</span><span style="color: #000000">);
</span><span style="color: #008080">22</span> <span style="color: #000000">                                    assemblyParts.Add(assemblyPart);
</span><span style="color: #008080">23</span> <span style="color: #000000">                                }
</span><span style="color: #008080">24</span> <span style="color: #000000">                            }
</span><span style="color: #008080">25</span> <span style="color: #000000">                        }
</span><span style="color: #008080">26</span> <span style="color: #000000">
</span><span style="color: #008080">27</span> <span style="color: #000000">                        </span><span style="color: #0000ff">break</span><span style="color: #000000">;
</span><span style="color: #008080">28</span> <span style="color: #000000">                    }
</span><span style="color: #008080">29</span> <span style="color: #000000">                }
</span><span style="color: #008080">30</span> <span style="color: #000000">            }
</span><span style="color: #008080">31</span> <span style="color: #000000">
</span><span style="color: #008080">32</span> <span style="color: #000000">            </span><span style="color: #0000ff">return</span><span style="color: #000000"> assemblyParts;
</span><span style="color: #008080">33</span> <span style="color: #000000">        }
</span><span style="color: #008080">34</span> <span style="color: #000000">(...)
</span><span style="color: #008080">35</span> <span style="color: #000000"> </span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
</div>
<h2>The Unity Solution</h2>
<p>As a possible workaround to avoid this problem from happening, we created a modified version of the <strong>XapModuleTypeLoader </strong>(named <strong>LibraryCachingXapModuleTypeLoader</strong>), which loads the extension parts in memory before loading the assembly parts. To do this, we modified the <strong>IFileDownloader_DownloadCompleted</strong> method to obtain an <strong>ExternalPartsLoader</strong> from the container and call its <strong>LoadExtensionParts</strong> method before calling the <strong>HandleModuleDownloaded</strong>. The <strong>ExternalPartsLoader.LoadExtensionParts</strong> method basically searches for the <strong>AppManifest.xaml</strong> inside the XAP file, downloads the ZIP files containing the extension parts and loads the corresponding libraries in memory. Once this operation has finished, the <strong>HandleModuleDownloaded</strong> (which had been passed as a callback) is called, and the module loading process continues as it would regularly do.</p>
<p>To make this work, we had to create a class that inherits from <strong>ModuleManager </strong>and overrides its <strong>ModuleTypeLoaders </strong>property to use the <strong>LibraryCachingXapModuleTypeLoaderWith </strong>class instead of the regular <strong>XapModuleTypeLoader</strong>. We then overrode the <strong>ConfigureContainer </strong>method in the bootstrapper to register this custom module manager (named <strong>LibraryCachingModuleManager</strong>) in the container, so that it is used instead of the regular one.</p>
<p>You can find a sample that contains all the aforementioned modifications in my <a href="https://skydrive.live.com/#cid=7890102B5B8BC928&amp;id=7890102B5B8BC928%21103">Skydrive account</a> under the name <strong>LibraryCachingSupport.zip</strong>. This sample contains a Shell project and a module; both of which use Application Library Caching.</p>
<h2>The MEF Solution</h2>
<p>In the <strong>MefXapModuleTypeLoader</strong> a <strong>DeploymentCatalog</strong> is used to download the module’s XAP file and then compose all the parts defined in that file. Unlike in the <strong>XapModuleTypeLoader</strong>, it’s not possible to insert the external parts loading logic in the middle, so for this workaround, we had to opt out of the <strong>DeploymentCatalog </strong>and implement a similar functionality using the <strong>LibraryCachingXapModuleTypeLoader</strong> class.</p>
<p>Basically, the main aspect that should be considered for the MEF version is that the <strong>DeploymentCatalog</strong>, aside from loading the modules in memory, composes the parts discovered in it into the container. So, we added the logic to do so in both the <strong>LibraryCachingMefXapModuleTypeLoader</strong> and the <strong>MefExternalPartsLoader</strong>:</p>
<div class="wlWriterEditableSmartContent" style="margin: 0px;float: none;padding: 0px">
<pre style="width: 694px;height: 163px;background-color: white;overflow: auto">
<div><span style="color: #008080"> 1</span> <span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> ComposePartsInContainer(Assembly assembly)
</span><span style="color: #008080"> 2</span> <span style="color: #000000">        {
</span><span style="color: #008080"> 3</span> <span style="color: #000000">            var catalog </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> AssemblyCatalog(assembly);
</span><span style="color: #008080"> 4</span> <span style="color: #000000">
</span><span style="color: #008080"> 5</span> <span style="color: #000000">            var batch </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> CompositionBatch(catalog.Parts.Select(e </span><span style="color: #000000">=&gt;</span><span style="color: #000000"> e.CreatePart()), </span><span style="color: #0000ff">null</span><span style="color: #000000">);
</span><span style="color: #008080"> 6</span> <span style="color: #000000">
</span><span style="color: #008080"> 7</span> <span style="color: #000000">            var container </span><span style="color: #000000">=</span><span style="color: #000000"> ServiceLocator.Current.GetInstance</span><span style="color: #000000">&lt;</span><span style="color: #000000">CompositionContainer</span><span style="color: #000000">&gt;</span><span style="color: #000000">();
</span><span style="color: #008080"> 8</span> <span style="color: #000000">
</span><span style="color: #008080"> 9</span> <span style="color: #000000">            container.Compose(batch);
</span><span style="color: #008080">10</span> <span style="color: #000000">        }</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
</div>
<p>Additionally, we had to register the <strong>CompositionContainer</strong> in itself in order to be retrieved by the service locator in that piece of code.</p>
<p>You can find a sample that contains the MEF version of this approach in my <a href="https://skydrive.live.com/#cid=7890102B5B8BC928&amp;id=7890102B5B8BC928%21103">Skydrive account</a> under the name <strong>MefLibraryCachingSupport.zip</strong>.</p>
<p>Please note that this might not be the best approach to achieve this functionality, and it hasn’t been thoroughly tested; the intention of this post is to explain why this happens, and provide a possible workaround that might also serve as an example to implement the approach differently.</p>
<div class="feedflare">
<a href="http://feeds.southworks.net/~ff/master-feed?a=dp6c349HhTs:czOZbXhB54A:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=dp6c349HhTs:czOZbXhB54A:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/master-feed?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=dp6c349HhTs:czOZbXhB54A:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/master-feed?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=dp6c349HhTs:czOZbXhB54A:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=dp6c349HhTs:czOZbXhB54A:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/master-feed?i=dp6c349HhTs:czOZbXhB54A:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=dp6c349HhTs:czOZbXhB54A:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/master-feed?i=dp6c349HhTs:czOZbXhB54A:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=dp6c349HhTs:czOZbXhB54A:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/master-feed?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/master-feed/~4/dp6c349HhTs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.southworks.net/gmaliandi/2012/01/how-to-use-application-library-caching-in-prism-modules/</feedburner:origLink></item>
		<item>
		<title>How to: define module-specific resource dictionaries in Prism</title>
		<link>http://feeds.southworks.net/~r/master-feed/~3/xqjO4KQcyvI/</link>
		<comments>http://blogs.southworks.net/gmaliandi/2012/01/how-to-define-module-specific-resource-dictionaries-in-prism/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 21:09:15 +0000</pubDate>
		<dc:creator>Guido Leandro Maliandi</dc:creator>
				<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://64.126</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/gmaliandi/2012/01/how-to-define-module-specific-resource-dictionaries-in-prism/" class="more-link">read more<img src="http://blogs.southworks.net/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>Resource dictionaries are a nice way to specify styles, data templates, and similar items in WPF/Silverlight applications. In Prism modules, some times one would expect to define resource dictionaries that are specific to a certain module, as this would avoid exposing module specifics to the rest of the application. Yet, this might not be totally trivial, because resource dictionaries are usually defined in the <strong>App.xaml</strong>, and the<strong> </strong>only <strong>App.xaml </strong>that is used in most Prism applications is the one that belongs to the <strong>Shell</strong> project. I thought of a possible way to overcome this problem, which I’ll explain below.</p>
<p>But first, let’s examine what happens with those resource dictionaries when they are specified in the Shell’s <strong>App.xaml</strong>, and why views can consume them even if they’re defined on a separate project. Resources defined in the <strong>App.xaml</strong> become available in the <strong>Application.Resources</strong> <strong>ResourceDictionary</strong> of the current <strong>Application</strong> class (which can be accessed through the <strong>Application.Current</strong> static property.) Once they’re available there, they can be consumed from within the XAML as static resources. Since modules are loaded into the same application domain as the <strong>Shell</strong> project, views defined there can access resources as long as they can be found in the corresponding <strong>Application.Resources</strong> dictionary.</p>
<p>You may have noticed that some times modules also contain an <strong>App.xaml</strong> file. This file isn’t loaded when Prism modules are loaded; only one <strong>Application</strong> class is instantiated, and that’s the one in the <strong>Shell</strong> project.</p>
<p><img style="padding-left: 0px;padding-right: 0px;padding-top: 0px;border: 0px" src="http://blogs.southworks.net/gmaliandi/files/2012/01/image.png" border="0" alt="image" width="244" height="231" /></p>
<p>So, while defining the resources in the module’s <strong>App.xaml</strong> file would make them show in the designer, they wouldn’t work when the application is ran. Going backwards a little, <strong>Application.Current.Resources </strong>can be accessed from anywhere inside the Prism application (even modules), and the <strong>ResourceDictionary</strong> class supports adding new entries! So you might see where I’m going with this…</p>
<h2>The approach</h2>
<p>I tried programmatically adding new entries to the <strong>Application.Current.Resources</strong> dictionary and it worked! So this leaves us with two more needs in my opinion:</p>
<ol>
<li>A way to get the resources to add from a XAML resource dictionary file (in the module, of course.)</li>
<li>A comfortable way to specify that the resources in that file should be loaded.</li>
</ol>
<p>The first one was actually simple. We can create a new instance of the <strong>ResourceDictionary</strong> class passing the file’s URI as the source. As for the second one, I thought that perhaps abstracting the whole thing with an attribute might be a good idea. So, I created an attribute named <strong>ModuleResourceAttribute</strong>, which has a constructor that accepts a string as a parameter; this string should be the location of the XAML file, e.g. <em>“/ModuleA;component/ModuleResources/Resources.xaml”</em>. The idea is that this attribute could be specified on a module, like this:</p>
<div class="wlWriterEditableSmartContent" style="margin: 0px;float: none;padding: 0px">
<pre style="width: 652px;height: 119px;background-color: white;overflow: auto">
<div><span style="color: #008080">1</span> <span style="color: #000000">[ModuleResource(</span><span style="color: #800000">"</span><span style="color: #800000">/ModuleA;component/ModuleResources/Resources.xaml</span><span style="color: #800000">"</span><span style="color: #000000">)]
</span><span style="color: #008080">2</span> <span style="color: #000000">    </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> ModuleA : IModule
</span><span style="color: #008080">3</span> <span style="color: #000000">    {
</span><span style="color: #008080">4</span> <span style="color: #000000">        (...)
</span><span style="color: #008080">5</span> <span style="color: #000000">    }</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
</div>
<p>Then, I created a simple service to load resources into the <strong>Application.Current.Resources</strong> dictionary:</p>
<div class="wlWriterEditableSmartContent" style="margin: 0px;float: none;padding: 0px">
<pre style="width: 652px;height: 260px;background-color: white;overflow: auto">
<div><span style="color: #008080"> 1</span> <span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">interface</span><span style="color: #000000"> IResourceLoader
</span><span style="color: #008080"> 2</span> <span style="color: #000000">    {
</span><span style="color: #008080"> 3</span> <span style="color: #000000">        </span><span style="color: #0000ff">void</span><span style="color: #000000"> LoadModuleResources(Uri resourceUri);
</span><span style="color: #008080"> 4</span> <span style="color: #000000">    }
</span><span style="color: #008080"> 5</span> <span style="color: #000000">
</span><span style="color: #008080"> 6</span> <span style="color: #000000"> </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> ResourceLoader : IResourceLoader
</span><span style="color: #008080"> 7</span> <span style="color: #000000">    {
</span><span style="color: #008080"> 8</span> <span style="color: #000000">        </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> LoadModuleResources(Uri resourceUri)
</span><span style="color: #008080"> 9</span> <span style="color: #000000">        {
</span><span style="color: #008080">10</span> <span style="color: #000000">            var resources </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> ResourceDictionary { Source </span><span style="color: #000000">=</span><span style="color: #000000"> resourceUri };
</span><span style="color: #008080">11</span> <span style="color: #000000">
</span><span style="color: #008080">12</span> <span style="color: #000000">            </span><span style="color: #0000ff">foreach</span><span style="color: #000000"> (var key </span><span style="color: #0000ff">in</span><span style="color: #000000"> resources.Keys)
</span><span style="color: #008080">13</span> <span style="color: #000000">            {
</span><span style="color: #008080">14</span> <span style="color: #000000">                Application.Current.Resources.Add(key, resources[key]);
</span><span style="color: #008080">15</span> <span style="color: #000000">            }
</span><span style="color: #008080">16</span> <span style="color: #000000">        }
</span><span style="color: #008080">17</span> <span style="color: #000000">    }</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
</div>
<p>Finally, I created a modified implementation of the <strong>ModuleInitializer</strong> so that it checks if the module has any <strong>ModuleResourceAttribute</strong>s to load the necessary resources prior to module initialization:</p>
<div class="wlWriterEditableSmartContent" style="margin: 0px;float: none;padding: 0px">
<pre style="width: 877px;height: 624px;background-color: white;overflow: auto">
<div><span style="color: #008080"> 1</span> <span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> ModifiedModuleInitializer : IModuleInitializer
</span><span style="color: #008080"> 2</span> <span style="color: #000000">    {
</span><span style="color: #008080"> 3</span> <span style="color: #000000">        (...)
</span><span style="color: #008080"> 4</span> <span style="color: #000000">
</span><span style="color: #008080"> 5</span> <span style="color: #000000">
</span><span style="color: #008080"> 6</span> <span style="color: #000000">        </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> Initialize(ModuleInfo moduleInfo)
</span><span style="color: #008080"> 7</span> <span style="color: #000000">        {
</span><span style="color: #008080"> 8</span> <span style="color: #000000">            </span><span style="color: #0000ff">if</span><span style="color: #000000"> (moduleInfo </span><span style="color: #000000">==</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">) </span><span style="color: #0000ff">throw</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> ArgumentNullException(</span><span style="color: #800000">"</span><span style="color: #800000">moduleInfo</span><span style="color: #800000">"</span><span style="color: #000000">);
</span><span style="color: #008080"> 9</span> <span style="color: #000000">
</span><span style="color: #008080">10</span> <span style="color: #000000">            IModule moduleInstance </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">;
</span><span style="color: #008080">11</span> <span style="color: #000000">            </span><span style="color: #0000ff">try</span><span style="color: #000000">
</span><span style="color: #008080">12</span> <span style="color: #000000">            {
</span><span style="color: #008080">13</span> <span style="color: #000000">                moduleInstance </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">this</span><span style="color: #000000">.CreateModule(moduleInfo);
</span><span style="color: #008080">14</span> <span style="color: #000000">                </span><span style="color: #0000ff">this</span><span style="color: #000000">.LoadResources(moduleInstance);
</span><span style="color: #008080">15</span> <span style="color: #000000">                moduleInstance.Initialize();
</span><span style="color: #008080">16</span> <span style="color: #000000">            }
</span><span style="color: #008080">17</span> <span style="color: #000000">            </span><span style="color: #0000ff">catch</span><span style="color: #000000"> (Exception ex)
</span><span style="color: #008080">18</span> <span style="color: #000000">            {
</span><span style="color: #008080">19</span> <span style="color: #000000">                </span><span style="color: #0000ff">this</span><span style="color: #000000">.HandleModuleInitializationError(
</span><span style="color: #008080">20</span> <span style="color: #000000">                    moduleInfo,
</span><span style="color: #008080">21</span> <span style="color: #000000">                    moduleInstance </span><span style="color: #000000">!=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000"> </span><span style="color: #000000">?</span><span style="color: #000000"> moduleInstance.GetType().Assembly.FullName : </span><span style="color: #0000ff">null</span><span style="color: #000000">,
</span><span style="color: #008080">22</span> <span style="color: #000000">                    ex);
</span><span style="color: #008080">23</span> <span style="color: #000000">            }
</span><span style="color: #008080">24</span> <span style="color: #000000">        }
</span><span style="color: #008080">25</span> <span style="color: #000000">
</span><span style="color: #008080">26</span> <span style="color: #000000">           (...)
</span><span style="color: #008080">27</span> <span style="color: #000000">
</span><span style="color: #008080">28</span> <span style="color: #000000">        </span><span style="color: #0000ff">protected</span><span style="color: #000000"> </span><span style="color: #0000ff">virtual</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> LoadResources(IModule moduleInstance)
</span><span style="color: #008080">29</span> <span style="color: #000000">        {
</span><span style="color: #008080">30</span> <span style="color: #000000">            var attributes </span><span style="color: #000000">=</span><span style="color: #000000"> moduleInstance.GetType().GetCustomAttributes(</span><span style="color: #0000ff">typeof</span><span style="color: #000000">(ModuleResourceAttribute), </span><span style="color: #0000ff">true</span><span style="color: #000000">).Cast</span><span style="color: #000000">&lt;</span><span style="color: #000000">ModuleResourceAttribute</span><span style="color: #000000">&gt;</span><span style="color: #000000">();
</span><span style="color: #008080">31</span> <span style="color: #000000">            </span><span style="color: #0000ff">if</span><span style="color: #000000"> (attributes </span><span style="color: #000000">!=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">)
</span><span style="color: #008080">32</span> <span style="color: #000000">            {
</span><span style="color: #008080">33</span> <span style="color: #000000">                </span><span style="color: #0000ff">foreach</span><span style="color: #000000"> (var attribute </span><span style="color: #0000ff">in</span><span style="color: #000000"> attributes)
</span><span style="color: #008080">34</span> <span style="color: #000000">                {
</span><span style="color: #008080">35</span> <span style="color: #000000">                    var resourceUri </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> Uri(attribute.ResourceLocation, UriKind.RelativeOrAbsolute);
</span><span style="color: #008080">36</span> <span style="color: #000000">                    resourceLoader.LoadModuleResources(resourceUri);
</span><span style="color: #008080">37</span> <span style="color: #000000">                }
</span><span style="color: #008080">38</span> <span style="color: #000000">            }
</span><span style="color: #008080">39</span> <span style="color: #000000">        }
</span><span style="color: #008080">40</span> <span style="color: #000000">    }</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
</div>
<p>I also created a little sample that portrays this, which can be found <a href="https://skydrive.live.com/#cid=12A8B70137345033&amp;id=12A8B70137345033!119">in my SkyDrive account</a> under the name <strong>ModuleSpecificResourceDictionaries</strong>.</p>
<p>I hope you find this handy!</p>
<div class="feedflare">
<a href="http://feeds.southworks.net/~ff/master-feed?a=xqjO4KQcyvI:lMYB8TmlMfw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=xqjO4KQcyvI:lMYB8TmlMfw:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/master-feed?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=xqjO4KQcyvI:lMYB8TmlMfw:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/master-feed?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=xqjO4KQcyvI:lMYB8TmlMfw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=xqjO4KQcyvI:lMYB8TmlMfw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/master-feed?i=xqjO4KQcyvI:lMYB8TmlMfw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=xqjO4KQcyvI:lMYB8TmlMfw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/master-feed?i=xqjO4KQcyvI:lMYB8TmlMfw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=xqjO4KQcyvI:lMYB8TmlMfw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/master-feed?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/master-feed/~4/xqjO4KQcyvI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.southworks.net/gmaliandi/2012/01/how-to-define-module-specific-resource-dictionaries-in-prism/</feedburner:origLink></item>
		<item>
		<title>Windows Azure Caching Service: How distributed and local caches work together</title>
		<link>http://feeds.southworks.net/~r/master-feed/~3/NB1CkQxoASw/</link>
		<comments>http://blogs.southworks.net/jrowies/2012/01/17/windows-azure-caching-service-how-distributed-and-local-caches-work-together/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 14:12:49 +0000</pubDate>
		<dc:creator>Jorge Rowies</dc:creator>
				<category><![CDATA[Cache]]></category>
		<category><![CDATA[Caching Services]]></category>
		<category><![CDATA[Windows Azure]]></category>

		<guid isPermaLink="false">http://132.56</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/jrowies/2012/01/17/windows-azure-caching-service-how-distributed-and-local-caches-work-together/" class="more-link">read more<img src="http://blogs.southworks.net/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>The intention of this post is to show how the distributed and local cache of the Windows Azure Caching Service work together. We are going to cover the implications of enabling the local cache feature, the interaction between the local and distributed caches, and how to prevent unexpected errors that can be caused by the in-memory nature of the local cache.</p>
<p>For a complete description about what the Windows Azure Caching Service is and how it can be configured, please read:<br />
<a href="http://msdn.microsoft.com/en-us/magazine/gg983488.aspx">Introducing the Windows Azure Caching Service</a><br />
<a href="http://convective.wordpress.com/2010/12/18/azure-appfabric-caching-service/">Azure AppFabric Caching Service</a><br />
<a href="http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_buildingappswithcacheservice#_Toc310505077">Building Windows Azure Applications with the Caching Service</a></p>
<p><strong>Implications of enabling the local cache feature</strong></p>
<p>When a client enables the local cache feature, an in-memory cache is created in the same memory space where the client is running. This dramatically improves performance when storing and retrieving cache objects, but this does not come without a cost. By enabling local cache in every client, more replicas of the same data will exist, since you will have copies of the data in the original source (i.e. SQL database), in the distributed cache (cloud) and in every client’s local cache as well. Handling data replication is not a trivial matter, so deciding whether to enable local caching or not will depend on the scenario.</p>
<p><strong>Interaction between the local and distributed caches</strong></p>
<p>One important thing to know is how local and distributed caches interact with each other. Below you can find diagrams showing how two clients (Blue and Green) perform actions against the cache, and the consequences that each action has on the data of every cache instance.</p>
<p><em>Blue client stores key “A” in the cache:</em><br />
<a href="http://blogs.southworks.net/jrowies/files/2012/01/1.Blue-client-stores-key-A-in-the-cache.png"><img src="http://blogs.southworks.net/jrowies/files/2012/01/1.Blue-client-stores-key-A-in-the-cache-690x487.png" alt="" width="690" height="487" class="alignnone size-large wp-image-78" /></a></p>
<p><em>Green client retrieves key “A” from the cache</em><br />
<a href="http://blogs.southworks.net/jrowies/files/2012/01/2.Green-client-retrieves-key-A-from-the-cache.png"><img src="http://blogs.southworks.net/jrowies/files/2012/01/2.Green-client-retrieves-key-A-from-the-cache-690x485.png" alt="" width="690" height="485" class="alignnone size-large wp-image-79" /></a></p>
<p><em>Blue client retrieves key “A” from the cache</em><br />
<a href="http://blogs.southworks.net/jrowies/files/2012/01/3.Blue-client-retrieves-key-A-from-the-cache.png"><img src="http://blogs.southworks.net/jrowies/files/2012/01/3.Blue-client-retrieves-key-A-from-the-cache-690x485.png" alt="" width="690" height="485" class="alignnone size-large wp-image-80" /></a></p>
<p><em>Blue client updates value for key “A”</em><br />
<a href="http://blogs.southworks.net/jrowies/files/2012/01/4.Blue-client-updates-value-for-key-A.png"><img src="http://blogs.southworks.net/jrowies/files/2012/01/4.Blue-client-updates-value-for-key-A-690x485.png" alt="" width="690" height="485" class="alignnone size-large wp-image-81" /></a></p>
<p><em>Blue client removes key “A” from the cache</em><br />
<a href="http://blogs.southworks.net/jrowies/files/2012/01/5.Blue-client-removes-key-A-from-the-cache.png"><img src="http://blogs.southworks.net/jrowies/files/2012/01/5.Blue-client-removes-key-A-from-the-cache-690x485.png" alt="" width="690" height="485" class="alignnone size-large wp-image-82" /></a></p>
<p><em>Green client retrieves key “A” from the cache</em><br />
<a href="http://blogs.southworks.net/jrowies/files/2012/01/6.Green-client-retrieves-key-A-from-the-cache-2.png"><img src="http://blogs.southworks.net/jrowies/files/2012/01/6.Green-client-retrieves-key-A-from-the-cache-2-690x485.png" alt="" width="690" height="485" class="alignnone size-large wp-image-83" /></a></p>
<p>NOTE: for the use cases depicted in the diagrams, we are assuming that the objects stored in the caches will not expire before clients try to retrieve them.</p>
<p><strong>The in-memory nature of the local cache</strong></p>
<p>Given that the local cache resides in-memory, keep in mind that every change to an object after it was stored in the cache, will change the cached object as well (because the objects are the same). Clearly, this is not true with the distributed cache, because a serialized representation of the object is stored in that case.</p>
<p><em>Storing a new Movie object in the cache:</em><br />
<a href="http://blogs.southworks.net/jrowies/files/2012/01/InMemory1.png"><img src="http://blogs.southworks.net/jrowies/files/2012/01/InMemory1-690x228.png" alt="" width="690" height="228" class="alignnone size-large wp-image-84" /></a></p>
<p><em>Changing the properties of the same Movie object will change the object stored in the local cache as well:</em><br />
<a href="http://blogs.southworks.net/jrowies/files/2012/01/InMemory2.png"><img src="http://blogs.southworks.net/jrowies/files/2012/01/InMemory2-690x229.png" alt="" width="690" height="229" class="alignnone size-large wp-image-85" /></a></p>
<p>That&#8217;s it, I hope this helps!</p>
<div class="feedflare">
<a href="http://feeds.southworks.net/~ff/master-feed?a=NB1CkQxoASw:GjymZAASc-M:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=NB1CkQxoASw:GjymZAASc-M:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/master-feed?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=NB1CkQxoASw:GjymZAASc-M:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/master-feed?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=NB1CkQxoASw:GjymZAASc-M:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=NB1CkQxoASw:GjymZAASc-M:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/master-feed?i=NB1CkQxoASw:GjymZAASc-M:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=NB1CkQxoASw:GjymZAASc-M:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/master-feed?i=NB1CkQxoASw:GjymZAASc-M:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=NB1CkQxoASw:GjymZAASc-M:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/master-feed?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/master-feed/~4/NB1CkQxoASw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.southworks.net/jrowies/2012/01/17/windows-azure-caching-service-how-distributed-and-local-caches-work-together/</feedburner:origLink></item>
		<item>
		<title>When/Then Unit Test Naming Pattern</title>
		<link>http://feeds.southworks.net/~r/master-feed/~3/IK1N8p6rDwE/</link>
		<comments>http://blogs.southworks.net/geoff/2012/01/16/whenthen/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 18:46:26 +0000</pubDate>
		<dc:creator>Geoff Cox</dc:creator>
				<category><![CDATA[Practice of Software Development]]></category>
		<category><![CDATA[Naming]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[Then]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[When]]></category>

		<guid isPermaLink="false">http://65.271</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/geoff/2012/01/16/whenthen/" class="more-link">read more<img src="http://blogs.southworks.net/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>Giving meaningful names to unit tests is critically important to quality unit tests.  Unit tests classes often contain a large set of test methods and it can be challenging to distinguish from between tests because of the small permutations of the condition, the action, or the result.</p>
<p>I was clued in to the When/Then naming pattern when working with Patterns &amp; Practices at Microsoft.  I’ve seen this naming pattern work well across both client and web projects containing several hundred unit tests for all kinds of classes.  I’ve adopted for all my unit tests with success.</p>
<h2>The pattern</h2>
<p><strong>When</strong>&lt;<em>ActionAndCondition</em>&gt;<strong>Then</strong>&lt;<em>ExpectedResult</em>&gt;.</p>
<p>For example, a unit test that verifies the PropertyChanged event is raised when the Name property is changed might read:  “WhenNameSetToDifferentValueThenPropertyChangedRaised”.</p>
<h2>Benefits</h2>
<p>The When/Then naming pattern works well because it includes the action, condition, and result.  By putting the key semantic information in the name of the unit test there is no longer a need for method or code comments explaining what is being tested.</p>
<p>The When/Then naming pattern has several other benefits.</p>
<p>•    It naturally focuses each unit test on verifying one result.  This encourages writing atomic tests an discourages integration tests posting as unit tests.<br />
•    It helps evaluate the purpose of each member of a class by thinking about the conditions and results.  This also illuminates other unit test permutations.<br />
•    It helps describe the test independent of the code.  This helps when the test code doesn’t make the condition or result as obvious as the reader would like.  Most often this is due to mocking frameworks, verifying complex data, or other aspects of the test obfuscate the test&#8217;s purpose.</p>
<h2>Tips</h2>
<p>Some tips to consider when applying the pattern:</p>
<p>•    To keep the names a little shorter, you can remove passive verbs.  “WhenNameIsSetToDifferentValueThenPropertyChangedIsRaised” becomes just WhenNameSetToDifferentValueThenPropertyChangedRaised.  At one point I was tempted to remove the “When” and the “Then” and separate them with an underscore, but I found that it made the test name harder to read for comprehension.<br />
•    Use standard verbs in your test names.  I use “Set” for properties, “Called” for methods, and “Raised” for events. I avoid synonyms like Updated, Recalculated, Invoked, or Fired.<br />
•    Often a set of tests are focused on single part of your class (such as the Name property).  I use #region to group test cases that are related.  This helps me avoid injecting excessive class structure into my test names and makes it easy to evaluate the set of tests when working toward 100% code coverage.</p>
<h2>Additional Examples</h2>
<p>Here are some additional examples from my own code:</p>
<p><span style="font-family: Consolas">#region Name Tests</span></p>
<p><span style="font-family: Consolas">WhenNameSetThenValueSet<br />
WhenNameSetToDifferentValueThenPropertyChangedRaised<br />
WhenNameSetToSameValueThenPropertyChangedNotRaised<br />
WhenNameSetToNullThenExceptionThrown<br />
WhenNameSetToEmptyThenValueSet</span></p>
<p><span style="font-family: Consolas">#endregion</span></p>
<p><span style="font-family: Consolas">#region UpdateStatistics Tests</span></p>
<p><span style="font-family: Consolas">WhenUpdateStatisticsCalledThenTotalPriceSet<br />
WhenUpdateStatisticsCalledThenAveragePriceSet</span></p>
<p><span style="font-family: Consolas">#endregion</span></p>
<div class="feedflare">
<a href="http://feeds.southworks.net/~ff/master-feed?a=IK1N8p6rDwE:aDCUCY4Q3Pk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=IK1N8p6rDwE:aDCUCY4Q3Pk:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/master-feed?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=IK1N8p6rDwE:aDCUCY4Q3Pk:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/master-feed?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=IK1N8p6rDwE:aDCUCY4Q3Pk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=IK1N8p6rDwE:aDCUCY4Q3Pk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/master-feed?i=IK1N8p6rDwE:aDCUCY4Q3Pk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=IK1N8p6rDwE:aDCUCY4Q3Pk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/master-feed?i=IK1N8p6rDwE:aDCUCY4Q3Pk:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=IK1N8p6rDwE:aDCUCY4Q3Pk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/master-feed?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/master-feed/~4/IK1N8p6rDwE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.southworks.net/geoff/2012/01/16/whenthen/</feedburner:origLink></item>
		<item>
		<title>Using multiple CorrelationFilter objects in a Windows Azure Service Bus subscription</title>
		<link>http://feeds.southworks.net/~r/master-feed/~3/-RE4Otx2Hs4/</link>
		<comments>http://blogs.southworks.net/ajezierski/2012/01/10/using-multiple-correlationfilter-objects-in-a-windows-azure-service-bus-subscription/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 20:58:50 +0000</pubDate>
		<dc:creator>ajezierski</dc:creator>
				<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[BrokeredMessage]]></category>
		<category><![CDATA[CorrelationFilter]]></category>
		<category><![CDATA[Service Bus]]></category>

		<guid isPermaLink="false">http://139.6</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/ajezierski/2012/01/10/using-multiple-correlationfilter-objects-in-a-windows-azure-service-bus-subscription/" class="more-link">read more<img src="http://blogs.southworks.net/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>Using filters in Windows Azure Service Bus subscriptions is very useful when it comes to message categorization.  When setting up a subscription, you can specify a Filter object that will be responsible of allowing messages that match a specified criteria.  In this post I will focus on how we can set multiple CorrelationFilter objects for a Service Bus subscription.</p>
<p>Correlation filters help to establish a call-response type of relationship between a sender and a receiver through the use of the CorrelationId property of the BrokeredMessage class.  Typically, the sender might set the CorrelationId property of the brokered message to some identifier.  This same identifier can be used in a CorrelationFilter object associated to that particular sender when creating a subscription for the response topic.</p>
<pre class="brush: csharp; title: ; notranslate">
    var id = Guid.NewGuid();
    var filter = new CorrelationFilter(id.ToString());
    namespaceClient.CreateSubscription(description, filter);
</pre>
<p>The receiver, after getting the message,  will prepare a new response, setting the CorrelationId property equal to the one it received in the message it downloaded, and will post the response to a topic that will be shared by multiple sender entities.  Each sender will always receive the expected response through the associated CorrelationFilter (which delivers the message to the subscription only if the CorrelationId property of the brokered message matches the id expression in the filter.  Tip: consider the use of CorrelationFilter instead of SqlFilter when it comes to equality comparisons.  SqlFilter has an extra overhead when evaluating the criteria expression.</p>
<p>Consider the following scenario:</p>
<ul>
<li>We have n senders posting messages to a topic, allowing for m subscriptions.</li>
<li>We have m receivers subscribed to the sender topic, posting reply messages back to a shared reply topic.</li>
<li>A sender may want to make multiple requests and expect the respective replies to each request.</li>
<li>Each reply message may be treated differently by the sender.</li>
</ul>
<p>The question is, how can a sender keep track of the requests it makes, and how can it receive the expected reply message without the knowledge of the other senders?</p>
<p>The answer is as simple as&#8230; &#8220;let the sender manage a collection of correlation filters! &#8220;  We can achieve this through the use of Rules.  A rule allows a subscription to execute an action on messages that match a rule&#8217;s filtering criteria.  Rules can be managed through the SubscriptionClient class.  Let&#8217;s take a look at the code.</p>
<p>Through the MessagingFactory we create a SubscriptionClient.  We then call the AddRule method, creating a new RuleDescription object.  The RuleDescription will contain the name or identifier of that rule, and the corresponding associated CorrelationFilter.  Using the RuleAction property escapes the scope of this post, but you can read about it <a href="http://blogs.southworks.net/jrowies/2012/01/06/using-rule-actions-in-windows-azure-service-bus-subscriptions/" target="_blank">here</a>.</p>
<pre class="brush: csharp; title: ; notranslate">
    // Create new rule containing a new CorrelationFilter.
    var subscriptionClient = this.messagingFactory.CreateSubscriptionClient(Constants.ReplyTopic, this.senderName);

    var rule = new RuleDescription
    {
       Filter = new Microsoft.ServiceBus.Messaging.CorrelationFilter(id.ToString()),
       Name = id.ToString(),
    };

    subscriptionClient.AddRule(rule);
</pre>
<p>When we are done with rule, we can call the RemoveRule method of the SubscriptionClientClass.</p>
<p>Note that we can use Windows Azure Service Bus for a wide variety of scenarios, and solve similar problems in many different ways.  Today we went down the path of subscriptions and correlation filters.</p>
<p>Check out these other posts if you want more information on Windows Azure Service Bus Brokered Messaging</p>
<p><a title="Windows Azure Appfabric Service Bus Brokered Messaging" href="http://convective.wordpress.com/2011/09/21/windows-azure-appfabric-service-bus-brokered-messaging/" target="_blank">http://convective.wordpress.com/2011/09/21/windows-azure-appfabric-service-bus-brokered-messaging/</a></p>
<p><a href="http://social.technet.microsoft.com/wiki/contents/articles/best-practices-for-leveraging-windows-azure-service-bus-brokered-messaging.aspx" target="_blank">http://social.technet.microsoft.com/wiki/contents/articles/best-practices-for-leveraging-windows-azure-service-bus-brokered-messaging.aspx</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/windowsazure/hh367512.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/windowsazure/hh367512.aspx</a></p>
<p>Happy learning!</p>
<div class="feedflare">
<a href="http://feeds.southworks.net/~ff/master-feed?a=-RE4Otx2Hs4:WAsx9YzSJpc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=-RE4Otx2Hs4:WAsx9YzSJpc:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/master-feed?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=-RE4Otx2Hs4:WAsx9YzSJpc:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/master-feed?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=-RE4Otx2Hs4:WAsx9YzSJpc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=-RE4Otx2Hs4:WAsx9YzSJpc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/master-feed?i=-RE4Otx2Hs4:WAsx9YzSJpc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=-RE4Otx2Hs4:WAsx9YzSJpc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/master-feed?i=-RE4Otx2Hs4:WAsx9YzSJpc:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=-RE4Otx2Hs4:WAsx9YzSJpc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/master-feed?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/master-feed/~4/-RE4Otx2Hs4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.southworks.net/ajezierski/2012/01/10/using-multiple-correlationfilter-objects-in-a-windows-azure-service-bus-subscription/</feedburner:origLink></item>
		<item>
		<title>High memory consumption in WaWorkerHost.exe</title>
		<link>http://feeds.southworks.net/~r/master-feed/~3/wuQSsPkF3I4/</link>
		<comments>http://blogs.southworks.net/jrowies/2012/01/09/high-memory-consumption-in-waworkerhost-exe/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 21:08:05 +0000</pubDate>
		<dc:creator>Jorge Rowies</dc:creator>
				<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Worker Roles]]></category>

		<guid isPermaLink="false">http://132.37</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/jrowies/2012/01/09/high-memory-consumption-in-waworkerhost-exe/" class="more-link">read more<img src="http://blogs.southworks.net/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>When the memory usage of the WaWorkerHost.exe process starts going up without apparent reason, and you are using Tasks in your worker role, it might be the time to check for unhandled exceptions and start handling them properly.</p>
<p>Throwing exceptions from Tasks in a worker role and NOT properly handling them:</p>
<pre class="brush: csharp; title: ; notranslate">
    public class WorkerRole : RoleEntryPoint
    {
        public override void Run()
        {
            while (true)
            {
                Task.Factory.StartNew(() =&gt; { throw new NotImplementedException(); });
                Thread.Sleep(100);
            }
        }
    }
</pre>
<p>Might cause this memory consumption in the WaWorkerHost.exe process:</p>
<p><a href="http://blogs.southworks.net/jrowies/files/2012/01/WorkerMemoryIssue.png"><img src="http://blogs.southworks.net/jrowies/files/2012/01/WorkerMemoryIssue.png" alt="" width="447" height="519" class="alignnone size-full wp-image-43" /></a></p>
<p>NOTE: WaWorkerHost.exe is the process in charge of hosting your worker roles when running in the emulator.</p>
<p>Below you can find one way to handle exceptions that are thrown in Tasks.</p>
<pre class="brush: csharp; title: ; notranslate">
    public class WorkerRole : RoleEntryPoint
    {
        public override void Run()
        {
            while (true)
            {
                Task.Factory.StartNew(
                    () =&gt;
                    {
                        throw new NotImplementedException();
                    })
                    .ContinueWith((t) =&gt;
                    {
                        Trace.WriteLine(string.Format(&quot;Exception in Worker Role: {0}&quot;,
                            t.Exception.InnerException.ToString()));
                    },
                    TaskContinuationOptions.OnlyOnFaulted);

                Thread.Sleep(100);
            }
        }
    }
</pre>
<div class="feedflare">
<a href="http://feeds.southworks.net/~ff/master-feed?a=wuQSsPkF3I4:ydwp6TbHzD8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=wuQSsPkF3I4:ydwp6TbHzD8:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/master-feed?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=wuQSsPkF3I4:ydwp6TbHzD8:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/master-feed?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=wuQSsPkF3I4:ydwp6TbHzD8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/master-feed?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=wuQSsPkF3I4:ydwp6TbHzD8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/master-feed?i=wuQSsPkF3I4:ydwp6TbHzD8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=wuQSsPkF3I4:ydwp6TbHzD8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/master-feed?i=wuQSsPkF3I4:ydwp6TbHzD8:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.southworks.net/~ff/master-feed?a=wuQSsPkF3I4:ydwp6TbHzD8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/master-feed?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/master-feed/~4/wuQSsPkF3I4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.southworks.net/jrowies/2012/01/09/high-memory-consumption-in-waworkerhost-exe/</feedburner:origLink></item>
	</channel>
</rss>

