<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>.NET: C#</title><link>http://blogs.clearscreen.com/migs/category/4.aspx</link><description>just object oriented coding with dotnet using the c# language</description><managingEditor>Miguel Jiménez</managingEditor><dc:language>en-US</dc:language><generator>.Text Version 0.95.2004.102</generator><item><dc:creator>Miguel Jiménez</dc:creator><title>Speaking engagements for January 2007</title><link>http://blogs.clearscreen.com/migs/archive/2006/12/28/5740.aspx</link><pubDate>Thu, 28 Dec 2006 14:30:00 GMT</pubDate><guid>http://blogs.clearscreen.com/migs/archive/2006/12/28/5740.aspx</guid><wfw:comment>http://blogs.clearscreen.com/migs/comments/5740.aspx</wfw:comment><comments>http://blogs.clearscreen.com/migs/archive/2006/12/28/5740.aspx#Feedback</comments><slash:comments>29</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/migs/comments/commentRss/5740.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/migs/services/trackbacks/5740.aspx</trackback:ping><description>&lt;p&gt;Next year it's starting with a busy busy month. This is the list of the engagements I already have, if you are nearby any of the cities I'll be visiting don't hesitate and we can have some beers ;) I'm also interested in meeting people in Tenerife that are willing to join INETA and create a .NET User Group over there...&lt;/p&gt; &lt;p&gt;So actually this are the planned speaks:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;C# 3.0 Language Features // &lt;/strong&gt;&lt;strong&gt;Madrid .NET User Group, January, 18th 2007&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt; &lt;p&gt;Introducing Extension Methods, Query Languages, Lambda Expressions and all the upcoming C# 3.0 language features. Further details and registration at &lt;a href="http://www.madriddotnet.com"&gt;http://www.madriddotnet.com&lt;/a&gt; &lt;/p&gt;&lt;/blockquote&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;C# 3.0 Language Features // .NET User Group Galicia, Coruña, January, 19th 2007&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt; &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;First meeting of .NET User Group Galicia, and I'll be there presenting Extension Methods, Query Languages, Lambda Expressions and all the upcoming C# 3.0 language features. Further details and registration at &lt;a href="http://www.nugg.es"&gt;http://www.nugg.es&lt;/a&gt; &lt;/p&gt;&lt;/blockquote&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;LOVE Tour: Windows Workflow and Windows Communication Foundation // Tenerife, January, 23rd 2007&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt; &lt;p&gt;I keep collaborating with MSDN presenting .NET Framework 3.0 over major cities in Spain. This time I'll be in Tenerife (Canary Islands) presenting Windows Workflow and Windows Communication Foundation. Further details and registration at &lt;a title="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032312578&amp;amp;Culture=es-ES" href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032312578&amp;amp;Culture=es-ES"&gt;http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032312578&amp;amp;Culture=es-ES&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;LOVE Tour: Windows Presentation Foundation // Málaga, January, 25th 2007&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt; &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;I keep collaborating with MSDN presenting .NET Framework 3.0 over major cities in Spain. This time I'll be in Málaga, directly from Tenerife, presenting user interface improvements with Windows Presentation Foundation. Further details and registration at &lt;a title="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032312580&amp;amp;Culture=es-ES" href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032312580&amp;amp;Culture=es-ES"&gt;http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032312580&amp;amp;Culture=es-ES&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt; More to come for February.&lt;/p&gt;&lt;img src ="http://blogs.clearscreen.com/migs/aggbug/5740.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>Next year it's starting with a busy busy month. This is the list of the engagements I already have, if you are nearby any of the cities I'll be visiting don't hesitate and we can have some beers ;) I'm also interested in meeting people in Tenerife that are willing to join INETA and create a .NET User Group over there...</p> <p>So actually this are the planned speaks:</p> <ul> <li><strong>C# 3.0 Language Features // </strong><strong>Madrid .NET User Group, January, 18th 2007</strong></li></ul> <blockquote> <p>Introducing Extension Methods, Query Languages, Lambda Expressions and all the upcoming C# 3.0 language features. Further details and registration at <a href="http://www.madriddotnet.com">http://www.madriddotnet.com</a> </p></blockquote> <ul> <li><strong>C# 3.0 Language Features // .NET User Group Galicia, Coruña, January, 19th 2007</strong></li></ul> <blockquote> <p><strong></strong>First meeting of .NET User Group Galicia, and I'll be there presenting Extension Methods, Query Languages, Lambda Expressions and all the upcoming C# 3.0 language features. Further details and registration at <a href="http://www.nugg.es">http://www.nugg.es</a> </p></blockquote> <ul> <li><strong>LOVE Tour: Windows Workflow and Windows Communication Foundation // Tenerife, January, 23rd 2007</strong></li></ul> <blockquote> <p>I keep collaborating with MSDN presenting .NET Framework 3.0 over major cities in Spain. This time I'll be in Tenerife (Canary Islands) presenting Windows Workflow and Windows Communication Foundation. Further details and registration at <a title="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032312578&amp;Culture=es-ES" href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032312578&amp;Culture=es-ES">http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032312578&amp;Culture=es-ES</a></p></blockquote> <ul> <li><strong>LOVE Tour: Windows Presentation Foundation // Málaga, January, 25th 2007</strong></li></ul> <blockquote> <p><strong></strong>I keep collaborating with MSDN presenting .NET Framework 3.0 over major cities in Spain. This time I'll be in Málaga, directly from Tenerife, presenting user interface improvements with Windows Presentation Foundation. Further details and registration at <a title="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032312580&amp;Culture=es-ES" href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032312580&amp;Culture=es-ES">http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032312580&amp;Culture=es-ES</a></p></blockquote> <p> More to come for February.</p><img src ="http://blogs.clearscreen.com/migs/aggbug/5740.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Miguel Jiménez</dc:creator><title>Stuck in reverse. Playing with strings, bits and floating points</title><link>http://blogs.clearscreen.com/migs/archive/2006/12/27/5712.aspx</link><pubDate>Wed, 27 Dec 2006 14:58:00 GMT</pubDate><guid>http://blogs.clearscreen.com/migs/archive/2006/12/27/5712.aspx</guid><wfw:comment>http://blogs.clearscreen.com/migs/comments/5712.aspx</wfw:comment><comments>http://blogs.clearscreen.com/migs/archive/2006/12/27/5712.aspx#Feedback</comments><slash:comments>45</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/migs/comments/commentRss/5712.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/migs/services/trackbacks/5712.aspx</trackback:ping><description>&lt;p&gt;A couple of days ago my fellow friend &lt;a href="http://geeks.ms/blogs/programancia101/" target="_blank"&gt;Ricardo Varela started to blog in spanish&lt;/a&gt; (in parallel with &lt;a href="http://phobeo.com/wordpress/" target="_blank"&gt;his actual english blog&lt;/a&gt;). Former member of Microsoft communities, he is actually working at Google UK. The actual point is that on his new blog he started a &lt;a href="http://geeks.ms/blogs/programancia101/archive/2006/12/26/empezando-por-el-principio.aspx" target="_blank"&gt;post with some kind of coding teasers&lt;/a&gt;, going back to basics, to the principles of coding. This is going to be funny.&lt;/p&gt; &lt;p&gt;Well, this is my answer to his post. There were three questions regarding data structures and alternative thinking about reversing things.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Do you know how to reverse a string?&lt;/strong&gt; In example, if you get "abc" the returned string should be "cba"&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt; &lt;p&gt;This seemed pretty easy. In C# every string is represented as an array of chars, so you can use the indexers to get chars at any position and reverse them "manually" with something like:&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8c70f28c-5681-4087-a8de-ff301d4d1e49" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF; "&gt;string&lt;/span&gt;&lt;span style="color: #000000; "&gt; inputString &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;"&lt;/span&gt;&lt;span style="color: #000000; "&gt;abc&lt;/span&gt;&lt;span style="color: #000000; "&gt;"&lt;/span&gt;&lt;span style="color: #000000; "&gt;;
&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;string&lt;/span&gt;&lt;span style="color: #000000; "&gt; reversedString &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;string&lt;/span&gt;&lt;span style="color: #000000; "&gt;.Empty;

&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;for&lt;/span&gt;&lt;span style="color: #000000; "&gt; (&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;int&lt;/span&gt;&lt;span style="color: #000000; "&gt; c &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; inputString.Length; c &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;0&lt;/span&gt;&lt;span style="color: #000000; "&gt;; c&lt;/span&gt;&lt;span style="color: #000000; "&gt;--&lt;/span&gt;&lt;span style="color: #000000; "&gt;)
{
    reversedString &lt;/span&gt;&lt;span style="color: #000000; "&gt;+=&lt;/span&gt;&lt;span style="color: #000000; "&gt; inputString[c &lt;/span&gt;&lt;span style="color: #000000; "&gt;-&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;1&lt;/span&gt;&lt;span style="color: #000000; "&gt;];
}

Console.WriteLine(&lt;/span&gt;&lt;span style="color: #000000; "&gt;"&lt;/span&gt;&lt;span style="color: #000000; "&gt;Original String: &lt;/span&gt;&lt;span style="color: #000000; "&gt;"&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;+&lt;/span&gt;&lt;span style="color: #000000; "&gt; inputString);
Console.WriteLine(&lt;/span&gt;&lt;span style="color: #000000; "&gt;"&lt;/span&gt;&lt;span style="color: #000000; "&gt;Reversed String: &lt;/span&gt;&lt;span style="color: #000000; "&gt;"&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;+&lt;/span&gt;&lt;span style="color: #000000; "&gt; reversedString);&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Or you can use some of the features of the .NET Framework to do it in a more "elegant" way:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:0ced2329-88b6-40e2-b630-6c4361f65c91" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF; "&gt;char&lt;/span&gt;&lt;span style="color: #000000; "&gt;[] chars &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; inputString.ToCharArray();
Array.Reverse(chars);

&lt;/span&gt;&lt;span style="color: #008000; "&gt;//&lt;/span&gt;&lt;span style="color: #008000; "&gt; Use the reversed array of chars&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Going deeper into data structures, &lt;strong&gt;do you know how to reverse the bits of a byte?&lt;/strong&gt; In example, if you get 1 the returned byte should be 128&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;I must admit this was a hard one. Although I perfectly know the concepts of bits and bitwise operations the C# language doesn't provide an easy or structured way to access those elementary elements of data structures. I finally managed to achieve it. The smallest numeric data structure available to represent a byte internals I found was a simple byte[8], so now I just have to fill it with the values for each byte:&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:2d195fac-cd85-4079-8439-78090cd01cd9" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF; "&gt;static&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[] getBits(&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt; inputByte)
{
    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[] bits &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;new&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[&lt;/span&gt;&lt;span style="color: #000000; "&gt;8&lt;/span&gt;&lt;span style="color: #000000; "&gt;];

    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;for&lt;/span&gt;&lt;span style="color: #000000; "&gt; (&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;int&lt;/span&gt;&lt;span style="color: #000000; "&gt; p &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;0&lt;/span&gt;&lt;span style="color: #000000; "&gt;; p &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;8&lt;/span&gt;&lt;span style="color: #000000; "&gt;; p&lt;/span&gt;&lt;span style="color: #000000; "&gt;++&lt;/span&gt;&lt;span style="color: #000000; "&gt;)
    {
        bits[&lt;/span&gt;&lt;span style="color: #000000; "&gt;7&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;-&lt;/span&gt;&lt;span style="color: #000000; "&gt; p] &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; (&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;)(&lt;/span&gt;&lt;span style="color: #000000; "&gt;1&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;amp;&lt;/span&gt;&lt;span style="color: #000000; "&gt; (inputByte &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000; "&gt; p));
    }

    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;return&lt;/span&gt;&lt;span style="color: #000000; "&gt; bits;
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Simple? Ok, I'll explain it a bit... the bitwise operator &amp;gt;&amp;gt; just shifts the bits in the byte to the right so if 01010101 is shifted one position to the right it becomes 00101010... then I perform a logical AND operation with the mask 00000001 to determine if the bit is setted. I just store the state of every bit in the output array and return it. As a quick note, the bit array could be directly reversed if I change the line inside the for loop to:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:7429306c-e08f-48b1-a2af-c6b27bd81e7a" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #000000; "&gt;bits[p] &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; (&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;)(&lt;/span&gt;&lt;span style="color: #000000; "&gt;1&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;amp;&lt;/span&gt;&lt;span style="color: #000000; "&gt; (inputByte &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000; "&gt; p));&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But I wanted more generic methods to convert between byte and bits, so I didn't included reversing directly in that method. Once I have an array, it's simple to reverse it just with the previous method used with string arrays or via the .NET framework features:&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:702b1ce0-0cf0-44ae-9362-9c90b0b0a0b3" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #000000; "&gt;Array.Reverse(bits);&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;And know, we only have to be able to convert the bit array back to a byte structure:&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:5a2dd212-1fec-4890-86b8-a49ba4476643" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF; "&gt;static&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt; setBits(&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[] bits)
{
    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt; obyte &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; bits[&lt;/span&gt;&lt;span style="color: #000000; "&gt;0&lt;/span&gt;&lt;span style="color: #000000; "&gt;];

    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;for&lt;/span&gt;&lt;span style="color: #000000; "&gt; (&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;int&lt;/span&gt;&lt;span style="color: #000000; "&gt; p &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;1&lt;/span&gt;&lt;span style="color: #000000; "&gt;; p &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;8&lt;/span&gt;&lt;span style="color: #000000; "&gt;; p&lt;/span&gt;&lt;span style="color: #000000; "&gt;++&lt;/span&gt;&lt;span style="color: #000000; "&gt;)
    {
        obyte &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; (&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;)((obyte &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;1&lt;/span&gt;&lt;span style="color: #000000; "&gt;) &lt;/span&gt;&lt;span style="color: #000000; "&gt;+&lt;/span&gt;&lt;span style="color: #000000; "&gt; bits[p]);
    }

    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;return&lt;/span&gt;&lt;span style="color: #000000; "&gt; obyte;
}
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;The method used is similar to the one I used to extract the bits, but this time the bitwise operator &amp;lt;&amp;lt; is shifting bits to the left, so I can increase the number til it reach to the desired value. A simple test program to test how it works would be:&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8519a241-222d-4fe5-8714-7c1d32280bc2" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt; inputByte &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;1&lt;/span&gt;&lt;span style="color: #000000; "&gt;;
&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt; outputByte &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;0&lt;/span&gt;&lt;span style="color: #000000; "&gt;;

&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[] bits &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; getBits(inputByte);
Array.Reverse(bits);
outputByte &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; setBits(bits);

Console.WriteLine(&lt;/span&gt;&lt;span style="color: #000000; "&gt;"&lt;/span&gt;&lt;span style="color: #000000; "&gt;Input Byte: &lt;/span&gt;&lt;span style="color: #000000; "&gt;"&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;+&lt;/span&gt;&lt;span style="color: #000000; "&gt; inputByte);
Console.WriteLine(&lt;/span&gt;&lt;span style="color: #000000; "&gt;"&lt;/span&gt;&lt;span style="color: #000000; "&gt;Reversed Byte: &lt;/span&gt;&lt;span style="color: #000000; "&gt;"&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;+&lt;/span&gt;&lt;span style="color: #000000; "&gt; outputByte);
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;And a more complex one. Floating point numbers are represented usually by the standard IEEE 754, &lt;strong&gt;would you be able to reverse the bits of a floating point number?&lt;/strong&gt; In example, if you get 118.625f the output should be -17180580000f&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Wow! This is was a really hard one. I didn't know how the &lt;a href="http://en.wikipedia.org/wiki/IEEE_754" target="_blank"&gt;IEEE 754 standard&lt;/a&gt; worked so I read it at the wikipedia (&lt;a href="http://grouper.ieee.org/groups/754/" target="_blank"&gt;the IEEE page for this standard is under revision&lt;/a&gt; and there was no info available) and it seems pretty simple. The floating point its a 32bit data structured divided like this:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://upload.wikimedia.org/wikipedia/en/7/7b/Float_example.PNG" /&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;So now it seems much simpler to me. It's just a bit reversing operation, in C# the two floating point structures are Float or Double, the former to store floating point numbers with 32bits precision and the last with 64bits; the problem is that those types don't allow bitwise operations, so I need to create a new set of methods to work with them using the BitConverter class. &lt;/p&gt;
&lt;p&gt;It's probably refactorizable so just a pair of methods suit all the needs of bit operations, but the goal was to reverse the floating point number, so here I go:&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:284db004-068a-4dd4-8133-6cba57bc6d10" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF; "&gt;static&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[] getFloatingBits(&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;double&lt;/span&gt;&lt;span style="color: #000000; "&gt; input)
{
    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[] bytes &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; BitConverter.GetBytes(input);

    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;if&lt;/span&gt;&lt;span style="color: #000000; "&gt; (BitConverter.IsLittleEndian)
    {
        Array.Reverse(bytes);
    }

    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[] bits &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;new&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[&lt;/span&gt;&lt;span style="color: #000000; "&gt;64&lt;/span&gt;&lt;span style="color: #000000; "&gt;];

    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;for&lt;/span&gt;&lt;span style="color: #000000; "&gt; (&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;int&lt;/span&gt;&lt;span style="color: #000000; "&gt; i &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;0&lt;/span&gt;&lt;span style="color: #000000; "&gt;; i &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;8&lt;/span&gt;&lt;span style="color: #000000; "&gt;; i&lt;/span&gt;&lt;span style="color: #000000; "&gt;++&lt;/span&gt;&lt;span style="color: #000000; "&gt;)
    {
        Array.Copy(getBits(bytes[i]), &lt;/span&gt;&lt;span style="color: #000000; "&gt;0&lt;/span&gt;&lt;span style="color: #000000; "&gt;, bits, i &lt;/span&gt;&lt;span style="color: #000000; "&gt;*&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;8&lt;/span&gt;&lt;span style="color: #000000; "&gt;, &lt;/span&gt;&lt;span style="color: #000000; "&gt;8&lt;/span&gt;&lt;span style="color: #000000; "&gt;);
    }

    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;return&lt;/span&gt;&lt;span style="color: #000000; "&gt; bits;
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I explain the method it...The float type can by divided into 4 bytes and the BitConverter.GetBytes method can give us an array of that four bytes, but unfortunately it doesn't include a method to turn back an array of four bytes to a float, so I created this method for the double type and used casting :(&lt;/p&gt;
&lt;p&gt;The method is pretty simple, I extract the 8 bytes of the double precision float number. Then, I verify if the processor is &lt;a href="http://en.wikipedia.org/wiki/Endianness"&gt;LittleEndian&lt;/a&gt; and in that case I reverse the byte order to reflect the actual value. Everything is copied to an array of bits, and we are done. Now we only need to reverse that array of bits:&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:724037ef-8dd1-4267-803f-d84a8889fde8" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #000000; "&gt;Array.Reverse(bits);&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And turn back to the method that reverse the process from a bit array to a double precision floating number:&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:85fb2bc3-d929-4b64-bfb4-8bf1c0e41000" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF; "&gt;static&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;double&lt;/span&gt;&lt;span style="color: #000000; "&gt; setFloatingBits(&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[] bits)
{
    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[] bytes &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;new&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[&lt;/span&gt;&lt;span style="color: #000000; "&gt;8&lt;/span&gt;&lt;span style="color: #000000; "&gt;];

    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;for&lt;/span&gt;&lt;span style="color: #000000; "&gt; (&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;int&lt;/span&gt;&lt;span style="color: #000000; "&gt; i &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;0&lt;/span&gt;&lt;span style="color: #000000; "&gt;; i &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;8&lt;/span&gt;&lt;span style="color: #000000; "&gt;; i&lt;/span&gt;&lt;span style="color: #000000; "&gt;++&lt;/span&gt;&lt;span style="color: #000000; "&gt;)
    {
        &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[] actualByte &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;new&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;byte&lt;/span&gt;&lt;span style="color: #000000; "&gt;[&lt;/span&gt;&lt;span style="color: #000000; "&gt;8&lt;/span&gt;&lt;span style="color: #000000; "&gt;];
        Array.Copy(bits, i &lt;/span&gt;&lt;span style="color: #000000; "&gt;*&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;8&lt;/span&gt;&lt;span style="color: #000000; "&gt;, actualByte, &lt;/span&gt;&lt;span style="color: #000000; "&gt;0&lt;/span&gt;&lt;span style="color: #000000; "&gt;, &lt;/span&gt;&lt;span style="color: #000000; "&gt;8&lt;/span&gt;&lt;span style="color: #000000; "&gt;);
        
        bytes[i] &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; setBits(actualByte);
    }

    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;if&lt;/span&gt;&lt;span style="color: #000000; "&gt; (BitConverter.IsLittleEndian)
    {
        Array.Reverse(bytes);
    }

    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;return&lt;/span&gt;&lt;span style="color: #000000; "&gt; BitConverter.ToDouble(bytes, &lt;/span&gt;&lt;span style="color: #000000; "&gt;0&lt;/span&gt;&lt;span style="color: #000000; "&gt;);
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;The issue is that the expected floating number is not the one I got with this method that reverse the complete array of bits. In fact, I've also re-read the question and it said "are you able to reverse the order of the bits for the exponent and mantissa?" ... I actually did also that, reversing only bits for mantissa and exponent, obtaining the following bit arrays:&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:3f8846f9-9b46-4cff-9f8e-26495884cfcd" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #000000; "&gt;Original: &lt;/span&gt;&lt;span style="color: #000000; "&gt;0&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;10000000&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;10111011010100000000000&lt;/span&gt;&lt;span style="color: #000000; "&gt;
Reversed: &lt;/span&gt;&lt;span style="color: #000000; "&gt;0&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;00000001&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;00000000000101011011101&lt;/span&gt;&lt;span style="color: #000000; "&gt;
Expected: &lt;/span&gt;&lt;span style="color: #000000; "&gt;1&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;10000100&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;00100000000000000101011&lt;/span&gt;&lt;span style="color: #000000; "&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;But that reversed number doesn't represent the one that Ricardo stated in his post. What am I doing wrong? Is anything wrong in my point of view or is the expected number wrong? I'm really curious about why there is one bit less in the expected number and how the sign bit changed.&lt;/p&gt;&lt;/blockquote&gt;&lt;img src ="http://blogs.clearscreen.com/migs/aggbug/5712.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>A couple of days ago my fellow friend <a href="http://geeks.ms/blogs/programancia101/" target="_blank">Ricardo Varela started to blog in spanish</a> (in parallel with <a href="http://phobeo.com/wordpress/" target="_blank">his actual english blog</a>). Former member of Microsoft communities, he is actually working at Google UK. The actual point is that on his new blog he started a <a href="http://geeks.ms/blogs/programancia101/archive/2006/12/26/empezando-por-el-principio.aspx" target="_blank">post with some kind of coding teasers</a>, going back to basics, to the principles of coding. This is going to be funny.</p> <p>Well, this is my answer to his post. There were three questions regarding data structures and alternative thinking about reversing things.</p> <p> </p> <ul> <li><strong>Do you know how to reverse a string?</strong> In example, if you get "abc" the returned string should be "cba"</li></ul> <blockquote> <p>This seemed pretty easy. In C# every string is represented as an array of chars, so you can use the indexers to get chars at any position and reverse them "manually" with something like:</p> <div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8c70f28c-5681-4087-a8de-ff301d4d1e49" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><pre style="background-color:White;"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">string</span><span style="color: #000000; "> inputString </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">"</span><span style="color: #000000; ">abc</span><span style="color: #000000; ">"</span><span style="color: #000000; ">;
</span><span style="color: #0000FF; ">string</span><span style="color: #000000; "> reversedString </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">string</span><span style="color: #000000; ">.Empty;

</span><span style="color: #0000FF; ">for</span><span style="color: #000000; "> (</span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> c </span><span style="color: #000000; ">=</span><span style="color: #000000; "> inputString.Length; c </span><span style="color: #000000; ">&gt;</span><span style="color: #000000; "> </span><span style="color: #000000; ">0</span><span style="color: #000000; ">; c</span><span style="color: #000000; ">--</span><span style="color: #000000; ">)
{
    reversedString </span><span style="color: #000000; ">+=</span><span style="color: #000000; "> inputString[c </span><span style="color: #000000; ">-</span><span style="color: #000000; "> </span><span style="color: #000000; ">1</span><span style="color: #000000; ">];
}

Console.WriteLine(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Original String: </span><span style="color: #000000; ">"</span><span style="color: #000000; "> </span><span style="color: #000000; ">+</span><span style="color: #000000; "> inputString);
Console.WriteLine(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Reversed String: </span><span style="color: #000000; ">"</span><span style="color: #000000; "> </span><span style="color: #000000; ">+</span><span style="color: #000000; "> reversedString);</span></div></pre></div>
<p>Or you can use some of the features of the .NET Framework to do it in a more "elegant" way:</p>
<p></p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:0ced2329-88b6-40e2-b630-6c4361f65c91" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><pre style="background-color:White;"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">char</span><span style="color: #000000; ">[] chars </span><span style="color: #000000; ">=</span><span style="color: #000000; "> inputString.ToCharArray();
Array.Reverse(chars);

</span><span style="color: #008000; ">//</span><span style="color: #008000; "> Use the reversed array of chars</span></div></pre></div></blockquote>
<ul>
<li>Going deeper into data structures, <strong>do you know how to reverse the bits of a byte?</strong> In example, if you get 1 the returned byte should be 128</li></ul>
<blockquote>
<p>I must admit this was a hard one. Although I perfectly know the concepts of bits and bitwise operations the C# language doesn't provide an easy or structured way to access those elementary elements of data structures. I finally managed to achieve it. The smallest numeric data structure available to represent a byte internals I found was a simple byte[8], so now I just have to fill it with the values for each byte:</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:2d195fac-cd85-4079-8439-78090cd01cd9" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><pre style="background-color:White;"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">static</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[] getBits(</span><span style="color: #0000FF; ">byte</span><span style="color: #000000; "> inputByte)
{
    </span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[] bits </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[</span><span style="color: #000000; ">8</span><span style="color: #000000; ">];

    </span><span style="color: #0000FF; ">for</span><span style="color: #000000; "> (</span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> p </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">0</span><span style="color: #000000; ">; p </span><span style="color: #000000; ">&lt;</span><span style="color: #000000; "> </span><span style="color: #000000; ">8</span><span style="color: #000000; ">; p</span><span style="color: #000000; ">++</span><span style="color: #000000; ">)
    {
        bits[</span><span style="color: #000000; ">7</span><span style="color: #000000; "> </span><span style="color: #000000; ">-</span><span style="color: #000000; "> p] </span><span style="color: #000000; ">=</span><span style="color: #000000; "> (</span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">)(</span><span style="color: #000000; ">1</span><span style="color: #000000; "> </span><span style="color: #000000; ">&amp;</span><span style="color: #000000; "> (inputByte </span><span style="color: #000000; ">&gt;&gt;</span><span style="color: #000000; "> p));
    }

    </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> bits;
}</span></div></pre></div></blockquote>
<blockquote>
<p>Simple? Ok, I'll explain it a bit... the bitwise operator &gt;&gt; just shifts the bits in the byte to the right so if 01010101 is shifted one position to the right it becomes 00101010... then I perform a logical AND operation with the mask 00000001 to determine if the bit is setted. I just store the state of every bit in the output array and return it. As a quick note, the bit array could be directly reversed if I change the line inside the for loop to:</p>
<p></p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:7429306c-e08f-48b1-a2af-c6b27bd81e7a" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><pre style="background-color:White;"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #000000; ">bits[p] </span><span style="color: #000000; ">=</span><span style="color: #000000; "> (</span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">)(</span><span style="color: #000000; ">1</span><span style="color: #000000; "> </span><span style="color: #000000; ">&amp;</span><span style="color: #000000; "> (inputByte </span><span style="color: #000000; ">&gt;&gt;</span><span style="color: #000000; "> p));</span></div></pre></div>
<p></p>
<p>But I wanted more generic methods to convert between byte and bits, so I didn't included reversing directly in that method. Once I have an array, it's simple to reverse it just with the previous method used with string arrays or via the .NET framework features:</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:702b1ce0-0cf0-44ae-9362-9c90b0b0a0b3" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><pre style="background-color:White;"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #000000; ">Array.Reverse(bits);</span></div></pre></div></blockquote>
<blockquote>
<p>And know, we only have to be able to convert the bit array back to a byte structure:</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:5a2dd212-1fec-4890-86b8-a49ba4476643" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><pre style="background-color:White;"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">static</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">byte</span><span style="color: #000000; "> setBits(</span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[] bits)
{
    </span><span style="color: #0000FF; ">byte</span><span style="color: #000000; "> obyte </span><span style="color: #000000; ">=</span><span style="color: #000000; "> bits[</span><span style="color: #000000; ">0</span><span style="color: #000000; ">];

    </span><span style="color: #0000FF; ">for</span><span style="color: #000000; "> (</span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> p </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">1</span><span style="color: #000000; ">; p </span><span style="color: #000000; ">&lt;</span><span style="color: #000000; "> </span><span style="color: #000000; ">8</span><span style="color: #000000; ">; p</span><span style="color: #000000; ">++</span><span style="color: #000000; ">)
    {
        obyte </span><span style="color: #000000; ">=</span><span style="color: #000000; "> (</span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">)((obyte </span><span style="color: #000000; ">&lt;&lt;</span><span style="color: #000000; "> </span><span style="color: #000000; ">1</span><span style="color: #000000; ">) </span><span style="color: #000000; ">+</span><span style="color: #000000; "> bits[p]);
    }

    </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> obyte;
}
</span></div></pre></div></blockquote>
<blockquote>
<p>The method used is similar to the one I used to extract the bits, but this time the bitwise operator &lt;&lt; is shifting bits to the left, so I can increase the number til it reach to the desired value. A simple test program to test how it works would be:</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8519a241-222d-4fe5-8714-7c1d32280bc2" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><pre style="background-color:White;"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">byte</span><span style="color: #000000; "> inputByte </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">1</span><span style="color: #000000; ">;
</span><span style="color: #0000FF; ">byte</span><span style="color: #000000; "> outputByte </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">0</span><span style="color: #000000; ">;

</span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[] bits </span><span style="color: #000000; ">=</span><span style="color: #000000; "> getBits(inputByte);
Array.Reverse(bits);
outputByte </span><span style="color: #000000; ">=</span><span style="color: #000000; "> setBits(bits);

Console.WriteLine(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Input Byte: </span><span style="color: #000000; ">"</span><span style="color: #000000; "> </span><span style="color: #000000; ">+</span><span style="color: #000000; "> inputByte);
Console.WriteLine(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Reversed Byte: </span><span style="color: #000000; ">"</span><span style="color: #000000; "> </span><span style="color: #000000; ">+</span><span style="color: #000000; "> outputByte);
</span></div></pre></div></blockquote>
<ul>
<li>And a more complex one. Floating point numbers are represented usually by the standard IEEE 754, <strong>would you be able to reverse the bits of a floating point number?</strong> In example, if you get 118.625f the output should be -17180580000f</li></ul>
<blockquote>
<p>Wow! This is was a really hard one. I didn't know how the <a href="http://en.wikipedia.org/wiki/IEEE_754" target="_blank">IEEE 754 standard</a> worked so I read it at the wikipedia (<a href="http://grouper.ieee.org/groups/754/" target="_blank">the IEEE page for this standard is under revision</a> and there was no info available) and it seems pretty simple. The floating point its a 32bit data structured divided like this:</p>
<p><img src="http://upload.wikimedia.org/wikipedia/en/7/7b/Float_example.PNG" /></p></blockquote>
<blockquote>
<p>So now it seems much simpler to me. It's just a bit reversing operation, in C# the two floating point structures are Float or Double, the former to store floating point numbers with 32bits precision and the last with 64bits; the problem is that those types don't allow bitwise operations, so I need to create a new set of methods to work with them using the BitConverter class. </p>
<p>It's probably refactorizable so just a pair of methods suit all the needs of bit operations, but the goal was to reverse the floating point number, so here I go:</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:284db004-068a-4dd4-8133-6cba57bc6d10" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><pre style="background-color:White;"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">static</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[] getFloatingBits(</span><span style="color: #0000FF; ">double</span><span style="color: #000000; "> input)
{
    </span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[] bytes </span><span style="color: #000000; ">=</span><span style="color: #000000; "> BitConverter.GetBytes(input);

    </span><span style="color: #0000FF; ">if</span><span style="color: #000000; "> (BitConverter.IsLittleEndian)
    {
        Array.Reverse(bytes);
    }

    </span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[] bits </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[</span><span style="color: #000000; ">64</span><span style="color: #000000; ">];

    </span><span style="color: #0000FF; ">for</span><span style="color: #000000; "> (</span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> i </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">0</span><span style="color: #000000; ">; i </span><span style="color: #000000; ">&lt;</span><span style="color: #000000; "> </span><span style="color: #000000; ">8</span><span style="color: #000000; ">; i</span><span style="color: #000000; ">++</span><span style="color: #000000; ">)
    {
        Array.Copy(getBits(bytes[i]), </span><span style="color: #000000; ">0</span><span style="color: #000000; ">, bits, i </span><span style="color: #000000; ">*</span><span style="color: #000000; "> </span><span style="color: #000000; ">8</span><span style="color: #000000; ">, </span><span style="color: #000000; ">8</span><span style="color: #000000; ">);
    }

    </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> bits;
}</span></div></pre></div>
<p>I explain the method it...The float type can by divided into 4 bytes and the BitConverter.GetBytes method can give us an array of that four bytes, but unfortunately it doesn't include a method to turn back an array of four bytes to a float, so I created this method for the double type and used casting :(</p>
<p>The method is pretty simple, I extract the 8 bytes of the double precision float number. Then, I verify if the processor is <a href="http://en.wikipedia.org/wiki/Endianness">LittleEndian</a> and in that case I reverse the byte order to reflect the actual value. Everything is copied to an array of bits, and we are done. Now we only need to reverse that array of bits:</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:724037ef-8dd1-4267-803f-d84a8889fde8" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><pre style="background-color:White;"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #000000; ">Array.Reverse(bits);</span></div></pre></div>
<p>And turn back to the method that reverse the process from a bit array to a double precision floating number:</p></blockquote>
<blockquote>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:85fb2bc3-d929-4b64-bfb4-8bf1c0e41000" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><pre style="background-color:White;"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">static</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">double</span><span style="color: #000000; "> setFloatingBits(</span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[] bits)
{
    </span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[] bytes </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[</span><span style="color: #000000; ">8</span><span style="color: #000000; ">];

    </span><span style="color: #0000FF; ">for</span><span style="color: #000000; "> (</span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> i </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">0</span><span style="color: #000000; ">; i </span><span style="color: #000000; ">&lt;</span><span style="color: #000000; "> </span><span style="color: #000000; ">8</span><span style="color: #000000; ">; i</span><span style="color: #000000; ">++</span><span style="color: #000000; ">)
    {
        </span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[] actualByte </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">byte</span><span style="color: #000000; ">[</span><span style="color: #000000; ">8</span><span style="color: #000000; ">];
        Array.Copy(bits, i </span><span style="color: #000000; ">*</span><span style="color: #000000; "> </span><span style="color: #000000; ">8</span><span style="color: #000000; ">, actualByte, </span><span style="color: #000000; ">0</span><span style="color: #000000; ">, </span><span style="color: #000000; ">8</span><span style="color: #000000; ">);
        
        bytes[i] </span><span style="color: #000000; ">=</span><span style="color: #000000; "> setBits(actualByte);
    }

    </span><span style="color: #0000FF; ">if</span><span style="color: #000000; "> (BitConverter.IsLittleEndian)
    {
        Array.Reverse(bytes);
    }

    </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> BitConverter.ToDouble(bytes, </span><span style="color: #000000; ">0</span><span style="color: #000000; ">);
}</span></div></pre></div></blockquote>
<blockquote>
<p>The issue is that the expected floating number is not the one I got with this method that reverse the complete array of bits. In fact, I've also re-read the question and it said "are you able to reverse the order of the bits for the exponent and mantissa?" ... I actually did also that, reversing only bits for mantissa and exponent, obtaining the following bit arrays:</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:3f8846f9-9b46-4cff-9f8e-26495884cfcd" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><pre style="background-color:White;"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #000000; ">Original: </span><span style="color: #000000; ">0</span><span style="color: #000000; "> </span><span style="color: #000000; ">10000000</span><span style="color: #000000; "> </span><span style="color: #000000; ">10111011010100000000000</span><span style="color: #000000; ">
Reversed: </span><span style="color: #000000; ">0</span><span style="color: #000000; "> </span><span style="color: #000000; ">00000001</span><span style="color: #000000; "> </span><span style="color: #000000; ">00000000000101011011101</span><span style="color: #000000; ">
Expected: </span><span style="color: #000000; ">1</span><span style="color: #000000; "> </span><span style="color: #000000; ">10000100</span><span style="color: #000000; "> </span><span style="color: #000000; ">00100000000000000101011</span><span style="color: #000000; ">
</span></div></pre></div></blockquote>
<blockquote>
<p>But that reversed number doesn't represent the one that Ricardo stated in his post. What am I doing wrong? Is anything wrong in my point of view or is the expected number wrong? I'm really curious about why there is one bit less in the expected number and how the sign bit changed.</p></blockquote><img src ="http://blogs.clearscreen.com/migs/aggbug/5712.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Miguel Jiménez</dc:creator><title>Provider Pattern: A practical guide to decoupling .NET 2.0 applications</title><link>http://blogs.clearscreen.com/migs/archive/2006/12/01/4781.aspx</link><pubDate>Fri, 01 Dec 2006 07:19:00 GMT</pubDate><guid>http://blogs.clearscreen.com/migs/archive/2006/12/01/4781.aspx</guid><wfw:comment>http://blogs.clearscreen.com/migs/comments/4781.aspx</wfw:comment><comments>http://blogs.clearscreen.com/migs/archive/2006/12/01/4781.aspx#Feedback</comments><slash:comments>69</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/migs/comments/commentRss/4781.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/migs/services/trackbacks/4781.aspx</trackback:ping><description>&lt;p&gt;During the following post I'm going to explain a design pattern widely used during software development processes and how it fits into the .NET ecosystem. This pattern would probably fits into the structural patterns group and it's mainly used to decouple components, so abstractions and concrete implementations can vary independently.&lt;/p&gt;
&lt;p&gt;Using the provider pattern in .NET (and most object oriented languages) is pretty easy. We need the following artifacts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A provider definition, used as a contract that specifies what it should do 
&lt;/li&gt;&lt;li&gt;One or multiple provider implementations of the declared contract 
&lt;/li&gt;&lt;li&gt;A consumer willing to make use of the provider and it's implementations&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Imaging the following real life scenario: There is a basic definition of what a car should do (provider definition) and what is considered a car: it must have 4 wheels, an engine, steering wheel, etc.. in the market you are able to find lot of implementations following the actual definition of a car (implementations of the provider), and we, as consumers, can make use of the knowledge and methods defined in the provider contract to change the implementation we use without affecting our behavior (we are able to switch cars and use the common definition of it, as a car, to drive any of the implementations).&lt;/p&gt;
&lt;p&gt;So know, imagine it in the context of software development. We have an interface that defines a set of properties and methods that our provider must implement; we then have one or multiple implementations of that interface available; and of course, any consuming application can use the interface to switch between implementations without being affected. Have a look to the following diagram:&lt;/p&gt;
&lt;p&gt;&lt;img src="/migs/files/ProviderModel1.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;This is pretty awesome and practical when we are willing to create componentized and decoupled applications. We just use interfaces. This pattern has been widely used in the new ASP.NET 2.0 to create the application services provider infrastructure. For example, the MembershipProvider can be defined either as SqlMembershipProvider or as a custom OracleMembershipProvider; they both provide the same functionality but with different behavior (one uses SQL Server as repository while the other is using Oracle databases)&lt;/p&gt;
&lt;p&gt;This pattern itself, IMHO, can dramatically increase the quality of your architecture because of the modularity and simplicity it provides.&lt;/p&gt;
&lt;p&gt;One of the hidden treasures of .NET is the existence of a Provider Model Framework that allows you to create custom Providers for anything (not only extensions of ASP.NET Providers, but any kind of .NET application or service) &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Using .NET Framework 2.0 Provider Model&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So let's start writting some code. To create a provider we first have to create a public abstract class that defines our contract. This class must implement the System.Configuration.ProviderBase abstract class and it should contain the definition of methods and properties used as the "contract" of our provider.&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:52fb5bef-1140-40d8-a455-411caba9dd11" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: white; WORD-WRAP: break-word"&gt;&lt;div&gt;&lt;!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--&gt;&lt;span style="COLOR: #008080"&gt;1&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;abstract&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; ImageProvider : ProviderBase
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;2&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;{
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;3&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;   &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;abstract&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; CanSaveImages { &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;; }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;4&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;   &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;abstract&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; Image GetImage(&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; id);
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;5&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;   &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;abstract&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; SaveImage(Image image);
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;6&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We then need to add the actual implementations of the provider. In this case, we are going to add an image provider for the file system and an extra one for SQL Server.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:9e9f7924-5c36-48fd-9d00-44a140fd29c8" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: white"&gt;&lt;div&gt;&lt;!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--&gt;&lt;span style="COLOR: #008080"&gt; 1&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; FileSystemImageProvider : ImageProvider
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 2&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;{
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 3&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; CanSaveImages
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 4&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 5&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 6&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 7&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;            &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;true&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;; &lt;/span&gt;&lt;span style="COLOR: #008000"&gt;//&lt;/span&gt;&lt;span style="COLOR: #008000"&gt; As we allow to save images&lt;/span&gt;&lt;span style="COLOR: #008000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 8&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;        }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 9&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;10&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;11&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; Image GetImage(&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; id)
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;12&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;13&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        &lt;/span&gt;&lt;span style="COLOR: #008000"&gt;//&lt;/span&gt;&lt;span style="COLOR: #008000"&gt; Some witty code to get the image from a folder in the FileSystem&lt;/span&gt;&lt;span style="COLOR: #008000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;14&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;        &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;15&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;16&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;17&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; SaveImage(System.Drawing.Image image)
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;18&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;19&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        &lt;/span&gt;&lt;span style="COLOR: #008000"&gt;//&lt;/span&gt;&lt;span style="COLOR: #008000"&gt; Some witty code to save the image to a folder in the FileSystem&lt;/span&gt;&lt;span style="COLOR: #008000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;20&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;    }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;21&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;}
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;22&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;23&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;24&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; SqlImageProvider : ImageProvider
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;25&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;{
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;26&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; CanSaveImages
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;27&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;28&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;29&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;30&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;            &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;true&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;; &lt;/span&gt;&lt;span style="COLOR: #008000"&gt;//&lt;/span&gt;&lt;span style="COLOR: #008000"&gt; As we allow to save images&lt;/span&gt;&lt;span style="COLOR: #008000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;31&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;        }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;32&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;33&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;34&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; Image GetImage(&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; id)
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;35&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;36&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        &lt;/span&gt;&lt;span style="COLOR: #008000"&gt;//&lt;/span&gt;&lt;span style="COLOR: #008000"&gt; Some witty code to get the image from a folder in the FileSystem&lt;/span&gt;&lt;span style="COLOR: #008000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;37&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;        &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;; ;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;38&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;39&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;40&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; SaveImage(System.Drawing.Image image)
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;41&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;42&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        &lt;/span&gt;&lt;span style="COLOR: #008000"&gt;//&lt;/span&gt;&lt;span style="COLOR: #008000"&gt; Some witty code to save the image to a folder in the FileSystem&lt;/span&gt;&lt;span style="COLOR: #008000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;43&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;    }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;44&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And finally, we need to create the service that will use the ImageProvider. It's is coupled to the contract definition of our provider and not to it's implementations, so it knows what to ask for but no actually how or where will it be done. The service just initializes the provider using the LoadProvider() method (it should read the provider from the config file; have in mind that here it's hardcoded for instructional purposes and you only need to change the LoadProvider method to achieve that goal)&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:3a204809-402d-4298-b5b3-d3a1e6b395e0" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: white; WORD-WRAP: break-word"&gt;&lt;div&gt;&lt;!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--&gt;&lt;span style="COLOR: #008080"&gt; 1&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; ImageService
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 2&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;{
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 3&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; ImageProvider _provider;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 4&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 5&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; ImageProvider Provider
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 6&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 7&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 8&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 9&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;            &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; _provider;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;10&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;11&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;12&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;13&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; ImageService()
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;14&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;15&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        LoadProvider();
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;16&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;17&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;18&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; LoadProvider()
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;19&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;20&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        ProviderSettings ps &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;=&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; ProviderSettings(&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;FileSystemImageProvider&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;, &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;FileSystemImageProvider_Type_Assembly&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;);
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;21&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        _provider &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;=&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; ProvidersHelper.InstantiateProvider(ps, &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;typeof&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;(FileSystemImageProvider)) &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; ImageProvider;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;22&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;23&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;24&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; Image GetImage(&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; id)
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;25&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;26&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; _provider.GetImage(id);
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;27&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;28&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;29&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; SaveImage(Image image)
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;30&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    {
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;31&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;        _provider.SaveImage(image);
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;32&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;33&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The main caveat of using the .NET Provider Model is that you must reference the System.Web assembly in, probably, non-web projects. This is needed in order to access the ProvidersHelper class used to instantiate the provider collection. And it also forces the application to use the System.Configuration namespace and classes to read the provider configuration located in the web.config or app.config files. &lt;/p&gt;
&lt;p&gt;You'll have to deal with the types and assembly names where those types are defined to create the ProviderSettings instance needed by the ProvidersHelper.InstantiateProvider method. It's maybe not recommended to use all this "web" references in a desktop or service context; so there's a clean and elegant alternative for the OO purists :)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The pure OO implementation&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So, we need to get rid of the System.Web reference and make the provider pattern work without using the .NET Framework 2.0 model. The first thing we need to do is to refactor provider's abstract class to an interface (or leave it as a class, it's up to you, but remove the ProviderBase inheritance and any reference to the System.Configuration namespace) and change the concrete providers implementations to make them use the newly created interface. The class diagram should look similar to:&lt;/p&gt;
&lt;p&gt;&lt;img src="/migs/files/ProviderModel2.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;First, we should create the following code for the provider contract:&lt;/p&gt;
&lt;p&gt;&lt;font color="#ff0000"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:60686d22-92ef-4cc1-bd6f-e5a73d070dc8" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: white; WORD-WRAP: break-word"&gt;&lt;div&gt;&lt;!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--&gt;&lt;span style="COLOR: #008080"&gt;1&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;interface&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; IImageProvider
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;2&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;{
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;3&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; CanSaveImages { &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;; }
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;4&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    Image GetImage(&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; id);
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;5&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; SaveImage(Image image);
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;6&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And of course change the signature of the concrete provider implementations for FileSystemImageProvider and SqlImageProvider so they use the new contract:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:c3466cc5-db96-42b4-8b02-d86036b937e4" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: white; WORD-WRAP: break-word"&gt;&lt;div&gt;&lt;!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--&gt;&lt;span style="COLOR: #008080"&gt; 1&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; FileSystemImageProvider : IImageProvider
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 2&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;{
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 3&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;   &lt;/span&gt;&lt;span style="COLOR: #008000"&gt;//&lt;/span&gt;&lt;span style="COLOR: #008000"&gt; Implementation of the provider code, only signature of the class changed&lt;/span&gt;&lt;span style="COLOR: #008000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 4&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;}
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 5&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 6&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 7&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; SqlSystemImageProvider : IImageProvider
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 8&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;{
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt; 9&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;   &lt;/span&gt;&lt;span style="COLOR: #008000"&gt;//&lt;/span&gt;&lt;span style="COLOR: #008000"&gt; Implementation of the provider code, only signature of the class changed&lt;/span&gt;&lt;span style="COLOR: #008000"&gt;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;10&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The ImageService still almost the same, we only need to change LoadProvider's code so it creates an instance of the desired concrete implementation without using the ProvidersHelper class. Something like this may work perfectly:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:d44ec1d0-586e-40e4-b657-bfd5caba0113" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: white; WORD-WRAP: break-word"&gt;&lt;div&gt;&lt;!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--&gt;&lt;span style="COLOR: #008080"&gt;1&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; LoadProvider()
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;2&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;{
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;3&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;    _provider &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;=&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; Activator.CreateInstance(&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;typeof&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;(FileSystemImageProvider)) &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; IImageProvider;
&lt;/span&gt;&lt;span style="COLOR: #008080"&gt;4&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Any conclusion?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the approach it's quite similar for both methods and it's really simple to introduce it in most of actual software projects and architectures. It provides ease of installation, highly decoupled systems and modularity both in development and deployment.&lt;/p&gt;
&lt;p&gt;There's no excuse to avoid this pattern, as far as it's possible and pragmatic to use it in the context of your architecture :) &lt;/p&gt;
&lt;p&gt;Hope this helps anyone.&lt;/p&gt;&lt;img src ="http://blogs.clearscreen.com/migs/aggbug/4781.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>During the following post I'm going to explain a design pattern widely used during software development processes and how it fits into the .NET ecosystem. This pattern would probably fits into the structural patterns group and it's mainly used to decouple components, so abstractions and concrete implementations can vary independently.</p>
<p>Using the provider pattern in .NET (and most object oriented languages) is pretty easy. We need the following artifacts:</p>
<ul>
<li>A provider definition, used as a contract that specifies what it should do 
</li><li>One or multiple provider implementations of the declared contract 
</li><li>A consumer willing to make use of the provider and it's implementations</li></ul>
<p>Imaging the following real life scenario: There is a basic definition of what a car should do (provider definition) and what is considered a car: it must have 4 wheels, an engine, steering wheel, etc.. in the market you are able to find lot of implementations following the actual definition of a car (implementations of the provider), and we, as consumers, can make use of the knowledge and methods defined in the provider contract to change the implementation we use without affecting our behavior (we are able to switch cars and use the common definition of it, as a car, to drive any of the implementations).</p>
<p>So know, imagine it in the context of software development. We have an interface that defines a set of properties and methods that our provider must implement; we then have one or multiple implementations of that interface available; and of course, any consuming application can use the interface to switch between implementations without being affected. Have a look to the following diagram:</p>
<p><img src="/migs/files/ProviderModel1.jpg" /></p>
<p>This is pretty awesome and practical when we are willing to create componentized and decoupled applications. We just use interfaces. This pattern has been widely used in the new ASP.NET 2.0 to create the application services provider infrastructure. For example, the MembershipProvider can be defined either as SqlMembershipProvider or as a custom OracleMembershipProvider; they both provide the same functionality but with different behavior (one uses SQL Server as repository while the other is using Oracle databases)</p>
<p>This pattern itself, IMHO, can dramatically increase the quality of your architecture because of the modularity and simplicity it provides.</p>
<p>One of the hidden treasures of .NET is the existence of a Provider Model Framework that allows you to create custom Providers for anything (not only extensions of ASP.NET Providers, but any kind of .NET application or service) </p>
<p><strong></strong> </p>
<p><strong>Using .NET Framework 2.0 Provider Model</strong></p>
<p>So let's start writting some code. To create a provider we first have to create a public abstract class that defines our contract. This class must implement the System.Configuration.ProviderBase abstract class and it should contain the definition of methods and properties used as the "contract" of our provider.</p>
<div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:52fb5bef-1140-40d8-a455-411caba9dd11" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"><pre style="BACKGROUND-COLOR: white; WORD-WRAP: break-word"><div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="COLOR: #008080">1</span> <span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">abstract</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> ImageProvider : ProviderBase
</span><span style="COLOR: #008080">2</span> <span style="COLOR: #000000">{
</span><span style="COLOR: #008080">3</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">abstract</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">bool</span><span style="COLOR: #000000"> CanSaveImages { </span><span style="COLOR: #0000ff">get</span><span style="COLOR: #000000">; }
</span><span style="COLOR: #008080">4</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">abstract</span><span style="COLOR: #000000"> Image GetImage(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> id);
</span><span style="COLOR: #008080">5</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">abstract</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> SaveImage(Image image);
</span><span style="COLOR: #008080">6</span> <span style="COLOR: #000000">}</span></div></pre></div>
<p>We then need to add the actual implementations of the provider. In this case, we are going to add an image provider for the file system and an extra one for SQL Server.</p>
<p></p>
<div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:9e9f7924-5c36-48fd-9d00-44a140fd29c8" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"><pre style="BACKGROUND-COLOR: white"><div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="COLOR: #008080"> 1</span> <span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> FileSystemImageProvider : ImageProvider
</span><span style="COLOR: #008080"> 2</span> <span style="COLOR: #000000">{
</span><span style="COLOR: #008080"> 3</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">override</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">bool</span><span style="COLOR: #000000"> CanSaveImages
</span><span style="COLOR: #008080"> 4</span> <span style="COLOR: #000000">    {
</span><span style="COLOR: #008080"> 5</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">get</span><span style="COLOR: #000000">
</span><span style="COLOR: #008080"> 6</span> <span style="COLOR: #000000">        {
</span><span style="COLOR: #008080"> 7</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> As we allow to save images</span><span style="COLOR: #008000">
</span><span style="COLOR: #008080"> 8</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">        }
</span><span style="COLOR: #008080"> 9</span> <span style="COLOR: #000000">    }
</span><span style="COLOR: #008080">10</span> <span style="COLOR: #000000">
</span><span style="COLOR: #008080">11</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">override</span><span style="COLOR: #000000"> Image GetImage(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> id)
</span><span style="COLOR: #008080">12</span> <span style="COLOR: #000000">    {
</span><span style="COLOR: #008080">13</span> <span style="COLOR: #000000">        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Some witty code to get the image from a folder in the FileSystem</span><span style="COLOR: #008000">
</span><span style="COLOR: #008080">14</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;
</span><span style="COLOR: #008080">15</span> <span style="COLOR: #000000">    }
</span><span style="COLOR: #008080">16</span> <span style="COLOR: #000000">
</span><span style="COLOR: #008080">17</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">override</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> SaveImage(System.Drawing.Image image)
</span><span style="COLOR: #008080">18</span> <span style="COLOR: #000000">    {
</span><span style="COLOR: #008080">19</span> <span style="COLOR: #000000">        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Some witty code to save the image to a folder in the FileSystem</span><span style="COLOR: #008000">
</span><span style="COLOR: #008080">20</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">    }
</span><span style="COLOR: #008080">21</span> <span style="COLOR: #000000">}
</span><span style="COLOR: #008080">22</span> <span style="COLOR: #000000">
</span><span style="COLOR: #008080">23</span> <span style="COLOR: #000000">
</span><span style="COLOR: #008080">24</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> SqlImageProvider : ImageProvider
</span><span style="COLOR: #008080">25</span> <span style="COLOR: #000000">{
</span><span style="COLOR: #008080">26</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">override</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">bool</span><span style="COLOR: #000000"> CanSaveImages
</span><span style="COLOR: #008080">27</span> <span style="COLOR: #000000">    {
</span><span style="COLOR: #008080">28</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">get</span><span style="COLOR: #000000">
</span><span style="COLOR: #008080">29</span> <span style="COLOR: #000000">        {
</span><span style="COLOR: #008080">30</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> As we allow to save images</span><span style="COLOR: #008000">
</span><span style="COLOR: #008080">31</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">        }
</span><span style="COLOR: #008080">32</span> <span style="COLOR: #000000">    }
</span><span style="COLOR: #008080">33</span> <span style="COLOR: #000000">
</span><span style="COLOR: #008080">34</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">override</span><span style="COLOR: #000000"> Image GetImage(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> id)
</span><span style="COLOR: #008080">35</span> <span style="COLOR: #000000">    {
</span><span style="COLOR: #008080">36</span> <span style="COLOR: #000000">        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Some witty code to get the image from a folder in the FileSystem</span><span style="COLOR: #008000">
</span><span style="COLOR: #008080">37</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">; ;
</span><span style="COLOR: #008080">38</span> <span style="COLOR: #000000">    }
</span><span style="COLOR: #008080">39</span> <span style="COLOR: #000000">
</span><span style="COLOR: #008080">40</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">override</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> SaveImage(System.Drawing.Image image)
</span><span style="COLOR: #008080">41</span> <span style="COLOR: #000000">    {
</span><span style="COLOR: #008080">42</span> <span style="COLOR: #000000">        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Some witty code to save the image to a folder in the FileSystem</span><span style="COLOR: #008000">
</span><span style="COLOR: #008080">43</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">    }
</span><span style="COLOR: #008080">44</span> <span style="COLOR: #000000">}</span></div></pre></div>
<p></p>
<p>And finally, we need to create the service that will use the ImageProvider. It's is coupled to the contract definition of our provider and not to it's implementations, so it knows what to ask for but no actually how or where will it be done. The service just initializes the provider using the LoadProvider() method (it should read the provider from the config file; have in mind that here it's hardcoded for instructional purposes and you only need to change the LoadProvider method to achieve that goal)</p>
<div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:3a204809-402d-4298-b5b3-d3a1e6b395e0" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"><pre style="BACKGROUND-COLOR: white; WORD-WRAP: break-word"><div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="COLOR: #008080"> 1</span> <span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> ImageService
</span><span style="COLOR: #008080"> 2</span> <span style="COLOR: #000000">{
</span><span style="COLOR: #008080"> 3</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">private</span><span style="COLOR: #000000"> ImageProvider _provider;
</span><span style="COLOR: #008080"> 4</span> <span style="COLOR: #000000">
</span><span style="COLOR: #008080"> 5</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> ImageProvider Provider
</span><span style="COLOR: #008080"> 6</span> <span style="COLOR: #000000">    {
</span><span style="COLOR: #008080"> 7</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">get</span><span style="COLOR: #000000">
</span><span style="COLOR: #008080"> 8</span> <span style="COLOR: #000000">        {
</span><span style="COLOR: #008080"> 9</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> _provider;
</span><span style="COLOR: #008080">10</span> <span style="COLOR: #000000">        }
</span><span style="COLOR: #008080">11</span> <span style="COLOR: #000000">    }
</span><span style="COLOR: #008080">12</span> <span style="COLOR: #000000">
</span><span style="COLOR: #008080">13</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> ImageService()
</span><span style="COLOR: #008080">14</span> <span style="COLOR: #000000">    {
</span><span style="COLOR: #008080">15</span> <span style="COLOR: #000000">        LoadProvider();
</span><span style="COLOR: #008080">16</span> <span style="COLOR: #000000">    }
</span><span style="COLOR: #008080">17</span> <span style="COLOR: #000000">
</span><span style="COLOR: #008080">18</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> LoadProvider()
</span><span style="COLOR: #008080">19</span> <span style="COLOR: #000000">    {
</span><span style="COLOR: #008080">20</span> <span style="COLOR: #000000">        ProviderSettings ps </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> ProviderSettings(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">FileSystemImageProvider</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">FileSystemImageProvider_Type_Assembly</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);
</span><span style="COLOR: #008080">21</span> <span style="COLOR: #000000">        _provider </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> ProvidersHelper.InstantiateProvider(ps, </span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(FileSystemImageProvider)) </span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000"> ImageProvider;
</span><span style="COLOR: #008080">22</span> <span style="COLOR: #000000">    }
</span><span style="COLOR: #008080">23</span> <span style="COLOR: #000000">
</span><span style="COLOR: #008080">24</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> Image GetImage(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> id)
</span><span style="COLOR: #008080">25</span> <span style="COLOR: #000000">    {
</span><span style="COLOR: #008080">26</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> _provider.GetImage(id);
</span><span style="COLOR: #008080">27</span> <span style="COLOR: #000000">    }
</span><span style="COLOR: #008080">28</span> <span style="COLOR: #000000">
</span><span style="COLOR: #008080">29</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> SaveImage(Image image)
</span><span style="COLOR: #008080">30</span> <span style="COLOR: #000000">    {
</span><span style="COLOR: #008080">31</span> <span style="COLOR: #000000">        _provider.SaveImage(image);
</span><span style="COLOR: #008080">32</span> <span style="COLOR: #000000">    }
</span><span style="COLOR: #008080">33</span> <span style="COLOR: #000000">}</span></div></pre></div>
<p>The main caveat of using the .NET Provider Model is that you must reference the System.Web assembly in, probably, non-web projects. This is needed in order to access the ProvidersHelper class used to instantiate the provider collection. And it also forces the application to use the System.Configuration namespace and classes to read the provider configuration located in the web.config or app.config files. </p>
<p>You'll have to deal with the types and assembly names where those types are defined to create the ProviderSettings instance needed by the ProvidersHelper.InstantiateProvider method. It's maybe not recommended to use all this "web" references in a desktop or service context; so there's a clean and elegant alternative for the OO purists :)</p>
<p><strong></strong> </p>
<p><strong>The pure OO implementation</strong></p>
<p>So, we need to get rid of the System.Web reference and make the provider pattern work without using the .NET Framework 2.0 model. The first thing we need to do is to refactor provider's abstract class to an interface (or leave it as a class, it's up to you, but remove the ProviderBase inheritance and any reference to the System.Configuration namespace) and change the concrete providers implementations to make them use the newly created interface. The class diagram should look similar to:</p>
<p><img src="/migs/files/ProviderModel2.jpg" /></p>
<p>First, we should create the following code for the provider contract:</p>
<p><font color="#ff0000"></font></p>
<div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:60686d22-92ef-4cc1-bd6f-e5a73d070dc8" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"><pre style="BACKGROUND-COLOR: white; WORD-WRAP: break-word"><div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="COLOR: #008080">1</span> <span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">interface</span><span style="COLOR: #000000"> IImageProvider
</span><span style="COLOR: #008080">2</span> <span style="COLOR: #000000">{
</span><span style="COLOR: #008080">3</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">bool</span><span style="COLOR: #000000"> CanSaveImages { </span><span style="COLOR: #0000ff">get</span><span style="COLOR: #000000">; }
</span><span style="COLOR: #008080">4</span> <span style="COLOR: #000000">    Image GetImage(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> id);
</span><span style="COLOR: #008080">5</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> SaveImage(Image image);
</span><span style="COLOR: #008080">6</span> <span style="COLOR: #000000">}</span></div></pre></div>
<p>And of course change the signature of the concrete provider implementations for FileSystemImageProvider and SqlImageProvider so they use the new contract:</p>
<p></p>
<div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:c3466cc5-db96-42b4-8b02-d86036b937e4" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"><pre style="BACKGROUND-COLOR: white; WORD-WRAP: break-word"><div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="COLOR: #008080"> 1</span> <span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> FileSystemImageProvider : IImageProvider
</span><span style="COLOR: #008080"> 2</span> <span style="COLOR: #000000">{
</span><span style="COLOR: #008080"> 3</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Implementation of the provider code, only signature of the class changed</span><span style="COLOR: #008000">
</span><span style="COLOR: #008080"> 4</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">}
</span><span style="COLOR: #008080"> 5</span> <span style="COLOR: #000000">
</span><span style="COLOR: #008080"> 6</span> <span style="COLOR: #000000">
</span><span style="COLOR: #008080"> 7</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> SqlSystemImageProvider : IImageProvider
</span><span style="COLOR: #008080"> 8</span> <span style="COLOR: #000000">{
</span><span style="COLOR: #008080"> 9</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Implementation of the provider code, only signature of the class changed</span><span style="COLOR: #008000">
</span><span style="COLOR: #008080">10</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">}</span></div></pre></div>
<p></p>
<p>The ImageService still almost the same, we only need to change LoadProvider's code so it creates an instance of the desired concrete implementation without using the ProvidersHelper class. Something like this may work perfectly:</p>
<p></p>
<div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:d44ec1d0-586e-40e4-b657-bfd5caba0113" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"><pre style="BACKGROUND-COLOR: white; WORD-WRAP: break-word"><div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="COLOR: #008080">1</span> <span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> LoadProvider()
</span><span style="COLOR: #008080">2</span> <span style="COLOR: #000000">{
</span><span style="COLOR: #008080">3</span> <span style="COLOR: #000000">    _provider </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> Activator.CreateInstance(</span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(FileSystemImageProvider)) </span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000"> IImageProvider;
</span><span style="COLOR: #008080">4</span> <span style="COLOR: #000000">}</span></div></pre></div>
<p></p>
<p><strong>Any conclusion?</strong></p>
<p>As you can see, the approach it's quite similar for both methods and it's really simple to introduce it in most of actual software projects and architectures. It provides ease of installation, highly decoupled systems and modularity both in development and deployment.</p>
<p>There's no excuse to avoid this pattern, as far as it's possible and pragmatic to use it in the context of your architecture :) </p>
<p>Hope this helps anyone.</p><img src ="http://blogs.clearscreen.com/migs/aggbug/4781.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Miguel Jiménez</dc:creator><title>Unit testing, adopting a practice by Roy Osherove</title><link>http://blogs.clearscreen.com/migs/archive/2006/11/07/4170.aspx</link><pubDate>Tue, 07 Nov 2006 11:23:00 GMT</pubDate><guid>http://blogs.clearscreen.com/migs/archive/2006/11/07/4170.aspx</guid><wfw:comment>http://blogs.clearscreen.com/migs/comments/4170.aspx</wfw:comment><comments>http://blogs.clearscreen.com/migs/archive/2006/11/07/4170.aspx#Feedback</comments><slash:comments>25</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/migs/comments/commentRss/4170.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/migs/services/trackbacks/4170.aspx</trackback:ping><description>&lt;p&gt;Yesterday I spent all the day in the preconference sessions at TechEd Developers 2006. I was going to attend Software Architecture sessions by Scott Hanselman, by I ended up at Agile Team System sessions by Roy Osherove.&lt;/p&gt;
&lt;p&gt;It's really interesting to see Royt explain Agile and Team System concepts, althought the were not very deep if you are experienced with agile methods and practices. We saw Agile concepts, TDD and Continuous Integrantion practices and finally how to apply Scrum with Team System.&lt;/p&gt;
&lt;p&gt;The most productive part to me was the Scrum session, and I got a really nice piece of intelligence from the Test Driven Development session. The name of test methods is really important because it's used directly as documentation, as a permanent sample of your code represented by unit tests. I already knew this, but the naming rules I used made me create names like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;public void CreateUserWithNullUserName&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;And there's nothing wrong with that name, it's almost perfect from my point of view, because it states clearly what the unit test is testing. But Roy presented a naming rule based in three parts that results in a much much better name:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;public void CreateUser_WhenUsernameIsNull_ThrowsInvalidOperationException&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Indredible!!! Much more pragmatic. Much more readable. Much simpler to see the behaviour of that unit test with the pattern MethodName_Behaviour_ExpectedResult.&lt;/p&gt;
&lt;p&gt;This has become an adopted practice. Inmediatly. During the next days I'll keep posting my thoughts about TechEd and sessions here.&lt;/p&gt;&lt;img src ="http://blogs.clearscreen.com/migs/aggbug/4170.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>Yesterday I spent all the day in the preconference sessions at TechEd Developers 2006. I was going to attend Software Architecture sessions by Scott Hanselman, by I ended up at Agile Team System sessions by Roy Osherove.</p>
<p>It's really interesting to see Royt explain Agile and Team System concepts, althought the were not very deep if you are experienced with agile methods and practices. We saw Agile concepts, TDD and Continuous Integrantion practices and finally how to apply Scrum with Team System.</p>
<p>The most productive part to me was the Scrum session, and I got a really nice piece of intelligence from the Test Driven Development session. The name of test methods is really important because it's used directly as documentation, as a permanent sample of your code represented by unit tests. I already knew this, but the naming rules I used made me create names like this:</p>
<blockquote>
<p><font face="courier new,courier">public void CreateUserWithNullUserName</font></p></blockquote>
<p>And there's nothing wrong with that name, it's almost perfect from my point of view, because it states clearly what the unit test is testing. But Roy presented a naming rule based in three parts that results in a much much better name:</p>
<blockquote>
<p><font face="courier new,courier">public void CreateUser_WhenUsernameIsNull_ThrowsInvalidOperationException</font></p></blockquote>
<p>Indredible!!! Much more pragmatic. Much more readable. Much simpler to see the behaviour of that unit test with the pattern MethodName_Behaviour_ExpectedResult.</p>
<p>This has become an adopted practice. Inmediatly. During the next days I'll keep posting my thoughts about TechEd and sessions here.</p><img src ="http://blogs.clearscreen.com/migs/aggbug/4170.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Miguel Jiménez</dc:creator><title>Something about robotics: Lego Mindstorms NXT launched!!!</title><link>http://blogs.clearscreen.com/migs/archive/2006/02/02/2745.aspx</link><pubDate>Thu, 02 Feb 2006 19:15:00 GMT</pubDate><guid>http://blogs.clearscreen.com/migs/archive/2006/02/02/2745.aspx</guid><wfw:comment>http://blogs.clearscreen.com/migs/comments/2745.aspx</wfw:comment><comments>http://blogs.clearscreen.com/migs/archive/2006/02/02/2745.aspx#Feedback</comments><slash:comments>40</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/migs/comments/commentRss/2745.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/migs/services/trackbacks/2745.aspx</trackback:ping><description>&lt;p&gt;I've been a fan of Lego Mindstorms since I first saw it two or three years ago. I bought my own Robotic Invention System (well, frankly it was Diana's gift for one of my birthdays... yoohoo!!!) and I love it... it provides me great intellectual and funny moments... I've learned how to use C# and .NET to program my robots and tried to attach a bluetooth device to it with no success.&lt;/p&gt;
&lt;p&gt;I was really sad when Lego retired the kit, because I thought it would be almost impossible to find more pieces or expansion kits... but far away from what I though Lego announced a new version of the Mindstorms kit called NXT ... and it looks much more impressive than (the now old-fashioned) RIS; look at it:&lt;/p&gt;
&lt;p&gt;&lt;img src="/migs/files/legonxt.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;I want one of those now! While I manage to buy one this is a list of interesting resources (an interesting fact is that the Lego website is developed using ASP.NET):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.lego.com/eng/info/default.asp?page=pressdetail&amp;amp;contentid=17278&amp;amp;countrycode=2057&amp;amp;yearcode=&amp;amp;archive=false"&gt;Lego Mindstorms NXT press announcement&lt;/a&gt; (dated 4 January?!?) 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.nxtbot.com/"&gt;http://www.nxtbot.com/&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://mindstorms.lego.com/press/2057/LEGO%20MINDSTORMS%20NXT%20Key%20Product%20Features.aspx"&gt;Lego Mindstorms NXT product features&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://mindstorms.lego.com/press/2057/LEGO%20MINDSTORMS%20Issues%20Call%20for%20NXT%20Great%20Developers.aspx"&gt;Lego Mindstorms NXT Issues Call for "NXT" Great Developers&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;By the way... Just related to my Lego Mindstorms addiction, I'll be speaking in an event called &lt;a href="http://msevents-eu.microsoft.com/CUI/EventDetail.aspx?EventID=118767508&amp;amp;Culture=es-ES"&gt;Applied robotics with Lego Mindstorms and C#&lt;/a&gt; in our April meeting (third Thursday) at &lt;a href="http://www.madriddotnet.com/"&gt;Madrid .NET User Group&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It would be held in Madrid, Spain; and in perfect spanish :-D ... If you can pass by and visit us that day, it would be great!&lt;/p&gt;&lt;img src ="http://blogs.clearscreen.com/migs/aggbug/2745.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>I've been a fan of Lego Mindstorms since I first saw it two or three years ago. I bought my own Robotic Invention System (well, frankly it was Diana's gift for one of my birthdays... yoohoo!!!) and I love it... it provides me great intellectual and funny moments... I've learned how to use C# and .NET to program my robots and tried to attach a bluetooth device to it with no success.</p>
<p>I was really sad when Lego retired the kit, because I thought it would be almost impossible to find more pieces or expansion kits... but far away from what I though Lego announced a new version of the Mindstorms kit called NXT ... and it looks much more impressive than (the now old-fashioned) RIS; look at it:</p>
<p><img src="/migs/files/legonxt.jpg" /></p>
<p>I want one of those now! While I manage to buy one this is a list of interesting resources (an interesting fact is that the Lego website is developed using ASP.NET):</p>
<ul>
<li><a href="http://www.lego.com/eng/info/default.asp?page=pressdetail&amp;contentid=17278&amp;countrycode=2057&amp;yearcode=&amp;archive=false">Lego Mindstorms NXT press announcement</a> (dated 4 January?!?) 
</li><li><a href="http://www.nxtbot.com/">http://www.nxtbot.com/</a> 
</li><li><a href="http://mindstorms.lego.com/press/2057/LEGO%20MINDSTORMS%20NXT%20Key%20Product%20Features.aspx">Lego Mindstorms NXT product features</a> 
</li><li><a href="http://mindstorms.lego.com/press/2057/LEGO%20MINDSTORMS%20Issues%20Call%20for%20NXT%20Great%20Developers.aspx">Lego Mindstorms NXT Issues Call for "NXT" Great Developers</a></li></ul>
<p>By the way... Just related to my Lego Mindstorms addiction, I'll be speaking in an event called <a href="http://msevents-eu.microsoft.com/CUI/EventDetail.aspx?EventID=118767508&amp;Culture=es-ES">Applied robotics with Lego Mindstorms and C#</a> in our April meeting (third Thursday) at <a href="http://www.madriddotnet.com/">Madrid .NET User Group</a></p>
<p>It would be held in Madrid, Spain; and in perfect spanish :-D ... If you can pass by and visit us that day, it would be great!</p><img src ="http://blogs.clearscreen.com/migs/aggbug/2745.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Miguel Jiménez</dc:creator><title>Upgrading to MCPD Web, Windows and Enterprise developer from MCAD and MCSD</title><link>http://blogs.clearscreen.com/migs/archive/2006/01/25/2697.aspx</link><pubDate>Wed, 25 Jan 2006 11:10:00 GMT</pubDate><guid>http://blogs.clearscreen.com/migs/archive/2006/01/25/2697.aspx</guid><wfw:comment>http://blogs.clearscreen.com/migs/comments/2697.aspx</wfw:comment><comments>http://blogs.clearscreen.com/migs/archive/2006/01/25/2697.aspx#Feedback</comments><slash:comments>25</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/migs/comments/commentRss/2697.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/migs/services/trackbacks/2697.aspx</track