<?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>Justin DuJardin &#187; Silverlight 3</title>
	<atom:link href="http://www.justindujardin.com/blog/?feed=rss2&#038;tag=silverlight-3" rel="self" type="application/rss+xml" />
	<link>http://www.justindujardin.com/blog</link>
	<description>&#124;O_o&#124; &#124;x_X&#124; &#124;-_-&#124; &#124;o_O&#124;</description>
	<lastBuildDate>Tue, 17 Aug 2010 18:31:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Canvas Element Positioning Performance</title>
		<link>http://www.justindujardin.com/blog/?p=1076</link>
		<comments>http://www.justindujardin.com/blog/?p=1076#comments</comments>
		<pubDate>Thu, 13 May 2010 00:32:19 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[DependencyProperty]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Silverlight 3]]></category>

		<guid isPermaLink="false">http://www.justindujardin.com/blog/?p=1076</guid>
		<description><![CDATA[C# and Silverlight provide a rich set of layout controls that can be used in constructing elegant user interfaces, including a do-it-yourself Canvas class that allows you to manually position elements on it&#8217;s surface. Positioning Elements in Code With a Canvas you&#8217;re almost always going to want to have some code that positions the child [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">C# and Silverlight provide a rich set of layout controls that can be used in constructing elegant user interfaces, including a do-it-yourself <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.canvas.aspx" target="_blank">Canvas</a> class that allows you to manually position elements on it&#8217;s surface.</p>
<p style="text-align: left;"><a href="http://www.justindujardin.com/blog/wp-content/uploads/2010/05/Silverlight_Canvas_Element_Positioning.jpg"><img class="size-medium wp-image-1078 alignright" title="Canvas Positioning    Performance" src="http://www.justindujardin.com/blog/wp-content/uploads/2010/05/Silverlight_Canvas_Element_Positioning-300x236.jpg" alt="" width="300" height="236" /></a><strong>Positioning Elements in Code<br />
</strong></p>
<p style="text-align: left;">With a Canvas you&#8217;re almost always going to want to have some code that positions the child elements.  To move things about, the property you are concerned with is not, as you might expect, a Position or Left/Top property on the child element, but rather it is a property of the Canvas that can be set on a child element.</p>
<p style="text-align: left;">There are two ways I have seen used to set the Canvas.Left or Canvas.Top property on a child element, and in some cases you&#8217;ll want to distinguish between the two.</p>
<p style="text-align: left;">The first way is to call SetValue on the Child element with the DependencyProperty  you want to set, Canvas.LeftProperty or Canvas.TopProperty.   The second way is to call Canvas.SetLeft or  Canvas.SetTop and pass in the UIElement to set it on.</p>
<p style="text-align: left;"><span id="more-1076"></span></p>
<p style="text-align: left;"><strong>When Speed Matters</strong></p>
<p style="text-align: left;">In some situations it can be helpful to understand the difference in performance of the various ways of setting these properties.</p>
<p style="text-align: left;">I could not find any information comparing the performance of these two methods so I wrote a small unit test (below) that could tell me which was faster.  It turns out that on average, calling the Canvas.SetLeft/SetTop methods are about 3 times faster than calling Element.SetValue with the DependencyProperty.</p>
<p style="text-align: left;">When you think about that for a moment, it begins to make sense, because the Element.SetValue method takes a DependencyProperty and a value, which means that it resolve the property to end up at it&#8217;s destination.  On the other hand the SetLeft/SetTop methods already know what data they&#8217;re setting (they even explicitly specify it in the naming!), which means they should have a pretty direct path to the data.</p>
<p style="text-align: left;"><strong>Testing Performance</strong></p>
<p>I&#8217;ve provided  below the source code that I used to generate the data  for this graph so you can try it for yourself.</p>
<table style="height: 108px;" border="0" cellspacing="0" cellpadding="3" width="412">
<tbody>
<tr style="text-align: center;">
<td></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">1,000,000</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">500,000</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">100,000</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">10,000</span></span></td>
</tr>
<tr>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">Canvas.SetLeft</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">446</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">220</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">46</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">5</span></span></td>
</tr>
<tr>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">Canvas.SetTop</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">456</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">222</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">46</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">5</span></span></td>
</tr>
<tr>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">Canvas.LeftProperty<br />
</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">1361</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">683</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">139</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">18</span></span></td>
</tr>
<tr>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">Canvas.TopProperty<br />
</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">1354</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">680</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">137</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">14</span></span></td>
</tr>
</tbody>
</table>
<pre class="brush: csharp;">
public void TestCanvasElementPositioning()
{
   long elapsedSetValueTop = 0;
   long elapsedSetTop = 0;
   long elapsedSetValueLeft = 0;
   long elapsedSetLeft = 0;
   var timer = new Stopwatch();

   var testCanvas = new Canvas();
   var testChild = new Ellipse();
   testCanvas.Children.Add(testChild);

   // How many iterations to time
   const long iterations = 10000;

   // Canvas.SetLeft
   timer.Start();
   for (int i = 0; i &lt; iterations; i++)
      Canvas.SetLeft(testChild, (double)i % 10);
   timer.Stop();
   elapsedSetLeft = timer.ElapsedMilliseconds;
   timer.Reset();

   // Element.SetValue(Canvas.LeftProperty)
   timer.Start();
   for (int i = 0; i &lt; iterations; i++)
      testChild.SetValue(Canvas.LeftProperty, (double)i % 10);
   timer.Stop();
   elapsedSetValueLeft = timer.ElapsedMilliseconds;
   timer.Reset();

   testCanvas = new Canvas();
   testChild = new Ellipse();
   GC.Collect();

   // Element.SetValue(Canvas.TopProperty)
   timer.Start();
   for (int i = 0; i &lt; iterations; i++)
      testChild.SetValue(Canvas.TopProperty, (double)i % 10);
   timer.Stop();
   elapsedSetValueTop = timer.ElapsedMilliseconds;
   timer.Reset();

   // Canvas.SetTop
   timer.Start();
   for (int i = 0; i &lt; iterations; i++)
      Canvas.SetTop(testChild, (double)i % 10);
   timer.Stop();
   elapsedSetTop = timer.ElapsedMilliseconds;
   timer.Reset();

   Assert.IsTrue(elapsedSetLeft &lt; elapsedSetValueLeft,
                 &quot;Expected SetLeft to be less than SetValue&quot;);
   Assert.IsTrue(elapsedSetTop &lt; elapsedSetValueTop,
                 &quot;Expected SetTop to be less than SetValue&quot;);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.justindujardin.com/blog/?feed=rss2&amp;p=1076</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight 3, LINQ, and Bing! Oh, my!</title>
		<link>http://www.justindujardin.com/blog/?p=724</link>
		<comments>http://www.justindujardin.com/blog/?p=724#comments</comments>
		<pubDate>Wed, 10 Mar 2010 02:09:09 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Bing]]></category>
		<category><![CDATA[Image Query]]></category>
		<category><![CDATA[Linq to Xml]]></category>
		<category><![CDATA[Silverlight 3]]></category>

		<guid isPermaLink="false">http://www.justindujardin.com/blog/?p=724</guid>
		<description><![CDATA[In my last post I talked about Silver Shorts and showed off my example Bing Image search application. For this post I want to go over the code that I created for doing a Bing image query, to demonstrate just how powerful and concise Silverlight 3 C# code can be. To truly appreciate this, I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.bing.com/"><img class="size-medium wp-image-879 alignright" title="Microsoft Bing" src="http://www.justindujardin.com/blog/wp-content/uploads/2010/03/bingLogo_lg-300x231.jpg" alt="" width="144" height="111" /></a>In my <a href="http://www.justindujardin.com/blog/?p=764">last post</a> I talked about Silver Shorts and showed off my<a href="http://www.justindujardin.com/blog/?p=764"> example Bing Image search application</a>.</p>
<p>For this post I want to <a title="Get the Silver Shorts Code" href="http://github.com/justindujardin/SilverShorts" target="_blank">go over the code</a> that I created for doing a Bing image query, to demonstrate just how powerful and concise Silverlight 3 C# code can be.  To truly appreciate this, I suggest <a title="Get the Silver Shorts Code" href="http://github.com/justindujardin/SilverShorts" target="_blank">checking out the code</a>, which totals about 225 lines for both the Image Search utility AND the Test Application.</p>
<p>To get started, let&#8217;s enumerate the requirements I came up with for the project:</p>
<ol>
<li>Image Search
<ul>
<li>Bing Image query based on textual search terms</li>
<li>Transform XML results into custom classes</li>
</ul>
</li>
</ol>
<p>We&#8217;ll refer back to these requirements as we build the code to make sure we stay on track.</p>
<p><span id="more-724"></span></p>
<h2>Image Search</h2>
<p>The image search has two parts, performing the query, and processing/returning the results.  C#, Silverlight, and LINQ to XML will make this a pretty trivial task for us.</p>
<p>We&#8217;re going to start by creating a static class to contain our image query code.  We&#8217;re creating a static class in this case because we will have no member data to store, and will have only one public method (Search) to access.  Here&#8217;s what it will look like as an outline, notice that it appears to conform to the goals for #1 above, that is, in its definition it contains a method for performing a query, and a private method for processing the results.</p>
<pre class="brush: csharp; highlight: [3,7,8,12]; wrap-lines: false;">
namespace djc.SilverShorts.Bing
{
   public class ImageResult {}
   static class ImageQuery
   {
      #region Public Search Interface
      public delegate void SearchResultCallback(List&lt;ImageResult&gt; results);
      static public void Search(string appId, string search, SearchResultCallback callback, int numImages = 10, int offsetIndex = 0, bool useSafeSearch = true) {}
      #endregion

      #region Xml to Object LINQ
      static private void _processXmlResults(string xml, SearchResultCallback callback) {}
      #endregion
   }
}
</pre>
<h2>Bing Image query based on textual search terms</h2>
<p>First we need to create a formatted Url string that the Bing service can understand, then we need to create a WebClient object and use it&#8217;s DownloadStringAsync method to perform the query.  Once we&#8217;ve done this, our new Search method looks like so:</p>
<pre class="brush: csharp; wrap-lines: false;">
      static public void Search(string appId, string search, SearchResultCallback callback, int numImages = 10, int offsetIndex = 0, bool useSafeSearch = true)
      {
         string requestString = &quot;http://api.bing.net/xml.aspx?&quot;
             + &quot;AppId=&quot; + appId
             + &quot;&amp;Query=&quot; + search
             + &quot;&amp;Sources=Image&quot;
             + &quot;&amp;Version=2.0&quot;
             + &quot;&amp;Market=en-us&quot;
             + (useSafeSearch ? &quot;&amp;Adult=Moderate&quot; : &quot;&quot;)
             + &quot;&amp;Image.Count=&quot; + numImages.ToString()
             + &quot;&amp;Image.Offset=&quot; + offsetIndex.ToString();
         Uri uri = new Uri(requestString, UriKind.Absolute);
         WebClient client = new WebClient();
         client.DownloadStringCompleted += _downloadStringCompleted;
         // Note that we're passing the callback delegate as user data
         client.DownloadStringAsync(uri, callback);
      }
</pre>
<blockquote><p>We&#8217;ve got a few hardcoded bits in here. For a more complete Bing query API implementation, see <a href="http://bingsharp.codeplex.com/" target="_blank">Bing Sharp</a>.</p></blockquote>
<p>The astute reader will note that we&#8217;ve registered a callback event handler function called _downloadStringCompleted that doesn&#8217;t exist in our initial class outline.  We&#8217;ll need to create this and use this event handler to trigger our _processXmlResults method.  We&#8217;ll make sure there was no error in the network query, and that a valid callback has been specified, then hand off control to our second bit of code that will transform the XML into custom class data.</p>
<pre class="brush: csharp; wrap-lines: false;">
      static private void _downloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
      {
         SearchResultCallback callback = e.UserState as SearchResultCallback;
         if (e.Error != null || callback == null)
            return;

         _processXmlResults(e.Result.ToString(), callback);
      }
</pre>
<h2>Transform XML results into custom classes</h2>
<p>At this point we&#8217;re ready to get into parsing the Bing XML  string into custom class data. Before we get there, let&#8217;s take a look at what the XML we&#8217;re going to be parsing will look like.  This structure will also inform how we implement our custom classes to hold the information we&#8217;ve retrieved.</p>
<p><strong>Bing Result XML Example</strong></p>
<pre class="brush: xml; highlight: [7,11,19]; wrap-lines: false;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;?pageview_candidate?&gt;
&lt;SearchResponse xmlns=&quot;http://schemas.microsoft.com/LiveSearch/2008/04/XML/element&quot; Version=&quot;2.0&quot;&gt;
   &lt;Query&gt;
      &lt;SearchTerms&gt;Waffles&lt;/SearchTerms&gt;
   &lt;/Query&gt;
   &lt;mms:Image xmlns:mms=&quot;http://schemas.microsoft.com/LiveSearch/2008/04/XML/multimedia&quot;&gt;
      &lt;mms:Total&gt;1200000&lt;/mms:Total&gt;
      &lt;mms:Offset&gt;0&lt;/mms:Offset&gt;
      &lt;mms:Results&gt;
         &lt;mms:ImageResult&gt;
            &lt;mms:Title&gt;Thank goodness for waffles&lt;/mms:Title&gt;
            &lt;mms:MediaUrl&gt;http://www.digsmagazine.com/images/nourisharticles/waffles.jpg&lt;/mms:MediaUrl&gt;
            &lt;mms:Url&gt;http://dwoolstar.blogspot.com/2005_05_01_archive.html&lt;/mms:Url&gt;
            &lt;mms:DisplayUrl&gt;http://dwoolstar.blogspot.com/2005_05_01_archive.html&lt;/mms:DisplayUrl&gt;
            &lt;mms:Width&gt;150&lt;/mms:Width&gt;
            &lt;mms:Height&gt;200&lt;/mms:Height&gt;
            &lt;mms:FileSize&gt;6895&lt;/mms:FileSize&gt;
            &lt;mms:Thumbnail&gt;
               &lt;mms:Url&gt;http://ts1.mm.bing.net/images/thumbnail.aspx?q=1383735232706&amp;amp;id=4778a42319f15e572deaa592c12334c5&lt;/mms:Url&gt;
               &lt;mms:ContentType&gt;image/jpeg&lt;/mms:ContentType&gt;
               &lt;mms:Width&gt;120&lt;/mms:Width&gt;
               &lt;mms:Height&gt;160&lt;/mms:Height&gt;
               &lt;mms:FileSize&gt;4218&lt;/mms:FileSize&gt;
            &lt;/mms:Thumbnail&gt;
         &lt;/mms:ImageResult&gt;
      &lt;/mms:Results&gt;
   &lt;/mms:Image&gt;
&lt;/SearchResponse&gt;
</pre>
<p>Now that we see the general information available to us, it&#8217;s time to go back to our empty ImageResult class that we defined above, and give it some meat.  We&#8217;re only concerned with the ImageResult elements and their children in this case, so we&#8217;ll copy them pretty directly.  The result looks like this:</p>
<p><strong>Custom ImageResult class</strong></p>
<pre class="brush: csharp; wrap-lines: false;">
   public class ImageResult
   {
      public string Title;
      public string MediaUrl;
      public string Url;
      public string DisplayUrl;
      public int Width;
      public int Height;
      public int FileSize;
      public class Thumbnail
      {
         public string Url;
         public string ContentType;
         public int Width;
         public int Height;
         public int FileSize;
      }
      public Thumbnail Thumb;
   }
</pre>
<p>Take a moment to look over the two codeblocks above and note the similarities in structure.   Once you see it, continue to the codeblock below and try to recognize the same similarities in structure.</p>
<p><strong>NOTE:</strong> It&#8217;s important to note that the C# classes I have do NOT need to have a direct mapping of member variable names to the XML elements we&#8217;ll be pulling data from.  To make this more clear, consider that the XML element for a thumbnail is &#8220;Thumbnail&#8221;, and our custom class variable is called &#8220;Thumb&#8221;.  Consider further that I could have called it SmallImage, Pinkynail, Luggage, or anything else and accounted for it accordingly in the LINQ query below.</p>
<p><strong>Using LINQ to transform XML</strong></p>
<p>Finally we&#8217;re to the point that we&#8217;re ready to take our XML and turn it into something that we can use in our Silverlight application somewhat generically.  Let us take a staged-approach to understanding the final, complex, nested query.  First we&#8217;ll look at a simpler query, then a more complex query, and finally we&#8217;ll put it all together into the actual query that jives with our intention and requirements.</p>
<p><strong>A Simple Query</strong></p>
<p>To better understand the final more complex query, let us consider a simpler query that doesn&#8217;t have a nested sub-query for thumbnails, and also does not have namespace&#8217;d elements.  It would look  like this:</p>
<pre class="brush: csharp; wrap-lines: false;">
var imageResults =
   // For each XML Element (ir) in the XML Document (doc.Descendants)
   from ir in doc.Descendants()
   // If the name is &quot;ImageResult&quot;
   where ir.Name.Equals(&quot;ImageResult&quot;)
   // Create a new ImageResult object
   select new ImageResult()
   {
      // Strings
      Title = ir.Element(&quot;Title&quot;).Value,
      MediaUrl = ir.Element(&quot;MediaUrl&quot;).Value,
      Url = ir.Element(&quot;Url&quot;).Value,
      DisplayUrl = ir.Element(&quot;DisplayUrl&quot;).Value,
      // Integers
      Width = Int32.Parse(ir.Element(&quot;Width&quot;).Value),
      Height = Int32.Parse(ir.Element(&quot;Height&quot;).Value),
      FileSize = Int32.Parse(ir.Element(&quot;FileSize&quot;).Value),
      Thumb = new ImageResult.Thumbnail()
   };
</pre>
<p><strong>A Slightly Less Simple Query</strong><br />
Once we understand what the above simplified query does, let us layer another bit of complexity on top of it, adding back in the Thumbnail objects nested query.  The query then looks like this:</p>
<pre class="brush: csharp; wrap-lines: false;">
   // For each XML Element (ir) in the XML Document (doc.Descendants)
   from ir in doc.Descendants()
   // If the name is &quot;ImageResult&quot;
   where ir.Name.Equals(&quot;ImageResult&quot;)
   // Create a new ImageResult object
   select new ImageResult()
   {
      Title = ir.Element(&quot;Title&quot;).Value,
      MediaUrl = ir.Element(&quot;MediaUrl&quot;).Value,
      Url = ir.Element(&quot;Url&quot;).Value,
      DisplayUrl = ir.Element(&quot;DisplayUrl&quot;).Value,
      Width = Int32.Parse(ir.Element(&quot;Width&quot;).Value),
      Height = Int32.Parse(ir.Element(&quot;Height&quot;).Value),
      FileSize = Int32.Parse(ir.Element(&quot;FileSize&quot;).Value),
      Thumb =
          // for each XML element (th) in the XML element (ir)'s Descendants
         (from th in ir.Descendants()
          // If the name is &quot;Thumbnail&quot;
          where th.Name.Equals(&quot;Thumbnail&quot;)
          // Create a new ImageResult.Thumbnail
          select new ImageResult.Thumbnail()
          {
             Url = th.Element(&quot;Url&quot;).Value,
             ContentType = th.Element(&quot;ContentType&quot;).Value,
             Width = Int32.Parse(th.Element(&quot;Width&quot;).Value),
             Height = Int32.Parse(th.Element(&quot;Height&quot;).Value),
             FileSize = Int32.Parse(th.Element(&quot;FileSize&quot;).Value)
          }).Single(), // &lt;-- Only one result for this sub-query
   };
</pre>
<p><strong>The Full <span style="text-decoration: line-through;">Monty</span> Query<span style="text-decoration: line-through;"><br />
</span></strong></p>
<p>Got it? Good.  Finally we add back in the namespace information, and the query becomes slightly more verbose (though not necessarily more complex).</p>
<pre class="brush: csharp; wrap-lines: false;">
// Parse the XML response text
XDocument doc = XDocument.Parse(xml);

// Elements in the response all conform to this schema and have a namespace prefix of mms:
// For our LINQ query to work properly, we must use mmsNs + ElementName
XNamespace mmsNs = XNamespace.Get(&quot;http://schemas.microsoft.com/LiveSearch/2008/04/XML/multimedia&quot;);

// Build a LINQ query to parse the XML data into our custom ImageResult objects
var imageResults =
   from ir in doc.Descendants()
   where ir.Name.Equals(mmsNs + &quot;ImageResult&quot;)
   select new ImageResult()
   {
      Title = ir.Element(mmsNs + &quot;Title&quot;).Value,
      MediaUrl = ir.Element(mmsNs + &quot;MediaUrl&quot;).Value,
      Url = ir.Element(mmsNs + &quot;Url&quot;).Value,
      DisplayUrl = ir.Element(mmsNs + &quot;DisplayUrl&quot;).Value,
      Width = Int32.Parse(ir.Element(mmsNs + &quot;Width&quot;).Value),
      Height = Int32.Parse(ir.Element(mmsNs + &quot;Height&quot;).Value),
      FileSize = Int32.Parse(ir.Element(mmsNs + &quot;FileSize&quot;).Value),

      Thumb =
         (from th in ir.Descendants()
          where th.Name.Equals(mmsNs + &quot;Thumbnail&quot;)
          select new ImageResult.Thumbnail()
          {
             Url = th.Element(mmsNs + &quot;Url&quot;).Value,
             ContentType = th.Element(mmsNs + &quot;ContentType&quot;).Value,
             Width = Int32.Parse(th.Element(mmsNs + &quot;Width&quot;).Value),
             Height = Int32.Parse(th.Element(mmsNs + &quot;Height&quot;).Value),
             FileSize = Int32.Parse(th.Element(mmsNs + &quot;FileSize&quot;).Value)
          }).Single(),
   };

// Execute the LINQ query and stuff the results into our list
results = imageResults.ToList();
</pre>
<p>That does it for the requirements of this demo.  If anything in this post could use clarification, please let me know.</p>
<h4>Silver Shorts : <a href="http://github.com/justindujardin/SilverShorts" target="_blank">Get  the Code on GitHub.com</a></h4>
]]></content:encoded>
			<wfw:commentRss>http://www.justindujardin.com/blog/?feed=rss2&amp;p=724</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
