<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>71</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>145</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>304</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>34</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>65</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>30</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</trackback:ping><description>&lt;p&gt;As part of my MVP package I received an email from my MVP lead with 4 vouchers to upgrade my current certifications (MCAD and MCSD) to the new 2.0 certs. Actually I will take the following exams:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.microsoft.com/learning/exams/70-551.asp"&gt;70-551 - UPGRADE: MCAD Skills to MCPD Web Developer by Using the Microsoft .NET Framework&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.microsoft.com/learning/exams/70-552.asp"&gt;70-552 - UPGRADE: MCAD Skills to MCPD Windows Developer by Using the Microsoft .NET Framework&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.microsoft.com/learning/exams/70-553.asp"&gt;70-553 - UPGRADE: MCSD Microsoft .NET Skills to MCPD Enterprise Application Developer by Using the Microsoft .NET Framework: Part 1&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.microsoft.com/learning/exams/70-554.asp"&gt;70-554 - UPGRADE: MCSD Microsoft .NET Skills to MCPD Enterprise Application Developer by Using the Microsoft .NET Framework: Part 2&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;All this exams are in beta status. I'll take all of them between Feb13th and Mar, 13th... one each Friday. There's no study materials nor books available yet, so the only info is what I already know and MSDN. I'm preparing a Fast Study Guide for each of those exams using the table of contents that Microsoft published in every prepartion guide (follow the links above) ... As soon as the TOC is almost complete I'll upload them so more people could use them to study for their exams.&lt;/p&gt;
&lt;p&gt;Is anyone else taking this exams?&lt;/p&gt;&lt;img src ="http://blogs.clearscreen.com/migs/aggbug/2697.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>As part of my MVP package I received an email from my MVP lead with 4 vouchers to upgrade my current certifications (MCAD and MCSD) to the new 2.0 certs. Actually I will take the following exams:</p>
<ul>
<li><a href="http://www.microsoft.com/learning/exams/70-551.asp">70-551 - UPGRADE: MCAD Skills to MCPD Web Developer by Using the Microsoft .NET Framework</a> 
</li><li><a href="http://www.microsoft.com/learning/exams/70-552.asp">70-552 - UPGRADE: MCAD Skills to MCPD Windows Developer by Using the Microsoft .NET Framework</a> 
</li><li><a href="http://www.microsoft.com/learning/exams/70-553.asp">70-553 - UPGRADE: MCSD Microsoft .NET Skills to MCPD Enterprise Application Developer by Using the Microsoft .NET Framework: Part 1</a> 
</li><li><a href="http://www.microsoft.com/learning/exams/70-554.asp">70-554 - UPGRADE: MCSD Microsoft .NET Skills to MCPD Enterprise Application Developer by Using the Microsoft .NET Framework: Part 2</a></li></ul>
<p>All this exams are in beta status. I'll take all of them between Feb13th and Mar, 13th... one each Friday. There's no study materials nor books available yet, so the only info is what I already know and MSDN. I'm preparing a Fast Study Guide for each of those exams using the table of contents that Microsoft published in every prepartion guide (follow the links above) ... As soon as the TOC is almost complete I'll upload them so more people could use them to study for their exams.</p>
<p>Is anyone else taking this exams?</p><img src ="http://blogs.clearscreen.com/migs/aggbug/2697.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Miguel Jiménez</dc:creator><title>I've been MVP Awarded</title><link>http://blogs.clearscreen.com/migs/archive/2006/01/09/2671.aspx</link><pubDate>Mon, 09 Jan 2006 15:24:00 GMT</pubDate><guid>http://blogs.clearscreen.com/migs/archive/2006/01/09/2671.aspx</guid><wfw:comment>http://blogs.clearscreen.com/migs/comments/2671.aspx</wfw:comment><comments>http://blogs.clearscreen.com/migs/archive/2006/01/09/2671.aspx#Feedback</comments><slash:comments>38</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/migs/comments/commentRss/2671.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/migs/services/trackbacks/2671.aspx</trackback:ping><description>&lt;p&gt;Hey, I just came from a quick new year's holidays in the snow and found in my mailbox that I've been awarded with an MVP for Visual Developer - Visual C# ... pretty good news and Xmas present to me. Thanks to the people who believed in me and had me in their minds for this award (I can assure you there are lot of benefits when becoming MVP) and I'll try me best to keep working for the communities (online and offline) during the whole 2006.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://mvp.support.microsoft.com/profile=60EBCBEE-174B-43BB-9786-31332AF0B556" target="new"&gt;&lt;img src="/migs/files/mvplogo.jpg" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks to Alberto Amescua, David Carmona and Alfonso Rodriguez from Microsoft Spain, to all the guys at INETA Europe, all the leaders of Spanish User Groups, all the members of Madrid .NET User Group... and, of course, to all the ilitios, my beloved mates at &lt;a title="ilitia technologies" href="http://www.ilitia.com/" target="_blank"&gt;Ilitia Technologies&lt;/a&gt;.&lt;/p&gt;&lt;img src ="http://blogs.clearscreen.com/migs/aggbug/2671.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>Hey, I just came from a quick new year's holidays in the snow and found in my mailbox that I've been awarded with an MVP for Visual Developer - Visual C# ... pretty good news and Xmas present to me. Thanks to the people who believed in me and had me in their minds for this award (I can assure you there are lot of benefits when becoming MVP) and I'll try me best to keep working for the communities (online and offline) during the whole 2006.</p>
<p><a href="https://mvp.support.microsoft.com/profile=60EBCBEE-174B-43BB-9786-31332AF0B556" target="new"><img src="/migs/files/mvplogo.jpg" border="0" /></a></p>
<p>Thanks to Alberto Amescua, David Carmona and Alfonso Rodriguez from Microsoft Spain, to all the guys at INETA Europe, all the leaders of Spanish User Groups, all the members of Madrid .NET User Group... and, of course, to all the ilitios, my beloved mates at <a title="ilitia technologies" href="http://www.ilitia.com/" target="_blank">Ilitia Technologies</a>.</p><img src ="http://blogs.clearscreen.com/migs/aggbug/2671.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Miguel Jiménez</dc:creator><title>Extension Methods in C# 3.0</title><link>http://blogs.clearscreen.com/migs/archive/2005/10/10/2484.aspx</link><pubDate>Mon, 10 Oct 2005 18:50:00 GMT</pubDate><guid>http://blogs.clearscreen.com/migs/archive/2005/10/10/2484.aspx</guid><wfw:comment>http://blogs.clearscreen.com/migs/comments/2484.aspx</wfw:comment><comments>http://blogs.clearscreen.com/migs/archive/2005/10/10/2484.aspx#Feedback</comments><slash:comments>145</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/migs/comments/commentRss/2484.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/migs/services/trackbacks/2484.aspx</trackback:ping><description>&lt;p&gt;I had the chance to read the overview and specs of Orcas' C# 3.0 and there are lot of interesting things that are put together to support &lt;a href="http://msdn.microsoft.com/netframework/future/linq/"&gt;LINQ&lt;/a&gt; in the next version of the language. One of the most easily applicable new features are Extension Methods, but what are they used for? Easy, the extend current types with new static methods by simply adding an using directive with the extender class and without adding a line of code to the previous existing classes... let's see an easy example:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;namespace&lt;/span&gt; Acme.Utilities
{
      &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;static&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;class&lt;/span&gt; Extensions
      {
            &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;static&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;int&lt;/span&gt; ToInt32(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;this&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;string&lt;/span&gt; s) {
                  &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;return&lt;/span&gt; Int32.Parse(s);
            }
            &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;static&lt;/span&gt; T[] Slice(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;this&lt;/span&gt; T[] source, &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;int&lt;/span&gt; index, &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;int&lt;/span&gt; count) {
                  &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;if&lt;/span&gt; (index &amp;lt; 0 || count &amp;lt; 0 || source.Length – index &amp;lt; count)
                       &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;throw&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;new&lt;/span&gt; ArgumentException();
                  T[] result &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;new&lt;/span&gt; T[count];
                  Array.Copy(source, index, result, 0, count);
                  &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;return&lt;/span&gt; result;
            }
      }
}

&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;string&lt;/span&gt; s &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; &lt;span style="color: #666666; background-color: #e4e4e4; font-family: Courier New; font-size: 11px"&gt;"1234"&lt;/span&gt;;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;int&lt;/span&gt; i &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; s.ToInt32();  &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;// Same as Extensions.ToInt32(s)&lt;/span&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;int&lt;/span&gt;[] digits &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;int&lt;/span&gt;[] a &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; digits.Slice(4, 3);      &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;// Same as Extensions.Slice(digits, 4, 3)&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt; 
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So, this seems quite useful to me right now, and obviously to the framework guys at Redmond. Firstly, the object type could be extended with lot of methods by simply adding the using System to each class, and thus classes will be more clean and modularized, containing only implementation and logic within their domain of action. Obviously, it wouldn't be that useful without C# 2.0 Generics, the cornerstone of all the upcoming features, and without new inference methods in arrays and vars.&lt;/p&gt;
&lt;p&gt;Well, extension methods seems a bit like one step forward than implementing interfaces or inheritance... I mean, why would I implement IMyInterface or inherit from a base class to extend it if I can extend my objects by simply adding an using MyNamespace.IMyExtension??&lt;/p&gt;
&lt;p&gt;Actually, I have in mind an easy-to-think example of a good scenario to apply method extensions: data access layers and object to relational mappers... Guess the following:&lt;/p&gt;
&lt;p&gt;We may have a set of object classes that describe the entities in my scenario, all of them decorated with a set of attributes that declare how they map to my rdbms database (i.e. table name, relations, fields, etc...) Now, guess we have developed a set of classes that contains typical database methods (save, retrieve, update, find, etc...) declared with generic types, and instrumented with the ability to read types attributes to discover what procedures and tables should it call to retrieve data...&lt;/p&gt;
&lt;p&gt;In this case, when we have our two dll's compiled (entities and the datamapping framework) it's just a done-puzzle to extend my entities with the new persistence methods and have full access to the database and data without modifying my original entities' code. And going further, this is so reusable that it can be plugged everywhere as far as my original classes contain the required attribute decoration to support the datamapping extension.&lt;/p&gt;
&lt;p&gt;It's just a shame that we have to wait that long to see this feature working in our development environments; but you can still test it with the &lt;a href="http://download.microsoft.com/download/4/7/0/4703eba2-78c4-4b09-8912-69f6c38d3a56/LINQ%20Preview.msi"&gt;C# 3.0 Community Technology Preview&lt;/a&gt;&lt;/p&gt;&lt;img src ="http://blogs.clearscreen.com/migs/aggbug/2484.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>I had the chance to read the overview and specs of Orcas' C# 3.0 and there are lot of interesting things that are put together to support <a href="http://msdn.microsoft.com/netframework/future/linq/">LINQ</a> in the next version of the language. One of the most easily applicable new features are Extension Methods, but what are they used for? Easy, the extend current types with new static methods by simply adding an using directive with the extender class and without adding a line of code to the previous existing classes... let's see an easy example:</p>
<p></p><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px"> <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">namespace</span> Acme.Utilities
{
      <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">public</span> <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">static</span> <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">class</span> Extensions
      {
            <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">public</span> <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">static</span> <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">int</span> ToInt32(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">this</span> <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">string</span> s) {
                  <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">return</span> Int32.Parse(s);
            }
            <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">public</span> <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">static</span> T[] Slice(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">this</span> T[] source, <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">int</span> index, <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">int</span> count) {
                  <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">if</span> (index &lt; 0 || count &lt; 0 || source.Length – index &lt; count)
                       <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">throw</span> <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">new</span> ArgumentException();
                  T[] result <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span> <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">new</span> T[count];
                  Array.Copy(source, index, result, 0, count);
                  <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">return</span> result;
            }
      }
}

<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">string</span> s <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span> <span style="color: #666666; background-color: #e4e4e4; font-family: Courier New; font-size: 11px">"1234"</span>;
<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">int</span> i <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span> s.ToInt32();  <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">// Same as Extensions.ToInt32(s)</span>
<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">int</span>[] digits <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span> {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">int</span>[] a <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span> digits.Slice(4, 3);      <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">// Same as Extensions.Slice(digits, 4, 3)</span></span></pre> 
<p></p>
<p>So, this seems quite useful to me right now, and obviously to the framework guys at Redmond. Firstly, the object type could be extended with lot of methods by simply adding the using System to each class, and thus classes will be more clean and modularized, containing only implementation and logic within their domain of action. Obviously, it wouldn't be that useful without C# 2.0 Generics, the cornerstone of all the upcoming features, and without new inference methods in arrays and vars.</p>
<p>Well, extension methods seems a bit like one step forward than implementing interfaces or inheritance... I mean, why would I implement IMyInterface or inherit from a base class to extend it if I can extend my objects by simply adding an using MyNamespace.IMyExtension??</p>
<p>Actually, I have in mind an easy-to-think example of a good scenario to apply method extensions: data access layers and object to relational mappers... Guess the following:</p>
<p>We may have a set of object classes that describe the entities in my scenario, all of them decorated with a set of attributes that declare how they map to my rdbms database (i.e. table name, relations, fields, etc...) Now, guess we have developed a set of classes that contains typical database methods (save, retrieve, update, find, etc...) declared with generic types, and instrumented with the ability to read types attributes to discover what procedures and tables should it call to retrieve data...</p>
<p>In this case, when we have our two dll's compiled (entities and the datamapping framework) it's just a done-puzzle to extend my entities with the new persistence methods and have full access to the database and data without modifying my original entities' code. And going further, this is so reusable that it can be plugged everywhere as far as my original classes contain the required attribute decoration to support the datamapping extension.</p>
<p>It's just a shame that we have to wait that long to see this feature working in our development environments; but you can still test it with the <a href="http://download.microsoft.com/download/4/7/0/4703eba2-78c4-4b09-8912-69f6c38d3a56/LINQ%20Preview.msi">C# 3.0 Community Technology Preview</a></p><img src ="http://blogs.clearscreen.com/migs/aggbug/2484.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Miguel Jiménez</dc:creator><title>Clearscreen SharpHIP 1.4 source code release</title><link>http://blogs.clearscreen.com/migs/archive/2005/10/05/2467.aspx</link><pubDate>Wed, 05 Oct 2005 23:26:00 GMT</pubDate><guid>http://blogs.clearscreen.com/migs/archive/2005/10/05/2467.aspx</guid><wfw:comment>http://blogs.clearscreen.com/migs/comments/2467.aspx</wfw:comment><comments>http://blogs.clearscreen.com/migs/archive/2005/10/05/2467.aspx#Feedback</comments><slash:comments>83</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/migs/comments/commentRss/2467.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/migs/services/trackbacks/2467.aspx</trackback:ping><description>&lt;p&gt;I'm finally releasing the source code of my Clearscreen SharpHIP 1.4 control, just in case any of wanna have a look to it. &lt;a href="http://blogs.clearscreen.com/migs/files/Clearscreen_SharpHip_14_src.zip"&gt;Download it here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you are new to the control, it's an approach of a Human Interaction Proof within a C# control that was created to stop spam comments on blogs and prevent automatic form submission in ASP.NET applications. Have a look to the &lt;a href="http://blogs.clearscreen.com/migs/archive/2005/04/05/1270.aspx"&gt;latest binaries release&lt;/a&gt;, because you'll find a readme.txt file there with instructions on how to install and use it.&lt;/p&gt;
&lt;p&gt;The source code is provided "as is", without any documentation beyond the source code. Anyway it's a quite simple control that features how to render images on the fly.&lt;/p&gt;&lt;img src ="http://blogs.clearscreen.com/migs/aggbug/2467.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>I'm finally releasing the source code of my Clearscreen SharpHIP 1.4 control, just in case any of wanna have a look to it. <a href="http://blogs.clearscreen.com/migs/files/Clearscreen_SharpHip_14_src.zip">Download it here</a></p>
<p>If you are new to the control, it's an approach of a Human Interaction Proof within a C# control that was created to stop spam comments on blogs and prevent automatic form submission in ASP.NET applications. Have a look to the <a href="http://blogs.clearscreen.com/migs/archive/2005/04/05/1270.aspx">latest binaries release</a>, because you'll find a readme.txt file there with instructions on how to install and use it.</p>
<p>The source code is provided "as is", without any documentation beyond the source code. Anyway it's a quite simple control that features how to render images on the fly.</p><img src ="http://blogs.clearscreen.com/migs/aggbug/2467.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Miguel Jiménez</dc:creator><title>Clearscreen CAPTCHA Control v1.4 Released with Community Server 1.0 support [UPDATED]</title><link>http://blogs.clearscreen.com/migs/archive/2005/04/05/1270.aspx</link><pubDate>Tue, 05 Apr 2005 01:30:00 GMT</pubDate><guid>http://blogs.clearscreen.com/migs/archive/2005/04/05/1270.aspx</guid><wfw:comment>http://blogs.clearscreen.com/migs/comments/1270.aspx</wfw:comment><comments>http://blogs.clearscreen.com/migs/archive/2005/04/05/1270.aspx#Feedback</comments><slash:comments>492</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/migs/comments/commentRss/1270.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/migs/services/trackbacks/1270.aspx</trackback:ping><description>&lt;p&gt;I've updated the Clearscreen.SharpHIP control to solve most of the reported issues. The new features and fixes for this release are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Bug Fixed: Enabled deletion of comments in .Text versions for logged admins 
&lt;/li&gt;&lt;li&gt;Bug Fixed: Use of IsValid property is now working correctly 
&lt;/li&gt;&lt;li&gt;Bug Fixed: Session and ViewState values for ValidationForm where mistyped on the code and where not working correctly. 
&lt;/li&gt;&lt;li&gt;New features added: 
&lt;ul&gt;
&lt;li&gt;Removed captcha at all when an admin or trusted used is logged in 
&lt;/li&gt;&lt;li&gt;Added support and compatibility for the new Community Server v1.0 
&lt;/li&gt;&lt;li&gt;Added help to install on Community Server v1.0 
&lt;/li&gt;&lt;li&gt;Added JavascriptURLDetection property (bool) to use Javascript or Server 
&lt;/li&gt;&lt;li&gt;side code to detect the URL that should be used in the image source. &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Follow the link to download: &lt;a href="http://blogs.clearscreen.com/migs/files/Clearscreen_SharpHIP_1_4.zip"&gt;Clearscreen SharpHIP HIP-CAPTCHA Control v1.4 for ASP.NET&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Hope that this new release helps to solve most of the actual issues, but if you find any bug or have any improvement that wasn't contained within this version, contact me and I'll try my best to solve it.&lt;/p&gt;
&lt;p&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;UPDATE: I updated the control to solve a reported error with image generation and javascript on some situations where the page that host the control has a formal querystring. The update is included in the zip file. [05/04/2005 21:00 GMT+1]&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src ="http://blogs.clearscreen.com/migs/aggbug/1270.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>I've updated the Clearscreen.SharpHIP control to solve most of the reported issues. The new features and fixes for this release are:</p>
<ul>
<li>Bug Fixed: Enabled deletion of comments in .Text versions for logged admins 
</li><li>Bug Fixed: Use of IsValid property is now working correctly 
</li><li>Bug Fixed: Session and ViewState values for ValidationForm where mistyped on the code and where not working correctly. 
</li><li>New features added: 
<ul>
<li>Removed captcha at all when an admin or trusted used is logged in 
</li><li>Added support and compatibility for the new Community Server v1.0 
</li><li>Added help to install on Community Server v1.0 
</li><li>Added JavascriptURLDetection property (bool) to use Javascript or Server 
</li><li>side code to detect the URL that should be used in the image source. </li></ul></li></ul>
<p>Follow the link to download: <a href="http://blogs.clearscreen.com/migs/files/Clearscreen_SharpHIP_1_4.zip">Clearscreen SharpHIP HIP-CAPTCHA Control v1.4 for ASP.NET</a></p>
<p>Hope that this new release helps to solve most of the actual issues, but if you find any bug or have any improvement that wasn't contained within this version, contact me and I'll try my best to solve it.</p>
<p><font color="#ff0000"><strong>UPDATE: I updated the control to solve a reported error with image generation and javascript on some situations where the page that host the control has a formal querystring. The update is included in the zip file. [05/04/2005 21:00 GMT+1]</strong></font></p><img src ="http://blogs.clearscreen.com/migs/aggbug/1270.aspx" width = "1" height = "1" /></body></item></channel></rss>