<?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>Software Rockstar &#187; C#</title>
	<atom:link href="http://www.softwarerockstar.com/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.softwarerockstar.com</link>
	<description>Coaching and mentoring on a journey from a Developer to an IT Leader</description>
	<lastBuildDate>Thu, 12 Nov 2009 18:12:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>SubSonic 3.0 Released</title>
		<link>http://www.softwarerockstar.com/2009/07/subsonic-30-released/</link>
		<comments>http://www.softwarerockstar.com/2009/07/subsonic-30-released/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 18:52:15 +0000</pubDate>
		<dc:creator>SoftwareRockstar</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Generation]]></category>
		<category><![CDATA[Cool Tools]]></category>
		<category><![CDATA[SubSonic]]></category>

		<guid isPermaLink="false">http://www.softwarerockstar.com/?p=486</guid>
		<description><![CDATA[Finally a new version of SubSonic was released today with a lot of new features.  SubSonic is one of my favorite Data Access Layer (DAL) generators, that makes it super easy to create data access code. As a developer you have a lot of control over what the generated code looks like, which is great [...]]]></description>
			<content:encoded><![CDATA[<div class="imageleft"><img class="alignnone size-medium wp-image-487" src="http://softwarerockstar.com/wp-content/uploads/2009/07/subsonic_demo-300x191.png" alt="Subsonic Demo" width="300" height="191" /></div>
<p>Finally a new version of SubSonic was released today with a lot of new features.  SubSonic is one of my favorite Data Access Layer (DAL) generators, that makes it super easy to create data access code.</p>
<p>As a developer you have a lot of control over what the generated code looks like, which is great because I do not like code generators to dictate the essence of my code.  But the beauty of SubSonic is that you never really have to interact with the generated code itself.  It&#8217;s automatically generated and compiled for you &#8212; you just need to learn how to use it, which is pretty simple.  What&#8217;s more, it&#8217;s free, and works with not only SQL Server, but also with MySQL, SQLite, and Oracle databases. <span id="more-486"></span></p>
<p>SubSonic was originally started by Rob Conery as an open source project.  Later, Microsoft hired Rob and asked him to continue working on this project.  The latest 3.0 version took about a year to be completed.  According to Rob&#8217;s blog following are some of the new features:</p>
<blockquote>
<li>A nice <a href="http://subsonicproject.com/docs/IQueryable">Linq engine</a> which parses IQueryable &#8220;stuff&#8221; into SQL (thanks to <a href="http://blogs.msdn.com/mattwar/">Matt Warren&#8217;s</a> excellent  work with the <a href="http://codeplex.com/iqtoolkit">IQToolkit</a>, which we stole mercilessly).</li>
<li>A <a href="http://subsonicproject.com/docs/T4_Templates">templating system</a> which allows you to use <a href="http://subsonicproject.com/docs/Using_ActiveRecord">ActiveRecord</a>, <a href="http://subsonicproject.com/docs/Using_AdvancedTemplates">good  old Linq in Linq to SQL style</a>, or <a href="http://subsonicproject.com/docs/Creating_Your_Own_DAL">whatever floats your boat</a>.</li>
<li>A <a href="http://subsonicproject.com/docs/Using_SimpleRepository">SimpleRepository</a> which is just about zero-drag and even builds  your database for you</li>
<li>A brand-new <a href="http://subsonicproject.com/">project  site</a> that will hopefully answer the question &#8220;is SubSonic dead&#8221;? Or probably  not</li>
<li>A <a href="http://subsonicproject.com/docs">new docs site</a> that has  permanently crushed my ability to type. It&#8217;s a wiki so if you feel like being  helpful and like SubSonic and want to help&#8230; nudge&#8230; nudge</li>
</blockquote>
<div>
<p>If you have never used SubSonic before you owe it to yourself to check out this <a href="http://subsonicproject.com/docs/The_5_Minute_Demo" target="_blank">5-minute demo</a>.</div>
<div>
<p>You can get more information on SubSonic and download it for free at the <a href="http://subsonicproject.com/" target="_blank">SubSonic project site</a>.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarerockstar.com/2009/07/subsonic-30-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learn ASP.NET MVC</title>
		<link>http://www.softwarerockstar.com/2009/03/learn-aps-net-mvc/</link>
		<comments>http://www.softwarerockstar.com/2009/03/learn-aps-net-mvc/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 05:38:00 +0000</pubDate>
		<dc:creator>SoftwareRockstar</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://mharoon.wordpress.com/2009/03/13/learn-aps-net-mvc/</guid>
		<description><![CDATA[ScottGu  just made available a free downloadable eBook in PDF format as well as a simple and easy-to-understand sample project called Nerddinner. The eBook is actually a chapter from his upcoming book on MVC, but it is an end-to-end tutorial that walks through building a small but complete ASP.NET MVC application from scratch. Download eBook. [...]]]></description>
			<content:encoded><![CDATA[<div class="imageleft"><a href="http://www.amazon.com/gp/product/0470384611?ie=UTF8&amp;tag=softwrocks-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0470384611"><img style="border: 0px;" src="http://ecx.images-amazon.com/images/I/41vsFoLZq9L._BO2,204,203,200_PIsitb-sticker-arrow-big-search,TopRight,35,-76_AA240_SH20_OU01_.jpg" border="0" alt="" width="216" height="216" /></a><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=softwrocks-20&amp;l=as2&amp;o=1&amp;a=0470384611" border="0" alt="" width="1" height="1" /></div>
<p>ScottGu  just made available a free downloadable eBook in PDF format as well as a simple and easy-to-understand sample project called Nerddinner.</p>
<p>The eBook is actually a chapter from his upcoming book on MVC, but it is an end-to-end tutorial that walks through building a small but complete ASP.NET MVC application from scratch.</p>
<p><a href="http://aspnetmvcbook.s3.amazonaws.com/aspnetmvc-nerdinner_v1.pdf" target="_blank">Download eBook</a>.</p>
<p><a href="http://nerddinner.codeplex.com/" target="_blank">Download Nerddinner sample code</a>.</p>
<p><a href="http://www.amazon.com/gp/product/0470384611?ie=UTF8&amp;tag=softwrocks-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0470384611">Buy ASP.NET MVC 1.0 Book at Amazon.com</a>. </p>
<p>If you do decide to read this book, please do not forget to share your thoughts with me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarerockstar.com/2009/03/learn-aps-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# 3.0 Automatic Properties</title>
		<link>http://www.softwarerockstar.com/2009/03/c-3-0-automatic-properties/</link>
		<comments>http://www.softwarerockstar.com/2009/03/c-3-0-automatic-properties/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 19:08:00 +0000</pubDate>
		<dc:creator>SoftwareRockstar</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[WinFX (.NET 3.0)]]></category>

		<guid isPermaLink="false">http://mharoon.wordpress.com/2009/03/12/c-3-0-automatic-properties/</guid>
		<description><![CDATA[OK, so better later than never! Somehow I missed the automatic properties feature of C# 3.0, and just discovered it while I was reading up on something unrelated. It’s a nice feature of C# 3.0 that saves you a few key strokes hence enhances developer productivity as well as allows for more clear and concise [...]]]></description>
			<content:encoded><![CDATA[<p>OK, so better later than never!  Somehow I missed the automatic properties feature of C# 3.0, and just discovered it while I was reading up on something unrelated.  It’s a nice feature of C# 3.0 that saves you a few key strokes hence enhances developer productivity as well as allows for more clear and concise code.</p>
<p>Using this new feature, instead of defining private variables and creating explicit getters and setters, you can create properties like this:</p>
<pre class="brush: csharp">
public class Employee
{
   public string ID { get; set; }
   public string LastName { get; set; }
   public string FirstName { get; set; }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarerockstar.com/2009/03/c-3-0-automatic-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free Visual Studio 2008 Productivity Add-in</title>
		<link>http://www.softwarerockstar.com/2009/03/free-visual-studio-2008-productivity-add-in/</link>
		<comments>http://www.softwarerockstar.com/2009/03/free-visual-studio-2008-productivity-add-in/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 19:30:00 +0000</pubDate>
		<dc:creator>SoftwareRockstar</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Other]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Cool Tools]]></category>
		<category><![CDATA[Rants & Raves]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://mharoon.wordpress.com/2009/03/11/free-visual-studio-2008-productivity-add-in/</guid>
		<description><![CDATA[Developer Express and Microsoft provide a new version of CodeRush licensed exclusively for C# developers working in Visual Studio. The new product is called CodeRush Xpress, and it includes a slew of useful features to boost your productivity under Visual Studio. You can download CodeRush Xpress here.]]></description>
			<content:encoded><![CDATA[<div class="imageleft"><img src="http://softwarerockstar.com/wp-content/uploads/2009/03/vs2008.png" alt="" width="141" /></div>
<p>Developer Express and Microsoft provide a new version of CodeRush licensed exclusively for C# developers working in Visual Studio. The new product is called CodeRush Xpress, and it includes a slew of useful features to boost your productivity under Visual Studio.</p>
<p><a title="Download CodeRush Xpress" href="http://msdn.microsoft.com/en-us/vcsharp/dd218053.aspx" target="_blank">You can download CodeRush Xpress here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarerockstar.com/2009/03/free-visual-studio-2008-productivity-add-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Castle Project</title>
		<link>http://www.softwarerockstar.com/2007/08/the-castle-project/</link>
		<comments>http://www.softwarerockstar.com/2007/08/the-castle-project/#comments</comments>
		<pubDate>Fri, 17 Aug 2007 20:37:00 +0000</pubDate>
		<dc:creator>SoftwareRockstar</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Design Principles]]></category>
		<category><![CDATA[OOA/OOD]]></category>

		<guid isPermaLink="false">http://mharoon.wordpress.com/2007/08/17/the-castle-project/</guid>
		<description><![CDATA[In the last couple of years I have noticed a steadily growing interest in the .NET community around the&#160;Inversion of Control (IoC) and Dependency Injection (DI) patterns.&#160; This is partly due to the fact that a number of excellent frameworks have emerged and gained popularity that allow us to use these designs in our applications [...]]]></description>
			<content:encoded><![CDATA[<div class="imageleft"><img src="http://softwarerockstar.com/wp-content/uploads/2007/08/castleinabox1.gif" alt="Castle Project" title="Castle Project" width="191" height="108" /></div>
<p>In the last couple of years I have noticed a steadily growing interest in the .NET community around the&nbsp;<a href="http://en.wikipedia.org/wiki/Inversion_of_control">Inversion of Control (IoC)</a> and <a href="http://en.wikipedia.org/wiki/Dependency_injection">Dependency Injection (DI)</a> patterns.&nbsp; This is partly due to the fact that a number of excellent frameworks have emerged and gained popularity that allow us to use these designs in our applications relatively painlessly.&nbsp; One such framework is the open source <a href="http://www.castleproject.org/">Castle Project</a>.&nbsp; In my opinion <a href="http://www.castleproject.org/">Castle</a> is the best implementation of IoC and DI among many others that I have come across including <a href="http://www.springframework.net/">Spring.NET</a>, <a href="http://ninject.org/">NInject</a>, and&nbsp;<a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=ObjectBuilder">ObjectBuilder</a>.&nbsp; This is however my opinion; which framework you use largely depends upon your requirements and your preferences.</p>
<p>If you are just getting started with Castle or are curious about why the heck one should use IoC and DI, I strongly suggest you check out the <a href="http://dotnetslackers.com/articles/designpatterns/InversionOfControlAndDependencyInjectionWithCastleWindsorContainerPart1.aspx">3-part article series</a> by&nbsp;<a href="http://dotnetslackers.com/community/blogs/simoneb">Simone Busoli</a>.&nbsp; I just came across <a href="http://dotnetslackers.com/articles/designpatterns/InversionOfControlAndDependencyInjectionWithCastleWindsorContainerPart1.aspx">these articles</a> and I can&#8217;t stress enough how well they are written.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarerockstar.com/2007/08/the-castle-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server Database Comparison and Synchronization</title>
		<link>http://www.softwarerockstar.com/2007/04/sql-server-database-comparison-and-synchronization/</link>
		<comments>http://www.softwarerockstar.com/2007/04/sql-server-database-comparison-and-synchronization/#comments</comments>
		<pubDate>Wed, 18 Apr 2007 12:02:00 +0000</pubDate>
		<dc:creator>SoftwareRockstar</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Cool Tools]]></category>
		<category><![CDATA[Rants & Raves]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://mharoon.wordpress.com/2007/04/18/sql-server-database-comparison-and-synchronization/</guid>
		<description><![CDATA[Since database are usually designed in development environments, migrating changes&#160;over to other environments (e.g. QA and production) is not a trivial task.&#160; This is because SQL Server does not have any built-in tools to compare database schemas.&#160; There are quite a few third-party tools that would make your life easier, most notably, Red Gate&#8217;s SQL [...]]]></description>
			<content:encoded><![CDATA[<div class="imageleft"><img src="http://softwarerockstar.com/wp-content/uploads/2007/04/ms_sql_logo1.gif" alt="SQL Server" width="240" height="118" /></div>
<p>Since database are usually designed in development environments, migrating changes&nbsp;over to other environments (e.g. QA and production) is not a trivial task.&nbsp; This is because SQL Server does not have any built-in tools to compare database schemas.&nbsp; </p>
<p>There are quite a few third-party tools that would make your life easier, most notably, <a title="Red Gate's SQL Compare" href="http://www.red-gate.com/" target="_blank">Red Gate&#8217;s SQL Compare</a>&nbsp;(reasonably priced around $300).</p>
<p>At times, buying a commercial tool is not really an option, so one must resort to googling for free tools.&nbsp; There are three such tools that I am aware of:</p>
<ol>
<li><a title="SQLDBDiff by SQLDBTools" href="http://www.sqldbtools.com/Snapshots.aspx?ProductId=1"><strong>SQLDBDiff by SQLDBTools</strong></a><br />A very decent tool that comes in both freeware and shareware versions.&nbsp; Freeware version is not badly crippled; only advanced features such as multi-database comparison, data content comparison, etc. are disabled.</p>
</li>
<li><a title="Database Schema Comparison Utility" href="http://www.codeproject.com/useritems/DatabaseCompare.asp"><strong>Database Schema Comparison Utility</strong></a><br />This is a Code Project article that comes with C# source code&nbsp;of a schema comparison utility.&nbsp; The utility itself is pretty bare-bone, but gets the job done.
</li>
<li><a title="StarInix Free Database Compare 2.0" href="http://www.starinix.com/sqlcompare02.htm"><strong>StarInix Free Database Compare 2.0</strong></a><br />I have not used this tool, but from the advertised feature list, it looks pretty good.&nbsp; Most notably, in addition to SQL Server, this tool works with Access and MySQL databases.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarerockstar.com/2007/04/sql-server-database-comparison-and-synchronization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JScript Eval Method In C#</title>
		<link>http://www.softwarerockstar.com/2007/02/jscript-eval-method-in-c/</link>
		<comments>http://www.softwarerockstar.com/2007/02/jscript-eval-method-in-c/#comments</comments>
		<pubDate>Wed, 07 Feb 2007 04:15:00 +0000</pubDate>
		<dc:creator>SoftwareRockstar</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[JScript]]></category>
		<category><![CDATA[Other]]></category>
		<category><![CDATA[Reflection]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://mharoon.wordpress.com/2007/02/06/jscript-eval-method-in-c/</guid>
		<description><![CDATA[JavaScript and JScript languages provide a convenient Eval method that allows for dynamic evaluation of expressions. This functionality can be duplicated in C# using Microsoft&#8217;s JScript CodeDomProvider and Reflection. Following class automatically compiles an in-memory assembly using JScript CodeDomProvider. The Eval method uses this assembly to dynamically evaluate specified expressions: using System; using System.CodeDom.Compiler; using [...]]]></description>
			<content:encoded><![CDATA[<div class="imageleft"><img src="http://softwarerockstar.com/wp-content/uploads/2007/02/jscript-file-256x256_21.png" alt="JScript" width="184" height="184" class="alignnone size-full wp-image-315" /></div>
<p><a href="http://en.wikipedia.org/wiki/JavaScript">JavaScript</a> and <a href="http://en.wikipedia.org/wiki/JScript">JScript</a> languages provide a convenient <a href="http://javascript.about.com/od/reference/g/seval.htm">Eval</a> method that allows for dynamic evaluation of expressions. This functionality can be duplicated in C# using Microsoft&#8217;s JScript <a href="http://msdn2.microsoft.com/en-us/system.codedom.compiler.codedomprovider.aspx">CodeDomProvider</a> and <a href="http://msdn2.microsoft.com/en-us/library/system.reflection.aspx">Reflection</a>.</p>
<p>Following class automatically compiles an in-memory assembly using JScript CodeDomProvider. The Eval method uses this assembly to dynamically evaluate specified expressions:</p>
<pre class="brush: csharp">
using System;
using System.CodeDom.Compiler;
using System.Reflection;
using Microsoft.JScript;

///
/// Implements JScript/JavaScript Eval like
/// functionality in C# to allow dynamic evaluation
/// of expressions.
///
public static class ExpressionEvaluator
{
    #region Private Members

    private static Type _evaluatorType;
    private static object _evaluatorInstance;
    private static readonly string _jscriptEvalClass =
    @&quot;import System;
class JScriptEvaluator
{
public static function Eval(expression : String) : String
{
return eval(expression);
}
}&quot;;

    #endregion

    #region Private Methods

    ///
    /// Creates a dynamic in-memory assembly using JScript.NET
    /// to evaluate expressions.
    ///
    private static void Initialize()
    {

        CodeDomProvider compiler = new JScriptCodeProvider();

        CompilerParameters parameters = new CompilerParameters();
        parameters.GenerateInMemory = true;
        parameters.ReferencedAssemblies.Add(&quot;system.dll&quot;);

        CompilerResults results = compiler.CompileAssemblyFromSource(parameters, _jscriptEvalClass);

        Assembly assembly = results.CompiledAssembly;
        _evaluatorType = assembly.GetType(&quot;JScriptEvaluator&quot;);
        _evaluatorInstance = Activator.CreateInstance(_evaluatorType);
    }

    #endregion

    #region Public Methods

    ///
    /// Evaluates specified expression using reflection
    /// on the assembly generated in Initialize() method.
    ///
    /// The expression.
    /// A string representing evaluated expression.
    public static string Eval(string expression)
    {
        if (_evaluatorInstance == null)
            Initialize();

        object result = _evaluatorType.InvokeMember(
        &quot;Eval&quot;,
       BindingFlags.InvokeMethod,
        null,
       _evaluatorInstance,
        new object[] { expression }
       );

        return (result == null) ? null : result.ToString();

    }

    #endregion
}
</pre>
</p>
<p>Using this class, we can execute statements such as:
</p>
<pre class="brush: csharp">
        Console.WriteLine(ExpressionEvaluator.Eval(&quot;2 + 9&quot;));
        Console.WriteLine(ExpressionEvaluator.Eval(&quot;System.DateTime&quot;));
        Console.WriteLine(ExpressionEvaluator.Eval(&quot;Environment.OSVersion.VersionString&quot;));
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarerockstar.com/2007/02/jscript-eval-method-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using IXmlSerializable To Overcome &#8220;not expected&#8221; Error On Derived Classes</title>
		<link>http://www.softwarerockstar.com/2006/12/using-ixmlserializable-to-overcome-not-expected-error-on-derived-classes/</link>
		<comments>http://www.softwarerockstar.com/2006/12/using-ixmlserializable-to-overcome-not-expected-error-on-derived-classes/#comments</comments>
		<pubDate>Sun, 10 Dec 2006 18:50:00 +0000</pubDate>
		<dc:creator>SoftwareRockstar</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[Serialization]]></category>

		<guid isPermaLink="false">http://mharoon.wordpress.com/2006/12/10/using-ixmlserializable-to-overcome-not-expected-error-on-derived-classes/</guid>
		<description><![CDATA[This article extends upon Simon Hewitt&#8217;s article on CodeProject. It is strongly recommended that you read Simon&#8217;s article also in order to fully understand the concepts. BACKGROUND XML serialization is an indispensable technique that has built-in support for in the .NET Framework. Using XML serialization, objects can be serialized to XML streams that may be [...]]]></description>
			<content:encoded><![CDATA[<p>This article extends upon <a href="http://www.codeproject.com/csharp/xmlserializerforunknown.asp">Simon Hewitt&#8217;s article on CodeProject</a>. It is strongly recommended that you read Simon&#8217;s article also in order to fully understand the concepts.</p>
<p><strong>BACKGROUND</strong><br />
XML serialization is an indispensable technique that has built-in support for in the .NET Framework. Using XML serialization, objects can be serialized to XML streams that may be persisted to permanent storage such as files, as well as XML streams can be converted back to objects with exactly the same state as at the time of serialization. With .NET Framework&#8217;s built-in support for XML serialization, all this can be achieved with only a few lines of code using the <a href="http://msdn2.microsoft.com/en-us/system.xml.serialization.xmlserializer.aspx">System.Xml.Serialization.XmlSerializer</a> object.</p>
<p><strong>PROBLEM</strong><br />
The problem with <a href="http://msdn2.microsoft.com/en-us/system.xml.serialization.xmlserializer.aspx">XmlSerializer</a> is, however, that it works by generating an on-the-fly assembly behind the scenes at compilation time, that has logic for serialization and deserialization of a given type. For this reason, the exact (concrete) type of the object and it&#8217;s public properties must be known to the compiler at the time of compilation. If we try to serialize an object that, for example, has a public member of a given base type, then at run-time we receive a <a href="http://msdn2.microsoft.com/en-us/system.invalidoperationexception.aspx">System.InvalidOperationException</a> if the public member was set to a derived type.</p>
<p><strong>WORKAROUND</strong><br />
The workaround to above problem has generally been resorting to custom XML serialization, which can get pretty complicated at times.</p>
<p><strong>SOLUTION</strong><br />
An ingenious solutions was discovered by <a href="http://www.codeproject.com/csharp/xmlserializerforunknown.asp">Simon Hewitt</a> using the <a href="http://msdn2.microsoft.com/en-us/system.xml.serialization.ixmlserializable.aspx">System.Xml.Serialization.IXmlSerializable</a> interface that allows us to mitigate the by-design issue of XmlSerializer object. While this solution works very well, it requires that a new class be created for each base class that we need serialization support for.</p>
<p>Using C# generics, I took the liberty of extending Simon&#8217;s solution, eliminating the need for such new classes, and encapsulating the grunt work into just one class. Once this class has been added to our project (our referenced from another assembly), all we really need to do is decorate any of our public members of base type (that may be substituted with derived types at runtime) with an attribute.</p>
<pre class="brush: csharp">
using System;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace Vocalsoft.Xml.Serialization
{
public class CustomSerializer : IXmlSerializable
{
#region Private Members
///
/// Holds the object that this serializer operates on.
///
private ItemType _parameters;
#endregion

#region Static Methods
///
/// Implicit operators the specified p.
///
/// The p.
///
public static implicit operator
CustomSerializer(ItemType p)
{
return p == null ? null : new CustomSerializer(p);
}

///
/// Implicit operators the specified p.
///
/// The p.
///
public static implicit operator
ItemType(CustomSerializer p)
{
return p.Equals(default(ItemType)) ? default(ItemType) : p.Parameters;
}
#endregion Static

#region Constructors
///
/// Initializes a new instance of the &quot;/&gt; class.
///
public CustomSerializer()
{
}

///
/// Initializes a new instance of the &quot;/&gt; class.
///
/// The parameters.
public CustomSerializer(ItemType parameters)
{
this._parameters = parameters;
}
#endregion Constructors

#region Properties

///
/// Gets parameters.
///
/// The parameters.
public ItemType Parameters
{
get { return _parameters; }
}

#endregion Properties

#region IXmlSerializable Implementation

///
/// Returns schema of the XML document representation of the object that is produced by the method and consumed by the method.
///
///
/// An that describes the XML representation of the object that is produced by the method and consumed by the method.
///
XmlSchema IXmlSerializable.GetSchema()
{
return null;
}

///
/// Generates an object from its XML representation.
///
/// The stream from which the object is deserialized.
void IXmlSerializable.ReadXml(XmlReader reader)
{
// Get type from xml attribute
Type type = Type.GetType(reader.GetAttribute(&quot;type&quot;));

// Deserialize
reader.ReadStartElement();
this._parameters = (ItemType)new XmlSerializer(type).Deserialize(reader);
reader.ReadEndElement();
}

///
/// Converts an object into its XML representation.
///
/// The stream to which the object is serialized.
void IXmlSerializable.WriteXml(XmlWriter writer)
{
// Write type as xml attribute
writer.WriteAttributeString(&quot;type&quot;, _parameters.GetType().ToString());
new XmlSerializer(_parameters.GetType()).Serialize(writer, _parameters);
}

#endregion IXmlSerializable Implementation

}
}
</pre>
<p>Once the above class has been added to our project, all we need to do is add an attribute directly on the base class property as follows:</p>
<pre class="brush: csharp">
[XmlElement(Type = typeof(CustomSerializer))]
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarerockstar.com/2006/12/using-ixmlserializable-to-overcome-not-expected-error-on-derived-classes/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>.NET 2.0: On-demand Configuration Encryption</title>
		<link>http://www.softwarerockstar.com/2006/10/net-2-0-on-demand-configuration-encryption/</link>
		<comments>http://www.softwarerockstar.com/2006/10/net-2-0-on-demand-configuration-encryption/#comments</comments>
		<pubDate>Mon, 02 Oct 2006 17:09:00 +0000</pubDate>
		<dc:creator>SoftwareRockstar</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[WinForms]]></category>

		<guid isPermaLink="false">http://mharoon.wordpress.com/2006/10/02/net-2-0-on-demand-configuration-encryption/</guid>
		<description><![CDATA[In .NET 2.0, apsnet_regiis can encrypt and decrypt sections of web.config and machine.config using RSA, DPAPI, or any other custom encryption provider. However, how do we encrypt/decrypt a custom application configuration (e.g. app.config of a WinForms application)? We are in luck, since the System.Configuration namespace provides everything we need to accomplish this task. The following [...]]]></description>
			<content:encoded><![CDATA[<div class="imageleft"><img src="http://softwarerockstar.com/wp-content/uploads/2006/10/encryption1.jpg" alt="Binary Code" width="300" height="244" class="alignnone size-full wp-image-325" /></div>
<p>In .NET 2.0, <a href="http://msdn2.microsoft.com/en-us/library/k6h9cz8h.aspx">apsnet_regiis</a> can encrypt and decrypt sections of web.config and machine.config using <a href="http://www.rsasecurity.com/">RSA</a>, <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsecure/html/windataprotection-dpapi.asp">DPAPI</a>, or any other custom encryption provider. However, how do we encrypt/decrypt a custom application configuration (e.g. app.config of a WinForms application)?</p>
<p>We are in luck, since the <a href="http://msdn2.microsoft.com/en-us/library/system.configuration.aspx">System.Configuration </a>namespace provides everything we need to accomplish this task. The following class, for example, can be used to encrypt/decrypt any .NET configuration file:</p>
<pre class="brush: csharp">
///
/// Implements a utility class that enables encrypting / decrypting
/// sections in .NET configuration files.
///
internal static class ConfigEncryptionHelper
{
    #region Encryption Methods

    ///
    /// Encrypts a section in a .NET configuration file using a named provider.
    ///
    /// Physical path of configuration file.
    /// Section name to encrypt.
    /// Name of the encryption provider.
    public static void EncryptConfigSection(string configPath, string sectionName, string protectionProviderName)
    {
        // Map the configuration file
        ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
        fileMap.ExeConfigFilename = configPath;

        // Open configuration file
        Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);

        // Get the desired section
        ConfigurationSection section = config.GetSection(sectionName);

        // Encrypt the section
        if (!section.SectionInformation.IsProtected)
            section.SectionInformation.ProtectSection(protectionProviderName);

        // Save configuration file
        config.Save();
    }

    ///
    /// Encrypts a section in a .NET configuration file using DataProtectionProvider.
    ///
    /// Physical path of configuration file.
    /// Section name to encrypt.
    public static void EncryptConfigSection(string configPath, string sectionName)
    {
        EncryptConfigSection(configPath, sectionName, &quot;DataProtectionConfigurationProvider&quot;);
    }

    #endregion

    #region Decryption Methods

    ///
    /// Decrypts a section in a .NET configuration file.
    ///
    /// Physical path of configuration file.
    /// Section name to encrypt.
    public static void DecryptConfigSection(string configPath, string sectionName)
    {
        // Map the configuration file
        ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
        fileMap.ExeConfigFilename = configPath;

        // Open configuration file
        Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);

        // Get the desired section
        ConfigurationSection section = config.GetSection(sectionName);

        // Decrypt section
        if (section.SectionInformation.IsProtected)
            section.SectionInformation.UnprotectSection();

        // Save configuration file
        config.Save();

    }

    #endregion
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarerockstar.com/2006/10/net-2-0-on-demand-configuration-encryption/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Controls To ASP.NET GridView Pager Row</title>
		<link>http://www.softwarerockstar.com/2006/09/adding-controls-to-asp-net-gridview-pager-row/</link>
		<comments>http://www.softwarerockstar.com/2006/09/adding-controls-to-asp-net-gridview-pager-row/#comments</comments>
		<pubDate>Thu, 14 Sep 2006 22:53:00 +0000</pubDate>
		<dc:creator>SoftwareRockstar</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://mharoon.wordpress.com/2006/09/14/adding-controls-to-asp-net-gridview-pager-row/</guid>
		<description><![CDATA[ASP.NET 2.0 GridView control contains the AllowPaging property. Setting this property to a value of true enables the paging feature of the GridView and displays data split across multiple pages if the number of rows in the underlying data source is greater than the PageSize property. By default ASP.NET automatically displays numeric paging controls at [...]]]></description>
			<content:encoded><![CDATA[<p>ASP.NET 2.0 <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx">GridView</a> control contains the <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.allowpaging.aspx">AllowPaging</a> property. Setting this property to a value of true enables the paging feature of the <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx">GridView</a> and displays data split across multiple pages if the number of rows in the underlying data source is greater than the <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.pagesize.aspx">PageSize</a> property. By default ASP.NET automatically displays numeric paging controls at the bottom of the <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx">GridView</a>.</p>
<p>While automatic paging is a very handy feature of <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx">GridView</a>, if you want to display any additional paging controls than those inherently supported by automatic paging, you must resort to specifying your own <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.pagertemplate.aspx">PagerTemplate</a> and write some additional code to preform the same functionality that <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx">GridView</a> would otherwise handle for you.</p>
<p>In certain situations, a better option, however, is to simply inject your custom control(s) into the pager generated by the <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx">GridView</a>. The following example shows how we can inject a &#8220;View All&#8221; <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.aspx">LinkButton</a> into <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx">GridView&#8217;s</a> pager row that allows users to view all rows in the underlying data source at the same time:</p>
<pre class="brush: csharp">
protected void MyGridView_RowCreated(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.Pager)
    {
        LiteralControl space = new LiteralControl(&quot;&amp;nbsp;&quot;);

        LinkButton lb = new LinkButton();
        lb.ID = &quot;ViewAllLinkButton&quot;;
        lb.Text = &quot;View All&quot;;
        lb.SkinID = &quot;ProfessionalGridViewPagerViewAll&quot;;
        lb.Click += new EventHandler(ViewAllLinkButton_Click);

        // Pager is rendered in a single cell as a table;
        // each page # is in a cell by it&#039;s own
        Table table = e.Row.Cells[0].Controls[0] as Table;

        // Add ViewAll linkbutton to the last cell
        TableCell parentCell = table.Rows[0].Cells[table.Rows[0].Cells.Count - 1];
        parentCell.Controls.Add(space);
        parentCell.Controls.Add(lb);
    }
}

protected void ViewAllLinkButton_Click(object sender, EventArgs e)
{
    MyGridView.AllowPaging = false;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarerockstar.com/2006/09/adding-controls-to-asp-net-gridview-pager-row/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->