<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>IT Weblog</title>
	<atom:link href="http://blog.klimczyk.pl/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.klimczyk.pl</link>
	<description>Software Development WebLog</description>
	<lastBuildDate>Tue, 01 May 2012 10:37:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Quotation of the day! 2012-03-15</title>
		<link>http://blog.klimczyk.pl/2012/03/08/quotation-of-the-day-2012-03-15/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quotation-of-the-day-2012-03-15</link>
		<comments>http://blog.klimczyk.pl/2012/03/08/quotation-of-the-day-2012-03-15/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 13:27:26 +0000</pubDate>
		<dc:creator>klimmass</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://blog.klimczyk.pl/?p=140</guid>
		<description><![CDATA[Science is the poetry of reality Tweet]]></description>
			<content:encoded><![CDATA[<p><em><strong>Science is the poetry of reality</strong></em></p>
<div class="simple_likebuttons_container_small">
      <div class="simple_likebuttons_googleplus">
        <g:plusone size="medium" count="false" href="http://blog.klimczyk.pl/2012/03/08/quotation-of-the-day-2012-03-15/"></g:plusone>
      </div>
    
      <div class="simple_likebuttons_twitter simple_likebuttons_twitter_s">
        <a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="http://blog.klimczyk.pl/2012/03/08/quotation-of-the-day-2012-03-15/" data-lang="en">Tweet</a>
      </div>
    
      <div class="simple_likebuttons_facebook">
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, "script", "facebook-jssdk"));</script>
        <div class="fb-like" data-href="http://blog.klimczyk.pl/2012/03/08/quotation-of-the-day-2012-03-15/" data-send="false" data-layout="button_count" data-show-faces="false" data-width="90"></div>
      </div>
    </div>]]></content:encoded>
			<wfw:commentRss>http://blog.klimczyk.pl/2012/03/08/quotation-of-the-day-2012-03-15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quotation of the day! 2012-03-08</title>
		<link>http://blog.klimczyk.pl/2012/03/08/quotation-of-the-day-2012-03-08/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quotation-of-the-day-2012-03-08</link>
		<comments>http://blog.klimczyk.pl/2012/03/08/quotation-of-the-day-2012-03-08/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 11:08:58 +0000</pubDate>
		<dc:creator>klimmass</dc:creator>
				<category><![CDATA[Quotes]]></category>

		<guid isPermaLink="false">http://blog.klimczyk.pl/?p=133</guid>
		<description><![CDATA[If you see a switch statement you should think polymorphisms! Tweet]]></description>
			<content:encoded><![CDATA[<p><em><strong>If you see a switch statement you should think polymorphisms!</strong></em></p>
<div class="simple_likebuttons_container_small">
      <div class="simple_likebuttons_googleplus">
        <g:plusone size="medium" count="false" href="http://blog.klimczyk.pl/2012/03/08/quotation-of-the-day-2012-03-08/"></g:plusone>
      </div>
    
      <div class="simple_likebuttons_twitter simple_likebuttons_twitter_s">
        <a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="http://blog.klimczyk.pl/2012/03/08/quotation-of-the-day-2012-03-08/" data-lang="en">Tweet</a>
      </div>
    
      <div class="simple_likebuttons_facebook">
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, "script", "facebook-jssdk"));</script>
        <div class="fb-like" data-href="http://blog.klimczyk.pl/2012/03/08/quotation-of-the-day-2012-03-08/" data-send="false" data-layout="button_count" data-show-faces="false" data-width="90"></div>
      </div>
    </div>]]></content:encoded>
			<wfw:commentRss>http://blog.klimczyk.pl/2012/03/08/quotation-of-the-day-2012-03-08/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quotation of the day! 2012-02-20</title>
		<link>http://blog.klimczyk.pl/2012/02/20/quotation-of-the-day-2012-02-20/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quotation-of-the-day-2012-02-20</link>
		<comments>http://blog.klimczyk.pl/2012/02/20/quotation-of-the-day-2012-02-20/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 09:00:18 +0000</pubDate>
		<dc:creator>klimmass</dc:creator>
				<category><![CDATA[Quotes]]></category>
		<category><![CDATA[quotation]]></category>

		<guid isPermaLink="false">http://blog.klimczyk.pl/?p=123</guid>
		<description><![CDATA[Never trust a programmer in a suit. Tweet]]></description>
			<content:encoded><![CDATA[<p><em><strong>Never trust a programmer in a suit.</strong></em></p>
<div class="simple_likebuttons_container_small">
      <div class="simple_likebuttons_googleplus">
        <g:plusone size="medium" count="false" href="http://blog.klimczyk.pl/2012/02/20/quotation-of-the-day-2012-02-20/"></g:plusone>
      </div>
    
      <div class="simple_likebuttons_twitter simple_likebuttons_twitter_s">
        <a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="http://blog.klimczyk.pl/2012/02/20/quotation-of-the-day-2012-02-20/" data-lang="en">Tweet</a>
      </div>
    
      <div class="simple_likebuttons_facebook">
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, "script", "facebook-jssdk"));</script>
        <div class="fb-like" data-href="http://blog.klimczyk.pl/2012/02/20/quotation-of-the-day-2012-02-20/" data-send="false" data-layout="button_count" data-show-faces="false" data-width="90"></div>
      </div>
    </div>]]></content:encoded>
			<wfw:commentRss>http://blog.klimczyk.pl/2012/02/20/quotation-of-the-day-2012-02-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quotation of the day! 2012-02-10</title>
		<link>http://blog.klimczyk.pl/2012/02/10/quotation-of-the-day-2012-02-10/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quotation-of-the-day-2012-02-10</link>
		<comments>http://blog.klimczyk.pl/2012/02/10/quotation-of-the-day-2012-02-10/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 10:34:29 +0000</pubDate>
		<dc:creator>klimmass</dc:creator>
				<category><![CDATA[Quotes]]></category>
		<category><![CDATA[quotation]]></category>

		<guid isPermaLink="false">http://blog.klimczyk.pl/?p=111</guid>
		<description><![CDATA[In the future, programming will be a basic course alongside reading and math. Tweet]]></description>
			<content:encoded><![CDATA[<p><em><strong>In the future, programming will be a basic course alongside reading and math.</strong></em></p>
<div class="simple_likebuttons_container_small">
      <div class="simple_likebuttons_googleplus">
        <g:plusone size="medium" count="false" href="http://blog.klimczyk.pl/2012/02/10/quotation-of-the-day-2012-02-10/"></g:plusone>
      </div>
    
      <div class="simple_likebuttons_twitter simple_likebuttons_twitter_s">
        <a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="http://blog.klimczyk.pl/2012/02/10/quotation-of-the-day-2012-02-10/" data-lang="en">Tweet</a>
      </div>
    
      <div class="simple_likebuttons_facebook">
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, "script", "facebook-jssdk"));</script>
        <div class="fb-like" data-href="http://blog.klimczyk.pl/2012/02/10/quotation-of-the-day-2012-02-10/" data-send="false" data-layout="button_count" data-show-faces="false" data-width="90"></div>
      </div>
    </div>]]></content:encoded>
			<wfw:commentRss>http://blog.klimczyk.pl/2012/02/10/quotation-of-the-day-2012-02-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Cult of Done Manifesto</title>
		<link>http://blog.klimczyk.pl/2012/02/05/the-cult-of-done-manifesto/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-cult-of-done-manifesto</link>
		<comments>http://blog.klimczyk.pl/2012/02/05/the-cult-of-done-manifesto/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 18:03:57 +0000</pubDate>
		<dc:creator>klimmass</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://blog.klimczyk.pl/?p=117</guid>
		<description><![CDATA[I hope this image is self-explaining Tweet]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.klimczyk.pl/wp-content/uploads/2012/02/cult-of-done-manifesto.jpg"><img class="aligncenter size-full wp-image-118" title="cult-of-done-manifesto" src="http://blog.klimczyk.pl/wp-content/uploads/2012/02/cult-of-done-manifesto.jpg" alt="" width="425" height="550" /></a></p>
<p>I hope this image is self-explaining <img src='http://blog.klimczyk.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="simple_likebuttons_container_small">
      <div class="simple_likebuttons_googleplus">
        <g:plusone size="medium" count="false" href="http://blog.klimczyk.pl/2012/02/05/the-cult-of-done-manifesto/"></g:plusone>
      </div>
    
      <div class="simple_likebuttons_twitter simple_likebuttons_twitter_s">
        <a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="http://blog.klimczyk.pl/2012/02/05/the-cult-of-done-manifesto/" data-lang="en">Tweet</a>
      </div>
    
      <div class="simple_likebuttons_facebook">
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, "script", "facebook-jssdk"));</script>
        <div class="fb-like" data-href="http://blog.klimczyk.pl/2012/02/05/the-cult-of-done-manifesto/" data-send="false" data-layout="button_count" data-show-faces="false" data-width="90"></div>
      </div>
    </div>]]></content:encoded>
			<wfw:commentRss>http://blog.klimczyk.pl/2012/02/05/the-cult-of-done-manifesto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quotation of the day!</title>
		<link>http://blog.klimczyk.pl/2012/02/03/quotation-of-the-day/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quotation-of-the-day</link>
		<comments>http://blog.klimczyk.pl/2012/02/03/quotation-of-the-day/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 12:53:20 +0000</pubDate>
		<dc:creator>klimmass</dc:creator>
				<category><![CDATA[Quotes]]></category>
		<category><![CDATA[quotation]]></category>

		<guid isPermaLink="false">http://blog.klimczyk.pl/?p=108</guid>
		<description><![CDATA[Programming is like sex&#8230; one mistake and you support it forever! Tweet]]></description>
			<content:encoded><![CDATA[<p><em><strong>Programming is like sex&#8230; one mistake and you support it forever!</strong></em></p>
<div class="simple_likebuttons_container_small">
      <div class="simple_likebuttons_googleplus">
        <g:plusone size="medium" count="false" href="http://blog.klimczyk.pl/2012/02/03/quotation-of-the-day/"></g:plusone>
      </div>
    
      <div class="simple_likebuttons_twitter simple_likebuttons_twitter_s">
        <a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="http://blog.klimczyk.pl/2012/02/03/quotation-of-the-day/" data-lang="en">Tweet</a>
      </div>
    
      <div class="simple_likebuttons_facebook">
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, "script", "facebook-jssdk"));</script>
        <div class="fb-like" data-href="http://blog.klimczyk.pl/2012/02/03/quotation-of-the-day/" data-send="false" data-layout="button_count" data-show-faces="false" data-width="90"></div>
      </div>
    </div>]]></content:encoded>
			<wfw:commentRss>http://blog.klimczyk.pl/2012/02/03/quotation-of-the-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Programming Rules] Describe summited bugs in details</title>
		<link>http://blog.klimczyk.pl/2011/09/27/programming-rules-describe-summited-bugs-in-details/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=programming-rules-describe-summited-bugs-in-details</link>
		<comments>http://blog.klimczyk.pl/2011/09/27/programming-rules-describe-summited-bugs-in-details/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 13:11:38 +0000</pubDate>
		<dc:creator>klimmass</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://blog.klimczyk.pl/?p=72</guid>
		<description><![CDATA[&#8220;Some fields should be read-only&#8221;&#8230; Is this a good description? If you can read in other minds, then it&#8217;s ok&#8230;.. otherwise be more precise when submitting a bug report! The rule is: Describe the bug in as many details as &#8230;<p class="read-more"><a href="http://blog.klimczyk.pl/2011/09/27/programming-rules-describe-summited-bugs-in-details/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>&#8220;Some fields should be read-only&#8221;&#8230; Is this a good description? If you can read in other minds, then it&#8217;s ok&#8230;.. otherwise <strong>be more precise when submitting a bug report!</strong><br />
The rule is: Describe the bug in as many details as needed to be reproduced by software engineer. Attach some crash reports if possible. </p>
<div class="simple_likebuttons_container_small">
      <div class="simple_likebuttons_googleplus">
        <g:plusone size="medium" count="false" href="http://blog.klimczyk.pl/2011/09/27/programming-rules-describe-summited-bugs-in-details/"></g:plusone>
      </div>
    
      <div class="simple_likebuttons_twitter simple_likebuttons_twitter_s">
        <a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="http://blog.klimczyk.pl/2011/09/27/programming-rules-describe-summited-bugs-in-details/" data-lang="en">Tweet</a>
      </div>
    
      <div class="simple_likebuttons_facebook">
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, "script", "facebook-jssdk"));</script>
        <div class="fb-like" data-href="http://blog.klimczyk.pl/2011/09/27/programming-rules-describe-summited-bugs-in-details/" data-send="false" data-layout="button_count" data-show-faces="false" data-width="90"></div>
      </div>
    </div>]]></content:encoded>
			<wfw:commentRss>http://blog.klimczyk.pl/2011/09/27/programming-rules-describe-summited-bugs-in-details/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Showing IDataErrorInfo for NULL objects</title>
		<link>http://blog.klimczyk.pl/2011/09/24/showing-idataerrorinfo-for-null-objects/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=showing-idataerrorinfo-for-null-objects</link>
		<comments>http://blog.klimczyk.pl/2011/09/24/showing-idataerrorinfo-for-null-objects/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 11:50:04 +0000</pubDate>
		<dc:creator>klimmass</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://blog.klimczyk.pl/?p=3</guid>
		<description><![CDATA[WPF provides, fairly easy to implement, possibility to validate entered data and notify user when something is incorrect. An example is available in MSDN, so I will skip further explanation how does this work&#8230; Everything works like a charm till &#8230;<p class="read-more"><a href="http://blog.klimczyk.pl/2011/09/24/showing-idataerrorinfo-for-null-objects/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>WPF provides, fairly easy to implement, possibility to validate entered data and notify user when something is incorrect. An <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.idataerrorinfo%28v=vs.95%29.aspx" title="IDataErrorInfo example" target="_blank">example</a> is available in MSDN, so I will skip further explanation how does this work&#8230;</p>
<p><a href="http://blog.klimczyk.pl/wp-content/uploads/2011/09/screenshot.jpg"><img src="http://blog.klimczyk.pl/wp-content/uploads/2011/09/screenshot.jpg" alt="" title="screenshot" width="525" height="700" class="aligncenter size-full wp-image-82" /></a></p>
<p>Everything works like a charm till you validate data bounded to main object. For instance let&#8217;s examine code below:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> abstract <span style="color: #6666cc; font-weight: bold;">class</span> AbstractCity <span style="color: #008000;">:</span> ICity
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> name<span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> Country country<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Name
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> name<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        set
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>name <span style="color: #008000;">!=</span> value<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                name <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>PropertyChanged <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
                    PropertyChanged<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span>, <span style="color: #008000;">new</span> PropertyChangedEventArgs<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Name&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> Country Country
    <span style="color: #008000;">&#123;</span>
        get
        <span style="color: #008000;">&#123;</span>
           <span style="color: #0600FF; font-weight: bold;">return</span> country<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        set
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>country <span style="color: #008000;">!=</span> value<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
               country <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
               ExecutePropertyChanged<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Country&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#91;</span><span style="color: #6666cc; font-weight: bold;">string</span> columnName<span style="color: #008000;">&#93;</span>
    <span style="color: #008000;">&#123;</span>
        get
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">switch</span> <span style="color: #008000;">&#40;</span>columnName<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;Name&quot;</span><span style="color: #008000;">:</span>
                    <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrWhiteSpace</span><span style="color: #008000;">&#40;</span>Name<span style="color: #008000;">&#41;</span> <span style="color: #008000;">?</span> <span style="color: #666666;">&quot;City name must be set&quot;</span> <span style="color: #008000;">:</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;Country&quot;</span><span style="color: #008000;">:</span>
                    <span style="color: #0600FF; font-weight: bold;">return</span> Country <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">?</span> <span style="color: #666666;">&quot;Country must be set&quot;</span> <span style="color: #008000;">:</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">:</span>
                    <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Error
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Name&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #6666cc; font-weight: bold;">void</span> ExecutePropertyChanged<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> propertyName<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>PropertyChanged <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
            PropertyChanged<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span>, <span style="color: #008000;">new</span> PropertyChangedEventArgs<span style="color: #008000;">&#40;</span>propertyName<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">event</span> PropertyChangedEventHandler PropertyChanged<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> CityNullCountry <span style="color: #008000;">:</span> AbstractCity <span style="color: #008000;">&#123;</span> <span style="color: #008000;">&#125;</span></pre></div></div>

<p>and binding in XAML:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;</span>TextBox  Grid<span style="color: #008000;">.</span><span style="color: #0000FF;">Column</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;1&quot;</span> Grid<span style="color: #008000;">.</span><span style="color: #0000FF;">Row</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;0&quot;</span> Text<span style="color: #008000;">=</span><span style="color: #666666;">&quot;{Binding Path=City.Name, ValidatesOnDataErrors=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}&quot;</span><span style="color: #008000;">/&gt;</span>
<span style="color: #008000;">&lt;</span>TextBox  Grid<span style="color: #008000;">.</span><span style="color: #0000FF;">Column</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;1&quot;</span> Grid<span style="color: #008000;">.</span><span style="color: #0000FF;">Row</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;1&quot;</span> HorizontalAlignment<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Left&quot;</span> Width<span style="color: #008000;">=</span><span style="color: #666666;">&quot;250&quot;</span> Text<span style="color: #008000;">=</span><span style="color: #666666;">&quot;{Binding Path=City.Country.Code, Mode=OneWay, ValidatesOnDataErrors=True, NotifyOnValidationError=True}&quot;</span> IsReadOnly<span style="color: #008000;">=</span><span style="color: #666666;">&quot;True&quot;</span><span style="color: #008000;">/&gt;</span>
<span style="color: #008000;">&lt;</span>ComboBox Grid<span style="color: #008000;">.</span><span style="color: #0000FF;">Column</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;1&quot;</span> Grid<span style="color: #008000;">.</span><span style="color: #0000FF;">Row</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;1&quot;</span> HorizontalAlignment<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Right&quot;</span> Width<span style="color: #008000;">=</span><span style="color: #666666;">&quot;100&quot;</span> SelectedItem<span style="color: #008000;">=</span><span style="color: #666666;">&quot;{Binding Path=City.Country}&quot;</span> ItemsSource<span style="color: #008000;">=</span><span style="color: #666666;">&quot;{Binding Path=Countries}&quot;</span> DisplayMemberPath<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Code&quot;</span><span style="color: #008000;">/&gt;</span>
<span style="color: #008000;">&lt;</span>TextBox  Grid<span style="color: #008000;">.</span><span style="color: #0000FF;">Column</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;1&quot;</span> Grid<span style="color: #008000;">.</span><span style="color: #0000FF;">Row</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;2&quot;</span> Text<span style="color: #008000;">=</span><span style="color: #666666;">&quot;{Binding Path=City.Country.Name, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=OneWay}&quot;</span> IsReadOnly<span style="color: #008000;">=</span><span style="color: #666666;">&quot;True&quot;</span><span style="color: #008000;">/&gt;</span></pre></div></div>

<p>in this code it is very easy validate and notify user when <strong>Name</strong> property in <strong>CityNullCountry</strong> object is NULL or empty. But there is no easy solution to validate <strong>City.Country.Name</strong> property. The reason is that Country object may not exists when City object is created.</p>
<p>So as up now we know that WPF needs Country class instance in order to validate it (using IDataErrorInfo in that class) and notify user when something is wrong. Some of you may ask, why I don&#8217;t check Country object in City class. The answer is simple. WPF validates bounded object and in that case it is Country object and it&#8217;s <strong>Name</strong> property. <strong>Text=&#8221;{Binding Path=City.Country.Name, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=OneWay}&#8221;</strong>. TextBox with such binding will check for IDataErrorInfo interface in Country class&#8230;. but Country object may be empty and nothing will be validated. User will be not aware of any errors at all.</p>
<p>So, my solution is fairly easy. I will simply provide an fake Country object when real object is NULL. Validation will run against my fake object and errors will popup in the user interface. One way to achieve that is to use Activator.CreateInstance() method. The whole mechanism implementation is showed below:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> CityNullIsDefaultCountry <span style="color: #008000;">:</span> AbstractCity
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> Country country<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">protected</span> DefaultsTable defaults <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> DefaultsTable<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> Country Country
    <span style="color: #008000;">&#123;</span>
        get
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> defaults<span style="color: #008000;">.</span><span style="color: #0000FF;">GetObjectOrDefault</span><span style="color: #008000;">&#40;</span>country, <span style="color: #666666;">&quot;Country&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        set
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>country <span style="color: #008000;">!=</span> value<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                country <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
                ExecutePropertyChanged<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Country&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> DefaultsTable
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">readonly</span> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">object</span><span style="color: #008000;">&gt;</span> defaults <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">object</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> T GetObjectOrDefault<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span>T obj,  <span style="color: #6666cc; font-weight: bold;">string</span> propName<span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">where</span> T <span style="color: #008000;">:</span> <span style="color: #6666cc; font-weight: bold;">class</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>obj <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> obj<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>defaults<span style="color: #008000;">.</span><span style="color: #0000FF;">ContainsKey</span><span style="color: #008000;">&#40;</span>propName<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span>defaults<span style="color: #008000;">&#91;</span>propName<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
        T defaultObject <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span>Activator<span style="color: #008000;">.</span><span style="color: #0000FF;">CreateInstance</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        defaults<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>propName, defaultObject<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> defaultObject<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p><strong>DefaultsTable defaults = new DefaultsTable();</strong> is responsible for providing fake object if it is NULL. When we set the Country property to some value, this value will be returned.</p>
<p>On of the challenges now is to determine what kind of object is returned when we access Country property on City class&#8230; I will discuss that somewhere in the future. In short: this can be determined by adding IsDefault flag and checking it.</p>
<p>Sample code for this example can by found <a href="http://blog.klimczyk.pl/wp-content/uploads/2011/09/IDataErrorInfoSample.zip" title="IDataErrorInfo sample code">here</a></p>
<p><a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblog.klimczyk.pl%2f2011%2f09%2f24%2fshowing-idataerrorinfo-for-null-objects%2f"><img src="http%3A%2F%2Fwww.dotnetkicks.com%2FServices%2FImages%2FKickItImageGenerator.ashx%3Furl%3Dhttp%253a%252f%252fblog.klimczyk.pl%252f2011%252f09%252f24%252fshowing-idataerrorinfo-for-null-objects%252f" border="0" alt="kick it on DotNetKicks.com" /></a></p>
<div class="simple_likebuttons_container_small">
      <div class="simple_likebuttons_googleplus">
        <g:plusone size="medium" count="false" href="http://blog.klimczyk.pl/2011/09/24/showing-idataerrorinfo-for-null-objects/"></g:plusone>
      </div>
    
      <div class="simple_likebuttons_twitter simple_likebuttons_twitter_s">
        <a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="http://blog.klimczyk.pl/2011/09/24/showing-idataerrorinfo-for-null-objects/" data-lang="en">Tweet</a>
      </div>
    
      <div class="simple_likebuttons_facebook">
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, "script", "facebook-jssdk"));</script>
        <div class="fb-like" data-href="http://blog.klimczyk.pl/2011/09/24/showing-idataerrorinfo-for-null-objects/" data-send="false" data-layout="button_count" data-show-faces="false" data-width="90"></div>
      </div>
    </div>]]></content:encoded>
			<wfw:commentRss>http://blog.klimczyk.pl/2011/09/24/showing-idataerrorinfo-for-null-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Programming Rules] Consider writing Unit Test for the bug you have fixed</title>
		<link>http://blog.klimczyk.pl/2011/09/18/programming-rules-consider-writing-unit-test-for-the-bug-you-have-fixed/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=programming-rules-consider-writing-unit-test-for-the-bug-you-have-fixed</link>
		<comments>http://blog.klimczyk.pl/2011/09/18/programming-rules-consider-writing-unit-test-for-the-bug-you-have-fixed/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 17:54:30 +0000</pubDate>
		<dc:creator>klimmass</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[pr]]></category>

		<guid isPermaLink="false">http://blog.klimczyk.pl/?p=45</guid>
		<description><![CDATA[Remember! When you fix a bug and you feel that it may occur in the future, don&#8217;t waste time and write at least one Unit Test to check code against that bug. Tweet]]></description>
			<content:encoded><![CDATA[<p>Remember!<br />
When you fix a bug and you feel that it may occur in the future, don&#8217;t waste time and write at least one Unit Test to check code against that bug.</p>
<div class="simple_likebuttons_container_small">
      <div class="simple_likebuttons_googleplus">
        <g:plusone size="medium" count="false" href="http://blog.klimczyk.pl/2011/09/18/programming-rules-consider-writing-unit-test-for-the-bug-you-have-fixed/"></g:plusone>
      </div>
    
      <div class="simple_likebuttons_twitter simple_likebuttons_twitter_s">
        <a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="http://blog.klimczyk.pl/2011/09/18/programming-rules-consider-writing-unit-test-for-the-bug-you-have-fixed/" data-lang="en">Tweet</a>
      </div>
    
      <div class="simple_likebuttons_facebook">
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, "script", "facebook-jssdk"));</script>
        <div class="fb-like" data-href="http://blog.klimczyk.pl/2011/09/18/programming-rules-consider-writing-unit-test-for-the-bug-you-have-fixed/" data-send="false" data-layout="button_count" data-show-faces="false" data-width="90"></div>
      </div>
    </div>]]></content:encoded>
			<wfw:commentRss>http://blog.klimczyk.pl/2011/09/18/programming-rules-consider-writing-unit-test-for-the-bug-you-have-fixed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Logging Exception with StackTrace</title>
		<link>http://blog.klimczyk.pl/2011/09/15/logging-exception-with-stacktrace/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=logging-exception-with-stacktrace</link>
		<comments>http://blog.klimczyk.pl/2011/09/15/logging-exception-with-stacktrace/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 08:48:10 +0000</pubDate>
		<dc:creator>klimmass</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://blog.klimczyk.pl/?p=196</guid>
		<description><![CDATA[C# language has a great Exception Handling mechanism build-in. If something in not predictable during compile time developer can easily embed that piece of code in try{ (...) } catch{ (...) } and say &#8220;case closed&#8221;. Sample code taken from &#8230;<p class="read-more"><a href="http://blog.klimczyk.pl/2011/09/15/logging-exception-with-stacktrace/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>C# language has a great <a href="http://msdn.microsoft.com/en-us/library/ms173160.aspx" title="MSDN Exception Handling" target="_blank">Exception Handling</a> mechanism build-in. If something in not predictable during compile time developer can easily embed that piece of code in <code>try{ (...) } catch{ (...) }</code> and say &#8220;case closed&#8221;. Sample code taken from MSDN:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">class</span> ExceptionTest
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">double</span> SafeDivision<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">double</span> x, <span style="color: #6666cc; font-weight: bold;">double</span> y<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>y <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;">throw</span> <span style="color: #008000;">new</span> <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">DivideByZeroException</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> x <span style="color: #008000;">/</span> y<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// Input for test purposes. Change the values to see</span>
        <span style="color: #008080; font-style: italic;">// exception handling behavior.</span>
        <span style="color: #6666cc; font-weight: bold;">double</span> a <span style="color: #008000;">=</span> <span style="color: #FF0000;">98</span>, b <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
        <span style="color: #6666cc; font-weight: bold;">double</span> result <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">try</span>
        <span style="color: #008000;">&#123;</span>
            result <span style="color: #008000;">=</span> SafeDivision<span style="color: #008000;">&#40;</span>a, b<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;{0} divided by {1} = {2}&quot;</span>, a, b, result<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>DivideByZeroException e<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Attempted divide by zero.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008080; font-style: italic;">//Logger.Error(&quot;Attempted divide by zero.&quot;)</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Works like a charm&#8230;. but this was very simple scenario. In more advanced scenarios we &#8211; developers &#8211; would like to get some more feedback, then just a logged information like:<i>Attempted divide by zero</i>. In business application a lot of other factors in involved. So it is necessary to have proper feedback information when something goes wrong. I&#8217;ve also faced that problem. Not sufficient information was provided with the bug description and we were unable to reproduce and fix the bug. </p>
<p>At that moment I&#8217;ve decided to do the obvious step. Serialize Exception object and save in separate log file <img src='http://blog.klimczyk.pl/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  </p>
<p>Code that realizes my idea is showed below:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ExceptionXElement <span style="color: #008000;">:</span> XElement
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> ExceptionXElement<span style="color: #008000;">&#40;</span>Exception exception<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> Func<span style="color: #008000;">&lt;</span>XElement<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>exception <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    <span style="color: #0600FF; font-weight: bold;">throw</span> <span style="color: #008000;">new</span> ArgumentNullException<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;exception&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
                XElement root <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> XElement
                  <span style="color: #008000;">&#40;</span>exception<span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>exception<span style="color: #008000;">.</span><span style="color: #0000FF;">Message</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    root<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> XElement<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Message&quot;</span>, exception<span style="color: #008000;">.</span><span style="color: #0000FF;">Message</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
&nbsp;
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>exception<span style="color: #008000;">.</span><span style="color: #0000FF;">StackTrace</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    root<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span>
                    <span style="color: #008000;">&#40;</span>
                      <span style="color: #008000;">new</span> XElement<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;StackTrace&quot;</span>,
                        <span style="color: #0600FF; font-weight: bold;">from</span> frame <span style="color: #0600FF; font-weight: bold;">in</span> exception<span style="color: #008000;">.</span><span style="color: #0000FF;">StackTrace</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Split</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">'n'</span><span style="color: #008000;">&#41;</span>
                        let prettierFrame <span style="color: #008000;">=</span> frame<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">6</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Trim</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
                        <span style="color: #0600FF; font-weight: bold;">select</span> <span style="color: #008000;">new</span> XElement<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Frame&quot;</span>, prettierFrame<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                    <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
&nbsp;
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>exception<span style="color: #008000;">.</span><span style="color: #0000FF;">Data</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    root<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span>
                    <span style="color: #008000;">&#40;</span>
                      <span style="color: #008000;">new</span> XElement<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Data&quot;</span>,
                        <span style="color: #0600FF; font-weight: bold;">from</span> entry <span style="color: #0600FF; font-weight: bold;">in</span>
                            exception<span style="color: #008000;">.</span><span style="color: #0000FF;">Data</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Cast</span><span style="color: #008000;">&lt;</span>DictionaryEntry<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
                        let key <span style="color: #008000;">=</span> entry<span style="color: #008000;">.</span><span style="color: #0000FF;">Key</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
                        let value <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>entry<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span> <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">?</span>
                          <span style="color: #666666;">&quot;null&quot;</span> <span style="color: #008000;">:</span> entry<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
                        <span style="color: #0600FF; font-weight: bold;">select</span> <span style="color: #008000;">new</span> XElement<span style="color: #008000;">&#40;</span>key, value<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                    <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
&nbsp;
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>exception<span style="color: #008000;">.</span><span style="color: #0000FF;">InnerException</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    root<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span>
                    <span style="color: #008000;">&#40;</span>
                      <span style="color: #008000;">new</span> ExceptionXElement
                        <span style="color: #008000;">&#40;</span>exception<span style="color: #008000;">.</span><span style="color: #0000FF;">InnerException</span><span style="color: #008000;">&#41;</span>
                    <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
&nbsp;
                <span style="color: #0600FF; font-weight: bold;">return</span> root<span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span></pre></div></div>

<p>Code above is nicely wrapped in a function that saves XElement into single file.</p>
<div class="simple_likebuttons_container_small">
      <div class="simple_likebuttons_googleplus">
        <g:plusone size="medium" count="false" href="http://blog.klimczyk.pl/2011/09/15/logging-exception-with-stacktrace/"></g:plusone>
      </div>
    
      <div class="simple_likebuttons_twitter simple_likebuttons_twitter_s">
        <a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="http://blog.klimczyk.pl/2011/09/15/logging-exception-with-stacktrace/" data-lang="en">Tweet</a>
      </div>
    
      <div class="simple_likebuttons_facebook">
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, "script", "facebook-jssdk"));</script>
        <div class="fb-like" data-href="http://blog.klimczyk.pl/2011/09/15/logging-exception-with-stacktrace/" data-send="false" data-layout="button_count" data-show-faces="false" data-width="90"></div>
      </div>
    </div>]]></content:encoded>
			<wfw:commentRss>http://blog.klimczyk.pl/2011/09/15/logging-exception-with-stacktrace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

