<?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>Orbifold &#187; Silverlight</title>
	<atom:link href="http://visualizationtools.net/default/category/software/net/silverlight/feed/" rel="self" type="application/rss+xml" />
	<link>http://visualizationtools.net/default</link>
	<description>Think. Visualize. Understand.</description>
	<lastBuildDate>Wed, 18 Jan 2012 09:08:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Particle systems and Silverlight</title>
		<link>http://visualizationtools.net/default/silverlight-particle-systems/</link>
		<comments>http://visualizationtools.net/default/silverlight-particle-systems/#comments</comments>
		<pubDate>Sun, 26 Jun 2011 17:17:55 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[data-visualization]]></category>
		<category><![CDATA[Layout algorithms]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/default/?p=5515</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div class="image-wrap portfolio"><a href="/default/wp-content/uploads/2011/06/image5.png" rel="prettyPhoto" title="Sample particle system"><span class="zoom"></span>
<img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="/default/wp-content/uploads/2011/06/image_thumb5.png" border="0" alt="image" width="530" height="368" />
</a></div><p style="clear:both;">&nbsp;</p><p style="clear:left;">&nbsp;</p>
<p>Recently a customer requested a particle simulation with the intention to investigate correlations and the effect of multiple ‘attractors’. The real, underlying issue in this demand is the fact that certain situations and systems are governed by laws (differential equations) which cannot be solved exactly and require a dynamic system to search for critical coefficients. These coefficients result in (semi) stable configurations or highlight boundary conditions inside which things make sense.</p>
<p>The problem with these kind of systems is the scalability which has two aspects; <strong>the visualization</strong> which doesn’t scale well with the retained graphics pipeline of WPF/SL/WP7 on the one hand&nbsp; and the O(N*N) <strong>calculation of interactions between particles</strong>.</p>
<p>Regarding the visuals there is really a lot to consider:</p>
<ul>
<li>if you inherit from a baseclass like FrameworkElement or Control or even UserControl you carry around with each and every particle a whole lot of stuff; data binding, styling, event and other infrastructure. While all these things are really great in an LOB, one doesn’t usually need all this when dealing with (lots of) particles</li>
<li>typically the underlying surface needs to be a Canvas but this element also brings along many gears; the retained rendering system, the measure/layout mechanics, styling and more. Maybe the bonus you miss when bypassing the Canvas is the ability to easily integrate zoom and pan in an application.</li>
<li>how much user-interaction is required, are mouse-events necessary or is it a ‘let it run’ system? Here as well, you need to consider carefully the implications (especially related to the scalability of the app).</li>
</ul>
<p>With respect to the simulation or calculation part things are more straightforward but you also need to think about</p>
<ul>
<li>the possibility to use F# for the more mathematically oriented parts. The disadvantage is however the need to constraint your model to make sure things talk to C#, or you have to go the full nine yards in F# (talking to XAML is still a disaster in this case).</li>
<li>how to optimize the calculations and to make sure that inside loops you break early and branch as much as possible</li>
<li>dropping unnecessary properties of the particles and make the particle system as lightweight as possible</li>
</ul>
<p>Within the Silverlight/WP context my experience is that if you use the Canvas/UIElement combination you easily hit a wall around <strong>500 particles</strong> due to the way the rendering engine is functioning and the fact that the UIElement (or FrameworkElement) are too ‘heavy’. The inter-particle calculation will still run OK with 500 particles but the end-result is that it’s not a good solution altogether.</p>
<p>One can keep the Canvas as underlying surface and render particles as inherited Shape items but this doesn’t push the boundary much.</p>
<p>A step further is to replace the Canvas with a bitmap and use direct pixel printing. This is easily done with the <a href="http://writeablebitmapex.codeplex.com/" target="_blank">WriteableBitmapEx</a> project you can find on CodePlex. This boosts your rendering to <strong>5000 particles</strong> if you drop interactions. However, if you switch on inter-particle forces you hit a calculational wall around <strong>1500 particles</strong> which is still way better than the retained rendering solution but still somewhat underwhelming.</p>
<p>So, as a next step it would be great to use parallel processing for the algorithmic part but unfortunately there is no task parallel processing library (TPL) for Silverlight (though somewhat made an unofficial port). Another possibility would be to use MailboxProcessor of F# but it would entail threading issues and an altogether more difficult system.</p>
<p>Various samples and libraries are available for XNA and Windows Phone which allow one to create particle effects but</p>
<ul>
<li>the often use sprites or similar techniques to minimize the particle count. The results are usually very good but the aim in the context of games is usually to create a certain effect rather than to give a physically correct simulation.</li>
<li>they often do not exhibit inter-particle forces. If they do the particle count is low.</li>
<li>they focus on effects and not physics</li>
</ul>
<p>See also the Flint-sharp library which is a port of the Flash/Flex library.</p>
<p>The conclusion is that one can perform simulations and develop particle system in Silverlight if the need is not above, say, a thousand particles. Above this threshold things become more difficult and Silverlight as a medium becomes less suitable for this type of task. Obviously there are high-tech solutions on the basis of C++ and GPU instructions but this was outside my client’s scope (and my technical know-how as well).</p>
<div class="bluebox">
<a href="/downloads/stuff/SilverlightParticles.zip">Attached is simple and fun particle system on the basis of WriteableBitmapEx and lightweight particles.</a>
</div>
<p><strong>Note</strong>: on different level you need to note in the attached simulation sample that</p>
<ul>
<li>the average speed varies a lot while the amount of interacting particles stays the same</li>
<li>the <strong>ergodic phenomenon</strong> if easily shown; that the average velocity over the sample equals the average of one item in time</li>
<li>it&#8217;s quite difficult to create stable configurations; which mimics well how the real world is also constantly influenced by quantum fluctuations</li>
</ul>
<h2>References</h2>
<ul>
<li><a href="http://www.damonpayne.com/post/2011/02/07/Task-Parallel-Library-Ported-to-Silverlight-4.aspx" target="_blank">TPL library ported to Silverlight 4</a></li>
<li><a href="http://create.msdn.com/en-US/education/catalog/sample/particle" target="_blank">Particle system for games (XNA &amp; WP)</a></li>
<li><a href="http://code.google.com/p/flint-sharp/" target="_blank">Flint for C#</a></li>
<li><a href="http://writeablebitmapex.codeplex.com/" target="_blank">WriteableBitmapEx on CodePlex</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/silverlight-particle-systems/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Silverlight Integration Pack</title>
		<link>http://visualizationtools.net/default/silverlight-integration-pack/</link>
		<comments>http://visualizationtools.net/default/silverlight-integration-pack/#comments</comments>
		<pubDate>Mon, 16 May 2011 11:27:45 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Think]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[EntLib]]></category>
		<category><![CDATA[NuGet]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/folia/?p=59</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=7613baa3-01b0-419c-af66-48db19bac393"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="/Default/wp-content/uploads/2011/05/image1.png" width="528" height="90" /></a></p>
<p>Silverlight Integration Pack for Enterprise Library is a collection of guidance and reusable application blocks designed to assist Silverlight application developers with common LOB development challenges.</p>
<p>These blocks are designed to encapsulate recommended practices which facilitate consistency, ease of use, integration, and extensibility. The release also addresses the needs of those who would like to port their existing LOB applications, that already leverage Enterprise Library, to Silverlight.</p>
<p><a title="Silverlight Integration Pack download." href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=7613baa3-01b0-419c-af66-48db19bac393" target="_blank">Download Enterprise Library 5 for Silverlight</a></p>
<h2>What’s in the box:</h2>
<ul>
<li><b>Caching Application Block</b> with support for:
<ul>
<li>In-memory cache </li>
<li>Isolated storage cache </li>
<li>Expiration and scavenging policies </li>
<li>Notification of cache purging </li>
</ul>
</li>
<li><b>Validation Application Block</b> with support for:
<ul>
<li>Multi-level complex validation </li>
<li>Attribute-based specification of validation rules </li>
<li>Configuration-based specification of validation rules </li>
<li>Simple cross-field validation </li>
<li>Self-validation </li>
<li>Cross-tier validation (through WCF RIA Services integration) </li>
<li>Multiple rule-sets </li>
<li>Meta data type for updating entities with external classes in Silverlight </li>
<li>Rich set of built-in validators </li>
</ul>
</li>
<li><b>Logging Application Block</b>, including:
<ul>
<li>Notification trace listener </li>
<li>Isolated storage trace listener </li>
<li>Remote service trace listener with support of batch logging </li>
<li>Implementation of a WCF Remote logging service that integrates with the desktop version of the Logging Application Block </li>
<li>Logging filters </li>
<li>Tracing </li>
<li>Logging settings runtime change API </li>
</ul>
<p>     <b>Exception Handling Application Block</b>, including:
<ul>
<li>Simple configurable, policy-based mechanism for dealing with exceptions consistently </li>
<li>Wrap handler </li>
<li>Replace handler </li>
<li>Logging handler </li>
</ul>
<p>     <b></b></li>
<li>Unity Application Block – a dependency injection container </li>
<li>Dependency injection container independence (Unity ships with the Enterprise Library, but can be replaced with a different container) </li>
<li><b>Unity Interception</b> mechanism, with support for:
<ul>
<li>Virtual method interception </li>
<li>Interface interception </li>
</ul>
</li>
<li><b>Policy Injection Application Block</b>, including:
<ul>
<li>Validation handler </li>
<li>Exception Handling handler </li>
<li>Logging handler </li>
</ul>
</li>
<li>Flexible <b>configuration </b>options, including:
<ul>
<li>XAML-based configuration support </li>
<li>Asynchronous configuration loading </li>
<li>Interactive configuration console supporting profiles (desktop vs. Silverlight) </li>
<li>Translation tool for XAML config (needed to convert conventional XML configuration files):
<ul>
<li>Standalone command-line tool </li>
<li>Config console wizard </li>
<li>MS Build task </li>
</ul>
</li>
<li>Programmatic configuration support via a fluent interface </li>
</ul>
</li>
<li>StockTrader V2 <b>Reference Implementation</b> (RI) (via a <a href="http://go.microsoft.com/fwlink/?LinkId=217987">separate download</a>) </li>
</ul>
<p><a href="/default/wp-content/uploads/2011/05/image2.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="/default/wp-content/uploads/2011/05/image_thumb1.png" width="522" height="484" /></a></p>
<h2>How to get it</h2>
<p>Both Enterprise Library 5.0 and Enterprise Library 5.0 Silverlight Integration Pack are to be available as Windows Installer Packages (MSI) via <a href="http://msdn.microsoft.com/entlib">MSDN</a> or as <a href="http://www.nuget.org/">NuGet</a> packages. The configuration tool is also available as a Visual Studio extension package (VSIX) from the <a href="http://visualstudiogallery.msdn.microsoft.com/">Visual Studio Gallery</a>. Today, you can NuGet and Visual Studio Gallery as the primary distribution channel, with the MSDN downloads following.</p>
<h2>References</h2>
<ul>
<li><a href="http://blogs.msdn.com/b/agile/archive/2011/05/11/silverlight-integration-pack-for-microsoft-enterprise-library-5-0-released.aspx" target="_blank">Grigori Melnik’s blog</a> on MSDN blogs </li>
<li><a title="The Enterprise Library on MSDN" href="http://msdn.microsoft.com/library/cc467894.aspx" rel="nofollow" target="_blank">The Enterprise Library on MSDN</a> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/silverlight-integration-pack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twirl: like Live Pivot but better</title>
		<link>http://visualizationtools.net/default/twirl-like-live-pivot-but-better/</link>
		<comments>http://visualizationtools.net/default/twirl-like-live-pivot-but-better/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 13:06:01 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Diverse]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Diagramming]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/default/?p=4188</guid>
		<description><![CDATA[We re-invented Live Pivot and took away the limitations along the way.]]></description>
			<content:encoded><![CDATA[<p>A recurring issue in the projects we do is centered around the scalability of diagramming solutions. Typically I get questions like &#8220;<em>How many nodes can one display in this or this framework?</em>&#8221; and  &#8220;<em>Will the graph layout be still fluid and interactive if we add a thousand items?&#8221;</em> These questions are legitimate but not always straightforward to answer. There are several aspects in this context:</p>
<ul>
<li> The <strong>usability </strong>aspect: how meaningful is a diagram with thousands of nodes, does the user still get insights with potentially a million links between so many nodes? Here are I have to think about how useless the <a title="Architecture tools in VS2010 ultimate" href="http://blogs.msdn.com/b/somasegar/archive/2009/08/29/architecture-tools-in-vsts-2010.aspx" target="_blank">Visual Studio 2010 architecture visualizer</a> is if you try to display a big assembly. See the picture below which displays a small portion of the G2 architecture; 20.000 nodes and 90.000 links&#8230;useful? I don&#8217;t think so.</li>
<li>The<strong> .Net framework</strong> aspect: out of the box the .Net classes related to WPF and Silverlight (the UIElement and FrameworkElement, that is) are &#8216;heavy&#8217;. These base classes contain stuff related to templating, databinding, triggers, animation and whatnot. It means that even if you don&#8217;t need any of this you have to carry around in the memory of your application a large amount of material. If you scale a diagramming solution to thousands of item it shows. If one really wants to display very large amount of data in a diagram there is no other way but to find alternatives to the retained graphics pipeline of .Net and go back to the good old low-level mechanisms.</li>
<li><a href="/default/wp-content/uploads/architecturediagram.png"><img class="size-medium wp-image-4189 alignright" title="G2 architecture diagram" src="/default/wp-content/uploads/architecturediagram-300x228.png" alt="G2 architecture diagram" width="300" height="228" /></a>The <strong>granularity </strong>aspect: much like the usability aspect, is it meaningful to have a lot of animations and gimmicks when displaying large datasets?  I suppose if you wish to display large diagrams you are not interested in details and interactivity, or do you? Well, some customer do and want to have both a high-level overview and the ability to zoom down to a finer level of details. This is difficult to achieve with the current technology and average hardware. Being able to display a million nodes with databound entities and remain fluid is tough, the only solution being to switch in the zooming process from one algorithm to another. Much to say about this but it&#8217;s not the topic of this post.</li>
</ul>
<p>In the end there are three solutions to these problems:</p>
<ul>
<li><strong>Drop Silverlight/WPF</strong> as the technology in which you try to visualize something and move to C/C++ but in this way sacrificing a lot of magic  these frameworks offer. While sometimes a viable solution for the customer, usually not a solution I like to push too much for obvious reasons.</li>
<li><strong>Compromise between scalability and functionality</strong> by emphasizing the usability aspect; decision makers want clear diagrams and yet another cluttered interface is the last thing a company wants to pay for.</li>
<li>Come up with an <strong>ingenious or new way of visualizing data</strong>. Often the type of data and the business context dictates here what &#8216;ingenious&#8217; means, each type of data has its own peculiarities. So, finding a generic solution in this line is usually not easy.</li>
</ul>
<p>While I describe all this in the context of diagramming, the remarks are valid for any data visualization solution. In the end, what matters the most to a customer is having a solution whether it&#8217;s a diagram or a different type of visualization often doesn&#8217;t matter.</p>
<p><a title="Live Pivot" href="http://www.getpivot.com/" target="_blank">Live Pivot</a> falls into the last category and is a new data visualization approach which handles the issues mentioned above quite well even if the amount of data it handles is still moderate. No links or diagramming here but a way to traverse a multi-dimensional dataset by filtering out data through various widgets and pivot-like datagrams which are well-known from Microsoft Excel. The name &#8216;Live&#8217; Pivot is hence aptly chosen as it displays pivot charts dynamically in function of the user&#8217;s criteria. I highly advice you to take a look and play with it, it&#8217;s a <a title="The Live Pivot SDK" href="http://www.silverlight.net/learn/pivotviewer/" target="_blank">free Silverlight framework</a> and I&#8217;m sure we&#8217;ll see interesting applications of it in the near future.</p>
<p>Now, the reason of this post is that although I was enjoying Live Pivot in the beginning I got more and more frustrated by the limitations imposed as time passed by:</p>
<ul>
<li>The datapool on which the visualization is based is a variation of XML called <strong>CXML</strong>. Though Microsoft created various tools to support the creation of CXML it remains a bit an awkward format if you want to work with data coming from WCF or use the visualization with your legacy data entities. Even if possible theoretically to convert your entities in memory using the supplied assemblies, it remains a bit of show-stopper when developing for Pivot.</li>
<li>The visuals in Live Pivot are based on the <a title="SeaDragon technology" href="http://www.seadragon.com/" target="_blank"><strong>SeaDragon </strong></a>technology which even for small amounts of entities will force you to have huge amounts of server space because for every image you need, say, a hundred copies of it in various resolutions. This is related to the Morton layout algorithm used internally to refine images as the user zooms on different levels of the dataset under consideration.</li>
<li> <strong>Updating or serving collections from a database</strong> is possible but in practice no-one is doing this because it involves undocumented wizardry (see for example <a title="What do you mean?" href="http://www.getpivot.com/developer-info/hosting.aspx" target="_blank">the cryptic explanation on the Pivot site</a>). I&#8217;m sure things will become easier in the future though.</li>
<li> The whole design and development process of Pivot collections is off the main development route, <strong>the framework doesn&#8217;t integrate well into a traditional N-tier application</strong>. In a way, creating a Pivot collection is more like the design of a Photoshop template for a website: you do it once and then try to not change it in fear of the consequences it has on the rest of the site.</li>
<li>Live Pivot is freely available and well developed but if you wish to customize things for a customer&#8230;well, you can&#8217;t since <strong>the source is not yours</strong>.</li>
</ul>
<p>Summary: Live Pivot is hardly a solution for the typical customer I meet. This said, I started to develop my own version of a Pivot-ish solution which would enable one to:</p>
<ul>
<li> Use WCF as a backend to serve collections and to handle large amounts of data (not limited by the client&#8217;s memory). One of our customer talks about terrabytes of records, how would one handle this in Live Pivot?</li>
<li> Use standard POCO entities as data buckets. This goes hand in hand with the WCF requirement, of course.</li>
<li> Use any XAML in the UI instead of only pictures. Let&#8217;s imagine you want buttons, tooltips, &#8230;in the display rather than just Morton-related images?</li>
<li> Adapt the partitioning and visualization in function of customer needs.</li>
<li> Have an iterative filtering of data outside the memory boundary. That is, use the whole SQL database backend as a datapool rather than just the entities in memory.</li>
<li> Make use of all the fluid animation features of Silverlight</li>
<li> Possibly combine diagramming and Pivot-ish visualization together.</li>
<li> Run away from the horrible SeaDragon mechanics involving hundreds of little images</li>
<li> The possibility to transpose the solution to WPF and have shared code WPF/Silverlight solutions</li>
</ul>
<p>This Silverlight library is called &#8216;<strong>Twirl</strong>&#8216; and contains (as good as) all the features above. The things which still need to be worked on are the WCF integration and the dynamic querying of the backend.</p>
<p>While developing Twirl I discovered that a whole lot of features are really available out of the box in Silverlight (together with the SL toolkit, Expression Blend etc.) which made the development easy, in particular:</p>
<ul>
<li>The new fluid animation features of SL4 and Blend</li>
<li>The ability to databind lists to any path, not just ItemsControl and ListBox</li>
<li>The filtering and sorting of data through ICollectionView and  related classes</li>
<li>The MVVM pattern with good support in Blend</li>
<li>Easing functions, animations etc.</li>
</ul>
<p>The biggest challenge was really <strong>how to partition data in several columns</strong>? That is; how do you organize an arbitrary set of data on the basis of a certain datatype into a limited amount of partitions? Here I had to go deep into unknown territories like <strong>data mining, clustering algorithms (k-means in particular), text analysis</strong> and more. At some point I developed an F# clustering library but had difficulties to map the F# vector type into C# types&#8230;and gave the interop effort up (it was a good learning exercise though). After much research and a lot of trials and errors I just developed my own view on the problem and a home-made algorithm came out of this. Currently the partitioning is quite good but more datasets and types of data need to be used in order to refine the algorithm.</p>
<p>Below are some screenshots of Twirl in various situations.</p>
<p><a href="/default/wp-content/uploads/Twirl4.png"><img class="alignnone size-medium wp-image-4194" title="Twirl " src="/default/wp-content/uploads/Twirl4-300x170.png" alt="" width="300" height="170" /></a></p>
<p><a href="/default/wp-content/uploads/Twirl3.png"><img class="alignnone size-medium wp-image-4195" title="Twirl " src="/default/wp-content/uploads/Twirl3-300x169.png" alt="" width="300" height="169" /></a></p>
<p><a href="/default/wp-content/uploads/Twirl2.png"><img class="alignnone size-medium wp-image-4196" title="Twirl " src="/default/wp-content/uploads/Twirl2-300x171.png" alt="" width="300" height="171" /></a></p>
<p><a href="/default/wp-content/uploads/Twirl1.png"><img class="alignnone size-medium wp-image-4197" title="Twirl1" src="/default/wp-content/uploads/Twirl1-300x185.png" alt="" width="300" height="185" /></a></p>
<p>Twirl offers, much like Live Pivot but beyond it as well, the following opportunities:</p>
<ul>
<li>visualization of large datasets stored on SQL Server</li>
<li>exploration of local drives through the out-of-browser or COM capability of Silverlight</li>
<li>traversals of datasets which share a common set of properties</li>
<li>interactive shopping carts and filtering of items</li>
<li>cataloguing of ebooks or e-documents in general. Here we are looking into the integration with Windows indexing service and alike</li>
<li>customization of the partitioning and the display</li>
<li>integration with other visualization techniques (diagramming, charting and whatnot)</li>
</ul>
<p>This Twirl development was inspired by a bigger customer project which also embraces Microsoft StreamInsight and correlation research of very large datasets. While the development of Twirl was mainly in function of our customers I realize it might benefit a lot from the input from others. Whether this means I need to put the code on CodePlex, I don&#8217;t know yet. Anyway, if you have interest in Twirl or want to share your thoughts, <a title="Contact us" href="/Contact" target="_blank">contact us</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/twirl-like-live-pivot-but-better/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Graph database</title>
		<link>http://visualizationtools.net/default/graph-database/</link>
		<comments>http://visualizationtools.net/default/graph-database/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 20:13:43 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Data]]></category>
		<category><![CDATA[Diagramming]]></category>
		<category><![CDATA[Diverse]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[NoSQL]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/default/?p=4159</guid>
		<description><![CDATA[How to store graph-like data structures of arbitrary data types in a relational database with multi-user and multi-application scope?]]></description>
			<content:encoded><![CDATA[<p><a href="/default/wp-content/uploads/Nyala.jpg"><img class="size-medium wp-image-4161 alignright" title="Nyala prototype" src="/default/wp-content/uploads/Nyala-300x204.jpg" alt="Nyala prototype" width="300" height="204" /></a></p>
<p>The customer wants to see relationships between multiple data types, groups of data, drill down into it, have a geographical view, a temporal view and a conceptual view. And much more of course. That&#8217;s the moment you realize you spent ten years of your life creating all possible variations on the subject &#8216;diagramming&#8217; and now you actually need a &#8216;diagramming database&#8217;. A whole different beast, not the usual yada-yada, what does it entail?</p>
<p>The thing is, relational database systems are not very suitable to act as repositories for graph-like structures but at the same time they are unavoidable because the whole world runs on them. Sure, there is something like an OO database but it would be even less suitable for graphs. So, you choose for a RDBMS even if you have some back-thoughts. At least RDBM systems are well supported on every API level and you get tons of fun tools which on the long run could be useful. In the case of SQL Server you know things like reporting services, StreamInsight, OLAP and whatnot will show up at the end of the road.</p>
<p>How do you store a graph-like system whose nodes are of an arbitrary data type? Say, you wish to store relationships between telephone numbers, file locations, car types, chat messages and credit card numbers. It wouldn&#8217;t be very wise to create data tables for each data type since you know at some point the customer will come along and ask for mobile numbers, addresses, book titles and cooking recipes! Well, there are not that many solutions in this case; you can use binary serialization of some data blob and store it as varbinary or you can use string-like serialization (which includes XML). Obviously, binary stuff in your database is not a good thing if you wish it to be searchable and ultimately open to other integrations. There is, hence, no other choice but to go for XML structs which at least is a well-supported standard across the while industry.</p>
<p>What about the relational structure? Easy enough, you just store the ‘from’ and the ‘to’ (sink, source, target, drain, start, end, initial, final…) in a two-field table. Voila, you’ve got a graph-database on top of an RDBMS.</p>
<p>Well, not really.Obviously having the data in place is just the beginning; you need to calculate a spanning tree, Hamiltonian cycles, Eulerian paths, shortest distance…and more fun pseudo-math stuff. If you want to use the standard algorithms it means you will put a lot of pressure on the data exchange with your client (say, a WCF service). Argh, you realize the only way is to actually do as much as possible on the database side. Through T-SQL or use .Net assemblies inside the SQL process? Not an easy choice. You start to wonder if creating a server is not a better option. But this means…writing a query processor, heavy threading programming and more wizardry which goes far beyond one’s standard toolbox. So…let’s assume T-SQL can do it. Actually T-SQL is not too bad if you are a bit fluent with it you can go quite far into this direction.<br />
Status: a graph-database consists of two tables and a lot of smart stored procedures.</p>
<p>But hold on, the customer wants it also multi-user and multi-application. That is, the total data is not always ‘on’, only a subset of if in function of the application the current user is using. More branching, more subtleties in the stored procedures.<br />
The situation is actually comparable to having heaps of XML documents where each user and each application adds attributes to the standard XML to decorate it with the necessary application-options and security settings. On top of that lots of tuples describe relationships between these XML documents. Did I mentions the relationships are also user and application dependent?</p>
<p>Maybe I’m giving you the impression that it’s an hopeless complexity and an overly open system which tries to embrace too much flexibility. It’s not that bad. In fact, we have a working prototype which includes a full-fledged client application (both for Silverlight and for WPF). The feeling sticks with me, however, that as far as abstract beauty is concerned a true graph database server would be better. This exists in Java but not in .Net and even if it would, I wonder how well adjacent systems (like reporting and such) would integrate with it. So,  the current prototype is a balanced solution between various poles and constraints. In a next phase we’ll develop connectors to StreamInsight, file system, legacy event aggregators and more. The purpose being to be able to store and analyze graphs which cross the boundary of the local storage and also capture real-time events (through, for example, StreamInsight). Big fun and more challenging stuff is ahead.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/graph-database/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Commodities: Graphite bound to WCF RIA Services</title>
		<link>http://visualizationtools.net/default/graphite-commodities/</link>
		<comments>http://visualizationtools.net/default/graphite-commodities/#comments</comments>
		<pubDate>Mon, 17 May 2010 10:00:45 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Diverse]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/default/?p=4131</guid>
		<description><![CDATA[About new Graphite sample based on a WCF RIA Service backend.]]></description>
			<content:encoded><![CDATA[<p><a href="/graphite/demo/commodities"><img class="alignnone size-medium wp-image-4121" title="Commodities sample" src="/default/wp-content/uploads/commodities-300x198.png" alt="Commodities sample" width="300" height="198" /></a></p>
<p>A new <a href="/Graphite">Graphite </a>sample (just click on the picture to see it live) has been added which demonstrates:</p>
<ul>
<li>Databinding of data coming a WCF RIA Service</li>
<li>Expand/collapse of nodes from a given node with data from the RIA Service</li>
<li>Labels on connections with data coming from the WCF RIA Services</li>
<li>Customization of the nodes and databinding to the fetched WCF data</li>
<li>Zooming and inflation (relaxation) of the diagram through databinding</li>
<li>Custom controls inside the node to expand/collapse adjacent nodes</li>
<li>General UI and Silverlight techniques (diverse utility classes are provided to help access resources, walk the visual tree and more)</li>
<li>A custom container control to expand/collapse some info and a search panel</li>
<li>Drag-drop from a control onto the surface (uses the DragdropManager of Telerik)</li>
</ul>
<p>This was a hugely fun project to work on, the only minor detail was the deployment and I guess a lot depends on your provider and how easy it is for you to manage the settings of IIS. A few things I learned from this is:</p>
<ul>
<li>set the &#8216;copy to local&#8217; to true to pretty much every assembly in your solution, don&#8217;t expect the assemblies to be present on the host</li>
<li>set the security to anonymous on IIS and remove the &#8220;&lt;authentication mode=&#8221;Forms&#8221;&gt;&#8221; section from your web.config. Typically you&#8217;ll get a &#8220;The remote server returned an error: NotFound&#8221; message which doesn&#8217;t reflect the real issue. Also, trying to discover the underlying issues through Fiddler or Firebug will not reveal much.</li>
</ul>
<p>Note: the data (company names, prices&#8230;) in the sample is random and is not connected to any real-world commodity-service. This sample demonstrates features of <a href="/Graphite">Graphite </a>and is not meant to give any information on any real-world commodity.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/graphite-commodities/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Belgian Silverlight Competition winner</title>
		<link>http://visualizationtools.net/default/belgian-silverlight-competition-winner/</link>
		<comments>http://visualizationtools.net/default/belgian-silverlight-competition-winner/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 06:31:37 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://localhost:1000/default/?p=3051</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>Our innovative Silverlight <a href="http://orbifold.net/L2/demo">diagramming tool &#8216;L2&#8242; </a>has won  the second place in <a title="Silverlight competition" href="http://blogs.msdn.com/katriend/archive/2009/12/22/belux-silverlight-contest-winners.aspx" target="_blank">the Belgian Silverlight competition</a>. Thanks!</p>
<p>You should also check out our latest <a href="http://orbifold.net/mindmapping">mindmap implementation for  Silverlight 4.</a> Note that you won&#8217;t be able to see this application  unless you installed Visual Studio 2010 beta since the Silverlight 4  plugin is not publily available (yet).</p>
<p><a href="http://www.orbifold.net/L2/demo"><img title="L2 diagramming for Silverlight" src="http://www.orbifold.net/default/wp-content/uploads/L2-300x188.PNG" alt="L2 diagramming for Silverlight" width="300" height="188" /></a></p>
<p><a href="http://www.orbifold.net/mindmapping"><img title="Mindmapping for Silverlight 4" src="http://www.orbifold.net/default/wp-content/uploads/mm1-300x166.png" alt="Mindmapping for Silverlight 4" width="300" height="166" /></a></p>
<p>More innovation and Silverlight stuff coming up this year, stay  tuned. We&#8217;ll also release the revamped website soon, hence the rather  silent blog these days. You can, however, follow me on <a title="Twittering loud and clear" href="http://twitter.com/TheOrbifold" target="_blank">Twitter </a>these  days, it gives a more complete and colorful overview of what keeps me  busy.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/belgian-silverlight-competition-winner/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>L2, iSee, Silverlight Property Grid and S#</title>
		<link>http://visualizationtools.net/default/l2-isee-silverlight-property-grid-and-s/</link>
		<comments>http://visualizationtools.net/default/l2-isee-silverlight-property-grid-and-s/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 19:38:08 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Diagramming]]></category>
		<category><![CDATA[Property Grid]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.orbifold.net/default/?p=2438</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.orbifold.net/default/wp-content/uploads/L2FirstShot.PNG"><img class="alignleft size-large wp-image-2410" title="L2 Screenshot" src="http://www.orbifold.net/default/wp-content/uploads/L2FirstShot-1024x905.PNG" alt="L2 Screenshot" width="352" height="310" /></a></p>
<p><span style="color: #666699; font-size: 30pt;">L2 </span>G2 is our biggest product and has been used by companies to create &#8216;big&#8217; applications in diverse markets. Because it is based on Unity for dependency injection and because Microsoft waited quite a while to release a Silverlight analog, it took a while to create a Silverlight analog of G2. We baptised it &#8216;L2&#8242;. Of course we could have used alternative injection libraries (many have popped up this year in fact) but we wanted to stay as parallel as possible to G2 in order to enable our customers to move with ease between G2 and L2. So, it&#8217;s there and you can<a title="L2 demo" href="/L2/demo" target="_self"> test it online here</a>. It&#8217;s still in beta and we welcome any feedback. You can also download the code and the core library, see<a title="L2 product page" href="/L2" target="_self"> the L2 product page</a> for more.</p>
<p><span style="color: #666699; font-size: 30pt;">S#</span>scripting library. This little jewel allows you in effect to alter an application at runtime much like macro&#8217;s. In fact, you can compare it to VBA in office except that our S# library will work in any .Net context (<strong>including XNA, Silverlight, WPF and WinForms</strong>). I will talk about S# more later this week in another blog posting and Denis Vuyka will also publish soon more information regarding S# and, another kid on the stage; <strong>Processing#</strong>.</p>
<p><a href="http://www.orbifold.net/default/wp-content/uploads/isee3.PNG"><img class="alignright size-medium wp-image-2425" title="isee 3" src="http://www.orbifold.net/default/wp-content/uploads/isee3-300x292.PNG" alt="isee 3" width="201" height="196" /></a><span style="color: #666699; font-size: 30pt;">iSee!</span> In addition to this we have been experimenting with novel approaches to diagramming and how to take full advantge of Silverlight and WPF animation capabilities. This lab project which has been now already for one year in the back of our minds is ready to be tested as well. Head over to <a title="iSee demo" href="/iSee/demo" target="_self">our iSee demo</a> and let us know what you think. iSee is all about animating visual elements and you can apply it anything which inherits from the FrameworkElement base class, that is&#8230;as good as anything you&#8217;ll find in WPF and Silverlight. Furthermore, iSee is really easy to use. It boast a<strong> fluent API</strong> and a very intuitive series of methods. The fluent things means you can chain actions ad infinitum.</p>
<p>For example, the following line of code:</p>
<pre>Attach(image, true).Scale(3, 3, Duration.Automatic)
.Move(new Point(145,150)).Scale(0.3, 0.3, Duration.Automatic).Play();</pre>
<p>will attach a given image to a canvas, scale it with a factor of three, subsequently move the image to another location and un-scale it to the original proportions. Easy! It would take a substantial amount of work to code this in C# or to create an equivalen storyboard in Expression Blend.</p>
<p><a href="http://www.orbifold.net/default/wp-content/uploads/isee4.PNG"><img class="size-medium wp-image-2426 alignleft" title="isee 4" src="http://www.orbifold.net/default/wp-content/uploads/isee4-300x261.PNG" alt="isee 4" width="237" height="206" /></a>We also wanted to enable certain diagramming scenario&#8217;s and have integrated diverse methods which allow you to create diagrams, mindmaps and data visualization with just a few methods. In the demo you will see a few examples of this.</p>
<p><span style="color: #666699; font-size: 30pt;">SPG</span>Last but not least, I&#8217;m also proud to announce our new Silverlight property grid. Much like L2 is an analog of G2, so is the Silverlight property grid (we call it &#8216;SPG&#8217;) an analof of our WPF property grid (&#8216;WPG&#8217;). You can <a title="SPF on Denis' blog" href="http://denisvuyka.wordpress.com/2009/10/31/silverlight-3-propertygrid-development-progress/" target="_blank">read about it on Denis&#8217; blog</a> and watch this space for more in the next few weeks.</p>
<p><a href="http://www.orbifold.net/default/wp-content/uploads/spg01.png"><img class="alignright size-medium wp-image-2445" title="SPG" src="http://www.orbifold.net/default/wp-content/uploads/spg01-268x300.png" alt="SPG" width="189" height="212" /></a>All these products represent a considerable amount of work (testing, demo versions, docs, samples&#8230;) and we are still in the process of packaging them. Also, for prices and official releases you&#8217;ll have to wait a bit, we&#8217;re working on it. Meanwhile let us know what you think. The Silverlight market is booming these days and there are excellent products around, still we think that our set of products fill a gap and represent a unique spectrum of solutions you&#8217;ll not find elsewhere.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/l2-isee-silverlight-property-grid-and-s/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Silverlight diagramming, WCF, the Entity Framework and MySQL.</title>
		<link>http://visualizationtools.net/default/wcfdiagrammingandmysql/</link>
		<comments>http://visualizationtools.net/default/wcfdiagrammingandmysql/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 20:30:37 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Diagramming]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[G2]]></category>

		<guid isPermaLink="false">http://www.orbifold.net/default/?p=1917</guid>
		<description><![CDATA[About our flashy diagramming framework for Silverlight, how to bind MySQL data to Silverlight via the Entity Framework and ADO.Net data service, how to demo a WCF bound Silverlight application without IIS or a dedicated webserver. Some news about our latest commercial moves and our sleepless nights.]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p><a href="http://www.orbifold.net/default/wp-content/uploads/crystalizerapplication.png"><img src="/oldsite/wp-content/uploads/crystalizerapplication-300x196.png" alt="Codename: Crystalizer" title="Codename: Crystalizer" width="300" height="196" class="aligncenter size-medium wp-image-1929" /></a></p>
<p>It&#8217;s been a while since I jotted something down on this blog&#8230;it&#8217;s been hectic for months now and the pace doesn&#8217;t seem to slow down but I think I have a few interesting things to mention.</p>
<p>Since the end of last year <a title="G2" href="/G2" target="_blank">G2</a> has grown bigger, stronger, more popular and various big customization projects are on our workbenches. At the same time, <a title="About Graphite" href="/Graphite" target="_blank">Graphite </a>continues to be our bestseller but most customers use it &#8216;as is&#8217; without much alterations. There are however a few lines of evolution. On the one hand, Silverlight becomes more and more popular and seems to have a better market penetration than WPF. This means that also Silverlight diagramming solutions are increasingly asked for. In this context, Graphite allows an easy path to data visualization but misses the flexibility and breadth of a true diagramming framework. Equally well (and enforced by the Silverlight wave), more and more customers wish to have a dual solution; all the advantages of diagraming in WPF and the possibility to bring as much as possible on the web (Sharepoint integration, read-only viewers and so on). These evolutions and the obvious gap in our products related to this meant a necessary investment in Silverlight and a common diagramming core. Now, hold your horses and don&#8217;t expect the sky since Silverlight still remains a subset of the .Net framework and even though Silverlight v3 broadens the horizon I don&#8217;t think any day soon you&#8217;ll have a full-compatibility tale (except through XBAP, but that&#8217;s another story). In any case, here is the good-news show and some notes from the field where diagramming meets Silverlight, the Entity Framework, MySQL and WCF.<br />
<span id="more-1917"></span><br />
Before describing the juicy technical details let me give you an overview of the application (screenshot above) we&#8217;ve been working on recently. It&#8217;s a Silverlight application which allows one to visualize any kind of relations between different types of entities; persons, documents, sites, etc. Any kind of relation means that it allows multiple links and generic graphs but can also handle tree-like data and multiple diagram layouts. The database uses just a few tables to store the graph structure and the actual data (persons, documents, metadata) can reside in the database but could also be stored in another database, in  XML files, you name it. The application also allows one to edit relations and to edit the entities; you can draw links and it will be saved in the database, you can change or add entities and so on. Finally (and this is what this blog items is mostly about) this Silverlight application can also be used as a WinForm application and accesses data through a local self-hosted WCF service. The WCF service is a RESTful ADO.Net data service which can also handle standard HTTP requests and thus acts as a local webserver. Minor features of this application is the integrated security system which can be connected to the ASP.Net membership mechanism, to ActiveDirectory services or any legacy single-sign on system you have in-house. <strong>Let me emphasize that this application boasts a full-fledged diagramming framework for Silverlight.</strong> which in many ways extends/surpasses our current Graphite product. For example, just for fun I developed in less than a day a reasonable mindmapping application for Silverlight (screenshot below).</p>
<p><a href="http://www.orbifold.net/default/wp-content/uploads/l2mm.png"><img src="/oldsite/wp-content/uploads/l2mm-300x155.png" alt="L2 based mindmapping" title="L2 based mindmapping" width="300" height="155" class="aligncenter size-medium wp-image-1930" /></a></p>
<h2>Entity Framework</h2>
<p>First off, I have been <strong>happily surprised by the Entity Framework (EF)</strong>. I know, it&#8217;s got a long list of shortcomings and I&#8217;ve walked the whole avenue of POCO adapters, detached entity tricks, constrained Visual Studio designer and more. However, in the context of Silverlight I was pleased to experience the ease with which it worked on top of MySQL and through the ADO.Net data services (aka Astoria). Initially I wrote the whole framework for SQL Server and had later on to move to MySQL&#8230;oh miraculus! <strong>Only minor changes were necessary on the database level (no Guid&#8217;s in MySQL, no triggers e.g.) and one needs at least MySQL v5 to make it work. </strong> Note that this happy message has more its origins in the hard work which went into developing <a target="_blank" href="http://www.mysql.com/products/connector/">the .Net driver for MySQL</a> rather than how open Microsoft is towards other relational database systems. In fact, I can also claim the same for other systems: <strong>EF works well with SQLite and with SQL Server Compact v3.5.</strong> There are pro&#8217;s and con&#8217;s with each and you need to tweak your model because of datatype differences, missing features (views, stored procedures etc.) but I expected a complete no-go orginally.</p>
<h2>ADO.Net Data Services</h2>
<p>Concerning ADO.Net data services. It<strong> works flawless with the EF, whatever the underlying database-dependent model is</strong>. In fact, if the data type signature is identical in different database systems, you only need to change one word in your code to switch from one to the other:</p>
<div class="wp_codebox">
<table>
<tr id="p19171">
<td class="line_numbers">
<pre>1
2
3
4
5
6
</pre>
</td>
<td class="code" id="p1917code1">
<pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span><span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ServiceModel</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ServiceBehavior</span><span style="color: #008000;">&#40;</span>IncludeExceptionDetailInFaults <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> CrystalMsSqlService <span style="color: #008000;">:</span> DataService<span style="color: #008000;">&lt;</span>crystalmysqlcontext<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&#123;</span>
<span style="color: #008000;">...</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&lt;/</span>crystalmysqlcontext<span style="color: #008000;">&gt;</span></pre>
</td>
</tr>
</table>
</div>
<p>This code is the generator of a REST WCF service on top of a EF model. The CrystalMySQLContext is the data context generated by the EF. If you wish to switch to, let&#8217;s say, SQL Server you only need to replace the data context specification and you&#8217;ll be safe for the rest of the journey.<br />
Note, as a side note, the <strong>ServiceBehavior </strong>attribute which propagates exceptions to the surface and which is not added by default in Visual Studio. You will also want to add a try-catch in the code to convert the exceptions to a <strong>DataServiceException </strong>like this:</p>
<div class="wp_codebox">
<table>
<tr id="p19172">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre>
</td>
<td class="code" id="p1917code2">
<pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> InitializeService<span style="color: #008000;">&#40;</span>IDataServiceConfiguration config<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">try</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008000;">..</span>
        <span style="color: #0000FF;">config</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SetEntitySetAccessRule</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;SomeTable&quot;</span>, EntitySetRights<span style="color: #008000;">.</span><span style="color: #0000FF;">All</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>Exception e<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">throw</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> DataServiceException<span style="color: #008000;">&#40;</span>e<span style="color: #008000;">.</span><span style="color: #0000FF;">Message</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre>
</td>
</tr>
</table>
</div>
<p>It will make debugging much easier, trust me.</p>
<p>Why ADO.Net data service (ADS)? You need to know that Silverlight only likes <strong>asynchronous data exchange</strong> with the outside world. Now, in order to expose data via WCF you can go via a artisanal, hand-crafted WCF service but ADS makes things easy and turns an EF into a RESTful service in a snap. In effect, it means you have all your tables and views available in Silverlight as if they were on the client. The price for this is the asynchronous behavior, which at times can be frustrating; <strong>you cannot have a data request and a data related action in the same C# method</strong>. A wisdom which I can give to you here is: <strong>don&#8217;t try to launch inner join requests from Silverlight</strong> to the REST, it doesn&#8217;t work. If you wish to do this<strong> you need to create a view</strong> in you database and make this view accessible in ADS as if it was a table. This simple fact makes SQL Server Compact immediately a bad choice because it doesn&#8217;t support views (SQL Express will do however).</p>
<h2>WCF (ah, so much beauty!)</h2>
<p>One of the things which kept me busy for a long time was how to demonstrate/ship a Silverlight demo without having to ship a database and without having to buy an expensive SQL Server license? Imagine you have a beautiful Silverlight application for a customer but you don&#8217;t want a whole setup involving a SQL Server database deployment (logins, connection strings etc.) and you also don&#8217;t want a complicated IIS setup wherein the Silverlight, WCF, XAP&#8230;reside. What to do? At first I tried to develop a local WCF proxy which would go to a file based data system. This meant a self-hosted WCF service, some sort of database on the client and a separate local webserver. This worked well up to the point that Silverlight kept on complaining about security issues. No mystery here: <strong>Silverlight doesn&#8217;t want to access data sources if they are not coming from the precise (includes the port number!) same origin as the xap</strong> (i.e. the Silverlight application).</p>
<p><a href="http://www.orbifold.net/default/wp-content/uploads/allinone.png"><img src="/oldsite/wp-content/uploads/allinone-216x300.png" alt="All in one solution" title="All in one solution" width="216" height="300" class="aligncenter size-medium wp-image-1921" /></a></p>
<p>Easy enough, I thought, but read on. You only need to supply the client with the clientaccesspolicy.xml or the server with the crossdomain.xml. Extend the WCF service like this:</p>
<div class="wp_codebox">
<table>
<tr id="p19173">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre>
</td>
<td class="code" id="p1917code3">
<pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>ServiceContract<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">interface</span> IWebServer
<span style="color: #008000;">&#123;</span>
    <span style="color: #008000;">&#91;</span>OperationContract, WebGet<span style="color: #008000;">&#40;</span>UriTemplate <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;/clientaccesspolicy.xml&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
    Stream GetSilverlightPolicy<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#91;</span>OperationContract, WebGet<span style="color: #008000;">&#40;</span>UriTemplate <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;/crossdomain.xml&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
    Stream GetFlashPolicy<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">...</span><span style="color: #008000;">&#125;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> CrystalMsSqlService <span style="color: #008000;">:</span> DataService<span style="color: #008000;">&lt;</span>crystalmysqlcontext<span style="color: #008000;">&gt;</span>, IWebServer
<span style="color: #008000;">&#123;</span><span style="color: #008000;">...</span>
<span style="color: #0600FF; font-weight: bold;">public</span> Stream GetSilverlightPolicy<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> result <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;&lt; ?xml version=&quot;</span><span style="color: #666666;">&quot;1.0&quot;</span><span style="color: #666666;">&quot; encoding=&quot;</span><span style="color: #666666;">&quot;utf-8&quot;</span><span style="color: #666666;">&quot;?&gt;
                                &lt;access -policy&gt;
                                    &lt;cross -domain-access&gt;
                                        &lt;policy&gt;
                                            &lt;allow -from http-request-headers=&quot;</span><span style="color: #666666;">&quot;*&quot;</span><span style="color: #666666;">&quot;&gt;
                                                &lt;domain uri=&quot;</span><span style="color: #666666;">&quot;*&quot;</span><span style="color: #666666;">&quot;/&gt;
                                            &lt;/allow&gt;
                                            &lt;grant -to&gt;
                                                &lt;resource path=&quot;</span><span style="color: #666666;">&quot;/&quot;</span><span style="color: #666666;">&quot; include-subpaths=&quot;</span><span style="color: #666666;">&quot;true&quot;</span><span style="color: #666666;">&quot;/&gt;
                                            &lt;/grant&gt;
                                        &lt;/policy&gt;
                                    &lt;/cross&gt;
                                &lt;/access&gt;&quot;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> StringToStream<span style="color: #008000;">&#40;</span>result<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> Stream GetFlashPolicy<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> result <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;&lt; ?xml version=&quot;</span><span style="color: #666666;">&quot;1.0&quot;</span><span style="color: #666666;">&quot;?&gt;
                                &lt; !DOCTYPE cross-domain-policy SYSTEM &quot;</span><span style="color: #666666;">&quot;http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd&quot;</span><span style="color: #666666;">&quot;&gt;
                                &lt;cross -domain-policy&gt;
                                    &lt;allow -access-from domain=&quot;</span><span style="color: #666666;">&quot;*&quot;</span><span style="color: #666666;">&quot; /&gt;
                                &lt;/cross&gt;&quot;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> StringToStream<span style="color: #008000;">&#40;</span>result<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">...</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&lt;/</span>crystalmysqlcontext<span style="color: #008000;">&gt;</span></pre>
</td>
</tr>
</table>
</div>
<p>It doesn&#8217;t work. Or at least, you can check that the WCF service does supply the policies but for some reasons Silverlight in my case still didn&#8217;t want to query the WCF service.</p>
<p><a href="http://www.orbifold.net/default/wp-content/uploads/wcfwebserver.png"><img src="/oldsite/wp-content/uploads/wcfwebserver-216x300.png" alt="WCF as a webserver" title="WCF as a webserver" width="216" height="300" class="aligncenter size-medium wp-image-1925" /></a></p>
<p>Now, because REST allows a client to query a WCF as if it&#8217;s a website and because one can serve both ascii and binary data through WCF/REST the obvious next step was to <strong>extend the WCF service with methods which would mimic a webserver behavior.</strong> Easy to do in fact by extending the service with more methods and templating the URL requests:</p>
<div class="wp_codebox">
<table>
<tr id="p19174">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
</pre>
</td>
<td class="code" id="p1917code4">
<pre class="csharp" style="font-family:monospace;">&nbsp;
<span style="color: #008000;">&#91;</span>ServiceContract<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">interface</span> IWebServer
<span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#91;</span>OperationContract, WebGet<span style="color: #008000;">&#40;</span>UriTemplate <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;/clientaccesspolicy.xml&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
Stream GetSilverlightPolicy<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#91;</span>OperationContract, WebGet<span style="color: #008000;">&#40;</span>UriTemplate <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;/crossdomain.xml&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
Stream GetFlashPolicy<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#91;</span>OperationContract, WebGet<span style="color: #008000;">&#40;</span>UriTemplate <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;/app.htm&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
Stream GetApplicationPage<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008000;">&#91;</span>OperationContract, WebGet<span style="color: #008000;">&#40;</span>UriTemplate <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;/{pagename}&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
Stream GetSitePage<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> pagename<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#91;</span>OperationContract, WebGet<span style="color: #008000;">&#40;</span>UriTemplate <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;/Images/{imagename}&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
Stream GetImage<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> imagename<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#91;</span>OperationContract, WebGet<span style="color: #008000;">&#40;</span>UriTemplate <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;/Crystalizer.One.xap&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
Stream GetCrytal<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008000;">&#125;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> CrystalMsSqlService <span style="color: #008000;">:</span> DataService<span style="color: #008000;">&lt;</span>crystalmysqlcontext<span style="color: #008000;">&gt;</span>, IWebServer
<span style="color: #008000;">&#123;</span><span style="color: #008000;">...</span>
<span style="color: #0600FF; font-weight: bold;">public</span> Stream GetSitePage<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> pagename<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">try</span>
    <span style="color: #008000;">&#123;</span>
        WebOperationContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OutgoingResponse</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ContentType</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;text/html&quot;</span><span style="color: #008000;">;</span>
        <span style="color: #6666cc; font-weight: bold;">string</span> fileContents<span style="color: #008000;">;</span>
        <span style="color: #6666cc; font-weight: bold;">string</span> path<span style="color: #008000;">;</span>
        path <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;WebRoot\{0}&quot;</span>, pagename<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>StreamReader sr <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> StreamReader<span style="color: #008000;">&#40;</span>path<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            fileContents <span style="color: #008000;">=</span> sr<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadToEnd</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> MemoryStream<span style="color: #008000;">&#40;</span>Encoding<span style="color: #008000;">.</span><span style="color: #0000FF;">UTF8</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetBytes</span><span style="color: #008000;">&#40;</span>fileContents<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>Exception<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> Stream GetImage<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> imagename<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> fileContents<span style="color: #008000;">;</span>
    fileContents <span style="color: #008000;">=</span> File<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadAllBytes</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;WebRoot\Images\{0}&quot;</span>, imagename<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">// byte[] resp = Encoding.ASCII.GetBytes(string.Format(HttpHeader, &quot;image/png&quot;, fileContents.Length, fileContents));</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> MemoryStream<span style="color: #008000;">&#40;</span>fileContents<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">...</span><span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&lt;/</span>crystalmysqlcontext<span style="color: #008000;">&gt;</span></pre>
</td>
</tr>
</table>
</div>
<p>This now turns your RESTful ADS service into a webserver which serves both the data, the site pages and site images.<br />
One last trick is the fact that because now your WCF service actually implements two interfaces the default endpoint configuration of ADS will not work. To solve this in the self-hosted scenario you can add another endpoint as follows:</p>
<div class="wp_codebox">
<table>
<tr id="p19175">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre>
</td>
<td class="code" id="p1917code5">
<pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> HostWithWebServiceHost<span style="color: #008000;">&#40;</span>Uri baseAddress<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
&nbsp;
    WCFHost <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> WebServiceHost<span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #008000;">&#40;</span>CrystalMsSqlService<span style="color: #008000;">&#41;</span>, baseAddress<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    WebHttpBinding binding <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> WebHttpBinding<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    WCFHost<span style="color: #008000;">.</span><span style="color: #0000FF;">AddServiceEndpoint</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #008000;">&#40;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Data</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Services</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IRequestHandler</span><span style="color: #008000;">&#41;</span>, binding, <span style="color: #666666;">&quot;dataservice&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
&nbsp;
    WCFHost<span style="color: #008000;">.</span><span style="color: #0000FF;">AddServiceEndpoint</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #008000;">&#40;</span>IWebServer<span style="color: #008000;">&#41;</span>, binding, <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Behaviors</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> WebHttpBehavior<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    ServiceMetadataBehavior smb <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ServiceMetadataBehavior <span style="color: #008000;">&#123;</span>HttpGetEnabled <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
    WCFHost<span style="color: #008000;">.</span><span style="color: #0000FF;">Description</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Behaviors</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>smb<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    WCFHost<span style="color: #008000;">.</span><span style="color: #0000FF;">Open</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre>
</td>
</tr>
</table>
</div>
<p><strong>At this point the Silverlight application will run at the client without any server or internet connection.</strong>. You can go a step further and even host the Silverlight application in a Windows form which at the same time hosts the WCF service, but that&#8217;s really a no-brainer. You simply add a webbrowser control in a WinForm and call the HTML page which contains the Silverlight control and you&#8217;re done. Note that by doing this you have <strong>a Silverlight 2 application which runs as if it&#8217;s a regular WinForm application</strong>. Still, because the WCF service serves ANY client you can also access the Silverlight application through a standard browser. Actually, this fact helps to debug the Silverlight code by attaching the debugger to the browser process. I have not found any other way to debug Silverlight if it&#8217;s not part of a Visual Studio web application (as in my case).</p>
<p><a href="http://www.orbifold.net/default/wp-content/uploads/finalsolution.png"><img src="/oldsite/wp-content/uploads/finalsolution-203x300.png" alt="Final solution" title="Final solution" width="203" height="300" class="aligncenter size-medium wp-image-1926" /></a></p>
<p>In my final &#8216;show it to the customer without deployment&#8217; solution, I removed the database from the client setup and kept the MySQL on a publicly available location. The only things you need to watch in this case is the fact that by default EF will store the database connection credentials in the web.config. You need to create a EF compiled connection with the EntityConnectionStringBuilder and override the CreateDataSource method of the ADS service:</p>
<div class="wp_codebox">
<table>
<tr id="p19176">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre>
</td>
<td class="code" id="p1917code6">
<pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> CrystalMySQLContext CreateDataSource<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    EntityConnectionStringBuilder entityBuilder <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> EntityConnectionStringBuilder<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    entityBuilder<span style="color: #008000;">.</span><span style="color: #0000FF;">Metadata</span> <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;res://*/MySql.CrystalMySQLModel.csdl|res://*/MySql.CrystalMySQLModel.ssdl|res://*/MySql.CrystalMySQLModel.msl&quot;</span><span style="color: #008000;">;</span>
    entityBuilder<span style="color: #008000;">.</span><span style="color: #0000FF;">Provider</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;MySql.Data.MySqlClient&quot;</span><span style="color: #008000;">;</span>
    entityBuilder<span style="color: #008000;">.</span><span style="color: #0000FF;">ProviderConnectionString</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;server=xxx;user id=xxx;password='xxx';persist security info=True;database=illumineo&quot;</span><span style="color: #008000;">;</span>
&nbsp;
    EntityConnection con <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> EntityConnection<span style="color: #008000;">&#40;</span>entityBuilder<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    CrystalMySQLContext ctx <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CrystalMySQLContext<span style="color: #008000;">&#40;</span>con<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> ctx<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre>
</td>
</tr>
</table>
</div>
<h2>MySQL</h2>
<p>During the testing and deployment phase of this project I encountered various difficulties which were all related to the fact that all the assemblies you assume are not necessarily on a blank machine. <strong>Adding these assemblies to the bin directory doesn&#8217;t solve these issues</strong>, the great trick here is a configuration you need to add in order to tell the CLR these assemblies are available. During the installation of a database driver the machine.config is altered but this is not the case if you deploy a self-hosted service and the binaries are not in the GAC:</p>
<div class="wp_codebox">
<table>
<tr id="p19177">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
</pre>
</td>
<td class="code" id="p1917code7">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;">&lt; ?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dbproviderfactories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;clear</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SqlClient Data Provider&quot;</span> <span style="color: #000066;">invariant</span>=<span style="color: #ff0000;">&quot;System.Data.SqlClient&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;.Net Framework Data Provider for SqlServer&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;MySQL Data Provider&quot;</span> <span style="color: #000066;">invariant</span>=<span style="color: #ff0000;">&quot;MySql.Data.MySqlClient&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;.Net Framework Data Provider for MySQL&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.0.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dbproviderfactories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre>
</td>
</tr>
</table>
</div>
<h2>Silverlight only likes it async</h2>
<p>Concerning the asynchronous behavior of Silverlight I can only say: you need a different mindset to live with it. In my Silverlight application I invested quite some time to create an MVC pattern on the basis of asynchronous data access. Because Silverlight handles templating/styling differently and doesn&#8217;t have a databinding mechanism which support element names all of this was tricky at times but in the end I think I was able to cook a very clean and felxible Silverlight framework which in fact has not much affinity with diagramming and could be used as a generic framework (just like our O2 framework for WPF).</p>
<h2>Commercial rands</h2>
<p>I mentioned in the introduction that one of the aims of this project was to have a common core between WPF and Silverlight. Bad news here: you cannot share assemblies between Silverlight and WPF, you cannot share template, you cannot share databinding patterns, you cannot&#8230;well, lots of things. You can find on the net different ways to handle these difficulties (pragma&#8217;s in your code for instance) but I haven&#8217;t found any of these satisfactory. So, the end result in this context is a big deception, until Microsoft brings on stage a clear strategy targetting this scenario you have to live with duplicated code. For our diagramming aims this means we have a completely different Silverlight library which covers a lot of the features available in G2 but is nowhere near identical in code as G2. On the surface (read: our commercial offering) we now have</p>
<ul>
<li> an enterprise level diagramming framework (product: G2) for WPF and a MEF-based framework for WPF applications (product: O2). </li>
<li>a very complete diagramming framework (product: L2) for Silverlight and a MVC-based framework for Silverlight applications</li>
</ul>
<p>which in look-and-feel will give you pretty much the same experience. A BPM modeller or a workflow application in Silverlight with the same functionality in WPF&#8230;it&#8217;s all possible but not on the basis of a common core. In commercial terms this means that a customer wishing to have a dual Silverlight/WPF product needs to pay twice for customizations but can share a common data access layer hidden behind a WCF facade. Speaking about <strong>commercial moves</strong> I should also mention that The Orbifold has acquired recently two new products which were previously in the open source realm: <strong>Denis&#8217; property grid for Silverlight and WPF, as well a Petro&#8217;s S# scripting framework (aka Script.Net)</strong>. More about this in the near future.</p>
<p>There is so much more to say about our other projects and our latest WPF magic but I&#8217;ll stop here and leave if for another blog post.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/wcfdiagrammingandmysql/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Silverlight diagramming with spring-embedder layout</title>
		<link>http://visualizationtools.net/default/silverlight-diagramming-with-spring-embedder-layout/</link>
		<comments>http://visualizationtools.net/default/silverlight-diagramming-with-spring-embedder-layout/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 00:01:50 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Diagramming]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.orbifold.net/default/?p=1225</guid>
		<description><![CDATA[A lightweight diagramming control in Silverlight with the spring-embedder layout.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.orbifold.net/default/wp-content/uploads/graphiteblack.png"><img style="float:right; margin:10px " title="The graphite control in a black styling." src="http://www.orbifold.net/default/wp-content/uploads/graphiteblack-300x269.png" alt="" width="371" height="333" /></a>Many years ago when Java appeared on the scene <a title="Graph layout applet" href="http://java.sun.com/applets/jdk/1.4/demo/applets/GraphLayout/example1.html" target="_blank">a little demo applet</a> was delivered together with the <a title="Java 1.4 SDK" href="http://java.sun.com/applets/jdk/1.4/index.html" target="_blank">Java SDK</a>. It was not a huge piece of software but it sparked many ideas and a whole industry evolved around it (see <a title="TouchGraph" href="http://www.touchgraph.com/navigator.html" target="_blank">TouchGraph </a>for example), especially in the academic world. In those days things were frustrating for a Visual Basic developer, well any Microsoft developer in fact, because we only had ActiveX controls and these were far behind in many respects. It took many years for Microsoft to get over the COM and ActiveX disaster, it took us developers many years to finally have the possibility to do what Java was enabling then. Through Silverlight  there&#8217;s finally the ease of .Net inside the browser and, in fact, much more; a lightweight version of WPF which includes animation and other fancy Flash-like stuff.<br />
<span id="more-1225"></span></p>
<p>It took me little effort to shift my WPF experience to Silverlight and to transpose some layout algorithms. There are some difference, for sure, but hardly anything I can complain about. Alltogether I truly enjoyed the hours I spent on developing this little &#8216;applet&#8217;. Graphite is very similar to the Java applet but the implementation is more clean and I have taken much care of the API. The only significant part is the layout algorithm, which you can almost copy/paste from the Java applet or fetch from some Netron code. Hyperbolic layout and tree layout are easily implemented but I&#8217;m not sure I will, because I have to focus my attention back to GraphSquare.</p>
<p>See for yourself:</p>
<ul>
<li> the <a title="The black version" href="/Graphite/demo/BlackGraphite/" target="_blank">black version</a></li>
<li>the <a title="The green version" href="/Graphite/demo/WhiteGraphite/" target="_blank">green version</a></li>
</ul>
<p><strong>Usage:</strong></p>
<ul>
<li>use <strong>CTRL-click</strong> on nodes or on the canvas to add random nodes</li>
<li>use <strong>SHIFT-click</strong> to select nodes before creating a new edge. Note that you can select only two of them.</li>
<li>use<strong> ALT-click</strong> to delete a node and its bindings</li>
<li>hover over a node to see the underlying info</li>
</ul>
<p><strong>Features:</strong></p>
<ul>
<li>things are pretty much all encapsulated into a custom Canvas object</li>
<li>the API and events make it easy to manipulte the diagram in any context</li>
<li>the architecture is model-view based, the model being a straightforward graph data structure</li>
<li>data can be imported from flat text files or from XML</li>
<li>the visualization is based on WPF/SIlverlight templating and styling features outside the control, which means one can customize colors and appearance. The flexibility of WPF&#8217;s triggers and other subtleties is missing in Silverlight but one can get quite far nevertheless.</li>
<li>the layout algorithm is continous, which means you can drag nodes around like beans in jam. It all behaves very &#8216;organic&#8217;.</li>
</ul>
<p><em>Addendum</em>: due to a different font on your side you might see node titles a little bit bigger or smaller than on the screenshots.<br />
<em>Demo</em>: go ahead and have fun with <a title="Download the Graphite Demo project." href="http://www.orbifold.net/Downloads/Graphite4Silverlight/Graphite.Demo.zip">the Graphite demo</a>.</p>
<p><a href="http://www.orbifold.net/default/wp-content/uploads/graphitegreen.png"><img style="float:right; margin:10px " title="The graphite control is a green styling." src="http://www.orbifold.net/default/wp-content/uploads/graphitegreen-300x200.png" alt="" width="300" height="200" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/silverlight-diagramming-with-spring-embedder-layout/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  www.visualizationtools.net/default/category/software/net/silverlight/feed/ ) in 1.09054 seconds, on Feb 9th, 2012 at 7:45 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 9th, 2012 at 8:45 am UTC -->
