<?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/"
	>

<channel>
	<title>caliberweb.com &#187; Uncategorized</title>
	<atom:link href="http://chris.caliberweb.com/topics/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://chris.caliberweb.com</link>
	<description></description>
	<lastBuildDate>Mon, 01 Jun 2009 22:35:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MEF, The DLR, IronRuby, and the Web</title>
		<link>http://chris.caliberweb.com/2009/06/01/mef-the-dlr-ironruby-and-the-web/</link>
		<comments>http://chris.caliberweb.com/2009/06/01/mef-the-dlr-ironruby-and-the-web/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 22:33:04 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://chris.caliberweb.com/?p=61</guid>
		<description><![CDATA[After seeing Glenn Block talk about MEF in phoenix last week, I began to write a demo for work.
We have a pretty big pain point in our flagship product at work and I think that MEF would be a great way to alleviate that pain. Specifically, I would love to be able to just simply [...]]]></description>
			<content:encoded><![CDATA[<p>After seeing <a href="http://codebetter.com/blogs/glenn.block" target="_blank">Glenn Block</a> talk about MEF in phoenix last week, I began to write a demo for work.</p>
<p>We have a pretty big pain point in our flagship product at work and I think that MEF would be a great way to alleviate that pain. Specifically, I would love to be able to just simply script that part of the application.</p>
<p>Enter Nicholas Blumhardt’s post about <a href="http://blogs.msdn.com/nblumhardt/archive/2008/12/09/hosting-ruby-parts-in-mef.aspx" target="_blank">hosting IronRuby parts in MEF</a>.</p>
<p>Nick has done quite a great job getting this to work. I had to update his code very little to use the latest version of MEF and the DLR.</p>
<p>Specifically, I had to add the “ExportTypeIdentity” metadata value to all ruby objects being exported.</p>
<pre style="border: 1px solid #cecece; padding: 5px; overflow: auto; background-color: #ffffff; min-height: 40px; width: 650px;">
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">  1: <span style="color: #0000ff">def</span> <span style="color: #0000ff">self</span>.export(cname, attrs={})</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">  2:</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">  3:   <span style="color: #0000ff">if</span> cname.is_a?(<a style="color: #ff0000" href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Module.html">Module</a>)</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">  4:     include cname</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">  5:   <span style="color: #0000ff">end</span></pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">  6:</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">  7:   attrs["<span style="color: #8b0000">ExportTypeIdentity</span>"]=contract_name(cname)</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">  8:</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">  9:   export_attr(cname, attrs) <span style="color: #0000ff">do</span></pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"> 10:     <span style="color: #0000ff">self</span></pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"> 11:   <span style="color: #0000ff">end</span></pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"> 12: <span style="color: #0000ff">end</span></pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"> 13:</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"> 14: <span style="color: #0000ff">def</span> <span style="color: #0000ff">self</span>.create_export_def(cname, attrs, accessor)</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"> 15:   metadata = System::Collections::Generic::Dictionary[System::<span style="color: #00008b">String</span>,System::<a style="color: #ff0000" href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Object.html">Object</a>].new</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"> 16:   attrs.each{|key, value| metadata.add key, value}</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"> 17:   RubyExportDefinition.new(contract_name(cname), metadata, accessor)</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"> 18: <span style="color: #0000ff">end</span></pre>
</pre>
<p>This works freaking great in my little test console app. But, it will not work for some reason in a web context. And as luck would have it, our flagship product is a web application. <img src='http://chris.caliberweb.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>This is the error I can’t seem to get around.</p>
<h4><em>1) The export &#8216;ClassLibrary1.IContract&#8217; is not assignable to type &#8216;ClassLibrary1.IContract&#8217;.</em></h4>
<p>Has anyone made this work?</p>
<p>Download a <a href="http://chris.caliberweb.com/wp-content/uploads/2009/06/consoleapplication1.zip">demo here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chris.caliberweb.com/2009/06/01/mef-the-dlr-ironruby-and-the-web/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
