<?xml version="1.0" encoding="iso-8859-1"?><!-- generator="b2evolution/4.0.3" -->
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Web Developer - Author(s): ThatRickGuy</title>
		<link>http://blogs.lessthandot.com/index.php/WebDev/</link>
		<atom:link rel="self" type="application/rss+xml" href="http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2" />
		<description></description>
		<language>en-GB</language>
		<docs>http://blogs.law.harvard.edu/tech/rss</docs>
		<admin:generatorAgent rdf:resource="http://b2evolution.net/?v=4.0.3"/>
		<ttl>60</ttl>
				<item>
			<title>Silverlight, RIA, Datagrids, and Joins</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-ria-datagrids-and-joins</link>
			<pubDate>Tue, 03 Aug 2010 13:16:43 +0000</pubDate>			<dc:creator>ThatRickGuy</dc:creator>
			<category domain="main">Web Design, Graphics &amp; Styling</category>			<guid isPermaLink="false">918@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Lately we&#039;ve been playing around with RIA services for Silverlight. Using them we lose the use of our stack, but the speed of development with them is quite impressive. &lt;/p&gt;

&lt;h2&gt;Watch and Learn&lt;/h2&gt;
&lt;p&gt;If you are unfamiliar with RIA in Silverlight, I would recommend this video: &lt;a href=&quot;http://www.silverlight.net/learn/videos/all/net-ria-services-intro/&quot;&gt;http://www.silverlight.net/learn/videos/all/net-ria-services-intro/&lt;/a&gt;. It is a complete walk through of creating a demo from the &#039;Business Application&#039; template in Visual Studio for SL 3. If you are working in SL4, be sure to check the comments in the video for the breaking changes.&lt;/p&gt;

&lt;h2&gt;What&#039;s the Skinny?&lt;/h2&gt;
&lt;p&gt;It&#039;s pretty fancy stuff. You make an Entity Framework model, based on your database. Then when you compile, the template generates a whole bunch of code for you. First, on the server it generates a Service and a Metadata class to expose your data entities and basic CRUD functionality to the client. Then in the client, another class is generated that handles the serialization and exposing of those server classes client side. One of the most impressive things about this interaction though, is that the return objects from the server are IQueriable, not arrays. Which gives you the ability to perform LINQ and deferred execution from the client!&lt;/p&gt;

&lt;h2&gt;So Why the Fuss?&lt;/h2&gt;
&lt;p&gt;Watch the video, play around with it. I&#039;m not going to go through the whole thing here, but I will show you something I ran into.&lt;/p&gt;

&lt;p&gt;I have a relational database, in this case I am looking at the &lt;em&gt;League&lt;/em&gt; and &lt;em&gt;Player&lt;/em&gt; tables. &lt;em&gt;League&lt;/em&gt; has an OwnerPlayer_ID field that links to the &lt;em&gt;Player&lt;/em&gt; table. The problem though, by using the RIA services and bindings out of the box, is that while the League class has a .Player property, it will never be populated. And showing people that a League is owned by Player #5237 isn&#039;t nearly as helpful as showing them the Player&#039;s name. We have to make 2 changes to get this to work correctly.&lt;/p&gt;

&lt;h2&gt;Reprimanding that Lazy EF&lt;/h2&gt;
&lt;p&gt;On the server side, find your service class. It should be called something like &#039;MyApplicationDomainService1&#039; and be in the &#039;Services&#039; folder by default. In that class look for a method called &#039;GetMyObjects&#039; where MyObjects is the collection you are binding to on the client side. It should contain something like &#039;Return (Me.ObjectContext.MyObjects)&#039;. Change it to:&lt;br /&gt;
&lt;code =VB&gt;Return (Me.ObjectContext.MyObjects.Include(&quot;MyChildObject&quot;)&lt;/code&gt;&lt;br /&gt;
In my case this was the &#039;GetLeagues&#039; method and it contains: &#039;Return (Me.ObjectContext.Leagues.Include(&quot;Player&quot;))&#039;&lt;/p&gt;

&lt;p&gt;This will tell the Entity Framework model that it should Eager Load the .Player property. But before we rejoice and rebuild, wait, there&#039;s more!&lt;/p&gt;

&lt;h2&gt;Getting RIA up off the Couch&lt;/h2&gt;
&lt;p&gt;Next up, right next to the DomainService1 file should be a file called MyApplicationDomainService1.metadata. In this file we need to find the class that represents what we are querying (The &quot;MyObject&quot; from the previous step). In that class you should see the property you want to load (The &quot;MyChildObject&quot; from above). On this property, you want to prepend the &amp;lt;Include()&amp;gt; attribute. This will tell the RIA services that it should include this property in the serialization and transmission of the query results. &lt;/p&gt;

&lt;p&gt;In my case of League and Owner Player, it looks like this:&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vb&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vb&quot; id=&quot;cb51255&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #2222dd;&quot;&gt;Friend&lt;/span&gt; NotInheritable Class LeagueMetadata&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #00aa00;&quot;&gt;&#039;...&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Include&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Display&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;AutoGenerateField:=&lt;span style=&quot;color: #2222dd;&quot;&gt;False&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2222dd;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #2222dd;&quot;&gt;Property&lt;/span&gt; Player &lt;span style=&quot;color: #2222dd;&quot;&gt;As&lt;/span&gt; Player&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #00aa00;&quot;&gt;&#039;...&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2222dd;&quot;&gt;End&lt;/span&gt; Class&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb78134&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;


&lt;h2&gt;And the Grid?&lt;/h2&gt;
&lt;p&gt;Now that the EF is loading the data we want, and the RIA services are returning the data we want, all we have to do is bind it! And this is the easiest part. It is just like they show in the video, with one minor change. Instead of just binding on the primary object&#039;s property, we use dot notation to get at the child object&#039;s property. Shown here as the &quot;Player.Name&quot; binding&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;xml&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;xml&quot; id=&quot;cb22806&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;sdk:DataGrid&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x:Name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;grdLeagues&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Margin&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;4,20,4,4&amp;quot;&lt;/span&gt; Grid.&lt;span style=&quot;color: #000066;&quot;&gt;Row&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;ItemsSource&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;{Binding ElementName=LeagueDomainDataSource, Path=Data}&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;AutoGenerateColumns&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;False&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;sdk:DataGrid&lt;/span&gt;.Columns&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;sdk:DataGridTextColumn&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Binding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;{Binding Path=Name}&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Header&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Name&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;sdk:DataGridTextColumn&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Binding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;{Binding Path=Player.Name, Mode=OneWay}&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Header&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Organizer&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;sdk:DataGridTextColumn&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Binding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;{Binding Path=Province}&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Header&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;State&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;sdk:DataGridTextColumn&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Binding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;{Binding Path=City}&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Header&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;City&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;sdk:DataGridTextColumn&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Binding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;{Binding Path=LGS}&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Header&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Game Store&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/sdk:DataGrid&lt;/span&gt;.Columns&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/sdk:DataGrid&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb53527&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;-Rick&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-ria-datagrids-and-joins&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Lately we've been playing around with RIA services for Silverlight. Using them we lose the use of our stack, but the speed of development with them is quite impressive. </p>

<h2>Watch and Learn</h2>
<p>If you are unfamiliar with RIA in Silverlight, I would recommend this video: <a href="http://www.silverlight.net/learn/videos/all/net-ria-services-intro/">http://www.silverlight.net/learn/videos/all/net-ria-services-intro/</a>. It is a complete walk through of creating a demo from the 'Business Application' template in Visual Studio for SL 3. If you are working in SL4, be sure to check the comments in the video for the breaking changes.</p>

<h2>What's the Skinny?</h2>
<p>It's pretty fancy stuff. You make an Entity Framework model, based on your database. Then when you compile, the template generates a whole bunch of code for you. First, on the server it generates a Service and a Metadata class to expose your data entities and basic CRUD functionality to the client. Then in the client, another class is generated that handles the serialization and exposing of those server classes client side. One of the most impressive things about this interaction though, is that the return objects from the server are IQueriable, not arrays. Which gives you the ability to perform LINQ and deferred execution from the client!</p>

<h2>So Why the Fuss?</h2>
<p>Watch the video, play around with it. I'm not going to go through the whole thing here, but I will show you something I ran into.</p>

<p>I have a relational database, in this case I am looking at the <em>League</em> and <em>Player</em> tables. <em>League</em> has an OwnerPlayer_ID field that links to the <em>Player</em> table. The problem though, by using the RIA services and bindings out of the box, is that while the League class has a .Player property, it will never be populated. And showing people that a League is owned by Player #5237 isn't nearly as helpful as showing them the Player's name. We have to make 2 changes to get this to work correctly.</p>

<h2>Reprimanding that Lazy EF</h2>
<p>On the server side, find your service class. It should be called something like 'MyApplicationDomainService1' and be in the 'Services' folder by default. In that class look for a method called 'GetMyObjects' where MyObjects is the collection you are binding to on the client side. It should contain something like 'Return (Me.ObjectContext.MyObjects)'. Change it to:<br />
<code =VB>Return (Me.ObjectContext.MyObjects.Include("MyChildObject")</code><br />
In my case this was the 'GetLeagues' method and it contains: 'Return (Me.ObjectContext.Leagues.Include("Player"))'</p>

<p>This will tell the Entity Framework model that it should Eager Load the .Player property. But before we rejoice and rebuild, wait, there's more!</p>

<h2>Getting RIA up off the Couch</h2>
<p>Next up, right next to the DomainService1 file should be a file called MyApplicationDomainService1.metadata. In this file we need to find the class that represents what we are querying (The "MyObject" from the previous step). In that class you should see the property you want to load (The "MyChildObject" from above). On this property, you want to prepend the &lt;Include()&gt; attribute. This will tell the RIA services that it should include this property in the serialization and transmission of the query results. </p>

<p>In my case of League and Owner Player, it looks like this:</p>
<div class="codebox"><div class="codeheader"><span>vb</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb68790'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb68790','cb39826'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vb" id="cb68790" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #2222dd;">Friend</span> NotInheritable Class LeagueMetadata</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00aa00;">'...</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &lt;Include<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>&gt;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &lt;Display<span style="color: #66cc66;">&#40;</span>AutoGenerateField:=<span style="color: #2222dd;">False</span><span style="color: #66cc66;">&#41;</span>&gt;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #2222dd;">Public</span> <span style="color: #2222dd;">Property</span> Player <span style="color: #2222dd;">As</span> Player</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00aa00;">'...</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #2222dd;">End</span> Class</li></ol></div><div id="cb39826" style="display: none; color: red;"></div></div></div>


<h2>And the Grid?</h2>
<p>Now that the EF is loading the data we want, and the RIA services are returning the data we want, all we have to do is bind it! And this is the easiest part. It is just like they show in the video, with one minor change. Instead of just binding on the primary object's property, we use dot notation to get at the child object's property. Shown here as the "Player.Name" binding</p>

<div class="codebox"><div class="codeheader"><span>xml</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb88192'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb88192','cb38520'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="xml" id="cb88192" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;sdk:DataGrid</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;grdLeagues&quot;</span> <span style="color: #000066;">Margin</span>=<span style="color: #ff0000;">&quot;4,20,4,4&quot;</span> Grid.<span style="color: #000066;">Row</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">ItemsSource</span>=<span style="color: #ff0000;">&quot;{Binding ElementName=LeagueDomainDataSource, Path=Data}&quot;</span> <span style="color: #000066;">AutoGenerateColumns</span>=<span style="color: #ff0000;">&quot;False&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;sdk:DataGrid</span>.Columns<span style="font-weight: bold; color: black;">&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;sdk:DataGridTextColumn</span> <span style="color: #000066;">Binding</span>=<span style="color: #ff0000;">&quot;{Binding Path=Name}&quot;</span> <span style="color: #000066;">Header</span>=<span style="color: #ff0000;">&quot;Name&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;sdk:DataGridTextColumn</span> <span style="color: #000066;">Binding</span>=<span style="color: #ff0000;">&quot;{Binding Path=Player.Name, Mode=OneWay}&quot;</span> <span style="color: #000066;">Header</span>=<span style="color: #ff0000;">&quot;Organizer&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;sdk:DataGridTextColumn</span> <span style="color: #000066;">Binding</span>=<span style="color: #ff0000;">&quot;{Binding Path=Province}&quot;</span> <span style="color: #000066;">Header</span>=<span style="color: #ff0000;">&quot;State&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;sdk:DataGridTextColumn</span> <span style="color: #000066;">Binding</span>=<span style="color: #ff0000;">&quot;{Binding Path=City}&quot;</span> <span style="color: #000066;">Header</span>=<span style="color: #ff0000;">&quot;City&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;sdk:DataGridTextColumn</span> <span style="color: #000066;">Binding</span>=<span style="color: #ff0000;">&quot;{Binding Path=LGS}&quot;</span> <span style="color: #000066;">Header</span>=<span style="color: #ff0000;">&quot;Game Store&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/sdk:DataGrid</span>.Columns<span style="font-weight: bold; color: black;">&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/sdk:DataGrid<span style="font-weight: bold; color: black;">&gt;</span></span></span></li></ol></div><div id="cb38520" style="display: none; color: red;"></div></div></div>

<p>-Rick</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-ria-datagrids-and-joins">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-ria-datagrids-and-joins#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=918</wfw:commentRss>
		</item>
				<item>
			<title>Solving Sudoku in Silverlight</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/solving-sudoku-in-silverlight</link>
			<pubDate>Fri, 09 Apr 2010 14:37:24 +0000</pubDate>			<dc:creator>ThatRickGuy</dc:creator>
			<category domain="main">Web Design, Graphics &amp; Styling</category>			<guid isPermaLink="false">719@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Long ago I came across  &lt;a href=&quot;http://oldschooldotnet.blogspot.com/2009/03/sudoku-in-silverlight.html&quot;&gt;OldSchoolDotNet&#039;s Silverlight Sudoku client&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;It&#039;s a great interface to a classic brain game. I especially enjoy the &quot;Hard&quot; difficulty level as it is pretty consistently solvable with out reverting to guessing. The &quot;Expert&quot; level though requires you to guess. And as a logic guy, I hate guessing. &lt;/p&gt;

&lt;p&gt;Not quite so long ago, in the &lt;a href=&quot;http://forum.lessthandot.com/viewforum.php?f=102&quot;&gt;Programmer&#039;s Puzzles forum&lt;/a&gt;, we had a &quot;Follow the Clues&quot; challenge. I approached this problem just as I do Sudoku. Writing out the possibilities and eliminating the incorrect answers as I went through the rules list over and over. But just solving the problem isn&#039;t enough, the goal, seeing as how most of us are coders of one sort or another, is to write a software solution. So I put together a system that given an array of possibilities and a set of rules, would iterate through the rules and grid filtering out all impossible answers till only the correct ones existed.&lt;/p&gt;

&lt;p&gt;It was a fun project, but it made me think. I was solving that problem in roughly the same way I approach Sudoku. So why not improve my solution to be able to solve Sudoku challenges as well?&lt;/p&gt;

&lt;p&gt;There are a set number of rules to Sudoku, and a number of patterns that we can see that make solving them easier. So it was just a matter of coding out these rules and inferences, and applying them to a 3-dimensional array of Boolean values (column, row, index).&lt;/p&gt;

&lt;p&gt;My initial attempts worked perfectly for anything up to the &quot;Hard&quot; level from OldSchoolDotNet&#039;s Sudoku client. But on the &quot;Expert&quot; level, it would get through all of the known steps and then stop. Adam came up with an idea for how to handling the guesses in a tree like branching method. And after a few attempts, I managed to come up with a decent solution.&lt;/p&gt;

&lt;p&gt;It isn&#039;t cleaned up at all, but if you&#039;re stuck on a sudoku puzzle, it may be of use to you. Each click of the &quot;Apply Rules&quot; button will perform one pass of each rule (horizontal, vertical, block) on each square in the board. With out guessing, most puzzles can be solved in about 6-10 passes. &lt;/p&gt;

&lt;p&gt;With guessing, it&#039;ll take a while. My last solving of an &quot;Expert&quot; puzzle wound up fielding over 18,000 branches. As the number of active branches increases, performance will degrade. But once you get through the bulk of them, the performance will increase as more and more branches are closed.&lt;/p&gt;

&lt;p&gt;So, if you&#039;re a Sudoku fan, check it out &lt;a href=&quot;http://ringdev.com.web10.reliabledomainspace.com/code/sodukusolver/index.html&quot;&gt;Here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Code is available &lt;a href=&quot;http://ringdev.com.web10.reliabledomainspace.com/code/sodukusolver/SodukuSolver.zip&quot;&gt;Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;-Rick&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/solving-sudoku-in-silverlight&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Long ago I came across  <a href="http://oldschooldotnet.blogspot.com/2009/03/sudoku-in-silverlight.html">OldSchoolDotNet's Silverlight Sudoku client</a>. </p>

<p>It's a great interface to a classic brain game. I especially enjoy the "Hard" difficulty level as it is pretty consistently solvable with out reverting to guessing. The "Expert" level though requires you to guess. And as a logic guy, I hate guessing. </p>

<p>Not quite so long ago, in the <a href="http://forum.lessthandot.com/viewforum.php?f=102">Programmer's Puzzles forum</a>, we had a "Follow the Clues" challenge. I approached this problem just as I do Sudoku. Writing out the possibilities and eliminating the incorrect answers as I went through the rules list over and over. But just solving the problem isn't enough, the goal, seeing as how most of us are coders of one sort or another, is to write a software solution. So I put together a system that given an array of possibilities and a set of rules, would iterate through the rules and grid filtering out all impossible answers till only the correct ones existed.</p>

<p>It was a fun project, but it made me think. I was solving that problem in roughly the same way I approach Sudoku. So why not improve my solution to be able to solve Sudoku challenges as well?</p>

<p>There are a set number of rules to Sudoku, and a number of patterns that we can see that make solving them easier. So it was just a matter of coding out these rules and inferences, and applying them to a 3-dimensional array of Boolean values (column, row, index).</p>

<p>My initial attempts worked perfectly for anything up to the "Hard" level from OldSchoolDotNet's Sudoku client. But on the "Expert" level, it would get through all of the known steps and then stop. Adam came up with an idea for how to handling the guesses in a tree like branching method. And after a few attempts, I managed to come up with a decent solution.</p>

<p>It isn't cleaned up at all, but if you're stuck on a sudoku puzzle, it may be of use to you. Each click of the "Apply Rules" button will perform one pass of each rule (horizontal, vertical, block) on each square in the board. With out guessing, most puzzles can be solved in about 6-10 passes. </p>

<p>With guessing, it'll take a while. My last solving of an "Expert" puzzle wound up fielding over 18,000 branches. As the number of active branches increases, performance will degrade. But once you get through the bulk of them, the performance will increase as more and more branches are closed.</p>

<p>So, if you're a Sudoku fan, check it out <a href="http://ringdev.com.web10.reliabledomainspace.com/code/sodukusolver/index.html">Here</a>.</p>

<p>Code is available <a href="http://ringdev.com.web10.reliabledomainspace.com/code/sodukusolver/SodukuSolver.zip">Here</a></p>

<p>-Rick</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/solving-sudoku-in-silverlight">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/solving-sudoku-in-silverlight#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=719</wfw:commentRss>
		</item>
				<item>
			<title>Detecting Property Changes in an Observable Collection</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/detecting-property-changes-in-an-observa</link>
			<pubDate>Wed, 07 Apr 2010 19:16:01 +0000</pubDate>			<dc:creator>ThatRickGuy</dc:creator>
			<category domain="main">Web Design, Graphics &amp; Styling</category>			<guid isPermaLink="false">804@http://blogs.lessthandot.com/</guid>
						<description>&lt;h3&gt;Work, Work, Work&lt;/h3&gt;
&lt;p&gt;I was working on a new interface this week for a rather complex item selection system. It deals with hierarchies and mandatory selections, multi-selects and single-selects. In order to make it easier for users to see what items were already selected, there was also a list of just the selected items.&lt;/p&gt;

&lt;h3&gt;Oh ObservableCollection, I See You!&lt;/h3&gt;
&lt;p&gt;I toyed around with a few different options, and debated some of them out with Adam, and finally decided to run with binding and an Observable Collection.&lt;/p&gt;

&lt;h3&gt;Everything is better with LINQ&lt;/h3&gt;
&lt;p&gt;One of the great things about observable collections is that you can pass them around like candy, make a change to it from any number of locations, and it will update all of the controls bound to it. Mix in a little LINQ and you&#039;ve got some awesome functionality with very little code.&lt;/p&gt;

&lt;h3&gt;What Do You Mean CollectionChanged Doesn&#039;t Fire?&lt;/h3&gt;
&lt;p&gt;One of the things I needed to do though, was to detect when the user selected an item from the collection. When the IsChecked flag was flipped, I needed to go to the server to get any child items. But the Observable Collection does not expose property changed events, which started me down this path. &lt;/p&gt;

&lt;h3&gt;The User Interface&lt;/h3&gt;
&lt;p&gt;For this demo app, the UI is pretty simple. I just have two list boxes. Each list box has a DataTemplate with a CheckBox in it. The CheckBox has its Content bound to the &quot;Text&quot; member and IsChecked is bound to a like named member. The IsChecked property is also set to TwoWay mode. This means that when the user changes its checked state, it will update the underlying collection.&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;xaml&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;xaml&quot; id=&quot;cb40411&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&amp;lt;ListBox x:Name=&amp;quot;lst1&amp;quot; Grid.Column=&amp;quot;0&amp;quot; &amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;ListBox.ItemTemplate &amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DataTemplate&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;CheckBox Content=&amp;quot;{Binding Text}&amp;quot; IsChecked=&amp;quot;{Binding IsChecked, Mode=TwoWay}&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/DataTemplate&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/ListBox.ItemTemplate&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/ListBox&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb23491&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3&gt;On to the Items&lt;/h3&gt;
&lt;p&gt;For the most part the Item class just contains our properties, but we have to beef it up just a bit. First, it needs &lt;code class=&quot;codespan&quot;&gt;Implements System.ComponentModel.INotifyPropertyChanged&lt;/code&gt;. INotifyPropertyChanged will create a public event called &quot;PropertyChanged&quot;. In order to save ourselves a bit of repeating code, we can make a method called &lt;em&gt;onPropertyChanged&lt;/em&gt; that raises that event for us:&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vb.net&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vb.net&quot; id=&quot;cb92356&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; onPropertyChanged&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; PropertyName &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RaiseEvent PropertyChanged&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;, &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; System.&lt;span style=&quot;color: #000000;&quot;&gt;ComponentModel&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;PropertyChangedEventArgs&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;PropertyName&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb10325&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt; Also in the item class we need to tweak the properties a bit. For instance:&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vb.net&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vb.net&quot; id=&quot;cb93118&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; _IsChecked &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Boolean&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; IsChecked&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Boolean&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return _IsChecked&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Set&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; value &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Boolean&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If value &amp;lt;&amp;gt; _IsChecked &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _IsChecked = value&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; onPropertyChanged&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;IsChecked&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Set&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb33078&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note that we are only calling the onPropertyChanged event when the value has indeed changed. Also, ensure that the underlying value has changed BEFORE you call the onPropertyChanged, otherwise you&#039;ll wind up with some really interesting behavior.&lt;/p&gt;

&lt;h3&gt;The Collection&lt;/h3&gt;
&lt;p&gt;The Observable collection doesn&#039;t expose the PropertyChanged event by default, so we have to bubble it up ourselves. That means we need to make a new class that inherits from ObservableCollection. In order to get a handler on the Items PropertyChanged events, we need to override the InsertItem and RemoveItem methods. Inside them we Add and Remove an event handler for the Property Changed event. And in the procedure that handles that event, all we need to do is to raise our new public event.&lt;/p&gt;

&lt;h3&gt;Back to the MainPage&lt;/h3&gt;
&lt;p&gt;In the code of the main page, we need an instance of the collection, using the WithEvents keyword will make it exceptionally easy to attach to our events. In the constructor, we can set the ItemSource of both of our list boxes to that collection. And if you check the objects/events drop downs, you should see that our collection now exposes both a CollectionChanged and ItemPropertyChanged event. Put a message box or break point in each and fire up the app.&lt;/p&gt;

&lt;h3&gt;Running&lt;/h3&gt;
&lt;p&gt;When you run it, you should see a number of identical items in each list box. When you click on the check boxes of either list, you should see the ItemPropertyChanged event fire, after which both list boxes should reflect the new value in the collection.&lt;/p&gt;

&lt;h3&gt;Show me the Demo&lt;/h3&gt;
&lt;p&gt;
        &lt;object data=&quot;data:application/x-silverlight-2,&quot; type=&quot;application/x-silverlight-2&quot; width=&quot;100%&quot; height=&quot;150px&quot;&gt;
		  &lt;param name=&quot;source&quot; value=&quot;http://ringdev.com.web10.reliabledomainspace.com/code/bindingdemo/trainingdemo2.xap&quot; /&gt; &lt;br /&gt;
		  &lt;param name=&quot;onError&quot; value=&quot;onSilverlightError&quot; /&gt;&lt;br /&gt;
		  &lt;param name=&quot;background&quot; value=&quot;white&quot; /&gt;&lt;br /&gt;
		  &lt;param name=&quot;minRuntimeVersion&quot; value=&quot;3.0.40624.0&quot; /&gt;&lt;br /&gt;
		  &lt;param name=&quot;autoUpgrade&quot; value=&quot;true&quot; /&gt;&lt;br /&gt;
		  &lt;a href=&quot;http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=3.0.40624.0&quot; style=&quot;text-decoration:none&quot;&gt;&lt;br /&gt;
 			  &lt;img src=&quot;http://go.microsoft.com/fwlink/?LinkId=108181&quot; alt=&quot;Get Microsoft Silverlight&quot; style=&quot;border-style:none&quot; /&gt;&lt;br /&gt;
		  &lt;/a&gt;&lt;br /&gt;
	    &lt;/object&gt;&lt;/p&gt;

&lt;h3&gt;Show Me the Code&lt;/h3&gt;
&lt;p&gt;Working VS 2008 solution can be downloaded from &lt;a href=&quot;http://ringdev.com.web10.reliabledomainspace.com/code/bindingdemo/trainingdemo2.zip&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/detecting-property-changes-in-an-observa&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<h3>Work, Work, Work</h3>
<p>I was working on a new interface this week for a rather complex item selection system. It deals with hierarchies and mandatory selections, multi-selects and single-selects. In order to make it easier for users to see what items were already selected, there was also a list of just the selected items.</p>

<h3>Oh ObservableCollection, I See You!</h3>
<p>I toyed around with a few different options, and debated some of them out with Adam, and finally decided to run with binding and an Observable Collection.</p>

<h3>Everything is better with LINQ</h3>
<p>One of the great things about observable collections is that you can pass them around like candy, make a change to it from any number of locations, and it will update all of the controls bound to it. Mix in a little LINQ and you've got some awesome functionality with very little code.</p>

<h3>What Do You Mean CollectionChanged Doesn't Fire?</h3>
<p>One of the things I needed to do though, was to detect when the user selected an item from the collection. When the IsChecked flag was flipped, I needed to go to the server to get any child items. But the Observable Collection does not expose property changed events, which started me down this path. </p>

<h3>The User Interface</h3>
<p>For this demo app, the UI is pretty simple. I just have two list boxes. Each list box has a DataTemplate with a CheckBox in it. The CheckBox has its Content bound to the "Text" member and IsChecked is bound to a like named member. The IsChecked property is also set to TwoWay mode. This means that when the user changes its checked state, it will update the underlying collection.</p>
<div class="codebox"><div class="codeheader"><span>xaml</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb97919'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb97919','cb83663'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="xaml" id="cb97919" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">&lt;ListBox x:Name=&quot;lst1&quot; Grid.Column=&quot;0&quot; &gt;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ListBox.ItemTemplate &gt;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;DataTemplate&gt;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;CheckBox Content=&quot;{Binding Text}&quot; IsChecked=&quot;{Binding IsChecked, Mode=TwoWay}&quot; /&gt;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/DataTemplate&gt;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/ListBox.ItemTemplate&gt;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/ListBox&gt;</li></ol></div><div id="cb83663" style="display: none; color: red;"></div></div></div>

<h3>On to the Items</h3>
<p>For the most part the Item class just contains our properties, but we have to beef it up just a bit. First, it needs <code class="codespan">Implements System.ComponentModel.INotifyPropertyChanged</code>. INotifyPropertyChanged will create a public event called "PropertyChanged". In order to save ourselves a bit of repeating code, we can make a method called <em>onPropertyChanged</em> that raises that event for us:</p>
<div class="codebox"><div class="codeheader"><span>vb.net</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb57862'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb57862','cb35278'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vb.net" id="cb57862" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">Private</span> <span style="color: #0600FF;">Sub</span> onPropertyChanged<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> PropertyName <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RaiseEvent PropertyChanged<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Me</span>, <span style="color: #0600FF;">New</span> System.<span style="color: #000000;">ComponentModel</span>.<span style="color: #000000;">PropertyChangedEventArgs</span><span style="color: #000000;">&#40;</span>PropertyName<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li></ol></div><div id="cb35278" style="display: none; color: red;"></div></div></div>
<p> Also in the item class we need to tweak the properties a bit. For instance:</p>
<div class="codebox"><div class="codeheader"><span>vb.net</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb12733'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb12733','cb23140'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vb.net" id="cb12733" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">Private</span> _IsChecked <span style="color: #0600FF;">As</span> Boolean</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Property</span> IsChecked<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> Boolean</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return _IsChecked</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Set</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> value <span style="color: #0600FF;">As</span> Boolean<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If value &lt;&gt; _IsChecked <span style="color: #0600FF;">Then</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _IsChecked = value</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onPropertyChanged<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;IsChecked&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Set</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Property</span></li></ol></div><div id="cb23140" style="display: none; color: red;"></div></div></div>
<p>Note that we are only calling the onPropertyChanged event when the value has indeed changed. Also, ensure that the underlying value has changed BEFORE you call the onPropertyChanged, otherwise you'll wind up with some really interesting behavior.</p>

<h3>The Collection</h3>
<p>The Observable collection doesn't expose the PropertyChanged event by default, so we have to bubble it up ourselves. That means we need to make a new class that inherits from ObservableCollection. In order to get a handler on the Items PropertyChanged events, we need to override the InsertItem and RemoveItem methods. Inside them we Add and Remove an event handler for the Property Changed event. And in the procedure that handles that event, all we need to do is to raise our new public event.</p>

<h3>Back to the MainPage</h3>
<p>In the code of the main page, we need an instance of the collection, using the WithEvents keyword will make it exceptionally easy to attach to our events. In the constructor, we can set the ItemSource of both of our list boxes to that collection. And if you check the objects/events drop downs, you should see that our collection now exposes both a CollectionChanged and ItemPropertyChanged event. Put a message box or break point in each and fire up the app.</p>

<h3>Running</h3>
<p>When you run it, you should see a number of identical items in each list box. When you click on the check boxes of either list, you should see the ItemPropertyChanged event fire, after which both list boxes should reflect the new value in the collection.</p>

<h3>Show me the Demo</h3>
<p>
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="150px">
		  <param name="source" value="http://ringdev.com.web10.reliabledomainspace.com/code/bindingdemo/trainingdemo2.xap" /> <br />
		  <param name="onError" value="onSilverlightError" /><br />
		  <param name="background" value="white" /><br />
		  <param name="minRuntimeVersion" value="3.0.40624.0" /><br />
		  <param name="autoUpgrade" value="true" /><br />
		  <a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=3.0.40624.0" style="text-decoration:none"><br />
 			  <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none" /><br />
		  </a><br />
	    </object></p>

<h3>Show Me the Code</h3>
<p>Working VS 2008 solution can be downloaded from <a href="http://ringdev.com.web10.reliabledomainspace.com/code/bindingdemo/trainingdemo2.zip">here</a>.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/detecting-property-changes-in-an-observa">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/detecting-property-changes-in-an-observa#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=804</wfw:commentRss>
		</item>
				<item>
			<title>Binding to Custom Properties in Silverlight</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/binding-to-custom-members-in-silverlight</link>
			<pubDate>Mon, 22 Mar 2010 12:52:17 +0000</pubDate>			<dc:creator>ThatRickGuy</dc:creator>
			<category domain="main">Web Design, Graphics &amp; Styling</category>			<guid isPermaLink="false">692@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;The Binding system is Silverlight is pretty cool. It lets us easily bind property values of UI Elements to all sorts of good stuff. But, if you want to create your own custom bind-able properties, it takes a bit more effort than the usual Property=&quot;{Binding=Field}&quot; in XAML.&lt;/p&gt;

&lt;p&gt;For example, I have a datagrid. One of the columns in that data grid holds a control that displays and icon and a tool tip based on the content of some data.&lt;/p&gt;

&lt;p&gt;So you would start with a control like this:&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vb.net&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vb.net&quot; id=&quot;cb69432&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;Imports System&lt;br /&gt;Imports System.&lt;span style=&quot;color: #000000;&quot;&gt;Windows&lt;/span&gt;&lt;br /&gt;Imports System.&lt;span style=&quot;color: #000000;&quot;&gt;Windows&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Controls&lt;/span&gt;&lt;br /&gt;Imports System.&lt;span style=&quot;color: #000000;&quot;&gt;Windows&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Media&lt;/span&gt;&lt;br /&gt;Imports System.&lt;span style=&quot;color: #000000;&quot;&gt;Windows&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Media&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Animation&lt;/span&gt;&lt;br /&gt;Imports System.&lt;span style=&quot;color: #000000;&quot;&gt;Windows&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Shapes&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;Partial &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt; CommentIndicator &lt;br /&gt;&amp;nbsp; &amp;nbsp; Inherits UserControl&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039; Required to initialize variables&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; InitializeComponent&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; Overrides &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt; ToString&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return MyToolTip&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; MyToolTip&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; o &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Object = &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;GetValue&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ToolTipService.&lt;span style=&quot;color: #000000;&quot;&gt;ToolTipProperty&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; sReturn &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #0600FF;&quot;&gt;Empty&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If Not o &lt;span style=&quot;color: #0600FF;&quot;&gt;Is&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sReturn = o.&lt;span style=&quot;color: #000000;&quot;&gt;ToString&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return sReturn&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Set&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; value &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;SetValue&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ToolTipService.&lt;span style=&quot;color: #000000;&quot;&gt;ToolTipProperty&lt;/span&gt;, value&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Set&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb45349&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then, in the XAML of the data grid:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;text&quot; id=&quot;cb59431&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&amp;lt;data:DataGrid.Columns&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;data:DataGridTextColumn x:Name=&amp;quot;dgcOrderNumber&amp;quot; CanUserReorder=&amp;quot;False&amp;quot; CanUserSort=&amp;quot;True&amp;quot; Header=&amp;quot;Order Number&amp;quot; SortMemberPath=&amp;quot;OrderNumber&amp;quot; Binding=&amp;quot;{Binding OrderNumber}&amp;quot; Width=&amp;quot;118&amp;quot;/&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;data:DataGridTextColumn CanUserReorder=&amp;quot;False&amp;quot; CanUserSort=&amp;quot;True&amp;quot; Header=&amp;quot;Request Date&amp;quot; SortMemberPath=&amp;quot;RequestDate&amp;quot; Binding=&amp;quot;{Binding RequestDate, Converter={StaticResource DateConverter}}&amp;quot; Width=&amp;quot;110&amp;quot;/&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;data:DataGridTextColumn CanUserReorder=&amp;quot;False&amp;quot; CanUserSort=&amp;quot;True&amp;quot; Header=&amp;quot;Status&amp;quot; SortMemberPath=&amp;quot;Status&amp;quot; Binding=&amp;quot;{Binding Status}&amp;quot; Width=&amp;quot;100&amp;quot;/&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;data:DataGridTemplateColumn CanUserSort=&amp;quot;True&amp;quot; CanUserReorder=&amp;quot;False&amp;quot; IsReadOnly=&amp;quot;True&amp;quot; SortMemberPath=&amp;quot;Comment&amp;quot; Width=&amp;quot;26&amp;quot; &amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;data:DataGridTemplateColumn.CellTemplate&amp;gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DataTemplate&amp;gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Local:CommentIndicator MyToolTip=&amp;quot;{Binding Comment}&amp;quot; &amp;nbsp;Width=&amp;quot;15&amp;quot; Height=&amp;quot;17&amp;quot; &amp;nbsp;/&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/DataTemplate&amp;gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/data:DataGridTemplateColumn.CellTemplate&amp;gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/data:DataGridTemplateColumn&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;lt;/data:DataGrid.Columns&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb82872&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Everything looks good, but running the app will pop one of Silverlight completely unenlightening errors.&lt;/p&gt;

&lt;p&gt;What we need to do is to set up MyToolTip as a dependency property. We just have to add a bit of code to the custom control:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vb.net&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vb.net&quot; id=&quot;cb36631&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; Shared ReadOnly _MyToolTipProperty &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; DependencyProperty = DependencyProperty.&lt;span style=&quot;color: #000000;&quot;&gt;Register&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;MyToolTip&amp;quot;&lt;/span&gt;, GetType&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, GetType&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;CommentIndicator&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; PropertyMetadata&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; PropertyChangedCallback&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;AddressOf MyToolTipCallback&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; Shared &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; MyToolTipCallback&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; d &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; DependencyObject, &lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; e &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; DependencyPropertyChangedEventArgs&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; d.&lt;span style=&quot;color: #000000;&quot;&gt;SetValue&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ToolTipService.&lt;span style=&quot;color: #000000;&quot;&gt;ToolTipProperty&lt;/span&gt;, e.&lt;span style=&quot;color: #000000;&quot;&gt;NewValue&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb95569&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And that fixes that. Why this wasn&#039;t just handled behind the scenes I don&#039;t know. I&#039;ve heard that they have done a lot of work on the Binding system for SL4, so maybe this will not be a requirement once the next update rolls out. &lt;/p&gt;

&lt;p&gt;-Rick&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/binding-to-custom-members-in-silverlight&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>The Binding system is Silverlight is pretty cool. It lets us easily bind property values of UI Elements to all sorts of good stuff. But, if you want to create your own custom bind-able properties, it takes a bit more effort than the usual Property="{Binding=Field}" in XAML.</p>

<p>For example, I have a datagrid. One of the columns in that data grid holds a control that displays and icon and a tool tip based on the content of some data.</p>

<p>So you would start with a control like this:</p>
<div class="codebox"><div class="codeheader"><span>vb.net</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb95903'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb95903','cb65706'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vb.net" id="cb95903" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">Imports System</li><li style="" class="li2">Imports System.<span style="color: #000000;">Windows</span></li><li style="" class="li1">Imports System.<span style="color: #000000;">Windows</span>.<span style="color: #000000;">Controls</span></li><li style="" class="li2">Imports System.<span style="color: #000000;">Windows</span>.<span style="color: #000000;">Media</span></li><li style="" class="li1">Imports System.<span style="color: #000000;">Windows</span>.<span style="color: #000000;">Media</span>.<span style="color: #000000;">Animation</span></li><li style="" class="li2">Imports System.<span style="color: #000000;">Windows</span>.<span style="color: #000000;">Shapes</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">Partial <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Class</span> CommentIndicator </li><li style="" class="li1">&nbsp; &nbsp; Inherits UserControl</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Sub</span> <span style="color: #0600FF;">New</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">' Required to initialize variables</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; InitializeComponent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> Overrides <span style="color: #0600FF;">Function</span> ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; Return MyToolTip</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Property</span> MyToolTip<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> o <span style="color: #0600FF;">As</span> Object = <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">GetValue</span><span style="color: #000000;">&#40;</span>ToolTipService.<span style="color: #000000;">ToolTipProperty</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> sReturn <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span> = <span style="color: #0600FF;">String</span>.<span style="color: #0600FF;">Empty</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If Not o <span style="color: #0600FF;">Is</span> <span style="color: #0600FF;">Nothing</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sReturn = o.<span style="color: #000000;">ToString</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return sReturn</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Get</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Set</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> value <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">SetValue</span><span style="color: #000000;">&#40;</span>ToolTipService.<span style="color: #000000;">ToolTipProperty</span>, value<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Set</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Property</span></li><li style="" class="li1"><span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></li></ol></div><div id="cb65706" style="display: none; color: red;"></div></div></div>

<p>Then, in the XAML of the data grid:</p>

<div class="codebox"><div class="codeheader"><span>text</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb45753'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb45753','cb17429'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="text" id="cb45753" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">&lt;data:DataGrid.Columns&gt;</li><li style="" class="li2">&nbsp; &nbsp; &lt;data:DataGridTextColumn x:Name=&quot;dgcOrderNumber&quot; CanUserReorder=&quot;False&quot; CanUserSort=&quot;True&quot; Header=&quot;Order Number&quot; SortMemberPath=&quot;OrderNumber&quot; Binding=&quot;{Binding OrderNumber}&quot; Width=&quot;118&quot;/&gt;</li><li style="" class="li1">&nbsp; &nbsp; &lt;data:DataGridTextColumn CanUserReorder=&quot;False&quot; CanUserSort=&quot;True&quot; Header=&quot;Request Date&quot; SortMemberPath=&quot;RequestDate&quot; Binding=&quot;{Binding RequestDate, Converter={StaticResource DateConverter}}&quot; Width=&quot;110&quot;/&gt;</li><li style="" class="li2">&nbsp; &nbsp; &lt;data:DataGridTextColumn CanUserReorder=&quot;False&quot; CanUserSort=&quot;True&quot; Header=&quot;Status&quot; SortMemberPath=&quot;Status&quot; Binding=&quot;{Binding Status}&quot; Width=&quot;100&quot;/&gt;</li><li style="" class="li1">&nbsp; &nbsp; &lt;data:DataGridTemplateColumn CanUserSort=&quot;True&quot; CanUserReorder=&quot;False&quot; IsReadOnly=&quot;True&quot; SortMemberPath=&quot;Comment&quot; Width=&quot;26&quot; &gt;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &lt;data:DataGridTemplateColumn.CellTemplate&gt; </li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;DataTemplate&gt; </li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Local:CommentIndicator MyToolTip=&quot;{Binding Comment}&quot; &nbsp;Width=&quot;15&quot; Height=&quot;17&quot; &nbsp;/&gt;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/DataTemplate&gt; </li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/data:DataGridTemplateColumn.CellTemplate&gt; </li><li style="" class="li1">&nbsp; &nbsp; &lt;/data:DataGridTemplateColumn&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </li><li style="" class="li2">&lt;/data:DataGrid.Columns&gt;</li></ol></div><div id="cb17429" style="display: none; color: red;"></div></div></div>

<p>Everything looks good, but running the app will pop one of Silverlight completely unenlightening errors.</p>

<p>What we need to do is to set up MyToolTip as a dependency property. We just have to add a bit of code to the custom control:</p>

<div class="codebox"><div class="codeheader"><span>vb.net</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb47081'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb47081','cb4804'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vb.net" id="cb47081" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">Public</span> Shared ReadOnly _MyToolTipProperty <span style="color: #0600FF;">As</span> DependencyProperty = DependencyProperty.<span style="color: #000000;">Register</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;MyToolTip&quot;</span>, GetType<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">String</span><span style="color: #000000;">&#41;</span>, GetType<span style="color: #000000;">&#40;</span>CommentIndicator<span style="color: #000000;">&#41;</span>, <span style="color: #0600FF;">New</span> PropertyMetadata<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">New</span> PropertyChangedCallback<span style="color: #000000;">&#40;</span>AddressOf MyToolTipCallback<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Private</span> Shared <span style="color: #0600FF;">Sub</span> MyToolTipCallback<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> d <span style="color: #0600FF;">As</span> DependencyObject, <span style="color: #0600FF;">ByVal</span> e <span style="color: #0600FF;">As</span> DependencyPropertyChangedEventArgs<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; d.<span style="color: #000000;">SetValue</span><span style="color: #000000;">&#40;</span>ToolTipService.<span style="color: #000000;">ToolTipProperty</span>, e.<span style="color: #000000;">NewValue</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li></ol></div><div id="cb4804" style="display: none; color: red;"></div></div></div>

<p>And that fixes that. Why this wasn't just handled behind the scenes I don't know. I've heard that they have done a lot of work on the Binding system for SL4, so maybe this will not be a requirement once the next update rolls out. </p>

<p>-Rick</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/binding-to-custom-members-in-silverlight">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/binding-to-custom-members-in-silverlight#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=692</wfw:commentRss>
		</item>
				<item>
			<title>Silverlight Spinner</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-spinner</link>
			<pubDate>Fri, 19 Mar 2010 14:27:48 +0000</pubDate>			<dc:creator>ThatRickGuy</dc:creator>
			<category domain="main">Web Design, Graphics &amp; Styling</category>
<category domain="alt">UI Development</category>			<guid isPermaLink="false">782@http://blogs.lessthandot.com/</guid>
						<description>&lt;script type=&quot;text/javascript&quot;&gt;
        function onSilverlightError(sender, args) {
            var appSource = &quot;&quot;;
            if (sender != null &amp;amp;&amp;amp; sender != 0) {
              appSource = sender.getHost().Source;
            }

            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == &quot;ImageError&quot; || errorType == &quot;MediaError&quot;) {
              return;
            }

            var errMsg = &quot;Unhandled Error in Silverlight Application &quot; +  appSource + &quot;\n&quot; ;

            errMsg += &quot;Code: &quot;+ iErrorCode + &quot;    \n&quot;;
            errMsg += &quot;Category: &quot; + errorType + &quot;       \n&quot;;
            errMsg += &quot;Message: &quot; + args.ErrorMessage + &quot;     \n&quot;;

            if (errorType == &quot;ParserError&quot;) {
                errMsg += &quot;File: &quot; + args.xamlFile + &quot;     \n&quot;;
                errMsg += &quot;Line: &quot; + args.lineNumber + &quot;     \n&quot;;
                errMsg += &quot;Position: &quot; + args.charPosition + &quot;     \n&quot;;
            }
            else if (errorType == &quot;RuntimeError&quot;) {
                if (args.lineNumber != 0) {
                    errMsg += &quot;Line: &quot; + args.lineNumber + &quot;     \n&quot;;
                    errMsg += &quot;Position: &quot; +  args.charPosition + &quot;     \n&quot;;
                }
                errMsg += &quot;MethodName: &quot; + args.methodName + &quot;     \n&quot;;
            }

            throw new Error(errMsg);
        }
    &lt;/script&gt;

&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;Every week in my shop we do cross training. Someone brings in something they are working on, some system that people are unfamiliar with, some new technology, basically anything related to any of our jobs as developers and maintainers of applications. Often enough I do presentations on Silverlight and Blend, introducing my coworkers to different tools and options that we have available to us. This blog is a write up of one such training presentation. I give you, the &lt;em&gt;Silverlight Spinner&lt;/em&gt;.&lt;/p&gt;
&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-spinner#more782&quot;&gt;Full story &amp;raquo;&lt;/a&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-spinner&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<script type="text/javascript">
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null &amp;&amp; sender != 0) {
              appSource = sender.getHost().Source;
            }

            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
              return;
            }

            var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;

            errMsg += "Code: "+ iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " +  args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
    </script>

<h3>Introduction</h3>
<p>Every week in my shop we do cross training. Someone brings in something they are working on, some system that people are unfamiliar with, some new technology, basically anything related to any of our jobs as developers and maintainers of applications. Often enough I do presentations on Silverlight and Blend, introducing my coworkers to different tools and options that we have available to us. This blog is a write up of one such training presentation. I give you, the <em>Silverlight Spinner</em>.</p>
<a href="http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-spinner#more782">Full story &raquo;</a><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-spinner">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-spinner#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=782</wfw:commentRss>
		</item>
				<item>
			<title>Silverlight Partial Classing a Webservice Reference</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-partial-classing-a-webservic</link>
			<pubDate>Thu, 10 Dec 2009 13:39:11 +0000</pubDate>			<dc:creator>ThatRickGuy</dc:creator>
			<category domain="main">Web Design, Graphics &amp; Styling</category>			<guid isPermaLink="false">691@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Hey Folks,&lt;/p&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Just ran into this minor quirk today, figured I&#039;d share the solution. I have a Webservice that returns an array of a class defined on the server. On the client side, I wanted to extend that class to link it to some GUI elements. Enter the partial class. If you haven&#039;t played with Partial Classes before, I&#039;d recommend checking them out. It allows you to build additional functionality into any class. Not by inheriting from a base, but actually extending that class without creating a new one. Anyways, I wound up with the following:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb41662&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;Namespace srAlerts&lt;br /&gt;&amp;nbsp; &amp;nbsp; Partial &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt; Alert&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; _CommentDisplay &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; CommentIndicator&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;System.&lt;span style=&quot;color: #000000;&quot;&gt;Xml&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Serialization&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;XmlIgnore&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;gt; _&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; CommentDisplay&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; CommentIndicator&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return _CommentDisplay&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Set&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; value &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; CommentIndicator&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _CommentDisplay = value&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Set&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; Namespace&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb38723&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;srAlerts is the namespace of my web service. Alert is the name of the class defined in my web service. CommentIndicatory is the GUI control that I was linking to.&lt;/p&gt; 

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;The critical part though, is the attribute. Without the System.Xml.Serialization.XmlIgnore attribute, you&#039;ll get an exception on the constructor of the web service Reference.vb file:&lt;/p&gt;

&lt;p&gt;Exception has been thrown by the target of an invocation.&lt;br /&gt;
-There was an error reflecting type &#039;Alerts.srAlerts.BaseResponse&#039;.&lt;br /&gt;
--There was an error reflecting type &#039;Alerts.srAlerts.GetAlertDataResponse&#039;.&lt;br /&gt;
---There was an error reflecting property &#039;Alerts&#039;.&lt;br /&gt;
----There was an error reflecting type &#039;Alerts.srAlerts.Alert&#039;.&lt;br /&gt;
-----There was an error reflecting property &#039;CommentDisplay&#039;.&lt;/p&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;It would appear that the web service system in Silverlight attempts to serialize all members of the class, even those that are defined client side in a partial class, and it gets a little confused. Using the XMLIgnore attribute forces the serializer to skip this property and allows us to use the partial class on the client side as we expected.&lt;/p&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;On a side note, there is also a WCF attribute: System.Runtime.Serialization.IgnoreDataMember which will NOT work for web service references.&lt;/p&gt;

&lt;p&gt;-Rick&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-partial-classing-a-webservic&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Hey Folks,</p>
<p style="text-indent: 30pt;">Just ran into this minor quirk today, figured I'd share the solution. I have a Webservice that returns an array of a class defined on the server. On the client side, I wanted to extend that class to link it to some GUI elements. Enter the partial class. If you haven't played with Partial Classes before, I'd recommend checking them out. It allows you to build additional functionality into any class. Not by inheriting from a base, but actually extending that class without creating a new one. Anyways, I wound up with the following:</p>

<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb41183'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb41183','cb44698'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb41183" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">Namespace srAlerts</li><li style="" class="li2">&nbsp; &nbsp; Partial <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Class</span> Alert</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Private</span> _CommentDisplay <span style="color: #0600FF;">As</span> CommentIndicator</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &lt;System.<span style="color: #000000;">Xml</span>.<span style="color: #000000;">Serialization</span>.<span style="color: #000000;">XmlIgnore</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>&gt; _</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Property</span> CommentDisplay<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> CommentIndicator</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return _CommentDisplay</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Set</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> value <span style="color: #0600FF;">As</span> CommentIndicator<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _CommentDisplay = value</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Set</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Property</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></li><li style="" class="li2"><span style="color: #0600FF;">End</span> Namespace</li></ol></div><div id="cb44698" style="display: none; color: red;"></div></div></div>

<p style="text-indent: 30pt;">srAlerts is the namespace of my web service. Alert is the name of the class defined in my web service. CommentIndicatory is the GUI control that I was linking to.</p> 

<p style="text-indent: 30pt;">The critical part though, is the attribute. Without the System.Xml.Serialization.XmlIgnore attribute, you'll get an exception on the constructor of the web service Reference.vb file:</p>

<p>Exception has been thrown by the target of an invocation.<br />
-There was an error reflecting type 'Alerts.srAlerts.BaseResponse'.<br />
--There was an error reflecting type 'Alerts.srAlerts.GetAlertDataResponse'.<br />
---There was an error reflecting property 'Alerts'.<br />
----There was an error reflecting type 'Alerts.srAlerts.Alert'.<br />
-----There was an error reflecting property 'CommentDisplay'.</p>

<p style="text-indent: 30pt;">It would appear that the web service system in Silverlight attempts to serialize all members of the class, even those that are defined client side in a partial class, and it gets a little confused. Using the XMLIgnore attribute forces the serializer to skip this property and allows us to use the partial class on the client side as we expected.</p>

<p style="text-indent: 30pt;">On a side note, there is also a WCF attribute: System.Runtime.Serialization.IgnoreDataMember which will NOT work for web service references.</p>

<p>-Rick</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-partial-classing-a-webservic">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/silverlight-partial-classing-a-webservic#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=691</wfw:commentRss>
		</item>
				<item>
			<title>Communicating with KBay, Design Pattern for Web Services</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/comms-for-kbay</link>
			<pubDate>Mon, 07 Dec 2009 19:06:46 +0000</pubDate>			<dc:creator>ThatRickGuy</dc:creator>
			<category domain="main">Web Design, Graphics &amp; Styling</category>			<guid isPermaLink="false">690@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Hey everyone, &lt;/p&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Sorry this post has been so delayed. I was wiped out last week  and a half with a nasty cold that I am still recovering from. I missed my entire Thanksgiving break, curled up under blankets and coughing my lungs up. Anyway, I&#039;m finally back on my feet, albeit completely buried under catch up work and a new project. But as promised, nuts and bolts from KBay!&lt;/p&gt;

&lt;h3&gt;The Power of Communication&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;One the best parts of KBay is, IMO, the communication design. Every web method in the service takes a single object parameter and returns a single parameter. These two objects are always called the Request and the Response. &lt;/p&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Some of the awesomeness behind this pattern includes:&lt;br /&gt;
1) Client side, you can hang on to a request and populated it as needed. No more piles of variables to pass in, just set up the single request object, it&#039;s all nice and self contained.&lt;br /&gt;
2) Super easy logging/debugging. At any point in time we can serialize the request/response objects to see what&#039;s in them. Even using a tool like Fiddler you can see a nicely formatted data layout of your parameters.&lt;br /&gt;
3) Server side additions will not break functionality. So long as the server side checks the value it wants to use before using it, the client side will continue to function. This was great for us as we had 2+ developers on the project the whole time. If Adam was adding more parameters and functionality server side, I could continue hitting the dev server with out having to rebind or implement any changes.&lt;/p&gt;

&lt;h3&gt;The Simplest Web Methods Ever&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;First off, the actual code behind on the web services:&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vb.net&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vb.net&quot; id=&quot;cb91772&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&amp;lt;WebMethod&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Description:=&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;Returns a set of data required at application startup.&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;gt; _&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt; GetInit&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; Request &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; GetInitRequest&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; GetInitResponse&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return Request.&lt;span style=&quot;color: #000000;&quot;&gt;FillRequest&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;WebMethod&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Description:=&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;Returns a list of Alert Data based on the filter criteria set in the request.&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;gt; _&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt; GetAlertData&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; Request &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; GetAlertDataRequest&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; GetAlertDataResponse&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return Request.&lt;span style=&quot;color: #000000;&quot;&gt;FillRequest&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb59182&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;This code is actually for a different project, but it&#039;s what I had handy. All of the functions follow the same pattern as the ones you can see here. They take a custom Request object and return a custom Response object (both named after the method). Inside the method, they call the Request.FillRequest method.&lt;/p&gt;

&lt;h3&gt;Where&#039;s the beef?&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;So let&#039;s keep digging. Here is the GetInit.vb file that contains the functionality for the GetInit method:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vb.net&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vb.net&quot; id=&quot;cb36505&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;Namespace Implementation&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;ServiceManager.&lt;span style=&quot;color: #000000;&quot;&gt;AutoCreateSessionId&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;gt; _&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt; GetInitRequest&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Inherits ServiceManager.&lt;span style=&quot;color: #000000;&quot;&gt;BaseRequest&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Of GetInitRequest, GetInitResponse&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; Overrides &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt; innerFillRequest&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; GetInitResponse&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; output &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; GetInitResponse&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; env = Utility.&lt;span style=&quot;color: #000000;&quot;&gt;GetEnvironement&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;Alerts|Development&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; Statuses &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt; = Utility.&lt;span style=&quot;color: #000000;&quot;&gt;GetEnvironmentSetting&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;Alerts|Development&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;StartupMessage&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;ToString&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If Statuses &amp;lt;&amp;gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #0600FF;&quot;&gt;Empty&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; output.&lt;span style=&quot;color: #000000;&quot;&gt;Statuses&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;AddRange&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Statuses.&lt;span style=&quot;color: #000000;&quot;&gt;Split&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt;c&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return output&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Protected Overrides &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt; GetLoggingReplacement&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; XMLElement &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; System.&lt;span style=&quot;color: #000000;&quot;&gt;Xml&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Linq&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;XElement&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt; GetInitResponse&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Inherits ServiceManager.&lt;span style=&quot;color: #000000;&quot;&gt;BaseResponse&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; _Statuses &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; List&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Of &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; Statuses&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; List&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Of &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return _Statuses&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Set&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; value &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; List&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Of &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _Statuses = value&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Set&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; Namespace&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb65678&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;A couple of things to notice here. First, there are two classes in this file, both the request and the response. This is just for organizational purposes. You&#039;ll also want to note the &quot;servicemanager.AutoCreateSessionId()&quot; attribute on the Request class. We&#039;ll use this again later.&lt;/p&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;One of the cool things about this system is that it uses generics to move data UP the hierarchy chain. In this case, you can see that we are inheriting from BaseRequest, which allows us to specify the types of the generic.&lt;/p&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;The &quot;innerFillRequest&quot; method is where the actual functionality of this web method takes place. In the case of GetInit, it grabs a string from the Environment Provider, splits it, and adds it to a member on the Response object.&lt;/p&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Below that is the GetInitResponse class, which in this case is pretty simple and just contains a property that exposes a list of strings. The same property that is populated in the Request object&#039;s innerFillRequest method.&lt;/p&gt;

&lt;h3&gt;Strange Child, Who is your Parent?&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;While these derived classes show us what the method does, it doesn&#039;t show us how they are called. The web methods called Request.FillRequest, not InnerFillRequest. So lets look at the class that the request inherits from, BaseRequest:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vb.net&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vb.net&quot; id=&quot;cb42152&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;Namespace ServiceManager&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;MustInherit&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt; BaseRequest&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Of Req &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt;, iRequest&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;, Res &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt;, BaseResponse&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Implements iRequest&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; mRequestToken &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; RequestToken&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt; Implements iRequest.&lt;span style=&quot;color: #000000;&quot;&gt;RequestToken&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return mRequestToken&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Set&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; value &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mRequestToken = value&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Set&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; mSessionId &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Long&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; SessionId&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Long&lt;/span&gt; Implements iRequest.&lt;span style=&quot;color: #000000;&quot;&gt;SessionId&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return mSessionId&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Set&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; value &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Long&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mSessionId = value&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Set&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; This procedure forms a response object and deals with any errors that take place while&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; that response is being created.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;typeparam name=&amp;quot;Req&amp;quot;&amp;gt;&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;typeparam name=&amp;quot;Res&amp;quot;&amp;gt;&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;param name=&amp;quot;Request&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;param name=&amp;quot;RunAction&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt; FillRequest&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Res&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// create a place holder for the output response object&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; Output &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Res = &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// note the time we started this service call.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; sw &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; Stopwatch : sw.&lt;span style=&quot;color: #000000;&quot;&gt;Start&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Try&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// if this request type implements the AutoCreateSessionIdAttribute AND the user has&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// not given a session ID then create a session ID.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; Atts = &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;GetType&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;GetCustomAttributes&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;GetType&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;AutoCreateSessionIdAttribute&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, True&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If Atts IsNot &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt; AndAlso Atts.&lt;span style=&quot;color: #000000;&quot;&gt;Count&lt;/span&gt; &amp;gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;SessionId&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;SessionId&lt;/span&gt; = Utility.&lt;span style=&quot;color: #000000;&quot;&gt;LogApplicationStartup&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// if at this point there is no session ID, throw an exception&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;SessionId&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Throw&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; ApplicationException&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;Invalid session ID given. Ensure you pass the session ID to every service call.&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// set a GUID token for this request&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;IsNullOrEmpty&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;RequestToken&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;RequestToken&lt;/span&gt; = System.&lt;span style=&quot;color: #000000;&quot;&gt;Guid&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;NewGuid&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;ToString&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// log the request XML&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Utility.&lt;span style=&quot;color: #000000;&quot;&gt;WriteLogEntry&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;SessionId&lt;/span&gt;, KerryAuditLoggingServices.&lt;span style=&quot;color: #000000;&quot;&gt;LogTypes&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Verbose&lt;/span&gt;, CreateXML&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// actually run the request and build a response object.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Output = innerFillRequest&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// note the session ID back to the response object&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Output.&lt;span style=&quot;color: #000000;&quot;&gt;SessionId&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;SessionId&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// note the request token&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Output.&lt;span style=&quot;color: #000000;&quot;&gt;RequestToken&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;RequestToken&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// log the response object about to be sent back.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Utility.&lt;span style=&quot;color: #000000;&quot;&gt;WriteLogEntry&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Output.&lt;span style=&quot;color: #000000;&quot;&gt;SessionId&lt;/span&gt;, KerryAuditLoggingServices.&lt;span style=&quot;color: #000000;&quot;&gt;LogTypes&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Verbose&lt;/span&gt;, CreateXML&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Output&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Catch ex &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Exception&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// create a new empty response object to hold the error that was thrown&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Output = &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; Res&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Output.&lt;span style=&quot;color: #0600FF;&quot;&gt;Error&lt;/span&gt; = ex.&lt;span style=&quot;color: #000000;&quot;&gt;ToString&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// note the session ID if the request isnot empty (the caller may have passed a sessionId in)&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt; IsNot &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Output.&lt;span style=&quot;color: #000000;&quot;&gt;SessionId&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;SessionId&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Output.&lt;span style=&quot;color: #000000;&quot;&gt;RequestToken&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;RequestToken&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// log the error&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Utility.&lt;span style=&quot;color: #000000;&quot;&gt;WriteLogEntry&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;SessionId&lt;/span&gt;, KerryAuditLoggingServices.&lt;span style=&quot;color: #000000;&quot;&gt;LogTypes&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;HandledException&lt;/span&gt;, CreateXML&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Output&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Finally&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If Output IsNot &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;// note the amount of time it took to complete this request.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Output.&lt;span style=&quot;color: #000000;&quot;&gt;CompletedInSeconds&lt;/span&gt; = sw.&lt;span style=&quot;color: #000000;&quot;&gt;Elapsed&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;TotalSeconds&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; Try&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return Output&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; MustOverride &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt; innerFillRequest&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Res&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; This procedure will take the given object and create an XML string representing the&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; public properties of the given object.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;param name=&amp;quot;Obj&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt; CreateXML&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; Obj &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Object&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; XML &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; xmlSer = &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; System.&lt;span style=&quot;color: #000000;&quot;&gt;Xml&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Serialization&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;XmlSerializer&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Obj.&lt;span style=&quot;color: #000000;&quot;&gt;GetType&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Using ms &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; System.&lt;span style=&quot;color: #000000;&quot;&gt;IO&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;MemoryStream&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlSer.&lt;span style=&quot;color: #000000;&quot;&gt;Serialize&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ms, Obj&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ms.&lt;span style=&quot;color: #0600FF;&quot;&gt;Seek&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;, IO.&lt;span style=&quot;color: #000000;&quot;&gt;SeekOrigin&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Begin&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; reader &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; System.&lt;span style=&quot;color: #000000;&quot;&gt;IO&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;StreamReader&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ms&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; XML = reader.&lt;span style=&quot;color: #000000;&quot;&gt;ReadToEnd&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; Using&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; XMLElements = XElement.&lt;span style=&quot;color: #000000;&quot;&gt;Parse&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;XML&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReplaceInvalidTags&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;XMLElements&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return XMLElements.&lt;span style=&quot;color: #000000;&quot;&gt;ToString&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; This procedure should be modified to remove any tags you do not want to send to the log. &lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; Tags that hold byte arrays are good candidates for removal.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;param name=&amp;quot;Source&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; ReplaceInvalidTags&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; Source &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; XElement&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; Nodes = &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;From e In Source.&lt;span style=&quot;color: #000000;&quot;&gt;Elements&lt;/span&gt; Select e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;ToArray&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;For&lt;/span&gt; Each n In Nodes&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; LoggingReplacement &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt; = GetLoggingReplacement&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;n&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;IsNullOrEmpty&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;LoggingReplacement&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReplaceInvalidTags&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;n&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Else&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; n.&lt;span style=&quot;color: #000000;&quot;&gt;Value&lt;/span&gt; = LoggingReplacement&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Next&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Protected &lt;span style=&quot;color: #0600FF;&quot;&gt;Overridable&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt; GetLoggingReplacement&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; XMLElement &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; XElement&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If XMLElement.&lt;span style=&quot;color: #000000;&quot;&gt;Name&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;ToString&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;SFDCSessionId&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return &lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;[SFDC Session ID Hidden]&amp;quot;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Else&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #0600FF;&quot;&gt;Empty&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; Namespace&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb82492&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;The BaseRequest class is abstract, it must be inherited. But even cooler, it is a generic class. We can define it&#039;s type dynamically. It implements iRequest, which just guarantees it some basic members:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vb.net&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vb.net&quot; id=&quot;cb3069&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;Namespace ServiceManager&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; Interface iRequest&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; SessionId&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Long&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; RequestToken&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; Interface&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; Namespace&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb80002&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;The &quot;FillRequest&quot; method is the conductor of this train. This is the method that the web services are actually calling. Right off the bat, if starts up a stop watch, so we can get performance indicators off of every web service call. &lt;/p&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;If you remember back to that GetInitRequest class, we set the AutoCreateSessionIDAttribute. And this is where it gets used. If that attribute is set, then we know that this is an acceptable application start method. So we Log the application start up, which returns the Session ID. The Session ID, from this point on, should always be passed back and forth between the client and server, so that all interactions with this user for this execution of the application are under one ID. If for any reason, this Session ID is not set, we kill the process with an exception. This prevents applications from jumping into web service calls with out following the appropriate chain of processes.&lt;/p&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;The RequestToken is a feature used for logging. It allows us to tie multiple log entries (say like a request, some server side process logs, and the response) into a single log entity. This is really only of use when viewing the log, so you can collapse multiple log entries into a single interaction.&lt;/p&gt;

&lt;p style=&quot;text-indent: 30pt;&quot;&gt;The &quot;GetLoggingReplacement&quot; is a block we use to replace chunks of text we don&#039;t want to log. For instance, if the request contains large binary blocks (like uploading files) or sensitive information, we can set up string manipulations here to remove those items from the serialized request before it gets logged. This sub is usually overridden by the derived classes to add more method specific replacements.&lt;/p&gt;

&lt;h3&gt;Until Next Time&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;The projects continue to pile up. Everyone is trying to wrap stuff up before the holidays and new year, so I&#039;ve got a lot on my plate. As I get more time, I&#039;ll try to put up more on some of the other technical tricks we used inside of Silverlight. But this communication system, in conjunction with our Logging system, Unit tests, and having 2 developers on each project has dramatically helped us cut down on development time, reduce released bugs, and improved user acceptance of the applications.&lt;/p&gt;

&lt;p&gt;-Rick&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/comms-for-kbay&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Hey everyone, </p>
<p style="text-indent: 30pt;">Sorry this post has been so delayed. I was wiped out last week  and a half with a nasty cold that I am still recovering from. I missed my entire Thanksgiving break, curled up under blankets and coughing my lungs up. Anyway, I'm finally back on my feet, albeit completely buried under catch up work and a new project. But as promised, nuts and bolts from KBay!</p>

<h3>The Power of Communication</h3>
<p style="text-indent: 30pt;">One the best parts of KBay is, IMO, the communication design. Every web method in the service takes a single object parameter and returns a single parameter. These two objects are always called the Request and the Response. </p>

<p style="text-indent: 30pt;">Some of the awesomeness behind this pattern includes:<br />
1) Client side, you can hang on to a request and populated it as needed. No more piles of variables to pass in, just set up the single request object, it's all nice and self contained.<br />
2) Super easy logging/debugging. At any point in time we can serialize the request/response objects to see what's in them. Even using a tool like Fiddler you can see a nicely formatted data layout of your parameters.<br />
3) Server side additions will not break functionality. So long as the server side checks the value it wants to use before using it, the client side will continue to function. This was great for us as we had 2+ developers on the project the whole time. If Adam was adding more parameters and functionality server side, I could continue hitting the dev server with out having to rebind or implement any changes.</p>

<h3>The Simplest Web Methods Ever</h3>
<p style="text-indent: 30pt;">First off, the actual code behind on the web services:</p>
<div class="codebox"><div class="codeheader"><span>vb.net</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb40302'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb40302','cb71465'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vb.net" id="cb40302" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">&lt;WebMethod<span style="color: #000000;">&#40;</span>Description:=<span style="color: #0600FF;">&quot;Returns a set of data required at application startup.&quot;</span><span style="color: #000000;">&#41;</span>&gt; _</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Function</span> GetInit<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> Request <span style="color: #0600FF;">As</span> GetInitRequest<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> GetInitResponse</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; Return Request.<span style="color: #000000;">FillRequest</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &lt;WebMethod<span style="color: #000000;">&#40;</span>Description:=<span style="color: #0600FF;">&quot;Returns a list of Alert Data based on the filter criteria set in the request.&quot;</span><span style="color: #000000;">&#41;</span>&gt; _</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Function</span> GetAlertData<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> Request <span style="color: #0600FF;">As</span> GetAlertDataRequest<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> GetAlertDataResponse</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; Return Request.<span style="color: #000000;">FillRequest</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li></ol></div><div id="cb71465" style="display: none; color: red;"></div></div></div>

<p style="text-indent: 30pt;">This code is actually for a different project, but it's what I had handy. All of the functions follow the same pattern as the ones you can see here. They take a custom Request object and return a custom Response object (both named after the method). Inside the method, they call the Request.FillRequest method.</p>

<h3>Where's the beef?</h3>
<p style="text-indent: 30pt;">So let's keep digging. Here is the GetInit.vb file that contains the functionality for the GetInit method:</p>

<div class="codebox"><div class="codeheader"><span>vb.net</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb16849'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb16849','cb91557'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vb.net" id="cb16849" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">Namespace Implementation</li><li style="" class="li2">&nbsp; &nbsp; &lt;ServiceManager.<span style="color: #000000;">AutoCreateSessionId</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>&gt; _</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Class</span> GetInitRequest</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; Inherits ServiceManager.<span style="color: #000000;">BaseRequest</span><span style="color: #000000;">&#40;</span>Of GetInitRequest, GetInitResponse<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Public</span> Overrides <span style="color: #0600FF;">Function</span> innerFillRequest<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> GetInitResponse</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> output <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">New</span> GetInitResponse</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> env = Utility.<span style="color: #000000;">GetEnvironement</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;Alerts|Development&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> Statuses <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span> = Utility.<span style="color: #000000;">GetEnvironmentSetting</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;Alerts|Development&quot;</span>, <span style="color: #0600FF;">&quot;StartupMessage&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #000000;">ToString</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If Statuses &lt;&gt; <span style="color: #0600FF;">String</span>.<span style="color: #0600FF;">Empty</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output.<span style="color: #000000;">Statuses</span>.<span style="color: #000000;">AddRange</span><span style="color: #000000;">&#40;</span>Statuses.<span style="color: #000000;">Split</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;,&quot;</span>c<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return output</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; Protected Overrides <span style="color: #0600FF;">Function</span> GetLoggingReplacement<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> XMLElement <span style="color: #0600FF;">As</span> System.<span style="color: #000000;">Xml</span>.<span style="color: #000000;">Linq</span>.<span style="color: #000000;">XElement</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return <span style="color: #0600FF;">Nothing</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Class</span> GetInitResponse</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; Inherits ServiceManager.<span style="color: #000000;">BaseResponse</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Private</span> _Statuses <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">New</span> List<span style="color: #000000;">&#40;</span>Of <span style="color: #0600FF;">String</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Property</span> Statuses<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> List<span style="color: #000000;">&#40;</span>Of <span style="color: #0600FF;">String</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return _Statuses</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Set</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> value <span style="color: #0600FF;">As</span> List<span style="color: #000000;">&#40;</span>Of <span style="color: #0600FF;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Statuses = value</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Set</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Property</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0600FF;">End</span> Namespace</li></ol></div><div id="cb91557" style="display: none; color: red;"></div></div></div>

<p style="text-indent: 30pt;">A couple of things to notice here. First, there are two classes in this file, both the request and the response. This is just for organizational purposes. You'll also want to note the "servicemanager.AutoCreateSessionId()" attribute on the Request class. We'll use this again later.</p>

<p style="text-indent: 30pt;">One of the cool things about this system is that it uses generics to move data UP the hierarchy chain. In this case, you can see that we are inheriting from BaseRequest, which allows us to specify the types of the generic.</p>

<p style="text-indent: 30pt;">The "innerFillRequest" method is where the actual functionality of this web method takes place. In the case of GetInit, it grabs a string from the Environment Provider, splits it, and adds it to a member on the Response object.</p>

<p style="text-indent: 30pt;">Below that is the GetInitResponse class, which in this case is pretty simple and just contains a property that exposes a list of strings. The same property that is populated in the Request object's innerFillRequest method.</p>

<h3>Strange Child, Who is your Parent?</h3>
<p style="text-indent: 30pt;">While these derived classes show us what the method does, it doesn't show us how they are called. The web methods called Request.FillRequest, not InnerFillRequest. So lets look at the class that the request inherits from, BaseRequest:</p>

<div class="codebox"><div class="codeheader"><span>vb.net</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb49600'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb49600','cb39656'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vb.net" id="cb49600" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">Namespace ServiceManager</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">MustInherit</span> <span style="color: #0600FF;">Class</span> BaseRequest<span style="color: #000000;">&#40;</span>Of Req <span style="color: #0600FF;">As</span> <span style="color: #000000;">&#123;</span><span style="color: #0600FF;">New</span>, iRequest<span style="color: #000000;">&#125;</span>, Res <span style="color: #0600FF;">As</span> <span style="color: #000000;">&#123;</span><span style="color: #0600FF;">New</span>, BaseResponse<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; Implements iRequest</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Private</span> mRequestToken <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Property</span> RequestToken<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span> Implements iRequest.<span style="color: #000000;">RequestToken</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return mRequestToken</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Set</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> value <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mRequestToken = value</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Set</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Property</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Private</span> mSessionId <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">Long</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Property</span> SessionId<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">Long</span> Implements iRequest.<span style="color: #000000;">SessionId</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Get</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return mSessionId</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Get</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Set</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> value <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">Long</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mSessionId = value</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Set</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Property</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;summary&gt;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' This procedure forms a response object and deals with any errors that take place while</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' that response is being created.</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;/summary&gt;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;typeparam name=&quot;Req&quot;&gt;&lt;/typeparam&gt;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;typeparam name=&quot;Res&quot;&gt;&lt;/typeparam&gt;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;param name=&quot;Request&quot;&gt;&lt;/param&gt;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;param name=&quot;RunAction&quot;&gt;&lt;/param&gt;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;returns&gt;&lt;/returns&gt;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;remarks&gt;&lt;/remarks&gt;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Function</span> FillRequest<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> Res</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// create a place holder for the output response object</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> Output <span style="color: #0600FF;">As</span> Res = <span style="color: #0600FF;">Nothing</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// note the time we started this service call.</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> sw <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">New</span> Stopwatch : sw.<span style="color: #000000;">Start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Try</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// if this request type implements the AutoCreateSessionIdAttribute AND the user has</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// not given a session ID then create a session ID.</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> Atts = <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">GetType</span>.<span style="color: #000000;">GetCustomAttributes</span><span style="color: #000000;">&#40;</span>GetType<span style="color: #000000;">&#40;</span>AutoCreateSessionIdAttribute<span style="color: #000000;">&#41;</span>, True<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If Atts IsNot <span style="color: #0600FF;">Nothing</span> AndAlso Atts.<span style="color: #000000;">Count</span> &gt; <span style="color: #FF0000;">0</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">SessionId</span> &lt;= <span style="color: #FF0000;">0</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">SessionId</span> = Utility.<span style="color: #000000;">LogApplicationStartup</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// if at this point there is no session ID, throw an exception</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">SessionId</span> &lt;= <span style="color: #FF0000;">0</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Throw</span> <span style="color: #0600FF;">New</span> ApplicationException<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;Invalid session ID given. Ensure you pass the session ID to every service call.&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// set a GUID token for this request</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If <span style="color: #0600FF;">String</span>.<span style="color: #000000;">IsNullOrEmpty</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Me</span>.<span style="color: #000000;">RequestToken</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">RequestToken</span> = System.<span style="color: #000000;">Guid</span>.<span style="color: #000000;">NewGuid</span>.<span style="color: #000000;">ToString</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// log the request XML</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Utility.<span style="color: #000000;">WriteLogEntry</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Me</span>.<span style="color: #000000;">SessionId</span>, KerryAuditLoggingServices.<span style="color: #000000;">LogTypes</span>.<span style="color: #000000;">Verbose</span>, CreateXML<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Me</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// actually run the request and build a response object.</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Output = innerFillRequest<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// note the session ID back to the response object</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Output.<span style="color: #000000;">SessionId</span> = <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">SessionId</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// note the request token</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Output.<span style="color: #000000;">RequestToken</span> = <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">RequestToken</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// log the response object about to be sent back.</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Utility.<span style="color: #000000;">WriteLogEntry</span><span style="color: #000000;">&#40;</span>Output.<span style="color: #000000;">SessionId</span>, KerryAuditLoggingServices.<span style="color: #000000;">LogTypes</span>.<span style="color: #000000;">Verbose</span>, CreateXML<span style="color: #000000;">&#40;</span>Output<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Catch ex <span style="color: #0600FF;">As</span> Exception</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// create a new empty response object to hold the error that was thrown</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Output = <span style="color: #0600FF;">New</span> Res<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Output.<span style="color: #0600FF;">Error</span> = ex.<span style="color: #000000;">ToString</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// note the session ID if the request isnot empty (the caller may have passed a sessionId in)</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If <span style="color: #0600FF;">Me</span> IsNot <span style="color: #0600FF;">Nothing</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Output.<span style="color: #000000;">SessionId</span> = <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">SessionId</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Output.<span style="color: #000000;">RequestToken</span> = <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">RequestToken</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// log the error</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Utility.<span style="color: #000000;">WriteLogEntry</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Me</span>.<span style="color: #000000;">SessionId</span>, KerryAuditLoggingServices.<span style="color: #000000;">LogTypes</span>.<span style="color: #000000;">HandledException</span>, CreateXML<span style="color: #000000;">&#40;</span>Output<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Finally</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If Output IsNot <span style="color: #0600FF;">Nothing</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'// note the amount of time it took to complete this request.</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Output.<span style="color: #000000;">CompletedInSeconds</span> = sw.<span style="color: #000000;">Elapsed</span>.<span style="color: #000000;">TotalSeconds</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> Try</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return Output</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Public</span> MustOverride <span style="color: #0600FF;">Function</span> innerFillRequest<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> Res</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;summary&gt;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' This procedure will take the given object and create an XML string representing the</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' public properties of the given object.</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;/summary&gt;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;param name=&quot;Obj&quot;&gt;&lt;/param&gt;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;returns&gt;&lt;/returns&gt;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;remarks&gt;&lt;/remarks&gt;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Private</span> <span style="color: #0600FF;">Function</span> CreateXML<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> Obj <span style="color: #0600FF;">As</span> Object<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> XML <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> xmlSer = <span style="color: #0600FF;">New</span> System.<span style="color: #000000;">Xml</span>.<span style="color: #000000;">Serialization</span>.<span style="color: #000000;">XmlSerializer</span><span style="color: #000000;">&#40;</span>Obj.<span style="color: #000000;">GetType</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Using ms <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">New</span> System.<span style="color: #000000;">IO</span>.<span style="color: #000000;">MemoryStream</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1000</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlSer.<span style="color: #000000;">Serialize</span><span style="color: #000000;">&#40;</span>ms, Obj<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ms.<span style="color: #0600FF;">Seek</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, IO.<span style="color: #000000;">SeekOrigin</span>.<span style="color: #000000;">Begin</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> reader <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">New</span> System.<span style="color: #000000;">IO</span>.<span style="color: #000000;">StreamReader</span><span style="color: #000000;">&#40;</span>ms<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; XML = reader.<span style="color: #000000;">ReadToEnd</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> Using</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> XMLElements = XElement.<span style="color: #000000;">Parse</span><span style="color: #000000;">&#40;</span>XML<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReplaceInvalidTags<span style="color: #000000;">&#40;</span>XMLElements<span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return XMLElements.<span style="color: #000000;">ToString</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;summary&gt;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' This procedure should be modified to remove any tags you do not want to send to the log. </span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' Tags that hold byte arrays are good candidates for removal.</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;/summary&gt;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;param name=&quot;Source&quot;&gt;&lt;/param&gt;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;remarks&gt;&lt;/remarks&gt;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Private</span> <span style="color: #0600FF;">Sub</span> ReplaceInvalidTags<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> Source <span style="color: #0600FF;">As</span> XElement<span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> Nodes = <span style="color: #000000;">&#40;</span>From e In Source.<span style="color: #000000;">Elements</span> Select e<span style="color: #000000;">&#41;</span>.<span style="color: #000000;">ToArray</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">For</span> Each n In Nodes</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> LoggingReplacement <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span> = GetLoggingReplacement<span style="color: #000000;">&#40;</span>n<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If <span style="color: #0600FF;">String</span>.<span style="color: #000000;">IsNullOrEmpty</span><span style="color: #000000;">&#40;</span>LoggingReplacement<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReplaceInvalidTags<span style="color: #000000;">&#40;</span>n<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Else</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n.<span style="color: #000000;">Value</span> = LoggingReplacement</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Next</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; Protected <span style="color: #0600FF;">Overridable</span> <span style="color: #0600FF;">Function</span> GetLoggingReplacement<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> XMLElement <span style="color: #0600FF;">As</span> XElement<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If XMLElement.<span style="color: #000000;">Name</span>.<span style="color: #000000;">ToString</span> = <span style="color: #0600FF;">&quot;SFDCSessionId&quot;</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return <span style="color: #0600FF;">&quot;[SFDC Session ID Hidden]&quot;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Else</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return <span style="color: #0600FF;">String</span>.<span style="color: #0600FF;">Empty</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></li><li style="" class="li1"><span style="color: #0600FF;">End</span> Namespace</li></ol></div><div id="cb39656" style="display: none; color: red;"></div></div></div>

<p style="text-indent: 30pt;">The BaseRequest class is abstract, it must be inherited. But even cooler, it is a generic class. We can define it's type dynamically. It implements iRequest, which just guarantees it some basic members:</p>

<div class="codebox"><div class="codeheader"><span>vb.net</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb45085'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb45085','cb90012'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vb.net" id="cb45085" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">Namespace ServiceManager</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> Interface iRequest</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Property</span> SessionId<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">Long</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Property</span> RequestToken<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> Interface</li><li style="" class="li2"><span style="color: #0600FF;">End</span> Namespace</li></ol></div><div id="cb90012" style="display: none; color: red;"></div></div></div>

<p style="text-indent: 30pt;">The "FillRequest" method is the conductor of this train. This is the method that the web services are actually calling. Right off the bat, if starts up a stop watch, so we can get performance indicators off of every web service call. </p>

<p style="text-indent: 30pt;">If you remember back to that GetInitRequest class, we set the AutoCreateSessionIDAttribute. And this is where it gets used. If that attribute is set, then we know that this is an acceptable application start method. So we Log the application start up, which returns the Session ID. The Session ID, from this point on, should always be passed back and forth between the client and server, so that all interactions with this user for this execution of the application are under one ID. If for any reason, this Session ID is not set, we kill the process with an exception. This prevents applications from jumping into web service calls with out following the appropriate chain of processes.</p>

<p style="text-indent: 30pt;">The RequestToken is a feature used for logging. It allows us to tie multiple log entries (say like a request, some server side process logs, and the response) into a single log entity. This is really only of use when viewing the log, so you can collapse multiple log entries into a single interaction.</p>

<p style="text-indent: 30pt;">The "GetLoggingReplacement" is a block we use to replace chunks of text we don't want to log. For instance, if the request contains large binary blocks (like uploading files) or sensitive information, we can set up string manipulations here to remove those items from the serialized request before it gets logged. This sub is usually overridden by the derived classes to add more method specific replacements.</p>

<h3>Until Next Time</h3>
<p style="text-indent: 30pt;">The projects continue to pile up. Everyone is trying to wrap stuff up before the holidays and new year, so I've got a lot on my plate. As I get more time, I'll try to put up more on some of the other technical tricks we used inside of Silverlight. But this communication system, in conjunction with our Logging system, Unit tests, and having 2 developers on each project has dramatically helped us cut down on development time, reduce released bugs, and improved user acceptance of the applications.</p>

<p>-Rick</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/comms-for-kbay">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/comms-for-kbay#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=690</wfw:commentRss>
		</item>
				<item>
			<title>An ode to Log, I love thee so</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/an-ode-to-log-i-love-thee-so</link>
			<pubDate>Fri, 20 Nov 2009 14:33:50 +0000</pubDate>			<dc:creator>ThatRickGuy</dc:creator>
			<category domain="main">Web Design, Graphics &amp; Styling</category>			<guid isPermaLink="false">682@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Hey Everyone,&lt;/p&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Rick here again. I really want to get to the nuts and bolts of KBay, but first, we have to get into some of the tools our shop has in place. We leverage these tools to improve almost all aspects of our development life cycle. Two of the biggest tools we refer to as Environment Provider and Application Logging.&lt;/p&gt;

&lt;h3&gt;The Environment Provider&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;The Environment Provider does exactly what its title suggests: It provides an environment, or more specifically, all of the meta-data an application needs to exist in a specific configuration. Connection strings, end points, application configurations, etc. There is one single database that holds all of this data. This data is identified by a &quot;context&quot;. For example, the KBay webservices can exist on a local developer&#039;s PC, a Development Server, a Staging Server, and a Production Server. Each of these locations can connect to either the Development or Production database. So a combination of the location of the application and the desired data environment gives us a context for which a set of environment parameters to use. In the case of KBay, the structure is pretty simple. We have some other apps, international apps with multiple data sources, well, they get a bit crazy, but we have an app just for managing all these settings:&lt;/p&gt;

&lt;h3&gt;The EP Tree&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;http://ringdev.com/images/EnvironmentProvider.JPG&quot; alt=&quot;Environment Provider Tree&quot; title=&quot;Environment Provider Tree&quot; style=&quot;margin-left:50px;&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;It started off as a proof of concept for organizing Environment Provider data when someone mentioned a &quot;Tree&quot; controller and someone (probably Adam!) put it to a Silverlight challenge. Different types of parameters (leaves) are color coded, and if connection strings are detected that point to databases other than their context (branches) would imply, they turn red. And yes, the sun and sky are also animated. Although it started off as a joke, we actually found some bad configurations with the color-coded leaves. &lt;/p&gt;

&lt;h3&gt;Accessing the Meta-Data&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;All of this data gets exposed through a web interface. A web service that takes a context, User Name, and other external parameters returns the appropriate environment data. So all of our applications go to 1 central point for configuration data. &lt;/p&gt;

&lt;h3&gt;It&#039;s Better Than Great, It&#039;s Log!&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;The other biggie is the Logging System. The Logging System is pretty straightforward. There is a table that stores application information, one that stores user information (tied in to Active Directory), one that stores Session information (User X started System Y at this date on this machine with this Environment Provider Context), and one table that stores log entries for the sessions. &lt;/p&gt;

&lt;h3&gt;By Your Powers Combined&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;We store the Environment Provider Context on each session. This is actually a function of the Environment Provider. When an application calls the EP web service, in addition to all of the environment data, it also gets a SessionID. The call into the Environment Provider calls the logging service which creates the log session, populates the appropriate data and logs an application start event. This allows us to quickly identify log entries not just to an application, but to a specific user, on a specific server, with a specific data connection, etc... &lt;/p&gt;

&lt;h3&gt;Getting at More Data&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;All of this log data is exposed through a really quick and dirty Silverlight app that provides us with some standard search functionality:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://ringdev.com/images/LogViewer.JPG&quot; alt=&quot;Log Viewer&quot; title=&quot;Log Viewer&quot; style=&quot;margin-left:50px;&quot; /&gt;&lt;/p&gt;

&lt;h3&gt;Great Business Value (aka: How to convince your boss it&#039;s worth doing)&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Being able to quickly and easily pull up log entries has proven absolutely essential for tracking down user issues, communicating error details between developers, and even determining usage and error rates in applications to help with prioritization. For instance, I give you our Application Usage tool:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://ringdev.com/images/AppUsage.JPG&quot; alt=&quot;Application Usage Sidebar&quot; title=&quot;Application Usage Sidebar&quot; style=&quot;margin-left:25px;&quot; /&gt;&lt;img src=&quot;http://ringdev.com/images/AppUsageDetail.JPG&quot; alt=&quot;Application Usage Sidebar - Single Application View&quot; title=&quot;Application Usage Sidebar - Single Application View&quot; style=&quot;margin-left:15px;&quot; /&gt;&lt;img src=&quot;http://ringdev.com/images/AppUsageDrill.JPG&quot; alt=&quot;Application Usage Sidebar - Usage By User&quot; title=&quot;Application Usage Sidebar - Usage By User&quot; style=&quot;margin-left:15px;&quot; /&gt;&lt;/p&gt;

&lt;h3&gt;Rendered Data at Your Finger Tips&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Application Usage is a tiny Silverlight App that sits on our developers&#039; Share Point portal. Similar to the lay out here at LessThanDot, we have a right hand column with generalized data displayed. We&#039;ve found that column to be a great place to add Silverlight apps for interactive reporting. The Application Usage app for instance, and another that tracks Source Control locks, lock durations, and even file names per developer.&lt;/p&gt;

&lt;h3&gt;Where&#039;s the Code?&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;That&#039;s about it for this post, tomorrow I hope to get more written about the communication system. And after that, some of the code and XAML that makes this stuff tick!&lt;/p&gt;

&lt;p&gt;-Rick&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/an-ode-to-log-i-love-thee-so&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Hey Everyone,</p>
<p style="text-indent: 30pt;">Rick here again. I really want to get to the nuts and bolts of KBay, but first, we have to get into some of the tools our shop has in place. We leverage these tools to improve almost all aspects of our development life cycle. Two of the biggest tools we refer to as Environment Provider and Application Logging.</p>

<h3>The Environment Provider</h3>
<p style="text-indent: 30pt;">The Environment Provider does exactly what its title suggests: It provides an environment, or more specifically, all of the meta-data an application needs to exist in a specific configuration. Connection strings, end points, application configurations, etc. There is one single database that holds all of this data. This data is identified by a "context". For example, the KBay webservices can exist on a local developer's PC, a Development Server, a Staging Server, and a Production Server. Each of these locations can connect to either the Development or Production database. So a combination of the location of the application and the desired data environment gives us a context for which a set of environment parameters to use. In the case of KBay, the structure is pretty simple. We have some other apps, international apps with multiple data sources, well, they get a bit crazy, but we have an app just for managing all these settings:</p>

<h3>The EP Tree</h3>
<p><img src="http://ringdev.com/images/EnvironmentProvider.JPG" alt="Environment Provider Tree" title="Environment Provider Tree" style="margin-left:50px;" /></p>
<p style="text-indent: 30pt;">It started off as a proof of concept for organizing Environment Provider data when someone mentioned a "Tree" controller and someone (probably Adam!) put it to a Silverlight challenge. Different types of parameters (leaves) are color coded, and if connection strings are detected that point to databases other than their context (branches) would imply, they turn red. And yes, the sun and sky are also animated. Although it started off as a joke, we actually found some bad configurations with the color-coded leaves. </p>

<h3>Accessing the Meta-Data</h3>
<p style="text-indent: 30pt;">All of this data gets exposed through a web interface. A web service that takes a context, User Name, and other external parameters returns the appropriate environment data. So all of our applications go to 1 central point for configuration data. </p>

<h3>It's Better Than Great, It's Log!</h3>
<p style="text-indent: 30pt;">The other biggie is the Logging System. The Logging System is pretty straightforward. There is a table that stores application information, one that stores user information (tied in to Active Directory), one that stores Session information (User X started System Y at this date on this machine with this Environment Provider Context), and one table that stores log entries for the sessions. </p>

<h3>By Your Powers Combined</h3>
<p style="text-indent: 30pt;">We store the Environment Provider Context on each session. This is actually a function of the Environment Provider. When an application calls the EP web service, in addition to all of the environment data, it also gets a SessionID. The call into the Environment Provider calls the logging service which creates the log session, populates the appropriate data and logs an application start event. This allows us to quickly identify log entries not just to an application, but to a specific user, on a specific server, with a specific data connection, etc... </p>

<h3>Getting at More Data</h3>
<p style="text-indent: 30pt;">All of this log data is exposed through a really quick and dirty Silverlight app that provides us with some standard search functionality:</p>
<p><img src="http://ringdev.com/images/LogViewer.JPG" alt="Log Viewer" title="Log Viewer" style="margin-left:50px;" /></p>

<h3>Great Business Value (aka: How to convince your boss it's worth doing)</h3>
<p style="text-indent: 30pt;">Being able to quickly and easily pull up log entries has proven absolutely essential for tracking down user issues, communicating error details between developers, and even determining usage and error rates in applications to help with prioritization. For instance, I give you our Application Usage tool:</p>

<p><img src="http://ringdev.com/images/AppUsage.JPG" alt="Application Usage Sidebar" title="Application Usage Sidebar" style="margin-left:25px;" /><img src="http://ringdev.com/images/AppUsageDetail.JPG" alt="Application Usage Sidebar - Single Application View" title="Application Usage Sidebar - Single Application View" style="margin-left:15px;" /><img src="http://ringdev.com/images/AppUsageDrill.JPG" alt="Application Usage Sidebar - Usage By User" title="Application Usage Sidebar - Usage By User" style="margin-left:15px;" /></p>

<h3>Rendered Data at Your Finger Tips</h3>
<p style="text-indent: 30pt;">Application Usage is a tiny Silverlight App that sits on our developers' Share Point portal. Similar to the lay out here at LessThanDot, we have a right hand column with generalized data displayed. We've found that column to be a great place to add Silverlight apps for interactive reporting. The Application Usage app for instance, and another that tracks Source Control locks, lock durations, and even file names per developer.</p>

<h3>Where's the Code?</h3>
<p style="text-indent: 30pt;">That's about it for this post, tomorrow I hope to get more written about the communication system. And after that, some of the code and XAML that makes this stuff tick!</p>

<p>-Rick</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/an-ode-to-log-i-love-thee-so">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/an-ode-to-log-i-love-thee-so#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=682</wfw:commentRss>
		</item>
				<item>
			<title>Developing KBay: It's All About the Team</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/developing-kbay-what-went-right</link>
			<pubDate>Wed, 18 Nov 2009 13:14:59 +0000</pubDate>			<dc:creator>ThatRickGuy</dc:creator>
			<category domain="main">Web Design, Graphics &amp; Styling</category>			<guid isPermaLink="false">677@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Hello Everyone,&lt;/p&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Rick here again with another little blurb on my most recent Silverlight project, KBay. Today, I&#039;d like to write a little bit about what went right.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://ringdev.com/code/KBayHome.PNG&quot; alt=&quot;KBay Home Page&quot; title=&quot;KBay Home Page &quot; style=&quot;margin-left:50px;&quot; /&gt;&lt;/p&gt;

&lt;h3&gt;Separation of Power&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;One of the biggest attributes of KBay&#039;s success, IMO, was the segregation of development. My coworker Adam (Hi Adam!) and I handled the majority of the work for this project. The initial goal was to try to involve everyone on the App Dev team, to give them more exposure to Silverlight. But with the tight time-line and other priorities, we couldn&#039;t keep the whole team on page. So after some initial design meetings and DB layout, it largely fell to Adam and me to get it to work. &lt;/p&gt;

&lt;h3&gt;Balance Your Strengths&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Adam and I approached the problem from our own strengths. Both of us are more than capable of writing the entire solution, but we both have our strengths and weaknesses. In my case, my experience with Blend and XAML, along with some rudimentary graphics arts knowledge, really allowed me to speed through the front end, while Adam&#039;s envelope pushing experience with LINQ and Generics allowed him to come up with some really awesome solutions to communication and technical issues.&lt;/p&gt;

&lt;h3&gt;Two Heads are Better Than One&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;This separation really allowed us to greatly improve not just our development speed, but it also worked as a sort of code review, where we were both interacting with each other&#039;s interfaces. Since we had virtually no requirements for the project, it allowed us to brainstorm freely and to consider many options that neither of us would have thought of on our own. &lt;/p&gt;

&lt;h3&gt;Lather, Rinse, Repeat&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Both of us were so struck by how excellently this approach worked in our environment, that we have recommended to our management that we reuse it in more projects . And so far, it has continued to work exceptionally well.&lt;/p&gt;

&lt;h3&gt;One of These Things is Not Like the Others&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Working in Silverlight, unlike any other mainstream MS platform, means that your only option for interacting with the server is via Webservice or WCF calls. Not only are these the only options (aside from some socket options) but they are also entirely Async in their behavior. &lt;/p&gt;

&lt;h3&gt;Limits Are Good?&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;This limitation opens up a number of options and challenges. First, there is a crystal clear separation between the presentation layer and the business/data layer. It allows for developers to be very pure on either side. A web service does nothing for layout and the UI does nothing for data manipulation (save for maybe some caching). &lt;/p&gt;

&lt;h3&gt;Green Light Go! Red Light Stop!&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Second, the UI developer can track explicitly when any IO begins and ends, and with a bit of wrapping, control the UI accordingly.&lt;/p&gt;

&lt;h3&gt;Unit Testing Made Easy!&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Third, and probably best of all, since almost all of the functionality is being controlled by web services, it is really easy to isolate functionality for integrated unit testing. This has been a huge boon for us in terms of stability of deployments, even in the dev environment with multiple developers. It takes 20 seconds to run every single method through all of our known use cases, and those unit tests are run before every deployment. These unit tests are a critical to reducing risks for off-schedule deployments.&lt;/p&gt;

&lt;h3&gt;Are Limits Bad?&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Maybe &#039;limits&#039; isn&#039;t the right word for this. You can still do almost everything you can do through other platforms, you just have to go about it through entirely different means. The limits that exist force developers to go through the new means, using async communication and webservices/WCF instead of continuing to depend on integrated IO and synchronous processing. So while there is a learning curve in changing the way we approach problems in Silverlight, I think that overcoming that curve will enable more developers to think in a parallel style. Removing the interface from the process, and making the processes async forces developers to partake in good development practices. Because every time I see a Windows app go to a white screen because some developer tried running I/O operations on the GUI thread, I cry a little on the inside.&lt;/p&gt;

&lt;h3&gt;I Love Log&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;That&#039;s it for the more abstract summary of the KBay project. I promise my next segment will deal with more of the technical nuts and bolts of the project. Including the communication layer and my personal favorite, LOGGING!!!&lt;/p&gt;

&lt;p&gt;-Rick&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/developing-kbay-what-went-right&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Hello Everyone,</p>
<p style="text-indent: 30pt;">Rick here again with another little blurb on my most recent Silverlight project, KBay. Today, I'd like to write a little bit about what went right.</p>

<p><img src="http://ringdev.com/code/KBayHome.PNG" alt="KBay Home Page" title="KBay Home Page " style="margin-left:50px;" /></p>

<h3>Separation of Power</h3>
<p style="text-indent: 30pt;">One of the biggest attributes of KBay's success, IMO, was the segregation of development. My coworker Adam (Hi Adam!) and I handled the majority of the work for this project. The initial goal was to try to involve everyone on the App Dev team, to give them more exposure to Silverlight. But with the tight time-line and other priorities, we couldn't keep the whole team on page. So after some initial design meetings and DB layout, it largely fell to Adam and me to get it to work. </p>

<h3>Balance Your Strengths</h3>
<p style="text-indent: 30pt;">Adam and I approached the problem from our own strengths. Both of us are more than capable of writing the entire solution, but we both have our strengths and weaknesses. In my case, my experience with Blend and XAML, along with some rudimentary graphics arts knowledge, really allowed me to speed through the front end, while Adam's envelope pushing experience with LINQ and Generics allowed him to come up with some really awesome solutions to communication and technical issues.</p>

<h3>Two Heads are Better Than One</h3>
<p style="text-indent: 30pt;">This separation really allowed us to greatly improve not just our development speed, but it also worked as a sort of code review, where we were both interacting with each other's interfaces. Since we had virtually no requirements for the project, it allowed us to brainstorm freely and to consider many options that neither of us would have thought of on our own. </p>

<h3>Lather, Rinse, Repeat</h3>
<p style="text-indent: 30pt;">Both of us were so struck by how excellently this approach worked in our environment, that we have recommended to our management that we reuse it in more projects . And so far, it has continued to work exceptionally well.</p>

<h3>One of These Things is Not Like the Others</h3>
<p style="text-indent: 30pt;">Working in Silverlight, unlike any other mainstream MS platform, means that your only option for interacting with the server is via Webservice or WCF calls. Not only are these the only options (aside from some socket options) but they are also entirely Async in their behavior. </p>

<h3>Limits Are Good?</h3>
<p style="text-indent: 30pt;">This limitation opens up a number of options and challenges. First, there is a crystal clear separation between the presentation layer and the business/data layer. It allows for developers to be very pure on either side. A web service does nothing for layout and the UI does nothing for data manipulation (save for maybe some caching). </p>

<h3>Green Light Go! Red Light Stop!</h3>
<p style="text-indent: 30pt;">Second, the UI developer can track explicitly when any IO begins and ends, and with a bit of wrapping, control the UI accordingly.</p>

<h3>Unit Testing Made Easy!</h3>
<p style="text-indent: 30pt;">Third, and probably best of all, since almost all of the functionality is being controlled by web services, it is really easy to isolate functionality for integrated unit testing. This has been a huge boon for us in terms of stability of deployments, even in the dev environment with multiple developers. It takes 20 seconds to run every single method through all of our known use cases, and those unit tests are run before every deployment. These unit tests are a critical to reducing risks for off-schedule deployments.</p>

<h3>Are Limits Bad?</h3>
<p style="text-indent: 30pt;">Maybe 'limits' isn't the right word for this. You can still do almost everything you can do through other platforms, you just have to go about it through entirely different means. The limits that exist force developers to go through the new means, using async communication and webservices/WCF instead of continuing to depend on integrated IO and synchronous processing. So while there is a learning curve in changing the way we approach problems in Silverlight, I think that overcoming that curve will enable more developers to think in a parallel style. Removing the interface from the process, and making the processes async forces developers to partake in good development practices. Because every time I see a Windows app go to a white screen because some developer tried running I/O operations on the GUI thread, I cry a little on the inside.</p>

<h3>I Love Log</h3>
<p style="text-indent: 30pt;">That's it for the more abstract summary of the KBay project. I promise my next segment will deal with more of the technical nuts and bolts of the project. Including the communication layer and my personal favorite, LOGGING!!!</p>

<p>-Rick</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/developing-kbay-what-went-right">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/developing-kbay-what-went-right#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=677</wfw:commentRss>
		</item>
				<item>
			<title>Pushing Silverlight for my Company</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/pushing-silverlight-for-my-company</link>
			<pubDate>Mon, 16 Nov 2009 20:09:58 +0000</pubDate>			<dc:creator>ThatRickGuy</dc:creator>
			<category domain="main">Web Design, Graphics &amp; Styling</category>			<guid isPermaLink="false">676@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Hey everyone,&lt;/p&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;It&#039;s me again, Rick the Silverlight nut. I&#039;ve been buried under a pile of work this last month and haven&#039;t had a chance to post much of the fun stuff I&#039;ve been working on. But I&#039;ve got a few minutes to write about my last big project. So I give you, the story of KBay:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://ringdev.com/code/KBay.PNG&quot; alt=&quot;KBay sample screen&quot; title=&quot;KBay Sample Screen&quot; style=&quot;margin-left:50px;&quot; /&gt;&lt;/p&gt;

&lt;h3&gt;The Story So Far...&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;I work for Kerry Americas, a food product company with a corporate office in Beloit, Wisconsin. Over the last year we have relocated much of our sales, service, R and D, and other folks to a brand new, state of the art office building and production facility. This place rocks. This did however, leave us with a whole lot of cruddy old furniture, that had been well-used in many of our older office spaces. So the building managers, remembering that almost a decade ago the IT shop had given them an EBay-like app used to auction off goods for charity, gave us a call. They wanted us to fire up this archaic app so they could try to move the furniture to employees for charity. My boss, seeing an opportunity for something better, got us 2 weeks to get something running. We could either get the classic site up and running again, or make one from scratch in Silverlight, but it had to be entirely off the books.&lt;/p&gt;

&lt;h3&gt;Racing the Clock...&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;So we worked our fingers to the bone pulling it off after hours, over lunch, etc, but after 9 days we had a working prototype. On day 10 we demo&#039;d it to the users and they were ecstatic. We had 3 weeks to the auction and we used some of that time to refine and improve the system (I hope to be posting about our communication frame work shortly!)&lt;/p&gt;

&lt;h3&gt;Going Live...&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Last week, Monday morning we went live with over 200 auctions and almost 600 available users. We had a huge load on the server that morning, but everything stayed up and stable. No crashes, no complaints. We had a few minor bugs, and since it was a non-critical app the boss-man gave us the go-ahead to push to production off-schedule.&lt;/p&gt;

&lt;h3&gt;Down to the Wire...&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;Friday evening was the big test though. All of the auctions ended at the exact same time. The managers were joking that they had never seen the parking lot so full on a Friday night. And the web server was showing some severe strain. With 300+ users sitting on their favored auction&#039;s page, hitting refresh over and over again, the server was having issues keeping up. But it never crashed, it just got slow to access the site.&lt;/p&gt;

&lt;h3&gt;In the End...&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;It was a huge success! The company off loaded almost all of the auctions. The employees got some great deals on some impressive furniture. A local charity food bank picked up a few thousand dollars. And we got Silverlight installed on almost every PC in the building AND got some major good-credit with the users. &lt;/p&gt;

&lt;h3&gt;The Post Mortem...&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;And post-hoc analysis is pointing to an obvious short coming in our interactions. Since we had developed the application so quickly, we had cut some corners. One of those corners was image caching. Each time users were browsing auctions they were downloading every thumbnail, and every time they looked at a single auction, they would download the full sized image. We had mentioned caching briefly during design, but with a 9 day window, we scrapped it and it was forgotten about while we polished. But looking back now, we could have just hosted the images via an ASP.Net page. Not only would that have solved the hosting issue, but it would have also allowed Silverlight to use the built in browser cache for all of the images. A full caching system without writing a single line of code. We&#039;re kicking ourselves now for not seeing it before, but we&#039;ll have it in for the next auction!&lt;/p&gt;

&lt;h3&gt;More to Come...&lt;/h3&gt;
&lt;p style=&quot;text-indent: 30pt;&quot;&gt;I hope to have time to post some more of what we learned on this project soon, but I&#039;ve got another hot deadline approaching for a Silverlight application that mocks Share Point inside of Sales Force.&lt;/p&gt;

&lt;p&gt;-Rick&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/pushing-silverlight-for-my-company&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Hey everyone,</p>
<p style="text-indent: 30pt;">It's me again, Rick the Silverlight nut. I've been buried under a pile of work this last month and haven't had a chance to post much of the fun stuff I've been working on. But I've got a few minutes to write about my last big project. So I give you, the story of KBay:</p>

<p><img src="http://ringdev.com/code/KBay.PNG" alt="KBay sample screen" title="KBay Sample Screen" style="margin-left:50px;" /></p>

<h3>The Story So Far...</h3>
<p style="text-indent: 30pt;">I work for Kerry Americas, a food product company with a corporate office in Beloit, Wisconsin. Over the last year we have relocated much of our sales, service, R and D, and other folks to a brand new, state of the art office building and production facility. This place rocks. This did however, leave us with a whole lot of cruddy old furniture, that had been well-used in many of our older office spaces. So the building managers, remembering that almost a decade ago the IT shop had given them an EBay-like app used to auction off goods for charity, gave us a call. They wanted us to fire up this archaic app so they could try to move the furniture to employees for charity. My boss, seeing an opportunity for something better, got us 2 weeks to get something running. We could either get the classic site up and running again, or make one from scratch in Silverlight, but it had to be entirely off the books.</p>

<h3>Racing the Clock...</h3>
<p style="text-indent: 30pt;">So we worked our fingers to the bone pulling it off after hours, over lunch, etc, but after 9 days we had a working prototype. On day 10 we demo'd it to the users and they were ecstatic. We had 3 weeks to the auction and we used some of that time to refine and improve the system (I hope to be posting about our communication frame work shortly!)</p>

<h3>Going Live...</h3>
<p style="text-indent: 30pt;">Last week, Monday morning we went live with over 200 auctions and almost 600 available users. We had a huge load on the server that morning, but everything stayed up and stable. No crashes, no complaints. We had a few minor bugs, and since it was a non-critical app the boss-man gave us the go-ahead to push to production off-schedule.</p>

<h3>Down to the Wire...</h3>
<p style="text-indent: 30pt;">Friday evening was the big test though. All of the auctions ended at the exact same time. The managers were joking that they had never seen the parking lot so full on a Friday night. And the web server was showing some severe strain. With 300+ users sitting on their favored auction's page, hitting refresh over and over again, the server was having issues keeping up. But it never crashed, it just got slow to access the site.</p>

<h3>In the End...</h3>
<p style="text-indent: 30pt;">It was a huge success! The company off loaded almost all of the auctions. The employees got some great deals on some impressive furniture. A local charity food bank picked up a few thousand dollars. And we got Silverlight installed on almost every PC in the building AND got some major good-credit with the users. </p>

<h3>The Post Mortem...</h3>
<p style="text-indent: 30pt;">And post-hoc analysis is pointing to an obvious short coming in our interactions. Since we had developed the application so quickly, we had cut some corners. One of those corners was image caching. Each time users were browsing auctions they were downloading every thumbnail, and every time they looked at a single auction, they would download the full sized image. We had mentioned caching briefly during design, but with a 9 day window, we scrapped it and it was forgotten about while we polished. But looking back now, we could have just hosted the images via an ASP.Net page. Not only would that have solved the hosting issue, but it would have also allowed Silverlight to use the built in browser cache for all of the images. A full caching system without writing a single line of code. We're kicking ourselves now for not seeing it before, but we'll have it in for the next auction!</p>

<h3>More to Come...</h3>
<p style="text-indent: 30pt;">I hope to have time to post some more of what we learned on this project soon, but I've got another hot deadline approaching for a Silverlight application that mocks Share Point inside of Sales Force.</p>

<p>-Rick</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/pushing-silverlight-for-my-company">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/pushing-silverlight-for-my-company#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=676</wfw:commentRss>
		</item>
			</channel>
</rss>
