<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Life of a geek and a part-time poet</title>
	<atom:link href="http://yoavniran.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://yoavniran.wordpress.com</link>
	<description>Yoav Niran&#039;s Geeky stuff, Poetry, Programming, Futurama and Life...</description>
	<lastBuildDate>Mon, 29 Apr 2013 06:52:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='yoavniran.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Life of a geek and a part-time poet</title>
		<link>http://yoavniran.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://yoavniran.wordpress.com/osd.xml" title="Life of a geek and a part-time poet" />
	<atom:link rel='hub' href='http://yoavniran.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Poem: המסע שלך</title>
		<link>http://yoavniran.wordpress.com/2013/02/25/poem-%d7%94%d7%9e%d7%a1%d7%a2-%d7%a9%d7%9c%d7%9a/</link>
		<comments>http://yoavniran.wordpress.com/2013/02/25/poem-%d7%94%d7%9e%d7%a1%d7%a2-%d7%a9%d7%9c%d7%9a/#comments</comments>
		<pubDate>Mon, 25 Feb 2013 20:50:39 +0000</pubDate>
		<dc:creator>Yoav Niran</dc:creator>
				<category><![CDATA[Poetry]]></category>
		<category><![CDATA[hebrew]]></category>
		<category><![CDATA[journey]]></category>
		<category><![CDATA[poem]]></category>

		<guid isPermaLink="false">http://yoavniran.wordpress.com/?p=869</guid>
		<description><![CDATA[This one is the latest of my poems, written recently for my daughter's first birthday in January.

No translation yet to English so only the Hebrew version for now. The English name for this poem would be "Your Journey". I'll try to publish the translation soon.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=869&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://yoavniran.files.wordpress.com/2013/02/main.png"><img class="aligncenter size-full wp-image-870" alt="Masa-main" src="http://yoavniran.files.wordpress.com/2013/02/main.png?w=595"   /></a></p>
<p>This one is the latest of my poems, written recently for my daughter&#8217;s first birthday in the beginning of the year.</p>
<p>No translation yet to English so only the Hebrew version for now. The English name for this poem would be &#8220;Your Journey&#8221;. I&#8217;ll try to publish the translation soon.</p>
<p>Without further ado:</p>
<p><span id="more-869"></span></p>
<h2 style="text-align:right;"><span style="color:#000080;">~ המסע שלך ~</span></h2>
<p dir="RTL">זוג רגלים קטנות</p>
<p dir="RTL">זוחלות והנה</p>
<p dir="RTL">כבר הולכות</p>
<p dir="RTL">תכף רצות.</p>
<p dir="RTL">התחלת מסע,</p>
<p dir="RTL">גדול הוא ממך</p>
<p dir="RTL">וממני</p>
<p dir="RTL">אך את התחלת.</p>
<p dir="RTL">זכרי שתהיה לך תמיד</p>
<p dir="RTL">עצה ויד חמה</p>
<p dir="RTL">עזרה ותמיכה</p>
<p dir="RTL">ביקורת ותובנה</p>
<p dir="RTL">האמיני בדרך</p>
<p dir="RTL">ובאבנים לרגליך</p>
<p dir="RTL">גם בחדות שביניהן</p>
<p dir="RTL">האמיני בשיר</p>
<p dir="RTL">ובמנגינה</p>
<p dir="RTL">האמיני באהבה</p>
<p dir="RTL">היא לנצח שלך.</p>
<p dir="RTL">עשי.</p>
<p dir="RTL">האמיני בך.</p>
<p dir="RTL">הקשיבי ללבך</p>
<p dir="RTL">ולמילים שברוח</p>
<p dir="RTL">שמעי לרזים שמספרת</p>
<p dir="RTL">זכרי זריחה</p>
<p dir="RTL">זכרי תמיד תקווה</p>
<p dir="RTL">רסיסי מראה שנשברה</p>
<p dir="RTL">ישרטו כפותייך</p>
<p dir="RTL">אך סודות יגלו</p>
<p dir="RTL">אם עינייך תפקחי.</p>
<p dir="RTL">הסופה תקפיא עצמותיך</p>
<p dir="RTL">אך גם תשטוף הפצעים.</p>
<p dir="RTL">השלט בתחילת הדרך</p>
<p dir="RTL">לא תמיד מספר סיפורה</p>
<p dir="RTL">האור מבעד לחלון</p>
<p dir="RTL">לא בהכרח השמש</p>
<p dir="RTL">ודלת סגורה</p>
<p dir="RTL">לאו דווקא נעולה.</p>
<p dir="RTL">השמרי נא</p>
<p dir="RTL">מפרחים צבעוניים</p>
<p dir="RTL">שלרגליהם אין אדמה</p>
<p dir="RTL">התרחקי ממלכים</p>
<p dir="RTL">של דקה</p>
<p dir="RTL">מאלה המציעים עזרה</p>
<p dir="RTL">בעוד שידם שבורה.</p>
<p dir="RTL">אמצי אליך הטיפה</p>
<p dir="RTL">בין אם דמעה</p>
<p dir="RTL">או מזיעה</p>
<p dir="RTL">חבקי את הדרך</p>
<p dir="RTL">והמלאכה</p>
<p dir="RTL">שכן ארוכה היא</p>
<p dir="RTL">ומרובה</p>
<p dir="RTL">אך לא בודדה</p>
<p dir="RTL">אני שם איתך</p>
<p dir="RTL">תמיד</p>
<p dir="RTL">במסע,</p>
<p dir="RTL">שלך.</p>
<p style="text-align:left;"><strong><strong>Written: 23/11/2012, Gi&#8217;vat Shmuel, Israel.</strong></strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yoavniran.wordpress.com/869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yoavniran.wordpress.com/869/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=869&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yoavniran.wordpress.com/2013/02/25/poem-%d7%94%d7%9e%d7%a1%d7%a2-%d7%a9%d7%9c%d7%9a/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/07022aa961aa6ee7facc9939f783a797?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yoavniran</media:title>
		</media:content>

		<media:content url="http://yoavniran.files.wordpress.com/2013/02/main.png" medium="image">
			<media:title type="html">Masa-main</media:title>
		</media:content>
	</item>
		<item>
		<title>Poem: How to part</title>
		<link>http://yoavniran.wordpress.com/2013/02/18/poem-how-to-part/</link>
		<comments>http://yoavniran.wordpress.com/2013/02/18/poem-how-to-part/#comments</comments>
		<pubDate>Mon, 18 Feb 2013 14:03:10 +0000</pubDate>
		<dc:creator>Yoav Niran</dc:creator>
				<category><![CDATA[Poetry]]></category>
		<category><![CDATA[goodbye]]></category>
		<category><![CDATA[parting]]></category>
		<category><![CDATA[personal]]></category>

		<guid isPermaLink="false">http://yoavniran.wordpress.com/?p=861</guid>
		<description><![CDATA[Back in July of 2011 (has it been that long ago?) I published what was my latest poem in Hebrew Eich Nifradim (How to Part).

I revisited that poem recently and decided to take a crack at translating it to English and I think it actually turned out quite nicely. <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=861&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://yoavniran.files.wordpress.com/2013/02/pict00333-83.jpg"><img class="aligncenter size-full wp-image-862" alt="how to part" src="http://yoavniran.files.wordpress.com/2013/02/pict00333-83.jpg?w=595"   /></a></p>
<p>Back in July of 2011 (has it been that long ago?) I published what was my latest poem in Hebrew <a title="Poem: איך נפרדים" href="http://yoavniran.wordpress.com/2011/07/21/poem-eich-nifradim/">Eich Nifradim</a> (How to Part).</p>
<p>I revisited that poem recently and decided to take a crack at translating it to English and I think it actually turned out quite nicely.</p>
<p>This poem holds a dear place in my heart as i read it in my grandfather&#8217;s funeral in the summer of that year&#8230;</p>
<p>So here it is:</p>
<p><span id="more-861"></span></p>
<h2><span style="color:#000080;">~ How to Part ~</span></h2>
<p>How to part</p>
<p>How to say goodbye</p>
<p>When there is no another-time to hope for</p>
<p>Which word to choose for last</p>
<p>How do you part and just walk away</p>
<p>Which touch to embrace, what caress to savor</p>
<p>Which tear immortalize</p>
<p>How do you part?</p>
<p>The stump that stood so tall</p>
<p>Now the wind shakes without rest</p>
<p>The stump that stood once and protected</p>
<p>That held experience of years and knowledge</p>
<p>Now left lost and frail</p>
<p>The one that showed the way</p>
<p>Now fumbles in the dark</p>
<p>When the time of sunset is past</p>
<p>And the red turns black.</p>
<p>How to part</p>
<p>When to release thy hand</p>
<p>How to leave and not look back</p>
<p>Which heartbeat you just let skip</p>
<p>How to stay standing and go on</p>
<p>How do you part?</p>
<p>Perhaps with a new life</p>
<p>A tiny grain of hope you promise</p>
<p>When its time for sunrise again</p>
<p>The colors return in bloom</p>
<p>joy and pain coalesce inside</p>
<p>perhaps a new beginning can be hoped</p>
<p>a new blossom aspired</p>
<p>maybe that is how,</p>
<p>you part.</p>
<pre><strong><strong>
Translated: 15/02/2013, Israel.</strong></strong></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yoavniran.wordpress.com/861/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yoavniran.wordpress.com/861/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=861&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yoavniran.wordpress.com/2013/02/18/poem-how-to-part/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/07022aa961aa6ee7facc9939f783a797?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yoavniran</media:title>
		</media:content>

		<media:content url="http://yoavniran.files.wordpress.com/2013/02/pict00333-83.jpg" medium="image">
			<media:title type="html">how to part</media:title>
		</media:content>
	</item>
		<item>
		<title>2012 in review</title>
		<link>http://yoavniran.wordpress.com/2012/12/31/2012-in-review/</link>
		<comments>http://yoavniran.wordpress.com/2012/12/31/2012-in-review/#comments</comments>
		<pubDate>Mon, 31 Dec 2012 18:14:02 +0000</pubDate>
		<dc:creator>Yoav Niran</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yoavniran.wordpress.com/?p=859</guid>
		<description><![CDATA[The WordPress.com stats helper monkeys prepared a 2012 annual report for this blog. Here&#8217;s an excerpt: 4,329 films were submitted to the 2012 Cannes Film Festival. This blog had 21,000 views in 2012. If each view were a film, this blog would power 5 Film Festivals Click here to see the complete report.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=859&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The WordPress.com stats helper monkeys prepared a 2012 annual report for this blog.</p>
<p><a href="http://yoavniran.wordpress.com/2012/annual-report/"><img alt="" src="http://www.wordpress.com/wp-content/mu-plugins/annual-reports/img/2012-emailteaser.png" width="100%" /></a></p>
<p>Here&#8217;s an excerpt:</p>
<blockquote><p>4,329 films were submitted to the 2012 Cannes Film Festival. This blog had <strong>21,000</strong> views in 2012. If each view were a film, this blog would power 5 Film Festivals</p></blockquote>
<p><a href="http://yoavniran.wordpress.com/2012/annual-report/">Click here to see the complete report.</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yoavniran.wordpress.com/859/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yoavniran.wordpress.com/859/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=859&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yoavniran.wordpress.com/2012/12/31/2012-in-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/07022aa961aa6ee7facc9939f783a797?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yoavniran</media:title>
		</media:content>

		<media:content url="http://www.wordpress.com/wp-content/mu-plugins/annual-reports/img/2012-emailteaser.png" medium="image" />
	</item>
		<item>
		<title>Unit Testing, WCF and MEF &#8211; Part 2</title>
		<link>http://yoavniran.wordpress.com/2012/10/18/unit-testing-wcf-and-mef-part-2/</link>
		<comments>http://yoavniran.wordpress.com/2012/10/18/unit-testing-wcf-and-mef-part-2/#comments</comments>
		<pubDate>Thu, 18 Oct 2012 17:08:43 +0000</pubDate>
		<dc:creator>Yoav Niran</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[mef]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[unit test]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://yoavniran.wordpress.com/?p=823</guid>
		<description><![CDATA[In the first part of this article I showed how I’ve been testing code using MEF and a generic base class that is in charge of wiring up the dependencies.

In this part I will focus on how I got WCF to wire up my web service using MEF in what I think is quite an elegant way.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=823&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<div style="margin:20px 0;"></div>
<p>In the <strong><a title="Unit Testing, WCF and MEF" href="http://yoavniran.wordpress.com/2012/10/18/unit-testing-wcf-and-mef/"><span style="color:#888888;">first part</span></a></strong> of this article I showed how I’ve been testing code using MEF and a generic base class that is in charge of wiring up the dependencies.</p>
<p>In this part I will focus on how I got WCF to wire up my web service using MEF in what I think is quite an elegant way.</p>
<p>My first requirement was to be able to write a web service that will use dependencies (imports) but that wouldn’t require me to write the composition code in the service class itself. Most of the examples I saw online didn’t provide me with a good way to do that unfortunately.</p>
<p>Until I came across this excellent <a href="http://www.timjroberts.com/2011/08/wcf-services-with-mef/" target="_blank" rel="nofollow">post by Tim Roberts</a> which shows how to tap into the WCF pipe-line and have your services composed automatically instead of having to do it per service or including wire-up code in your classes.</p>
<p>While the code Tim provided was a great start I thought it wasn’t just right for me. Specifically it was the fact that it required custom code in the Global.asax file which for me was not as elegant as it should be.</p>
<p>So I’ve done a bit more digging into the WCF pipe-line and discovered that I could achieve an elegant, completely configuration-based solution by implementing my own <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.description.iendpointbehavior.aspx" target="_blank" rel="nofollow">endpoint behavior</a>.</p>
<p>In the end I needed to only create 3 classes to achieve this: <strong>EndpointComposedElement</strong>, <strong>ComposedEndpointBehavior</strong> and <strong>ComposedInstanceProvider</strong>.</p>
<p><span id="more-823"></span></p>
<p>By the way, if you&#8217;re interested in the WCF pipe-line in general there is a nice diagram here: <a href="http://andrewtokeley.net/archive/2008/07/31/wcf-simplified-to-a-single-diagram.aspx" target="_blank" rel="nofollow">http://andrewtokeley.net/archive/2008/07/31/wcf-simplified-to-a-single-diagram.aspx</a>.</p>
<p>Now, onwards to the code:</p>
<h2>EndpointComposedElement</h2>
<pre style="color:#000020;background:#f6f8ff;margin-bottom:20px;"><span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>Collections<span style="color:#308080;">.</span>Generic<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>Linq<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>Web<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>Configuration<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>ComponentModel<span style="color:#308080;">.</span>Composition<span style="color:#308080;">.</span>Primitives<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>ComponentModel<span style="color:#308080;">.</span>Composition<span style="color:#308080;">.</span>Hosting<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>Reflection<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>ServiceModel<span style="color:#308080;">.</span>Configuration<span style="color:#406080;">;</span>

<span style="color:#200080;font-weight:bold;">namespace</span> SampleApplication<span style="color:#308080;">.</span>Web<span style="color:#308080;">.</span>ServiceModel
<span style="color:#406080;">{</span>
    <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">class</span> EndpointComposedElement <span style="color:#308080;">:</span> BehaviorExtensionElement
    <span style="color:#406080;">{</span>
        <span style="color:#308080;">[</span>ConfigurationProperty<span style="color:#308080;">(</span><span style="color:#800000;">"</span><span style="color:#1060b6;">assemblies</span><span style="color:#800000;">"</span><span style="color:#308080;">)</span><span style="color:#308080;">]</span>
        <span style="color:#308080;">[</span>ConfigurationCollection<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">typeof</span><span style="color:#308080;">(</span>NameValueConfigurationCollection<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">]</span>
        <span style="color:#200080;font-weight:bold;">public</span> NameValueConfigurationCollection ConfigAssemblies
        <span style="color:#406080;">{</span>
            get
            <span style="color:#406080;">{</span>
                <span style="color:#200080;font-weight:bold;">return</span> <span style="color:#308080;">(</span>NameValueConfigurationCollection<span style="color:#308080;">)</span><span style="color:#200080;font-weight:bold;">this</span><span style="color:#308080;">[</span><span style="color:#800000;">"</span><span style="color:#1060b6;">assemblies</span><span style="color:#800000;">"</span><span style="color:#308080;">]</span><span style="color:#406080;">;</span>
            <span style="color:#406080;">}</span>
        <span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">override</span> Type BehaviorType
        <span style="color:#406080;">{</span>
            get <span style="color:#406080;">{</span> <span style="color:#200080;font-weight:bold;">return</span> <span style="color:#200080;font-weight:bold;">typeof</span><span style="color:#308080;">(</span>ComposedEndpointBehavior<span style="color:#308080;">)</span><span style="color:#406080;">;</span> <span style="color:#406080;">}</span>
        <span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">protected</span> <span style="color:#200080;font-weight:bold;">override</span> <span style="color:#200080;font-weight:bold;">object</span> CreateBehavior<span style="color:#308080;">(</span><span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>
            ComposablePartCatalog catalog <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">null</span><span style="color:#406080;">;</span>

            var configTypes <span style="color:#308080;">=</span> ConfigAssemblies<span style="color:#406080;">;</span>

            <span style="color:#200080;font-weight:bold;">if</span> <span style="color:#308080;">(</span>configTypes <span style="color:#308080;">!</span><span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">null</span><span style="color:#308080;">)</span>
            <span style="color:#406080;">{</span>
                var assCatalogs <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> List<span style="color:#308080;">&lt;</span>AssemblyCatalog<span style="color:#308080;">&gt;</span><span style="color:#308080;">(</span>configTypes<span style="color:#308080;">.</span>Count<span style="color:#308080;">)</span><span style="color:#406080;">;</span>

                assCatalogs<span style="color:#308080;">.</span>Add<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">new</span> AssemblyCatalog<span style="color:#308080;">(</span>Assembly<span style="color:#308080;">.</span>GetExecutingAssembly<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span> <span style="color:#595979;">//first add the current assembly</span>

                <span style="color:#200080;font-weight:bold;">foreach</span> <span style="color:#308080;">(</span>NameValueConfigurationElement nvce <span style="color:#200080;font-weight:bold;">in</span> configTypes<span style="color:#308080;">)</span> <span style="color:#595979;">//add any additional assemblies from the configuration</span>
                <span style="color:#406080;">{</span>
                    assCatalogs<span style="color:#308080;">.</span>Add<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">new</span> AssemblyCatalog<span style="color:#308080;">(</span>Assembly<span style="color:#308080;">.</span>Load<span style="color:#308080;">(</span>nvce<span style="color:#308080;">.</span>Value<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
                <span style="color:#406080;">}</span>

                catalog <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> AggregateCatalog<span style="color:#308080;">(</span>assCatalogs<span style="color:#308080;">)</span><span style="color:#406080;">;</span>
            <span style="color:#406080;">}</span>
            <span style="color:#200080;font-weight:bold;">else</span> <span style="color:#595979;">//no configuration, only use the current assembly</span>
            <span style="color:#406080;">{</span>
                catalog <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> AssemblyCatalog<span style="color:#308080;">(</span>Assembly<span style="color:#308080;">.</span>GetExecutingAssembly<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
            <span style="color:#406080;">}</span>

            var container <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> CompositionContainer<span style="color:#308080;">(</span>catalog<span style="color:#308080;">)</span><span style="color:#406080;">;</span>

            <span style="color:#200080;font-weight:bold;">return</span> <span style="color:#200080;font-weight:bold;">new</span> ComposedEndpointBehavior<span style="color:#308080;">(</span>container<span style="color:#308080;">)</span><span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span>
    <span style="color:#406080;">}</span>
<span style="color:#406080;">}</span></pre>
<p>This class creates my custom behavior and passes to it the initialized CompositionContainer with the assemblies it found configured(<a href="#servicemodelconfig">see configuration</a>) and the assembly its running in (<em>GetExecutingAssembly()</em>).</p>
<h2>ComposedEndpointBehavior</h2>
<pre style="color:#000020;background:#f6f8ff;margin-bottom:20px;"><span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>Collections<span style="color:#308080;">.</span>Generic<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>Linq<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>Web<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>ServiceModel<span style="color:#308080;">.</span>Description<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>ServiceModel<span style="color:#308080;">.</span>Dispatcher<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>ServiceModel<span style="color:#308080;">.</span>Channels<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>ComponentModel<span style="color:#308080;">.</span>Composition<span style="color:#308080;">.</span>Hosting<span style="color:#406080;">;</span>

<span style="color:#200080;font-weight:bold;">namespace</span> SampleApplication<span style="color:#308080;">.</span>Web<span style="color:#308080;">.</span>ServiceModel
<span style="color:#406080;">{</span>
    <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">class</span> ComposedEndpointBehavior <span style="color:#308080;">:</span> IEndpointBehavior
    <span style="color:#406080;">{</span>        
        <span style="color:#200080;font-weight:bold;">private</span> <span style="color:#200080;font-weight:bold;">readonly</span> CompositionContainer container<span style="color:#406080;">;</span>

        <span style="color:#200080;font-weight:bold;">public</span> ComposedEndpointBehavior<span style="color:#308080;">(</span>CompositionContainer container<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>            
            <span style="color:#200080;font-weight:bold;">this</span><span style="color:#308080;">.</span>container <span style="color:#308080;">=</span> container<span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">void</span> AddBindingParameters<span style="color:#308080;">(</span>ServiceEndpoint endpoint<span style="color:#308080;">,</span> BindingParameterCollection bindingParameters<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span><span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">void</span> ApplyClientBehavior<span style="color:#308080;">(</span>ServiceEndpoint endpoint<span style="color:#308080;">,</span> ClientRuntime clientRuntime<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span><span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">void</span> ApplyDispatchBehavior<span style="color:#308080;">(</span>ServiceEndpoint endpoint<span style="color:#308080;">,</span> EndpointDispatcher endpointDispatcher<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>
            ComposedInstanceProvider provider <span style="color:#308080;">=</span> ComposedInstanceProvider<span style="color:#308080;">.</span>CreateProvider<span style="color:#308080;">(</span>endpoint<span style="color:#308080;">.</span>Address<span style="color:#308080;">.</span>Uri<span style="color:#308080;">.</span>ToString<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#308080;">,</span> 
                endpoint<span style="color:#308080;">.</span>Contract<span style="color:#308080;">.</span>ContractType<span style="color:#308080;">,</span> container<span style="color:#308080;">)</span><span style="color:#406080;">;</span>

            <span style="color:#200080;font-weight:bold;">if</span> <span style="color:#308080;">(</span>provider <span style="color:#308080;">=</span><span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">null</span><span style="color:#308080;">)</span> <span style="color:#200080;font-weight:bold;">throw</span> <span style="color:#200080;font-weight:bold;">new</span> InvalidOperationException<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>

            endpointDispatcher<span style="color:#308080;">.</span>DispatchRuntime<span style="color:#308080;">.</span>InstanceProvider <span style="color:#308080;">=</span> provider<span style="color:#406080;">;</span>                            
        <span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">void</span> Validate<span style="color:#308080;">(</span>ServiceEndpoint endpoint<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span><span style="color:#406080;">}</span>        
    <span style="color:#406080;">}</span>
<span style="color:#406080;">}</span></pre>
<p>This custom behavior’s role is to attach the ComposedInstanceProvider to the configured end-point. This behavior class which was initialized by the <em>EndpointComposedElement</em> already received the initialized container and therefore can create the custom Instance Provider with the container it received.</p>
<h2>ComposedInstanceProvider</h2>
<pre style="color:#000020;background:#f6f8ff;margin-bottom:20px;"><span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>Collections<span style="color:#308080;">.</span>Generic<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>Linq<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>Web<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>ServiceModel<span style="color:#308080;">.</span>Dispatcher<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>ComponentModel<span style="color:#308080;">.</span>Composition<span style="color:#308080;">.</span>Hosting<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>ServiceModel<span style="color:#308080;">.</span>Channels<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>ServiceModel<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>ComponentModel<span style="color:#308080;">.</span>Composition<span style="color:#308080;">.</span>Primitives<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">using</span> System<span style="color:#308080;">.</span>ComponentModel<span style="color:#308080;">.</span>Composition<span style="color:#406080;">;</span>

<span style="color:#200080;font-weight:bold;">namespace</span> SampleApplication<span style="color:#308080;">.</span>Web<span style="color:#308080;">.</span>ServiceModel
<span style="color:#406080;">{</span>
    <span style="color:#595979;">/// &lt;summary&gt;</span>
    <span style="color:#595979;">/// from: http://www.timjroberts.com/2011/08/wcf-services-with-mef/</span>
    <span style="color:#595979;">/// &lt;/summary&gt;</span>
    <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">class</span> ComposedInstanceProvider <span style="color:#308080;">:</span> IInstanceProvider
    <span style="color:#406080;">{</span>
        <span style="color:#200080;font-weight:bold;">private</span> <span style="color:#200080;font-weight:bold;">static</span> Dictionary<span style="color:#308080;">&lt;</span><span style="color:#200080;font-weight:bold;">string</span><span style="color:#308080;">,</span> ComposedInstanceProvider<span style="color:#308080;">&gt;</span> providers <span style="color:#308080;">=</span> 
                <span style="color:#200080;font-weight:bold;">new</span> Dictionary<span style="color:#308080;">&lt;</span><span style="color:#200080;font-weight:bold;">string</span><span style="color:#308080;">,</span> ComposedInstanceProvider<span style="color:#308080;">&gt;</span><span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>

        <span style="color:#200080;font-weight:bold;">private</span> <span style="color:#200080;font-weight:bold;">readonly</span> CompositionContainer container<span style="color:#406080;">;</span>

        <span style="color:#200080;font-weight:bold;">public</span> Type ServiceType <span style="color:#406080;">{</span> get<span style="color:#406080;">;</span> <span style="color:#200080;font-weight:bold;">private</span> set<span style="color:#406080;">;</span> <span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">private</span> ComposedInstanceProvider<span style="color:#308080;">(</span>Type serviceType<span style="color:#308080;">,</span> CompositionContainer container<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>            
            ServiceType <span style="color:#308080;">=</span> serviceType<span style="color:#406080;">;</span>
            <span style="color:#200080;font-weight:bold;">this</span><span style="color:#308080;">.</span>container <span style="color:#308080;">=</span> container<span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">static</span> ComposedInstanceProvider CreateProvider<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">string</span> address<span style="color:#308080;">,</span> Type serviceType<span style="color:#308080;">,</span> 
                                        CompositionContainer container<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>
            ComposedInstanceProvider provider <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">null</span><span style="color:#406080;">;</span>

            <span style="color:#200080;font-weight:bold;">if</span> <span style="color:#308080;">(</span>providers<span style="color:#308080;">.</span>ContainsKey<span style="color:#308080;">(</span>address<span style="color:#308080;">)</span><span style="color:#308080;">)</span>
            <span style="color:#406080;">{</span>
                provider <span style="color:#308080;">=</span> providers<span style="color:#308080;">[</span>address<span style="color:#308080;">]</span><span style="color:#406080;">;</span>
            <span style="color:#406080;">}</span>
            <span style="color:#200080;font-weight:bold;">else</span>
            <span style="color:#406080;">{</span>
                provider <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> ComposedInstanceProvider<span style="color:#308080;">(</span>serviceType<span style="color:#308080;">,</span> container<span style="color:#308080;">)</span><span style="color:#406080;">;</span>
                providers<span style="color:#308080;">.</span>Add<span style="color:#308080;">(</span>address<span style="color:#308080;">,</span> provider<span style="color:#308080;">)</span><span style="color:#406080;">;</span>
            <span style="color:#406080;">}</span>

            <span style="color:#200080;font-weight:bold;">return</span> provider<span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">static</span> ComposedInstanceProvider GetProvider<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">string</span> address<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>
            <span style="color:#200080;font-weight:bold;">if</span> <span style="color:#308080;">(</span>providers<span style="color:#308080;">.</span>ContainsKey<span style="color:#308080;">(</span>address<span style="color:#308080;">)</span><span style="color:#308080;">)</span>
            <span style="color:#406080;">{</span>
                <span style="color:#200080;font-weight:bold;">return</span> providers<span style="color:#308080;">[</span>address<span style="color:#308080;">]</span><span style="color:#406080;">;</span>
            <span style="color:#406080;">}</span>

            <span style="color:#200080;font-weight:bold;">return</span> <span style="color:#200080;font-weight:bold;">null</span><span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">object</span> GetInstance<span style="color:#308080;">(</span>InstanceContext instanceContext<span style="color:#308080;">,</span> Message message<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>            
            <span style="color:#200080;font-weight:bold;">return</span> GetInstance<span style="color:#308080;">(</span>instanceContext<span style="color:#308080;">)</span><span style="color:#406080;">;</span>            
        <span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">object</span> GetInstance<span style="color:#308080;">(</span>InstanceContext instanceContext<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>            
            Export export <span style="color:#308080;">=</span> GetServiceExport<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>

            <span style="color:#200080;font-weight:bold;">if</span> <span style="color:#308080;">(</span>export <span style="color:#308080;">=</span><span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">null</span><span style="color:#308080;">)</span>
            <span style="color:#406080;">{</span>                
                <span style="color:#200080;font-weight:bold;">throw</span> <span style="color:#200080;font-weight:bold;">new</span> InvalidOperationException<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
            <span style="color:#406080;">}</span>

            <span style="color:#200080;font-weight:bold;">return</span> export<span style="color:#308080;">.</span>Value<span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">void</span> ReleaseInstance<span style="color:#308080;">(</span>InstanceContext instanceContext<span style="color:#308080;">,</span> <span style="color:#200080;font-weight:bold;">object</span> instance<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>
            <span style="color:#200080;font-weight:bold;">throw</span> <span style="color:#200080;font-weight:bold;">new</span> NotImplementedException<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">private</span> Export GetServiceExport<span style="color:#308080;">(</span><span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>
            var importDefinition
              <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> ContractBasedImportDefinition<span style="color:#308080;">(</span>AttributedModelServices<span style="color:#308080;">.</span>GetContractName<span style="color:#308080;">(</span>ServiceType<span style="color:#308080;">)</span><span style="color:#308080;">,</span>
                                        AttributedModelServices<span style="color:#308080;">.</span>GetTypeIdentity<span style="color:#308080;">(</span>ServiceType<span style="color:#308080;">)</span><span style="color:#308080;">,</span>
                                        <span style="color:#200080;font-weight:bold;">null</span><span style="color:#308080;">,</span>
                                        ImportCardinality<span style="color:#308080;">.</span>ZeroOrMore<span style="color:#308080;">,</span>
                                        <span style="color:#200080;font-weight:bold;">true</span><span style="color:#308080;">,</span>
                                        <span style="color:#200080;font-weight:bold;">true</span><span style="color:#308080;">,</span>
                                        CreationPolicy<span style="color:#308080;">.</span>Any<span style="color:#308080;">)</span><span style="color:#406080;">;</span>

            <span style="color:#200080;font-weight:bold;">return</span> container<span style="color:#308080;">.</span>GetExports<span style="color:#308080;">(</span>importDefinition<span style="color:#308080;">)</span><span style="color:#308080;">.</span>FirstOrDefault<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span>
    <span style="color:#406080;">}</span>
<span style="color:#406080;">}</span></pre>
<p>Finally, the custom Instance Provider provides the WCF pipe-line with the instance of the service class already initialized and with imports fulfilled because the provider received the initialized composition container from the custom behavior.</p>
<h2>Web Service &amp; Configuration</h2>
<p>To be able to tie these things together I used the <em>system.serviceModel</em> configuration section like this:</p>
<pre id="servicemodelconfig" style="color:#000020;background:#f6f8ff;margin-bottom:20px;"><span style="color:#0057a6;">&lt;</span><span style="color:#333385;">system.serviceModel</span><span style="color:#0057a6;">&gt;</span>
    <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">extensions</span><span style="color:#0057a6;">&gt;</span>
      <span style="color:#0057a6;">&lt;</span><strong><span style="color:#333385;">behaviorExtensions</span></strong><span style="color:#0057a6;">&gt;</span>        
    <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">add</span> <span style="color:#474796;">name</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><strong><span style="color:#1060b6;">endpointComposed</span></strong><span style="color:#1060b6;">"</span> <span style="color:#474796;">type</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">SampleApplication.Web.ServiceModel.EndpointComposedElement, SampleApplication.Web</span><span style="color:#1060b6;">"</span><span style="color:#0057a6;">/&gt;</span>
      <span style="color:#0057a6;">&lt;/</span><strong><span style="color:#333385;">behaviorExtensions</span></strong><span style="color:#0057a6;">&gt;</span>
    <span style="color:#0057a6;">&lt;/</span><span style="color:#333385;">extensions</span><span style="color:#0057a6;">&gt;</span>
    <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">behaviors</span><span style="color:#0057a6;">&gt;</span>
      <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">endpointBehaviors</span><span style="color:#0057a6;">&gt;</span>
        <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">behavior</span> <span style="color:#474796;">name</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">jsonBehavior</span><span style="color:#1060b6;">"</span><span style="color:#0057a6;">&gt;</span>
          <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">enableWebScript</span><span style="color:#0057a6;">/&gt;</span>
      <span style="color:#0057a6;">&lt;</span><strong><span style="color:#333385;">endpointComposed</span></strong><span style="color:#0057a6;">&gt;</span>
        <span style="color:#0057a6;">&lt;</span><strong><span style="color:#333385;">assemblies</span></strong><span style="color:#0057a6;">&gt;</span>
            <span style="color:#0057a6;">&lt;</span><strong><span style="color:#333385;">add</span> <span style="color:#474796;">name</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">sampleApplication</span><span style="color:#1060b6;">"</span> <span style="color:#474796;">value</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">SampleApplication</span><span style="color:#1060b6;">"</span></strong><span style="color:#0057a6;">/&gt;</span>
        <span style="color:#0057a6;">&lt;/</span><strong><span style="color:#333385;">assemblies</span></strong><span style="color:#0057a6;">&gt;</span>
          <span style="color:#0057a6;">&lt;/</span><strong><span style="color:#333385;">endpointComposed</span></strong><span style="color:#0057a6;">&gt;</span>
        <span style="color:#0057a6;">&lt;/</span><span style="color:#333385;">behavior</span><span style="color:#0057a6;">&gt;</span>                
      <span style="color:#0057a6;">&lt;/</span><span style="color:#333385;">endpointBehaviors</span><span style="color:#0057a6;">&gt;</span>
      <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">serviceBehaviors</span><span style="color:#0057a6;">&gt;</span>
        <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">behavior</span> <span style="color:#474796;">name</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">SampleServiceAspNetAjaxBehavior</span><span style="color:#1060b6;">"</span><span style="color:#0057a6;">&gt;</span>
          <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">serviceMetadata</span> <span style="color:#474796;">httpGetEnabled</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">true</span><span style="color:#1060b6;">"</span><span style="color:#0057a6;">/&gt;</span>
          <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">serviceDebug</span> <span style="color:#474796;">httpHelpPageEnabled</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">true</span><span style="color:#1060b6;">"</span> <span style="color:#474796;">includeExceptionDetailInFaults</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">true</span><span style="color:#1060b6;">"</span><span style="color:#0057a6;">/&gt;</span>         
        <span style="color:#0057a6;">&lt;/</span><span style="color:#333385;">behavior</span><span style="color:#0057a6;">&gt;</span>
      <span style="color:#0057a6;">&lt;/</span><span style="color:#333385;">serviceBehaviors</span><span style="color:#0057a6;">&gt;</span>
    <span style="color:#0057a6;">&lt;/</span><span style="color:#333385;">behaviors</span><span style="color:#0057a6;">&gt;</span>
    <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">services</span><span style="color:#0057a6;">&gt;</span>
      <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">service</span> <span style="color:#474796;">name</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">SampleApplication.Web.Services.SampleService</span><span style="color:#1060b6;">"</span> <span style="color:#474796;">behaviorConfiguration</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">SampleServiceAspNetAjaxBehavior</span><span style="color:#1060b6;">"</span><span style="color:#0057a6;">&gt;</span>
        <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">endpoint</span> <span style="color:#474796;">address</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">json</span><span style="color:#1060b6;">"</span> <span style="color:#474796;">binding</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">webHttpBinding</span><span style="color:#1060b6;">"</span> <span style="color:#474796;">behaviorConfiguration</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">jsonBehavior</span><span style="color:#1060b6;">"</span> <span style="color:#474796;">contract</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">SampleApplication.Web.Services.ISampleService</span><span style="color:#1060b6;">"</span><span style="color:#0057a6;">/&gt;</span>
        <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">endpoint</span> <span style="color:#474796;">address</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">"</span> <span style="color:#474796;">binding</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">basicHttpBinding</span><span style="color:#1060b6;">"</span> <span style="color:#474796;">contract</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">SampleApplication.Web.Services.ISampleService</span><span style="color:#1060b6;">"</span><span style="color:#0057a6;">/&gt;</span>
      <span style="color:#0057a6;">&lt;/</span><span style="color:#333385;">service</span><span style="color:#0057a6;">&gt;</span>
    <span style="color:#0057a6;">&lt;/</span><span style="color:#333385;">services</span><span style="color:#0057a6;">&gt;</span>
    <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">serviceHostingEnvironment</span> <span style="color:#474796;">aspNetCompatibilityEnabled</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">true</span><span style="color:#1060b6;">"</span> <span style="color:#474796;">multipleSiteBindingsEnabled</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">true</span><span style="color:#1060b6;">"</span><span style="color:#0057a6;">/&gt;</span>
  <span style="color:#0057a6;">&lt;/</span><span style="color:#333385;">system.serviceModel</span><span style="color:#0057a6;">&gt;</span></pre>
<p>First, I declared my custom behavior extension under the <em>&lt;extensions&gt;</em> element. Then I defined the extension’s contents under the <em>&lt;endpointBehaviors&gt;/&lt;behavior&gt;/&lt;endpointComposed&gt;</em> section and provided the assembly name I wish to have used as part of the composition.</p>
<p>Finally I linked all of this behavior to my service&#8217;s endpoint using the <em>behaviorConfiguration</em> attribute on the endpoint element.</p>
<p>What of all of this allowed me to do is the ability to create a service class without any kind of wiring code as well as write tests for my service using the same exact process I’ve explained in the <a title="Unit Testing, WCF and MEF" href="http://yoavniran.wordpress.com/2012/10/18/unit-testing-wcf-and-mef/">first part of this article</a>. I am now able to take this code to existing and new projects alike and not have to write any custom code for the composition anew each time.</p>
<p>Here is my service class:</p>
<pre style="color:#000020;background:#f6f8ff;margin-bottom:20px;"><span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">class</span> SampleService <span style="color:#308080;">:</span> ISampleService
<span style="color:#406080;">{</span>
    <span style="color:#308080;">[</span>Import<span style="color:#308080;">]</span>
    <span style="color:#200080;font-weight:bold;">private</span> ISampleSentenceService sentenceService<span style="color:#406080;">;</span>

    <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">string</span> GetHelloWorld<span style="color:#308080;">(</span><span style="color:#308080;">)</span>
    <span style="color:#406080;">{</span>
        <span style="color:#200080;font-weight:bold;">string</span> response <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">null</span><span style="color:#406080;">;</span>

        <span style="color:#200080;font-weight:bold;">try</span>
        <span style="color:#406080;">{</span>
            response <span style="color:#308080;">=</span> sentenceService<span style="color:#308080;">.</span>GetSentence<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span>
        <span style="color:#200080;font-weight:bold;">catch</span> <span style="color:#308080;">(</span>Exception ex<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>
            response <span style="color:#308080;">=</span> <span style="color:#800000;">"</span><span style="color:#1060b6;">ERROR!</span><span style="color:#800000;">"</span><span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span>

        <span style="color:#200080;font-weight:bold;">return</span> response<span style="color:#406080;">;</span>
    <span style="color:#406080;">}</span>        
<span style="color:#406080;">}</span></pre>
<p><strong>No composition or wiring code here&#8230;</strong></p>
<p>And here is a test I’ve written for it:</p>
<pre style="color:#000020;background:#f6f8ff;margin-bottom:20px;"><span style="color:#308080;">[</span>TestClass<span style="color:#308080;">]</span>
<span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">class</span> SampleServiceIntegrationTest <span style="color:#308080;">:</span> AutoTestBase
<span style="color:#406080;">{</span>
    <span style="color:#308080;">[</span>Import<span style="color:#308080;">]</span>
    <span style="color:#200080;font-weight:bold;">private</span> ISampleService service<span style="color:#406080;">;</span>

    <span style="color:#308080;">[</span>TestMethod<span style="color:#308080;">]</span>
    <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">void</span> TestGetHelloWorldSuccess<span style="color:#308080;">(</span><span style="color:#308080;">)</span>
    <span style="color:#406080;">{</span>
        <span style="color:#200080;font-weight:bold;">string</span> expectedResponse <span style="color:#308080;">=</span> <span style="color:#800000;">"</span><span style="color:#1060b6;">Hello World</span><span style="color:#800000;">"</span><span style="color:#406080;">;</span>

        <span style="color:#200080;font-weight:bold;">string</span> response <span style="color:#308080;">=</span> service<span style="color:#308080;">.</span>GetHelloWorld<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>

        Assert<span style="color:#308080;">.</span>IsNotNull<span style="color:#308080;">(</span>response<span style="color:#308080;">)</span><span style="color:#406080;">;</span>
        Assert<span style="color:#308080;">.</span>AreEqual<span style="color:#308080;">(</span>expectedResponse<span style="color:#308080;">,</span> response<span style="color:#308080;">)</span><span style="color:#406080;">;</span>
    <span style="color:#406080;">}</span>
<span style="color:#406080;">}</span></pre>
<p>Here is the test configuration XML I used for my <em>SampleApplication.Web.Test</em> project:</p>
<pre style="color:#000020;background:#f6f8ff;margin-bottom:20px;"><span style="color:#308080;">&lt;</span>?xml version<span style="color:#308080;">=</span><span style="color:#800000;">"</span><span style="color:#1060b6;">1.0</span><span style="color:#800000;">"</span> encoding<span style="color:#308080;">=</span><span style="color:#800000;">"</span><span style="color:#1060b6;">utf-8</span><span style="color:#800000;">"</span> ?<span style="color:#308080;">&gt;</span>
<span style="color:#308080;">&lt;</span>configuration<span style="color:#308080;">&gt;</span>
    <span style="color:#308080;">&lt;</span>configSections<span style="color:#308080;">&gt;</span>
        <span style="color:#308080;">&lt;</span>section name<span style="color:#308080;">=</span><span style="color:#800000;">"</span><span style="color:#1060b6;">testConfiguration</span><span style="color:#800000;">"</span> 
        type<span style="color:#308080;">=</span><span style="color:#800000;">"</span><span style="color:#1060b6;">SampleApplication.Test.Base.Configuration.TestConfigurationSection, SampleApplication.Test.Base</span><span style="color:#800000;">"</span><span style="color:#308080;">/</span><span style="color:#308080;">&gt;</span>
    <span style="color:#308080;">&lt;</span><span style="color:#308080;">/</span>configSections<span style="color:#308080;">&gt;</span>

    <span style="color:#308080;">&lt;</span>testConfiguration<span style="color:#308080;">&gt;</span>
        <span style="color:#308080;">&lt;</span>Assemblies<span style="color:#308080;">&gt;</span>
          <span style="color:#308080;">&lt;</span>add name<span style="color:#308080;">=</span><span style="color:#800000;">"</span><span style="color:#1060b6;">sampleapplication</span><span style="color:#800000;">"</span> value<span style="color:#308080;">=</span><span style="color:#800000;">"</span><span style="color:#1060b6;">SampleApplication</span><span style="color:#800000;">"</span><span style="color:#308080;">/</span><span style="color:#308080;">&gt;</span>
          <span style="color:#308080;">&lt;</span>add name<span style="color:#308080;">=</span><span style="color:#800000;">"</span><span style="color:#1060b6;">sampleapplicationWeb</span><span style="color:#800000;">"</span> value<span style="color:#308080;">=</span><span style="color:#800000;">"</span><span style="color:#1060b6;">SampleApplication.Web</span><span style="color:#800000;">"</span><span style="color:#308080;">/</span><span style="color:#308080;">&gt;</span>
        <span style="color:#308080;">&lt;</span><span style="color:#308080;">/</span>Assemblies<span style="color:#308080;">&gt;</span>        
    <span style="color:#308080;">&lt;</span><span style="color:#308080;">/</span>testConfiguration<span style="color:#308080;">&gt;</span>
<span style="color:#308080;">&lt;</span><span style="color:#308080;">/</span>configuration<span style="color:#308080;">&gt;</span></pre>
<p>Naturally, The web service itself works just fine and can be accessed by an HTTP request:</p>
<p><a href="http://yoavniran.files.wordpress.com/2012/10/gethelloworld.png"><img class="aligncenter size-full wp-image-836" title="page showing the get hello world result" alt="gethelloworld" src="http://yoavniran.files.wordpress.com/2012/10/gethelloworld.png?w=595&#038;h=306" width="595" height="306" /></a></p>
<h2>Conclusion</h2>
<p>I was very happy to reach my goal of easily creating web services and tests alike without going through the hassle of managing dependencies manually or having to write a lot of wiring code just so my objects can play together.</p>
<p>While I have found this approach to work in several small applications this is not tested in Production or in large scale applications so if you plan on using this please thoroughly test and I&#8217;d of course love to hear feedback.</p>
<h2 id="code">Code</h2>
<p>Ive uploaded the code sample to BitBucket here: <a href="https://bitbucket.org/yoavniran/wcf-mef-and-testing-sample-code/src" target="_blank" rel="nofollow">https://bitbucket.org/yoavniran/wcf-mef-and-testing-sample-code</a></p>
<div style="margin:30px 0;"></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yoavniran.wordpress.com/823/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yoavniran.wordpress.com/823/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=823&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yoavniran.wordpress.com/2012/10/18/unit-testing-wcf-and-mef-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/07022aa961aa6ee7facc9939f783a797?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yoavniran</media:title>
		</media:content>

		<media:content url="http://yoavniran.files.wordpress.com/2012/10/gethelloworld.png" medium="image">
			<media:title type="html">page showing the get hello world result</media:title>
		</media:content>
	</item>
		<item>
		<title>Unit Testing, WCF and MEF</title>
		<link>http://yoavniran.wordpress.com/2012/10/18/unit-testing-wcf-and-mef/</link>
		<comments>http://yoavniran.wordpress.com/2012/10/18/unit-testing-wcf-and-mef/#comments</comments>
		<pubDate>Thu, 18 Oct 2012 16:53:14 +0000</pubDate>
		<dc:creator>Yoav Niran</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[composability]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[mef]]></category>
		<category><![CDATA[OO]]></category>
		<category><![CDATA[SOLID]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[unit test]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://yoavniran.wordpress.com/?p=785</guid>
		<description><![CDATA[This article will focus on how I’ve adopted unit testing in .NET using MEF and how to also apply this to WCF web services.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=785&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h2>Intro</h2>
<p>This article will focus on how I’ve adopted unit testing in .NET using MEF and how to also apply this to WCF web services.</p>
<p>I haven&#8217;t been dedicated to unit testing for a long time but once I started I couldn&#8217;t stop. There are many great benefits to doing unit tests, I wont list them here but a good article to read is at: <a href="http://www.agitar.com/solutions/why_unit_testing.html" target="_blank" rel="nofollow">Agitar.com</a></p>
<p>What made me build something on my own? I wanted something light that I could also integrate into existing code without making too many changes. So I focused on a couple of things: Testing and Dependency Injection. I wanted an elegant solution that didn’t rely on external libraries or that will require a steep learning-curve.</p>
<p>In this article I will focus on these topics and how I solved it for myself. I&#8217;m not going to dive into other topics such as <a href="http://en.wikipedia.org/wiki/SOLID_%28object-oriented_design%29" target="_blank" rel="nofollow"><span style="text-decoration:underline;">The SOLID principals</span></a>, <a href="http://en.wikipedia.org/wiki/Test-driven_development" target="_blank" rel="nofollow">T<span style="text-decoration:underline;">DD</span></a>, <a href="http://msdn.microsoft.com/en-us/magazine/cc163739.aspx" target="_blank" rel="nofollow"><span style="text-decoration:underline;">Dependency Injection</span></a>, <a href="http://en.wikipedia.org/wiki/Mock_object" target="_blank" rel="nofollow"><span style="text-decoration:underline;">Mocking</span></a>, etc. If these terms are not familiar to you, I suggest you read up on them first.</p>
<p>I’m actually going to divide this article into two parts, to keep them shorter and to the point:</p>
<ul>
<li>This first part will discuss how to do testing with MEF.</li>
<li>The second will discuss how to use <a title="Unit Testing, WCF and MEF - Part 2" href="http://yoavniran.wordpress.com/2012/10/18/unit-testing-wcf-and-mef-part-2"><span style="color:#888888;">MEF and test for a WCF service</span></a>.</li>
</ul>
<p><span id="more-785"></span></p>
<h2>Sample Solution</h2>
<p>The entire code sample (in C#) for this article is available through <a href="#code">here</a>.</p>
<p>The solution I’ve created to demonstrate the concepts is a simple one that includes a project with the “business logic”(SampleApplication) which is in charge of retrieving words from a file and then concatenating them into a sentence. I’ve separated the tasks involved into different objects to demonstrate the composability and separation of concerns that will typically take place in a real project.</p>
<p>On top of the BL I’ve included a web application project(SampleApplication.Web) that contains the WCF service which exposes the functionality through a web service.</p>
<p>Of course, I’ve also added the test projects that test that everything is working as it should.</p>
<p><a href="http://yoavniran.files.wordpress.com/2012/10/sampleproject1.png"><img class="aligncenter size-full wp-image-802" title="sample project" alt="sampleproject" src="http://yoavniran.files.wordpress.com/2012/10/sampleproject1.png?w=595"   /></a></p>
<h2>Testing</h2>
<p>The testing library I’ve chosen to use is the one built into <a href="http://msdn.microsoft.com/en-us/library/bb385902%28v=vs.90%29.aspx" target="_blank" rel="nofollow">.<span style="text-decoration:underline;">NET and Visual Studio</span></a>, not because it’s the best, its actually alright to use (definitely not great), but because it’s the only one that has a somewhat decent integration with Visual Studio.</p>
<p>I’ve tried using <a href="http://www.nunit.org/" target="_blank" rel="nofollow"><span style="text-decoration:underline;">NUnit</span></a> but there is no good integration with the IDE, the ones I found were quite awful.</p>
<p>Next, being able to test your code effectively relies a lot on the way you write your code and whether you follow concepts like Inversion of Control and Cohesiveness. The closer you follow the best practices the easier it becomes to test your code and really makes a difference in whether you can create specific unit tests that test a very limited scope of functionality as they should.</p>
<p>Managing dependencies between objects is therefore very important and while you can do it yourself there are frameworks dedicated to achieving just this. I’ve been following <strong>MEF</strong>(Managed Extensibility Framework) for a few years now, well before it became part of the official .NET framework and I find it very simple yet powerful to use.</p>
<p><span style="color:#993300;">Small note</span>: The MEF version I’m using for the samples in this article is the one that shipped with .NET 4 and not any of the newer previews available on the <a href="http://mef.codeplex.com/" target="_blank" rel="nofollow"><span style="text-decoration:underline;">codeplex site</span></a>.</p>
<p>I’m not going to go into how MEF works or how to use it in any detail, you can read more about that <a href="http://msdn.microsoft.com/en-us/library/dd460648.aspx" target="_blank" rel="nofollow"><span style="text-decoration:underline;">here</span></a>. The following piece of code shows how an object makes itself available as an export (the Export attribute):</p>
<pre style="color:#000020;background:#f6f8ff;margin-bottom:10px;"><span style="color:#308080;">[</span>Export<span style="color:#308080;">(</span><span style="color:#800000;">"</span><span style="color:#1060b6;">spaceConcatenator</span><span style="color:#800000;">"</span><span style="color:#308080;">,</span> <span style="color:#200080;font-weight:bold;">typeof</span><span style="color:#308080;">(</span>IWordConcatenator<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">]</span>
    <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">class</span> SpaceWordConcatenator <span style="color:#308080;">:</span> IWordConcatenator
    <span style="color:#406080;">{</span>
        <span style="color:#308080;">.</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span>
    <span style="color:#406080;">}</span></pre>
<p>The following code shows how that object can be imported (the Import attribute):</p>
<pre style="color:#000020;background:#f6f8ff;margin-bottom:10px;"><span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">class</span> HelloWorldSentenceService <span style="color:#308080;">:</span> ISampleSentenceService
<span style="color:#406080;">{</span>
    <span style="color:#308080;">[</span>Import<span style="color:#308080;">(</span><span style="color:#800000;">"</span><span style="color:#1060b6;">spaceConcatenator</span><span style="color:#800000;">"</span><span style="color:#308080;">)</span><span style="color:#308080;">]</span>
    <span style="color:#200080;font-weight:bold;">private</span> IWordConcatenator wordConcatenator<span style="color:#406080;">;</span>

    <span style="color:#308080;">.</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span>
<span style="color:#406080;">}</span></pre>
<p>While I was looking for examples on how to use MEF in a real application many of them show the composition taking place inside the application’s objects. Many examples show constructors that either define the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.composition.hosting.compositioncontainer.aspx" target="_blank" rel="nofollow"><span style="text-decoration:underline;">CompositionContainer</span></a> and/or accept it as a parameter. To me this looks wrong. I don’t want my plain objects to be aware of MEF any more than they should and I don’t want composition logic in my objects. I want these separate so there is less dependency on MEF and if needed, that I could replace MEF with another framework without having to gut half of my code.</p>
<p>Because of this requirement I came up with the structure where for my test projects the composition is done by using a test base class all tests inherit from and for my web application the composition happens in the WCF pipeline (<a title="Unit Testing, WCF and MEF - Part 2" href="http://yoavniran.wordpress.com/2012/10/18/unit-testing-wcf-and-mef-part-2"><span style="text-decoration:underline;color:#888888;">second part</span></a>).</p>
<p>I wanted a way to create tests without having to keep writing wire up code. For that purpose, i wrote a test base class that will take care of everything. I also wanted a simple way to pass to it the assemblies needed for the composition. So i chose to create a small configuration section that allowed me to configure the assembly names:</p>
<pre style="color:#000020;background:#f6f8ff;margin-bottom:10px;"><span style="color:#004a43;">&lt;?</span><span style="color:#200080;font-weight:bold;">xml</span><span style="color:#004a43;"> </span><span style="color:#074726;">version</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#7d0045;">1.0</span><span style="color:#1060b6;">"</span><span style="color:#004a43;"> </span><span style="color:#074726;">encoding</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">utf-8</span><span style="color:#1060b6;">"</span><span style="color:#004a43;"> </span><span style="color:#004a43;">?&gt;</span>
<span style="color:#0057a6;">&lt;</span><span style="color:#333385;">configuration</span><span style="color:#0057a6;">&gt;</span>
    <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">configSections</span><span style="color:#0057a6;">&gt;</span>
        <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">section</span> <span style="color:#474796;">name</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">testConfiguration</span><span style="color:#1060b6;">"</span> 
        <span style="color:#474796;">type</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">SampleApplication.Test.Base.Configuration.TestConfigurationSection, SampleApplication.Test.Base</span><span style="color:#1060b6;">"</span><span style="color:#0057a6;">/&gt;</span>
    <span style="color:#0057a6;">&lt;/</span><span style="color:#333385;">configSections</span><span style="color:#0057a6;">&gt;</span>

    <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">testConfiguration</span><span style="color:#0057a6;">&gt;</span>
        <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">Assemblies</span><span style="color:#0057a6;">&gt;</span>
            <span style="color:#0057a6;">&lt;</span><span style="color:#333385;">add</span> <span style="color:#474796;">name</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">sampleapplication</span><span style="color:#1060b6;">"</span> <span style="color:#474796;">value</span><span style="color:#308080;">=</span><span style="color:#1060b6;">"</span><span style="color:#1060b6;">SampleApplication</span><span style="color:#1060b6;">"</span><span style="color:#0057a6;">/&gt;</span>
        <span style="color:#0057a6;">&lt;/</span><span style="color:#333385;">Assemblies</span><span style="color:#0057a6;">&gt;</span>        
    <span style="color:#0057a6;">&lt;/</span><span style="color:#333385;">testConfiguration</span><span style="color:#0057a6;">&gt;</span>
<span style="color:#0057a6;">&lt;/</span><span style="color:#333385;">configuration</span><span style="color:#0057a6;">&gt;</span></pre>
<p>I’ve divided my tests into two main types: those that test functionality <span style="text-decoration:underline;">without mocking</span> and those that test functionality <span style="text-decoration:underline;">while mocking</span> out the dependencies.</p>
<h3 style="margin-top:16px;">No Mocks</h3>
<p>The tests that don’t need any mocking can inherit from my <em>AutoTestBase</em> abstract class. This class calls the <em>AutoWire</em> function of the <em>TestBase</em> class in its constructor without any parameters. The <em>AutoWrite</em> function looks at the XML configuration and passes the assemblies to the <em>CompositionContainer</em>.</p>
<p>So when my test methods are called any import should already be fulfilled and the tests can be carried out.</p>
<p>Here’s an example of a test class like that:</p>
<pre style="color:#000020;background:#f6f8ff;margin-bottom:10px;"><span style="color:#308080;">[</span>TestClass<span style="color:#308080;">]</span>
<span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">class</span> WordProviderTest <span style="color:#308080;">:</span> AutoTestBase
<span style="color:#406080;">{</span>
    <span style="color:#308080;">[</span>Import<span style="color:#308080;">]</span>
    <span style="color:#200080;font-weight:bold;">private</span> IWordProvider wordProvider<span style="color:#406080;">;</span>

    <span style="color:#308080;">[</span>TestMethod<span style="color:#308080;">]</span>
    <span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">void</span> TestGetWordsSuccess<span style="color:#308080;">(</span><span style="color:#308080;">)</span>
    <span style="color:#406080;">{</span>
        IEnumerable<span style="color:#308080;">&lt;</span><span style="color:#200080;font-weight:bold;">string</span><span style="color:#308080;">&gt;</span> words <span style="color:#308080;">=</span> wordProvider<span style="color:#308080;">.</span>GetWords<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>

        Assert<span style="color:#308080;">.</span>IsNotNull<span style="color:#308080;">(</span>words<span style="color:#308080;">)</span><span style="color:#406080;">;</span>
        Assert<span style="color:#308080;">.</span>AreEqual<span style="color:#308080;">(</span><span style="color:#008c00;">2</span><span style="color:#308080;">,</span> words<span style="color:#308080;">.</span>Count<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
        Assert<span style="color:#308080;">.</span>AreEqual<span style="color:#308080;">(</span><span style="color:#800000;">"</span><span style="color:#1060b6;">Hello</span><span style="color:#800000;">"</span><span style="color:#308080;">,</span> words<span style="color:#308080;">.</span>First<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
    <span style="color:#406080;">}</span>
<span style="color:#406080;">}</span></pre>
<p><strong>Notice that there isn&#8217;t even a single line of wire up code in this class which is what my goal was</strong>.</p>
<h3 style="margin-top:16px;">Yes Mocks</h3>
<p>My mocking tool of choice is <a href="http://code.google.com/p/moq/" target="_blank" rel="nofollow"><span style="text-decoration:underline;">Moq</span></a>. It’s a great library with excellent support for Linq and Lambda expressions.</p>
<p>For tests that do require mocking, there is a bit more work to do but not much.</p>
<p>This part of the solution took me probably the most time to figure out and I couldn’t have done it without the code sample I found here: <a href="http://pastie.org/467842" rel="nofollow">http://pastie.org/467842</a>. I adapted it a bit but basically what it allowed me to do was to create an <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.composition.hosting.exportprovider.aspx" target="_blank" rel="nofollow"><span style="text-decoration:underline;">ExportProvider</span></a> which is filled with the mocked objects. This provider is passed into the container first so the mocks will be the ones used to satisfy the imports and not the real implementations.</p>
<p>Here’s an example test that is in charge of testing my <em>HelloWorldSentenceService</em>, here I&#8217;m not interested in testing its dependencies so I mock them and pass the mocks to my <em>MockExportProvider</em> in the constructor, I then call <em>base.TestSetUp(provider)</em> to initiate the composition:</p>
<pre style="color:#000020;background:#f6f8ff;margin-bottom:10px;"><span style="color:#200080;font-weight:bold;">public</span> <span style="color:#200080;font-weight:bold;">class</span> HelloWorldSentenceServiceUnitTest <span style="color:#308080;">:</span> MockTestBase 
<span style="color:#406080;">{</span>
    <span style="color:#308080;">[</span>Import<span style="color:#308080;">]</span>
    <span style="color:#200080;font-weight:bold;">private</span> ISampleSentenceService service<span style="color:#406080;">;</span>

    <span style="color:#200080;font-weight:bold;">private</span> Mock<span style="color:#308080;">&lt;</span>IWordProvider<span style="color:#308080;">&gt;</span> wordProvider<span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> Mock<span style="color:#308080;">&lt;</span>IWordProvider<span style="color:#308080;">&gt;</span><span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
    <span style="color:#200080;font-weight:bold;">private</span> Mock<span style="color:#308080;">&lt;</span>IWordConcatenator<span style="color:#308080;">&gt;</span> wordConcatenator <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> Mock<span style="color:#308080;">&lt;</span>IWordConcatenator<span style="color:#308080;">&gt;</span><span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>

    <span style="color:#200080;font-weight:bold;">public</span> HelloWorldSentenceServiceUnitTest<span style="color:#308080;">(</span><span style="color:#308080;">)</span>
    <span style="color:#406080;">{</span>
        var provider <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> MockExportProvider
        <span style="color:#308080;">(</span>
            GetExport<span style="color:#308080;">&lt;</span>IWordProvider<span style="color:#308080;">&gt;</span><span style="color:#308080;">(</span>wordProvider<span style="color:#308080;">)</span><span style="color:#308080;">,</span>
            GetExport<span style="color:#308080;">&lt;</span>IWordConcatenator<span style="color:#308080;">&gt;</span><span style="color:#308080;">(</span>wordConcatenator<span style="color:#308080;">,</span> <span style="color:#800000;">"</span><span style="color:#1060b6;">spaceConcatenator</span><span style="color:#800000;">"</span><span style="color:#308080;">)</span>
        <span style="color:#308080;">)</span><span style="color:#406080;">;</span>

        <span style="color:#200080;font-weight:bold;">base</span><span style="color:#308080;">.</span>TestSetUp<span style="color:#308080;">(</span>provider<span style="color:#308080;">)</span><span style="color:#406080;">;</span>
    <span style="color:#406080;">}</span>

    <span style="color:#308080;">.</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span></pre>
<h3 style="margin-top:16px;">How it Works</h3>
<p>The code in the <em>TestBase</em> class is pretty straightforward and below is the main <em>AutoWire</em> function that ties everything together:</p>
<pre style="color:#000020;background:#f6f8ff;margin-bottom:20px;"><span style="color:#200080;font-weight:bold;">protected</span> <span style="color:#200080;font-weight:bold;">void</span> AutoWire<span style="color:#308080;">(</span>MockExportProvider mocksProvider<span style="color:#308080;">,</span> <span style="color:#200080;font-weight:bold;">params</span> Assembly<span style="color:#308080;">[</span><span style="color:#308080;">]</span> assemblies<span style="color:#308080;">)</span>
<span style="color:#406080;">{</span>            
    CompositionContainer container <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">null</span><span style="color:#406080;">;</span>

    var assCatalogs <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> List<span style="color:#308080;">&lt;</span>AssemblyCatalog<span style="color:#308080;">&gt;</span><span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>

    <span style="color:#200080;font-weight:bold;">foreach</span><span style="color:#308080;">(</span>var a <span style="color:#200080;font-weight:bold;">in</span> assemblies<span style="color:#308080;">)</span>
    <span style="color:#406080;">{</span>
        assCatalogs<span style="color:#308080;">.</span>Add<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">new</span> AssemblyCatalog<span style="color:#308080;">(</span>a<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
    <span style="color:#406080;">}</span>

    <span style="color:#200080;font-weight:bold;">if</span> <span style="color:#308080;">(</span>mocksProvider <span style="color:#308080;">!</span><span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">null</span><span style="color:#308080;">)</span>
    <span style="color:#406080;">{</span>
        var providers <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> List<span style="color:#308080;">&lt;</span>ExportProvider<span style="color:#308080;">&gt;</span><span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>

        providers<span style="color:#308080;">.</span>Add<span style="color:#308080;">(</span>mocksProvider<span style="color:#308080;">)</span><span style="color:#406080;">;</span> <span style="color:#595979;">//need to use the mocks provider before the assembly ones            </span>

        <span style="color:#200080;font-weight:bold;">foreach</span> <span style="color:#308080;">(</span>var ac <span style="color:#200080;font-weight:bold;">in</span> assCatalogs<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>
            var assemblyProvider <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> CatalogExportProvider<span style="color:#308080;">(</span>ac<span style="color:#308080;">)</span><span style="color:#406080;">;</span>                    
            providers<span style="color:#308080;">.</span>Add<span style="color:#308080;">(</span>assemblyProvider<span style="color:#308080;">)</span><span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span>

        container <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> CompositionContainer<span style="color:#308080;">(</span>providers<span style="color:#308080;">.</span>ToArray<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>

        <span style="color:#200080;font-weight:bold;">foreach</span> <span style="color:#308080;">(</span>var p <span style="color:#200080;font-weight:bold;">in</span> providers<span style="color:#308080;">)</span> <span style="color:#595979;">//must set the source provider for CatalogExportProvider back to the container (kinda stupid but apparently no way around this)</span>
        <span style="color:#406080;">{</span>
            <span style="color:#200080;font-weight:bold;">if</span> <span style="color:#308080;">(</span>p <span style="color:#200080;font-weight:bold;">is</span> CatalogExportProvider<span style="color:#308080;">)</span>
            <span style="color:#406080;">{</span>
                <span style="color:#308080;">(</span><span style="color:#308080;">(</span>CatalogExportProvider<span style="color:#308080;">)</span>p<span style="color:#308080;">)</span><span style="color:#308080;">.</span>SourceProvider <span style="color:#308080;">=</span> container<span style="color:#406080;">;</span>
            <span style="color:#406080;">}</span>
        <span style="color:#406080;">}</span>
    <span style="color:#406080;">}</span>
    <span style="color:#200080;font-weight:bold;">else</span>
    <span style="color:#406080;">{</span>
        container <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> CompositionContainer<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">new</span> AggregateCatalog<span style="color:#308080;">(</span>assCatalogs<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
    <span style="color:#406080;">}</span>

    container<span style="color:#308080;">.</span>ComposeParts<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">this</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>        
<span style="color:#406080;">}</span></pre>
<p>What it does is to collect the assemblies passed to it in an <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.composition.hosting.aggregatecatalog.aspx" target="_blank" rel="nofollow">AggregateCatalog </a>and pass it into the composition container. If a <em>MockExportProvider</em> is passed, it will be pushed into the container first so the mocks will be used to match any relevant import. Once the container is set I call <em>ComposeParts</em> on the test class so any of its dependencies and their own dependencies are fulfilled by MEF.</p>
<p>Thats it for now. In the <a title="Unit Testing, WCF and MEF - Part 2" href="http://yoavniran.wordpress.com/2012/10/18/unit-testing-wcf-and-mef-part-2"><span style="color:#ff0000;">second part</span></a> of this article I discuss how to set up a WCF service using MEF.</p>
<h2 id="code">Code<span style="text-decoration:underline;"></span></h2>
<p>Ive uploaded the code sample to BitBucket here: <a href="https://bitbucket.org/yoavniran/wcf-mef-and-testing-sample-code/src" target="_blank">https://bitbucket.org/yoavniran/wcf-mef-and-testing-sample-code</a></p>
<div style="margin:30px 0;"></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yoavniran.wordpress.com/785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yoavniran.wordpress.com/785/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=785&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yoavniran.wordpress.com/2012/10/18/unit-testing-wcf-and-mef/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/07022aa961aa6ee7facc9939f783a797?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yoavniran</media:title>
		</media:content>

		<media:content url="http://yoavniran.files.wordpress.com/2012/10/sampleproject1.png" medium="image">
			<media:title type="html">sample project</media:title>
		</media:content>
	</item>
		<item>
		<title>Dawn to Dusk 2012 &#8211; Fundraising for the Children</title>
		<link>http://yoavniran.wordpress.com/2012/04/24/dawn-to-dusk-2012-fundraising-for-the-children/</link>
		<comments>http://yoavniran.wordpress.com/2012/04/24/dawn-to-dusk-2012-fundraising-for-the-children/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 14:52:26 +0000</pubDate>
		<dc:creator>Yoav Niran</dc:creator>
				<category><![CDATA[LivePerson]]></category>
		<category><![CDATA[children]]></category>
		<category><![CDATA[donation]]></category>
		<category><![CDATA[fundraising]]></category>
		<category><![CDATA[giving]]></category>
		<category><![CDATA[hospice]]></category>
		<category><![CDATA[liveperson]]></category>

		<guid isPermaLink="false">http://yoavniran.wordpress.com/?p=765</guid>
		<description><![CDATA[This year LivePerson (the company I work for) is doing a fund-raising trek in Snowdonia (yes its really called that way) in order to raise funds for Naomi House &#38; Jacks Place which is a phenomenal hospice dedicated to help children and young adults in need. These kids are usually faced with conditions and illnesses [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=765&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This year <a title="LivePerson.com" href="http://www.liveperson.com/" target="_blank">LivePerson</a> (the company I work for) is doing a fund-raising trek in <a title="Snowdonia - Wikipedia" href="http://en.wikipedia.org/wiki/Snowdonia" target="_blank">Snowdonia </a>(yes its really called that way) in order to raise funds for <a title="Naomi House" href="http://www.naomihouse.org.uk/" target="_blank">Naomi House &amp; Jacks Place</a> which is a phenomenal hospice dedicated to help children and young adults in need. These kids are usually faced with conditions and illnesses that mean they are likely not going to make it to adulthood.</p>
<p>LivePerson UK is heavily involved with Naomi House and has been working with the hospice for several years to raise money and volunteer to help make it a better place.</p>
<p><a href="http://www.naomihouse.org.uk/"><img class="aligncenter" title="Naomi House" src="http://www.naomihouse.org.uk/images/logo.png" alt="Naomi House" width="291" height="80" /></a></p>
<p><span id="more-765"></span></p>
<p>Just a few weeks ago I had the opportunity to visit Jacks Place which is an extension of Naomi House dedicated to young adults who come to stay there with their families to get some relief, assistance and comfort. Before arriving I had a picture in my mind of a rundown shack, a place perhaps out of Oliver Twist&#8217;s story but I was greatly mistaken. Jacks Place is a modern and fully equipped hospice with vast grounds and gardens. Beautiful and spacious rooms for the teens who come to stay there.</p>
<p><a href="https://yoavniran.files.wordpress.com/2012/04/20120330_160831.jpg"><img class="aligncenter size-full wp-image-777" title="Naomi House &amp; JacksPlace Gardens" src="https://yoavniran.files.wordpress.com/2012/04/20120330_160831.jpg?w=595" alt="Naomi House &amp; JacksPlace Gardens"   /></a></p>
<p>It was really inspiring and moving to have had the chance to spend a few hours and help with the gardening of Jacks Place. An activity I plan on doing again soon.</p>
<p><a href="https://yoavniran.files.wordpress.com/2012/04/20120330_160929.jpg"><img class="aligncenter size-full wp-image-781" title="Naomi House &amp; Jacks Place Gardens 2" src="https://yoavniran.files.wordpress.com/2012/04/20120330_160929.jpg?w=595" alt="Naomi House &amp; Jacks Place Gardens 2"   /></a></p>
<p>In the meantime, This June LivePerson is having its 4th <strong>Dawn to Dusk</strong> challenge where we will walk in the mountains of North Wales in order to raise funds for this amazing and important place.</p>
<h2>Please help reach our goal of <span style="color:#3366ff;"><strong><em>£8,000.00</em></strong></span> by going to this page: <a title="http://www.justgiving.com/livepersondawntodusk2012" href="http://www.google.co.uk/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;ved=0CHAQFjAA&amp;url=http%3A%2F%2Fwww.justgiving.com%2Flivepersondawntodusk2012&amp;ei=ysKXT4C9O82v8QOwspDnBQ&amp;usg=AFQjCNGXXrqdsUuUP6ABxUPy4AdkaY0MYQ&amp;sig2=H2hB4Ua__QUpH34waKfuYA" target="_blank">LivePerson Dawn to Dusk 2012</a> and giving whatever you can. Just so you know, every amount counts.</h2>
<p>For example:</p>
<ul>
<li><strong>£5</strong> could provide art materials for life-limited children and young people to create treasured memories during their short break at Naomi House</li>
<li><strong>£25</strong> could fund our music room for a day, so that children and young people, regardless of their ability, can enjoy the pleasure of creating and experiencing music</li>
<li><strong>£50</strong> could run our sensory room for a day, enabling children and young people from across our region to enjoy having their senses stimulated</li>
<li><strong>£100</strong> could fund one day in our end of life suite, where a child or young person can stay after they die and where their family can be close by until the funeral</li>
</ul>
<p>Thank you!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yoavniran.wordpress.com/765/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yoavniran.wordpress.com/765/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=765&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yoavniran.wordpress.com/2012/04/24/dawn-to-dusk-2012-fundraising-for-the-children/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/07022aa961aa6ee7facc9939f783a797?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yoavniran</media:title>
		</media:content>

		<media:content url="http://www.naomihouse.org.uk/images/logo.png" medium="image">
			<media:title type="html">Naomi House</media:title>
		</media:content>

		<media:content url="https://yoavniran.files.wordpress.com/2012/04/20120330_160831.jpg" medium="image">
			<media:title type="html">Naomi House &#38; JacksPlace Gardens</media:title>
		</media:content>

		<media:content url="https://yoavniran.files.wordpress.com/2012/04/20120330_160929.jpg" medium="image">
			<media:title type="html">Naomi House &#38; Jacks Place Gardens 2</media:title>
		</media:content>
	</item>
		<item>
		<title>ImportanTweet.com&#8217;s new release is out</title>
		<link>http://yoavniran.wordpress.com/2012/02/01/importantweet-coms-new-release-is-out/</link>
		<comments>http://yoavniran.wordpress.com/2012/02/01/importantweet-coms-new-release-is-out/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 19:09:04 +0000</pubDate>
		<dc:creator>Yoav Niran</dc:creator>
				<category><![CDATA[ImportanTweet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[features]]></category>
		<category><![CDATA[importantweet]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[timeline]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://yoavniran.wordpress.com/?p=751</guid>
		<description><![CDATA[Today I've released the second version of ImportanTweet.com.

The site was first released about a couple of weeks in a very limited, invite only mode and a few lucky participants have gotten to use it and I have received some excellent feedback that to the greater part I've managed to incorporate in this release. Others will be added later as well as more features and improvements I already have in mind.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=751&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:left;"><a href="http://www.importantweet.com"><img class="aligncenter" title="importantweet logo large" src="http://importantweet.com/images/logo-large.png" alt="logolarge" width="400" height="150" /></a>Today I&#8217;ve released the second version of <a title="ImportanTweet" href="http://www.importantweet.com" target="_blank">ImportanTweet.com</a>.</p>
<p style="text-align:left;">The site was <a title="ImportanTweet – Tweets that matter to you" href="http://yoavniran.wordpress.com/2012/01/15/importantweet-tweets-that-matter-to-you/">first released</a> about a couple of weeks ago in a very limited, invite only mode and a few lucky participants have gotten to use it and I have received some excellent feedback that to the greater part I&#8217;ve managed to incorporate in this release. Others will be added later as well as more features and improvements I already have in mind.</p>
<p style="text-align:left;">Let me start by saying that your feedback is  crucial for the site to succeed so please keep it coming in any form you can. I can be contacted here through comments, on Twitter at <a title="ImportanTweet on Twitter" href="http://twitter.com/important_t_com" rel="nofollow" target="_blank">@important_t_com</a> and by <a title="Contact ImportanTweet" href="mailto:contact@importantweet.com" target="_blank">email</a>.</p>
<p style="text-align:left;">This new release is packed with new features, improvements and some bug fixes. Below is a list of the major ones to notice:</p>
<p style="text-align:left;"><span id="more-751"></span></p>
<h2 style="text-align:left;"><strong>Chronological Mode</strong></h2>
<p style="text-align:left;">Now it is possible to switch from the Important Tweets mode to Chronological mode so you can see tweets on your home timeline just like on Twitter or in your preferred client (thanks <a title="@nunolinhares on Twitter" href="http://twitter.com/nunolinhares" rel="nofollow" target="_blank">@nunolinhares</a>). Simply click on the clock tab at the top of the column:</p>
<p style="text-align:center;"><a href="http://yoavniran.files.wordpress.com/2012/02/importantweet-v0-2-chrono-tweets.png"><img class="aligncenter size-full wp-image-756" title="importantweet v0.2 chrono tweets" src="http://yoavniran.files.wordpress.com/2012/02/importantweet-v0-2-chrono-tweets.png?w=595" alt="importantweet chrono tweets"   /></a></p>
<h2 style="text-align:left;"><strong>Auto Refresh</strong></h2>
<p style="text-align:left;">From now on the site will automatically refresh the stream every once in a while. This can be managed through the settings dialog which you see when you right-click on the refresh button in the top panel or by tapping and holding the button on touch devices (hold until the dialog is shown):</p>
<p style="text-align:center;"><a href="http://yoavniran.files.wordpress.com/2012/02/importantweet-v0-2-auto-ref-settings.png"><img class="aligncenter size-full wp-image-755" title="importantweet v0.2 auto ref settings" src="http://yoavniran.files.wordpress.com/2012/02/importantweet-v0-2-auto-ref-settings.png?w=595" alt="importantweet auto ref settings"   /></a></p>
<p style="text-align:left;">You can turn off the auto refresh completely or set the interval you prefer (between 30 and 999 seconds).</p>
<h2 style="text-align:left;"><strong>Signing Out</strong></h2>
<p style="text-align:left;">An important feature, especially if you&#8217;re on a public or shared computer, the Sign Out button will ensure that a re-login is necessary before being able to use the site on that device again:</p>
<p style="text-align:center;"><a href="http://yoavniran.files.wordpress.com/2012/02/importantweet-v0-2-signout.png"><img class="aligncenter size-full wp-image-758" title="importantweet v0.2 signout" src="http://yoavniran.files.wordpress.com/2012/02/importantweet-v0-2-signout.png?w=595" alt="importantweet signout"   /></a></p>
<h2 style="text-align:left;"><strong>Invite a Friend</strong></h2>
<p style="text-align:left;">Now that the site has been running for a little while with no major problems I believe its time more users should get to use and enjoy it, therefore the first users that are already invited will be able to invite a few friends themselves. Those friends will be able to invite more friends of their own. If you do have the option to invite people please do so for the site to get more recognition and continue to grow:</p>
<p style="text-align:left;"><a href="http://yoavniran.files.wordpress.com/2012/02/importantweet-v0-2-invitedialog.png"><img class="aligncenter size-full wp-image-762" title="importantweet v0.2 invitedialog" src="http://yoavniran.files.wordpress.com/2012/02/importantweet-v0-2-invitedialog.png?w=595" alt="importantweet invitedialog"   /></a></p>
<p style="text-align:left;">
<h2 style="text-align:left;"><strong>More&#8230;</strong></h2>
<p style="text-align:left;">The new release contains many more improvements such as performance tuning and additional logic for the relevancy engine so hopefully you should be seeing even better results.</p>
<p style="text-align:left;">In the meantime, if you&#8217;re an invited user go ahead and continue using the site and keep up the feedback communication. If you haven&#8217;t received an invite and would like one just let me know and i&#8217;ll send it.</p>
<p style="text-align:left;">You can keep up with the site on the Twitter account: <a title="ImportanTweet on Twitter" href="http://twitter.com/important_t_com" rel="nofollow" target="_blank">@important_t_com</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yoavniran.wordpress.com/751/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yoavniran.wordpress.com/751/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=751&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yoavniran.wordpress.com/2012/02/01/importantweet-coms-new-release-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/07022aa961aa6ee7facc9939f783a797?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yoavniran</media:title>
		</media:content>

		<media:content url="http://importantweet.com/images/logo-large.png" medium="image">
			<media:title type="html">importantweet logo large</media:title>
		</media:content>

		<media:content url="http://yoavniran.files.wordpress.com/2012/02/importantweet-v0-2-chrono-tweets.png" medium="image">
			<media:title type="html">importantweet v0.2 chrono tweets</media:title>
		</media:content>

		<media:content url="http://yoavniran.files.wordpress.com/2012/02/importantweet-v0-2-auto-ref-settings.png" medium="image">
			<media:title type="html">importantweet v0.2 auto ref settings</media:title>
		</media:content>

		<media:content url="http://yoavniran.files.wordpress.com/2012/02/importantweet-v0-2-signout.png" medium="image">
			<media:title type="html">importantweet v0.2 signout</media:title>
		</media:content>

		<media:content url="http://yoavniran.files.wordpress.com/2012/02/importantweet-v0-2-invitedialog.png" medium="image">
			<media:title type="html">importantweet v0.2 invitedialog</media:title>
		</media:content>
	</item>
		<item>
		<title>ImportanTweet &#8211; Tweets that matter to you</title>
		<link>http://yoavniran.wordpress.com/2012/01/15/importantweet-tweets-that-matter-to-you/</link>
		<comments>http://yoavniran.wordpress.com/2012/01/15/importantweet-tweets-that-matter-to-you/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 15:36:08 +0000</pubDate>
		<dc:creator>Yoav Niran</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[beta]]></category>
		<category><![CDATA[important]]></category>
		<category><![CDATA[importantweet]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://yoavniran.wordpress.com/?p=737</guid>
		<description><![CDATA[I am very happy to announce that today I'm officially making my project named ImportanTweet available on the web!

The idea behind ImportantTweet is to show the tweets that are important to you so if you follow a considerable number of accounts on Twitter and it becomes difficult to keep track and you feel like you miss on tweets you find interesting, IT is the tool for you.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=737&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:center;"><a href="http://www.importantweet.com"><img class="aligncenter" title="importantweet logo large" src="http://importantweet.com/images/logo-large.png" alt="logolarge" width="400" height="150" /></a></p>
<p>I am very happy to announce that today I&#8217;m officially making my project named <strong><a title="ImportanTweet" href="http://www.importantweet.com" target="_blank">ImportanTweet </a></strong>available on the web!</p>
<p>The idea behind <strong>ImportantTweet</strong> is to show the tweets that are important to you so if you follow a considerable number of accounts on Twitter and it becomes difficult to keep track and you feel like you miss on tweets you find interesting, <strong>IT</strong> is the tool for you.</p>
<p><span id="more-737"></span></p>
<p><strong>IT</strong> uses an engine that evaluates the latest tweets in your home stream and through its algorithm attempts to display tweets in the order it thinks will be most important to you rather than by chronological order, allowing you to quickly find the tweets the matter most to you.</p>
<p>If you&#8217;re like me, and follow over a hundred accounts on Twitter, it becomes very difficult to read every single tweet that passes through your stream. Even with your favorite Twitter client open at all times it&#8217;s not always possible, you may be in a meeting or on a plane or changing your daughter&#8217;s diaper and those important tweets will simply go by never to be seen again&#8230;</p>
<p>That is why I built <strong>ImportanTweet</strong>, so I don&#8217;t miss as much on Twitter as I have up until now. Of course <strong>IT</strong> is not perfect (yet) and it is going to be a learning experience both for me and the tool as I will be working on improving it.</p>
<h2></h2>
<h2>BETA</h2>
<p>Today I am releasing <strong>IT in beta</strong> (version 0.1) and in limited trial mode so it will not be open for everyone just yet. I will be sending invites to a few people to begin testing and collecting feedback and hopefully  soon will be able to improve and make it completely open for everybody.</p>
<h2></h2>
<h2>Browser Compatibility</h2>
<p>To make the tool as useful as possible I&#8217;ve made sure it works well on all major browsers: Firefox, Chrome, IE as well as on mobile devices such as iPhone, iPad (iOS 5) and Android (2.3). so you can use it on your prefered device at all times.</p>
<h2></h2>
<h2>Looks</h2>
<p>This is how the site looks like:</p>
<p><a href="http://yoavniran.files.wordpress.com/2012/01/importantweet-v0-1.png"><img class="aligncenter  wp-image-739" title="importantweet v0.1" src="http://yoavniran.files.wordpress.com/2012/01/importantweet-v0-1.png?w=767&#038;h=395" alt="importantweet" width="767" height="395" /></a></p>
<p>I&#8217;ve attempted to give it a clean and simple design so the focus remains on the tweets and nothing else.</p>
<h2></h2>
<h2>Teach IT</h2>
<p>The bar at the top of the page contains a few options, click or hover over it to show them. Click the <a href="http://yoavniran.files.wordpress.com/2012/01/info.png"><img class="wp-image-741 alignnone" title="IT info" src="http://yoavniran.files.wordpress.com/2012/01/info.png?w=36&#038;h=36" alt="info" width="36" height="36" /></a> button to show the information which contains explanations about these.</p>
<p>The most important option is the word-selection mode which lets you click on any word within the tweets and store it as an &#8220;Important Word&#8221; which will let the engine know that you are interested in future tweets that contain these words.</p>
<p>You can also click on the avatar photo  of each user displayed in the list of tweets to promote or demote that user, this will tell the engine to make tweets from this user more relevant or less.</p>
<h2></h2>
<h2>Getting Started</h2>
<p>So <strong>ImportanTweet</strong> is starting out today and will continue to evolve. There are plenty of things I plan on adding and improving so make sure to come back here for updates and check out <strong><a title="ImportanTweet" href="http://www.importantweet.com" target="_blank">ImportanTweet.com</a></strong> and let me know what you think. You can comment here or send me an email at <a href="mailto:contact@importantweet.com" target="_blank">contact@importantweet.com</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yoavniran.wordpress.com/737/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yoavniran.wordpress.com/737/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=737&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yoavniran.wordpress.com/2012/01/15/importantweet-tweets-that-matter-to-you/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/07022aa961aa6ee7facc9939f783a797?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yoavniran</media:title>
		</media:content>

		<media:content url="http://importantweet.com/images/logo-large.png" medium="image">
			<media:title type="html">importantweet logo large</media:title>
		</media:content>

		<media:content url="http://yoavniran.files.wordpress.com/2012/01/importantweet-v0-1.png" medium="image">
			<media:title type="html">importantweet v0.1</media:title>
		</media:content>

		<media:content url="http://yoavniran.files.wordpress.com/2012/01/info.png" medium="image">
			<media:title type="html">IT info</media:title>
		</media:content>
	</item>
		<item>
		<title>Why I Will Never Shop at Overstock.com Again</title>
		<link>http://yoavniran.wordpress.com/2012/01/13/why-i-will-never-shop-at-overstock-com-again/</link>
		<comments>http://yoavniran.wordpress.com/2012/01/13/why-i-will-never-shop-at-overstock-com-again/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 16:16:40 +0000</pubDate>
		<dc:creator>Yoav Niran</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[brand]]></category>
		<category><![CDATA[chat]]></category>
		<category><![CDATA[customer care]]></category>
		<category><![CDATA[liveperson]]></category>
		<category><![CDATA[overstock]]></category>

		<guid isPermaLink="false">http://yoavniran.wordpress.com/?p=728</guid>
		<description><![CDATA[Three weeks ago I wanted to buy a present for my beautiful wife for having carried our recently born baby girl, she did it magnificently for over 9 months and I thought that a small token would be the least I can do to show my appreciation for bringing an amazing present into our lives.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=728&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Three weeks ago I wanted to buy a present for my beautiful wife for having carried our recently born baby girl, she did it magnificently for over 9 months and I thought that a small token would be the least I can do to show my appreciation for bringing an amazing present into our lives.</p>
<p>I looked online and found a pair of very nice white-gold earrings that I had hoped she will like on <strong>Overstock.com</strong>,  a site I had heard good things about and thought is a <strong>reputable brand</strong> that I could trust. The fact that they had <strong>online chat</strong> on their site bolstered that feeling as I&#8217;m a <strong><a title="LivePerson.com" href="http://www.liveperson.com" target="_blank">LivePerson </a></strong>employee I can now recognize and appreciate the value of live chat on a retail site. Overstock is not a LivePerson customer by the way (perhaps that should have tipped me off).</p>
<p>I have ordered the earrings on<strong> December 23rd, 2011</strong> and of course I knew they will take some time to arrive, after all it was just before Christmas but that was fine with me, I had hoped they will arrive a few days after the new year.</p>
<p>After they did not arrive for a while I looked at the confirmation email I received and used the tracking link they provided, this took me to the DHL tracking site which very &#8220;usefully&#8221; told me it couldn&#8217;t find the details for the tracking number. I thought to myself, alright, I will try in a few more days, surely it will appear soon.</p>
<p><span id="more-728"></span></p>
<p>So I have waited some more and still nothing, so a few days ago I contacted Overstock through their online chat. They kindly told me to <strong>wait 7 days</strong> (!) longer before contacting them again if the earrings hadn&#8217;t arrived by then. So I&#8217;ve waited a few more days until yesterday when the DHL site still couldn&#8217;t find the tracking details. I had resolved to contact Overstock again today even though it wasn&#8217;t 7 days yet and demand some explanations. Luckily, this morning the package with the earrings <strong>arrived</strong>.</p>
<p><strong>Oh joy!</strong> I thought to myself, finally, the earrings arrived and even before its time for my daughter to attend college. Gladly I opened the package and was very (very) surprised to find that they have sent me the wrong earrings, the ones I ordered were suppose to have a clear stone, what they sent were (<strong>disgusting</strong>) lime green!</p>
<p>So, I patiently waited for the overstock.com reps to come online today so I can demand they <strong>replace</strong> the earrings at once and hopefully give me some kind of <strong>compensation</strong> after such a terrible shopping experience.</p>
<p>This afternoon I started the chat and after apologizing the representative told me that all he could do for me is send me instructions on how to send the earrings back and receive a refund, if I wanted to actually receive the earrings I wanted I would need to order them <strong>again</strong>. When I told the rep that I was surprised they don&#8217;t offer any kind  of compensation he told me that they simply can&#8217;t offer anything to an <strong>international</strong> customer. So they can take orders from international customers but not compensate them when the <strong>blunder horribly</strong>.</p>
<p>So to summarize:</p>
<ul>
<li>Ordered earrings 3 weeks ago</li>
<li>Paid a lot more for shipping costs because I&#8217;m an international customer</li>
<li>Waited for 3 weeks for earrings to arrive</li>
<li>While waiting had no proper information on when they will actually arrive (not sure whos fault that is, overstock or DHL)</li>
<li>Overstock when contacted couldn&#8217;t tell me more than wait for more days, 7 days!</li>
<li>When finally earrings arrived they were the wrong ones!</li>
<li>I need to ship them back and get a refund (that for some reason is 70 pence less than what I paid)</li>
<li>If I want the earrings I actually paid for I need to go through the whole process again</li>
</ul>
<p>In short, I will <strong>never shop</strong> at overstock.com again, not because they&#8217;ve made a mistake with the product they sent, although that&#8217;s already infuriating but these things happen. It&#8217;s because their customer care is <strong>seriously lacking</strong>. The reps I chatted with were friendly and sympathetic enough but hardly went out of their way to help and as an international customer I feel I&#8217;ve been completely <strong>neglected</strong> by their customer care that apparently doesn&#8217;t value me the same as an <strong>American</strong> customer.</p>
<p>Throughout the overstock site and even the chat they refer to me as &#8220;<strong>Valued Customer</strong>&#8221; but its one thing to say it and quite another to actually mean and behave like you mean it! As far as im concerned, they have done the bare minimum and nothing more, this is not a brand I would like to have any more dealings with.</p>
<p>Just for comparison, a couple of weeks ago I returned a jar of Pesto sauce to Sainsbury&#8217;s  (UK Supermarket) that costs around 2 pounds because it went bad too quickly, not only did I receive my money back, I also received a 5 pound voucher! More than 200% compensation on top of the refund&#8230;</p>
<p>Very interestingly I just received an email asking me to fill in a survey to help Overstock advance their &#8220;<strong>worldclass customer care</strong>&#8220;. I think they need to advance quite a lot before they can call their service that. Dont worry, I will let them know!</p>
<p>Below is the full transcript from my last chat with overstock:</p>
<p><span style="color:red;">Cody</span>: <span style="color:#ff0000;">Hi, my name is Cody. How may I help you?</span><span style="color:blue;"><span style="color:blue;"><span class="rn_UserTextPrefix"><br />
</span></span></span></p>
<p><span style="color:blue;"><span style="color:blue;"><span class="rn_UserTextPrefix">Valued Customer</span>: hi</span></span></p>
<div id="rn_ChatTranscript_6" class="rn_ChatTranscript"><span style="color:red;"><span style="color:red;"><span style="color:red;">Cody</span>: Hi there.</span></span></div>
<div class="rn_ChatTranscript"><span id="1329143104000" style="color:blue;"><span class="rn_UserTextPrefix"><br />
Valued Customer</span>: today i finally received the earrings ive ordered from you &#8211; order: ******** after 3 weeks!<br />
</span><span id="1329143125000" style="color:blue;"><br />
<span class="rn_UserTextPrefix"> Valued Customer</span>: i was quite surprised to find that what i received is not what ive ordered<br />
</span><span id="1329143172000" style="color:red;"><br />
<span style="color:red;"> Cody</span>: I&#8217;m sorry to hear that you have received wrong item. I apologize for the inconvenience caused.<br />
</span><span style="color:red;"><span style="color:red;"><br />
<span style="color:red;"> Cody</span>: For security purposes, could you please verify the full name and billing address, including the city, state and zip code?</span></span></div>
<div class="rn_ChatTranscript"><span style="color:blue;"><span style="color:blue;"><span class="rn_UserTextPrefix"><br />
Valued Customer</span>: sure</span></span></div>
<div class="rn_ChatTranscript"></div>
<div class="rn_ChatTranscript"><span style="color:blue;"><span style="color:blue;"><span class="rn_UserTextPrefix">Valued Customer</span>: its an int. order btw</span></span></div>
<div class="rn_ChatTranscript">
<p><span style="color:#0000ff;"><span class="rn_UserTextPrefix">Valued Customer</span>: yoav  niran</span></p>
<p><span style="color:blue;"><span style="color:blue;"><span class="rn_UserTextPrefix">Valued Customer</span>: ****************</span></span></p>
<p><span style="color:#0000ff;"><span class="rn_UserTextPrefix">Valued Customer</span>: uk</span></p>
<div class="rn_ChatTranscript"><span style="color:red;"><span style="color:red;"><span style="color:red;">Cody</span>: Okay, I&#8217;m a international representative.</span></span></div>
<p><span style="color:#0000ff;"><span class="rn_UserTextPrefix">Valued Customer</span>: great</span></p>
<p><span style="color:red;"><span style="color:red;"><span style="color:red;">Cody</span>: Since you have received a wrong item, I will help you with the return for a full refund and you will have to re-order the item to receive a correct item.</span></span><span style="color:#0000ff;"><span class="rn_UserTextPrefix">Valued Customer</span>: i have to say im very disappointed</span></p>
<p><span style="color:blue;"><span style="color:blue;"><span class="rn_UserTextPrefix">Valued Customer</span>: not only did i have to wait for this long to receive what i bought but now i have to do that all over again?</span></span><span style="color:#ff0000;">Cody: I completely understand your concern, please accept my apologies for the inconvenience.</span></p>
<p><span style="color:#0000ff;"><span class="rn_UserTextPrefix">Valued Customer</span>: how do you even send the wrong product, very unproffesional, i know its not your fault but it looks really bad</span></p>
<p><span style="color:#ff0000;">Cody:I will help you with the free return shipping label via email.</span></p>
<p><span id="1329143710000" style="color:red;"><span style="color:red;">Cody</span>: *to return the wrong item.<br />
</span><span style="color:red;"><span style="color:red;"><br />
<span style="color:red;"> Cody</span>:  Click here to view our International Return Policy</span></span><span style="color:#ff0000;">Cody: Shall I go ahead and setup the return on this item and provide you the return instructions through this chat?</span></p>
<p><span style="color:#0000ff;"><span class="rn_UserTextPrefix">Valued Customer</span>: yes please</span></p>
<p><span style="color:#0000ff;"><span class="rn_UserTextPrefix">Valued Customer</span>: im surprised you dont offer any kind of compensation after such a bad experience&#8230;</span></p>
<p><span style="color:#ff0000;">Cody: I understand that it is a very bad experience, but we do not have any option to issue compensation for the international orders.</span></p>
<p><span style="color:#ff0000;">Cody: What is the email address that you would like us to send the return instructions to?</span></p>
<p><span style="color:#0000ff;"><span class="rn_UserTextPrefix">Valued Customer</span>: *****@gmail.com</span></p>
<p><span style="color:#0000ff;"><span class="rn_UserTextPrefix">Valued Customer</span>: sorry, thats a very bad answer.</span></p>
<p><span style="color:red;"><span style="color:red;"><span style="color:red;">Cody</span>: I have setup the return on the wrong item that you received for refund.</span></span><span style="color:#ff0000;">Cody: We will email the return instructions to you at your email address ( ***@gmail.com ) used to register with us and you should receive it within 24 hours.</span></p>
<p><span style="color:#0000ff;"><span class="rn_UserTextPrefix">Valued Customer</span>: so ive ordered from you, paid a lot more for shipping, waited 3 weeks, didnt get the product ive  ordered and you cant offer me anything? does that sound like it make any sense?</span></p>
<p><span style="color:#ff0000;">Cody: I agree to what you said. However we will not be able to offer a discount on the international orders. I sincerely apologize for the inconvenience caused to you.</span></p>
<p><span style="color:#ff0000;">Cody: We will notify you via (****@gmail.com) email address with the details of your refund.</span></p>
<p><span style="color:#ff0000;">Cody: You will receive your refund via the form of payment that you used.</span></p>
<p><span style="color:#ff0000;">Cody: Are there any further questions for me?</span></p>
<p><span style="color:#0000ff;"><span class="rn_UserTextPrefix">Valued Customer</span>: ok.</span></p>
<p><span style="color:#0000ff;"><span class="rn_UserTextPrefix">Valued Customer</span>: no more questions.</span></p>
<p><span style="color:#0000ff;"><span class="rn_UserTextPrefix">Valued Customer</span>: i can tell you that you have lost me as a customer forever though</span></p>
<p><span style="color:#ff0000;">Cody: I&#8217;m sorry to hear that, but you are always welcome to Overstock.com.</span></p>
<p><span style="color:red;"><span style="color:red;"><span style="color:red;">Cody</span>: Thank you for contacting O.co, Overstock.com&#8217;s shortcut.</span></span></p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yoavniran.wordpress.com/728/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yoavniran.wordpress.com/728/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=728&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yoavniran.wordpress.com/2012/01/13/why-i-will-never-shop-at-overstock-com-again/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/07022aa961aa6ee7facc9939f783a797?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yoavniran</media:title>
		</media:content>
	</item>
		<item>
		<title>jQuery Fade In and Fade Out with one method</title>
		<link>http://yoavniran.wordpress.com/2011/11/18/jquery-fade-in-and-fade-out-with-one-method/</link>
		<comments>http://yoavniran.wordpress.com/2011/11/18/jquery-fade-in-and-fade-out-with-one-method/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 12:46:28 +0000</pubDate>
		<dc:creator>Yoav Niran</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[fade in]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://yoavniran.wordpress.com/?p=722</guid>
		<description><![CDATA[In many occurrences i found myself wanting to fade in an item and then immediately fade it out as a way to convey that something happened in a non-obtrusive way.
Easy as it is to do I still find it annoying that i have to call two separate methods for an action i wish to be done as one so naturally since it is so easy to extend jQuery I wrote a little extension that does just that.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=722&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In many occurrences i find myself wanting to fade in an element on the page and then immediately fade it out as a way to convey that something happened in a non-obtrusive way.</p>
<p>To do that I need to call the <a title="jQuery fadeIn Documentation " href="http://api.jquery.com/fadeIn/" target="_blank">fadeIn</a> and <a title="jQuery fadeOut Documentation" href="http://api.jquery.com/fadeOut" target="_blank">fadeOut</a> jQuery methods in sequence. This can be done easily because fadeIn accepts a callback as a second parameter which will be called when the animation completes.</p>
<p>Easy as it is to do I still find it annoying that i have to call two separate methods for an action i wish to be done as one so naturally since it is so easy to <a title="jQuery Plugins/Authoring" href="http://docs.jquery.com/Plugins/Authoring" target="_blank">extend jQuery</a> I wrote a little extension that does just that.</p>
<p><span id="more-722"></span></p>
<p>Here is the code:<br />
<!-- HTML generated using hilite.me --></p>
<div style="background:white;overflow:auto;width:auto;color:black;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;">
<pre style="line-height:125%;margin:0;">(<span style="color:#0000aa;">function</span> ($)
{
	<span style="color:#aaaaaa;font-style:italic;">/*</span>
<span style="color:#aaaaaa;font-style:italic;"> This is a shortcut method for jQuery that does a fade In and then a fadeOut on the selected element(s)</span>
<span style="color:#aaaaaa;font-style:italic;"> It accepts the length of the In animation, the length of the Out animation and a handler to be called when both animations completed </span>

<span style="color:#aaaaaa;font-style:italic;"> Yoav Niran (http://wordpress.yoavniran.com)</span>
<span style="color:#aaaaaa;font-style:italic;"> */</span>
	<span style="color:#0000aa;">var</span> defaultDur = <span style="color:#009999;">1000</span>;

	$.fn.fadeInOut = <span style="color:#0000aa;">function</span>(inTime, outTime, callback)
	{
		<span style="color:#0000aa;">var</span> setDefaults = <span style="color:#0000aa;">function</span>()
		{
			inTime = outTime = defaultDur;<span style="color:#aaaaaa;font-style:italic;">//set a default 1 second for animation</span>
		};

		<span style="color:#0000aa;">if</span> (arguments.length == <span style="color:#009999;">0</span>)
		{
			setDefaults();
		}
		<span style="color:#0000aa;">else</span> <span style="color:#0000aa;">if</span> (arguments.length == <span style="color:#009999;">1</span>)
		{
			<span style="color:#0000aa;">if</span> (<span style="color:#0000aa;">typeof</span>( arguments[<span style="color:#009999;">0</span>]) === <span style="color:#aa5500;">"number"</span>)
			{
				outTime = inTime;
			}
			<span style="color:#0000aa;">else</span>
			{
				callback = inTime;
				setDefaults();
			}
		}
		<span style="color:#0000aa;">else</span> <span style="color:#0000aa;">if</span> (arguments.length == <span style="color:#009999;">2</span>)
		{
			<span style="color:#0000aa;">if</span> (<span style="color:#0000aa;">typeof</span>( arguments[<span style="color:#009999;">1</span>]) !== <span style="color:#aa5500;">"number"</span>)
			{
				callback = outTime;
				outTime = inTime;
			}
		}

		<span style="color:#0000aa;">var</span> c = <span style="color:#0000aa;">this</span>;

		<span style="color:#0000aa;">this</span>.fadeIn(inTime, <span style="color:#0000aa;">function</span>()
			{
				c.fadeOut(outTime,
					<span style="color:#0000aa;">function</span>()
					{
						<span style="color:#0000aa;">if</span> (callback &amp;&amp; <span style="color:#0000aa;">typeof</span>(callback) === <span style="color:#aa5500;">"function"</span>)
						{
							callback.apply(c);
						}
					})
			});
	};
} (jQuery));</pre>
</div>
<p>To use it you just need to add this code somewhere on your page or (preferably) in a separate JS file as long as its after the inclusion of jQuery and before you intend to use it.</p>
<p>Once you&#8217;ve added this code using the function is the same as using any jQuery method.</p>
<p>The new method that will be added to jQuery is called: <span style="text-decoration:underline;"><strong><em>fadeInOut</em></strong></span> and it accepts 3 (optional) arguments: inTime, outTime and callback.</p>
<p>The <strong>inTime</strong> is the duration of the fadeIn animation.</p>
<p>The <strong>outTime</strong> is the duration of the fadeOut animation.</p>
<p>The <strong>callback</strong> is a function to be called when both animations complete.</p>
<p>A few examples of using the fadeInOut method:<br />
<!-- HTML generated using hilite.me --></p>
<div style="background:white;overflow:auto;width:auto;color:black;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;">
<pre style="line-height:125%;margin:0;">$(<span style="color:#aa5500;">"#myElement"</span>).fadeInOut(); <span style="color:#aaaaaa;font-style:italic;">//use 1 second default</span>

$(<span style="color:#aa5500;">"#myElement"</span>).fadeInOut(<span style="color:#009999;">500</span>); <span style="color:#aaaaaa;font-style:italic;">//use half a second for fade in and out</span>

$(<span style="color:#aa5500;">"#myElement"</span>).fadeInOut(<span style="color:#009999;">500</span>, <span style="color:#009999;">1500</span>); <span style="color:#aaaaaa;font-style:italic;">//use half a second for fade in and a second and a half for fade out</span>

$(<span style="color:#aa5500;">"#myElement"</span>).fadeInOut(<span style="color:#009999;">500</span>, <span style="color:#009999;">1500</span>, <span style="color:#0000aa;">function</span> () { alert(<span style="color:#aa5500;">"finished"</span>); }); <span style="color:#aaaaaa;font-style:italic;">//set in and out durations and a callback method</span></pre>
</div>
<p>There are 4 ways you can call the method:</p>
<p>1) No arguments &#8211; The fade in and out will both be called with a default duration of 1 second.</p>
<p>2) One argument &#8211; If its a number it will be used as the duration for both in and out animations, if its a function it will be used as the callback and the 1 second default will be applied.</p>
<p>3) Two arguments &#8211; If both are numbers they will be used for the duration of the in and out animation respectively. If the second is a function it will be used as the callback and the first number will be used as the duration for both animations.</p>
<p>4) Three arguments &#8211; first two arguments will be used for the animations in and out duration respectively. The 3rd argument will be used for the callback.</p>
<p>You can easily change the default duration time by changing the value passed to the &#8220;defaultDur&#8221; variable.</p>
<p>Hope you find it useful.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yoavniran.wordpress.com/722/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yoavniran.wordpress.com/722/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yoavniran.wordpress.com&#038;blog=8128966&#038;post=722&#038;subd=yoavniran&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yoavniran.wordpress.com/2011/11/18/jquery-fade-in-and-fade-out-with-one-method/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/07022aa961aa6ee7facc9939f783a797?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yoavniran</media:title>
		</media:content>
	</item>
	</channel>
</rss>
