<?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>Alvin Ashcraft&#039;s Morning Dew &#187; how-to</title>
	<atom:link href="http://www.alvinashcraft.com/category/development/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alvinashcraft.com</link>
	<description>Your Source for .NET Development Resources</description>
	<lastBuildDate>Fri, 10 Feb 2012 12:57:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>C# + ReSharper = Awesome: Tip #8 &#8211; Extract Class From Parameters</title>
		<link>http://www.alvinashcraft.com/2012/01/23/c-resharper-awesome-tip-8-extract-class-from-parameters/</link>
		<comments>http://www.alvinashcraft.com/2012/01/23/c-resharper-awesome-tip-8-extract-class-from-parameters/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 01:37:23 +0000</pubDate>
		<dc:creator>Alvin Ashcraft</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.alvinashcraft.com/?p=2129</guid>
		<description><![CDATA[This is the eighth in a series of quick how-to articles on ReSharper. Tip #8 – Extract Class From Parameters Use: If you find yourself passing a set of related values to a method, you should probably put all of those items into a single class or struct. From JetBrains: This refactoring creates a new [...]]]></description>
			<content:encoded><![CDATA[<p>This is the eighth in a series of quick how-to articles on <a href="http://www.jetbrains.com/resharper/" target="_blank">ReSharper</a>.</p>
<h3>Tip #8 – Extract Class From Parameters</h3>
<p><strong>Use:</strong> If you find yourself passing a set of related values to a method, you should probably put all of those items into a single class or struct. From <a href="http://www.jetbrains.com/resharper/features/code_refactoring.html#Extract_Class_from_Parameters" target="_blank">JetBrains</a>:</p>
<blockquote><p>This refactoring creates a new class or struct and converts parameters of the selected method into encapsulated fields of the newly created type (with constructor taking parameters, fields to store values and properties to retrieve values). Usages of parameters are converted to usages of properties of created type.</p>
</blockquote>
<h5>Before</h5>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> EmployeeUtilities</pre>
<pre><span class="lnum">   2:  </span>    {</pre>
<pre><span class="lnum">   3:  </span>        <span class="kwrd">public</span> <span class="kwrd">bool</span> ValidateTerminatedEmployeeInfo(<span class="kwrd">int</span> employeeId</pre>
<pre><span class="lnum">   4:  </span>                                                 , <span class="kwrd">string</span> firstName</pre>
<pre><span class="lnum">   5:  </span>                                                 , <span class="kwrd">string</span> lastName</pre>
<pre><span class="lnum">   6:  </span>                                                 , DateTime hireDate</pre>
<pre><span class="lnum">   7:  </span>                                                 , DateTime terminateDate)</pre>
<pre><span class="lnum">   8:  </span>        {</pre>
<pre><span class="lnum">   9:  </span>            <span class="kwrd">if</span> (employeeId &gt; -1 &amp;&amp; </pre>
<pre><span class="lnum">  10:  </span>                !String.IsNullOrWhiteSpace(firstName) &amp;&amp; </pre>
<pre><span class="lnum">  11:  </span>                !String.IsNullOrWhiteSpace(lastName) &amp;&amp;</pre>
<pre><span class="lnum">  12:  </span>                hireDate &lt; DateTime.Now &amp;&amp; </pre>
<pre><span class="lnum">  13:  </span>                terminateDate &gt; hireDate)</pre>
<pre><span class="lnum">  14:  </span>            {</pre>
<pre><span class="lnum">  15:  </span>                <span class="rem">// do awesome stuff</span></pre>
<pre><span class="lnum">  16:  </span>                <span class="kwrd">return</span> <span class="kwrd">true</span>;</pre>
<pre><span class="lnum">  17:  </span>            }</pre>
<pre><span class="lnum">  18:  </span>&#160;</pre>
<pre><span class="lnum">  19:  </span>            <span class="kwrd">return</span> <span class="kwrd">false</span>;</pre>
<pre><span class="lnum">  20:  </span>        }</pre>
<pre><span class="lnum">  21:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<h5>Right-click the method</h5>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/image18.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.alvinashcraft.com/wp-content/uploads/image_thumb7.png" width="644" height="153" /></a></p>
<h5>Extract Class From Parameters</h5>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/SNAGHTML10f0d4a5.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML10f0d4a5" border="0" alt="SNAGHTML10f0d4a5" src="http://www.alvinashcraft.com/wp-content/uploads/SNAGHTML10f0d4a5_thumb.png" width="545" height="484" /></a></p>
<h5>After</h5>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> EmployeeInfo</pre>
<pre><span class="lnum">   2:  </span>    {</pre>
<pre><span class="lnum">   3:  </span>        <span class="kwrd">private</span> <span class="kwrd">int</span> _employeeId;</pre>
<pre><span class="lnum">   4:  </span>        <span class="kwrd">private</span> <span class="kwrd">string</span> _firstName;</pre>
<pre><span class="lnum">   5:  </span>        <span class="kwrd">private</span> <span class="kwrd">string</span> _lastName;</pre>
<pre><span class="lnum">   6:  </span>        <span class="kwrd">private</span> DateTime _hireDate;</pre>
<pre><span class="lnum">   7:  </span>        <span class="kwrd">private</span> DateTime _terminateDate;</pre>
<pre><span class="lnum">   8:  </span>&#160;</pre>
<pre><span class="lnum">   9:  </span>        <span class="kwrd">public</span> EmployeeInfo(<span class="kwrd">int</span> employeeId, <span class="kwrd">string</span> firstName, <span class="kwrd">string</span> lastName, DateTime hireDate, DateTime terminateDate)</pre>
<pre><span class="lnum">  10:  </span>        {</pre>
<pre><span class="lnum">  11:  </span>            _employeeId = employeeId;</pre>
<pre><span class="lnum">  12:  </span>            _firstName = firstName;</pre>
<pre><span class="lnum">  13:  </span>            _lastName = lastName;</pre>
<pre><span class="lnum">  14:  </span>            _hireDate = hireDate;</pre>
<pre><span class="lnum">  15:  </span>            _terminateDate = terminateDate;</pre>
<pre><span class="lnum">  16:  </span>        }</pre>
<pre><span class="lnum">  17:  </span>&#160;</pre>
<pre><span class="lnum">  18:  </span>        <span class="kwrd">public</span> <span class="kwrd">int</span> EmployeeId</pre>
<pre><span class="lnum">  19:  </span>        {</pre>
<pre><span class="lnum">  20:  </span>            get { <span class="kwrd">return</span> _employeeId; }</pre>
<pre><span class="lnum">  21:  </span>        }</pre>
<pre><span class="lnum">  22:  </span>&#160;</pre>
<pre><span class="lnum">  23:  </span>        <span class="kwrd">public</span> <span class="kwrd">string</span> FirstName</pre>
<pre><span class="lnum">  24:  </span>        {</pre>
<pre><span class="lnum">  25:  </span>            get { <span class="kwrd">return</span> _firstName; }</pre>
<pre><span class="lnum">  26:  </span>        }</pre>
<pre><span class="lnum">  27:  </span>&#160;</pre>
<pre><span class="lnum">  28:  </span>        <span class="kwrd">public</span> <span class="kwrd">string</span> LastName</pre>
<pre><span class="lnum">  29:  </span>        {</pre>
<pre><span class="lnum">  30:  </span>            get { <span class="kwrd">return</span> _lastName; }</pre>
<pre><span class="lnum">  31:  </span>        }</pre>
<pre><span class="lnum">  32:  </span>&#160;</pre>
<pre><span class="lnum">  33:  </span>        <span class="kwrd">public</span> DateTime HireDate</pre>
<pre><span class="lnum">  34:  </span>        {</pre>
<pre><span class="lnum">  35:  </span>            get { <span class="kwrd">return</span> _hireDate; }</pre>
<pre><span class="lnum">  36:  </span>        }</pre>
<pre><span class="lnum">  37:  </span>&#160;</pre>
<pre><span class="lnum">  38:  </span>        <span class="kwrd">public</span> DateTime TerminateDate</pre>
<pre><span class="lnum">  39:  </span>        {</pre>
<pre><span class="lnum">  40:  </span>            get { <span class="kwrd">return</span> _terminateDate; }</pre>
<pre><span class="lnum">  41:  </span>        }</pre>
<pre><span class="lnum">  42:  </span>    }</pre>
<pre><span class="lnum">  43:  </span>&#160;</pre>
<pre><span class="lnum">  44:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> EmployeeUtilities</pre>
<pre><span class="lnum">  45:  </span>    {</pre>
<pre><span class="lnum">  46:  </span>        <span class="kwrd">public</span> <span class="kwrd">bool</span> ValidateTerminatedEmployeeInfo(EmployeeInfo employeeInfo)</pre>
<pre><span class="lnum">  47:  </span>        {</pre>
<pre><span class="lnum">  48:  </span>            <span class="kwrd">if</span> (employeeInfo.EmployeeId &gt; -1 &amp;&amp; </pre>
<pre><span class="lnum">  49:  </span>                !String.IsNullOrWhiteSpace(employeeInfo.FirstName) &amp;&amp; </pre>
<pre><span class="lnum">  50:  </span>                !String.IsNullOrWhiteSpace(employeeInfo.LastName) &amp;&amp;</pre>
<pre><span class="lnum">  51:  </span>                employeeInfo.HireDate &lt; DateTime.Now &amp;&amp; </pre>
<pre><span class="lnum">  52:  </span>                employeeInfo.TerminateDate &gt; employeeInfo.HireDate)</pre>
<pre><span class="lnum">  53:  </span>            {</pre>
<pre><span class="lnum">  54:  </span>                <span class="rem">// do awesome stuff</span></pre>
<pre><span class="lnum">  55:  </span>                <span class="kwrd">return</span> <span class="kwrd">true</span>;</pre>
<pre><span class="lnum">  56:  </span>            }</pre>
<pre><span class="lnum">  57:  </span>&#160;</pre>
<pre><span class="lnum">  58:  </span>            <span class="kwrd">return</span> <span class="kwrd">false</span>;</pre>
<pre><span class="lnum">  59:  </span>        }</pre>
<pre><span class="lnum">  60:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><em>Happy coding!</em></p>
<p>&#160;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:5e099003-602b-436f-af23-5c4dda0a44f1" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/visual+studio" rel="tag">visual studio</a>,<a href="http://del.icio.us/popular/resharper" rel="tag">resharper</a>,<a href="http://del.icio.us/popular/refactoring" rel="tag">refactoring</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.alvinashcraft.com/2012/01/23/c-resharper-awesome-tip-8-extract-class-from-parameters/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>C# + ReSharper = Awesome: Tip #7&#8211;Move String to Resource</title>
		<link>http://www.alvinashcraft.com/2012/01/20/c-resharper-awesome-tip-7move-string-to-resource/</link>
		<comments>http://www.alvinashcraft.com/2012/01/20/c-resharper-awesome-tip-7move-string-to-resource/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 20:41:57 +0000</pubDate>
		<dc:creator>Alvin Ashcraft</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.alvinashcraft.com/?p=2121</guid>
		<description><![CDATA[This is the seventh in a series of quick how-to articles on ReSharper. Tip #7 – Move String to Resource Use: Moves a string into a resource file to enable localization. Tip: Ensure your project contains at least one Resource (resx) file or the operation will fail. Before 1: public string YouRock() 2: { 3: [...]]]></description>
			<content:encoded><![CDATA[<p>This is the seventh in a series of quick how-to articles on <a href="http://www.jetbrains.com/resharper/" target="_blank">ReSharper</a>.</p>
<h3>Tip #7 – Move String to Resource</h3>
<p><strong>Use:</strong> Moves a string into a resource file to enable localization.</p>
<p><strong>Tip:</strong> Ensure your project contains at least one Resource (resx) file or the operation will fail.</p>
<h5>Before</h5>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>     <span class="kwrd">public</span> <span class="kwrd">string</span> YouRock()</pre>
<pre><span class="lnum">   2:  </span>     {</pre>
<pre><span class="lnum">   3:  </span>         <span class="kwrd">return</span> <span class="str">&quot;No, YOU rock Mr. Method-Caller!&quot;</span>;</pre>
<pre><span class="lnum">   4:  </span>     }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<h5>Right-click the string –&gt; Refactor –&gt; Refactor This…</h5>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/image17.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.alvinashcraft.com/wp-content/uploads/image_thumb6.png" width="364" height="168" /></a></p>
<h5>Move to Resource</h5>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/SNAGHTML6f7080.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML6f7080" border="0" alt="SNAGHTML6f7080" src="http://www.alvinashcraft.com/wp-content/uploads/SNAGHTML6f7080_thumb.png" width="424" height="307" /></a></p>
<h5>After</h5>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>     <span class="kwrd">public</span> <span class="kwrd">string</span> YouRock()</pre>
<pre><span class="lnum">   2:  </span>     {</pre>
<pre><span class="lnum">   3:  </span>         <span class="kwrd">return</span> StringResources.No_YOU_rock_Mr_Method_Caller;</pre>
<pre><span class="lnum">   4:  </span>     }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><em>Happy coding!</em></p>
<p>&#160;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4c526044-a7ee-44e7-8132-b613a76d2b95" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/resharper" rel="tag">resharper</a>,<a href="http://del.icio.us/popular/visual+studio" rel="tag">visual studio</a>,<a href="http://del.icio.us/popular/refactoring" rel="tag">refactoring</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.alvinashcraft.com/2012/01/20/c-resharper-awesome-tip-7move-string-to-resource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# + ReSharper = Awesome: Tip #6 &#8211; Extract Interface</title>
		<link>http://www.alvinashcraft.com/2012/01/09/c-resharper-awesome-tip-6-extract-interface/</link>
		<comments>http://www.alvinashcraft.com/2012/01/09/c-resharper-awesome-tip-6-extract-interface/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 17:15:35 +0000</pubDate>
		<dc:creator>Alvin Ashcraft</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.alvinashcraft.com/?p=2089</guid>
		<description><![CDATA[This is the sixth in a series of quick how-to articles on ReSharper. Tip #6 – Extract Interface Use: Creates a new interface based on the selected class and updates the class to implement the new interface. This is most useful when working with an existing code base because we all define our interfaces first [...]]]></description>
			<content:encoded><![CDATA[<p>This is the sixth in a series of quick how-to articles on <a href="http://www.jetbrains.com/resharper/" target="_blank">ReSharper</a>.</p>
<h3>Tip #6 – Extract Interface</h3>
<p><strong>Use:</strong> Creates a new interface based on the selected class and updates the class to implement the new interface. This is most useful when working with an existing code base because we all define our interfaces first when doing greenfield development, right?&#160; <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.alvinashcraft.com/wp-content/uploads/wlEmoticon-smile3.png" /></p>
<h5>Before</h5>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> Shooter</pre>
<pre><span class="lnum">   2:  </span>    {</pre>
<pre><span class="lnum">   3:  </span>        <span class="kwrd">public</span> <span class="kwrd">string</span> Name { get; set; }</pre>
<pre><span class="lnum">   4:  </span>&#160;</pre>
<pre><span class="lnum">   5:  </span>        <span class="kwrd">public</span> <span class="kwrd">string</span> ReleaseDate { get; set; }</pre>
<pre><span class="lnum">   6:  </span>&#160;</pre>
<pre><span class="lnum">   7:  </span>        <span class="kwrd">public</span> <span class="kwrd">int</span> MaxPlayers { get; set; }</pre>
<pre><span class="lnum">   8:  </span>&#160;</pre>
<pre><span class="lnum">   9:  </span>        <span class="kwrd">public</span> <span class="kwrd">bool</span> HasZombies { get; set; }</pre>
<pre><span class="lnum">  10:  </span>&#160;</pre>
<pre><span class="lnum">  11:  </span>        <span class="kwrd">public</span> <span class="kwrd">bool</span> IsHalo { get; set; }</pre>
<pre><span class="lnum">  12:  </span>&#160;</pre>
<pre><span class="lnum">  13:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> Borrow()</pre>
<pre><span class="lnum">  14:  </span>        {</pre>
<pre><span class="lnum">  15:  </span>            <span class="rem">//TODO: Implement borrow logic.</span></pre>
<pre><span class="lnum">  16:  </span>        }</pre>
<pre><span class="lnum">  17:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<h5>Right-click the class</h5>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/image16.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.alvinashcraft.com/wp-content/uploads/image_thumb5.png" width="544" height="219" /></a></p>
<h5>Select members</h5>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/SNAGHTML4614fae1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML4614fae1" border="0" alt="SNAGHTML4614fae1" src="http://www.alvinashcraft.com/wp-content/uploads/SNAGHTML4614fae1_thumb.png" width="484" height="345" /></a></p>
<h5>After</h5>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">interface</span> IGame</pre>
<pre><span class="lnum">   2:  </span>    {</pre>
<pre><span class="lnum">   3:  </span>        <span class="kwrd">string</span> Name { get; set; }</pre>
<pre><span class="lnum">   4:  </span>        <span class="kwrd">string</span> ReleaseDate { get; set; }</pre>
<pre><span class="lnum">   5:  </span>        <span class="kwrd">int</span> MaxPlayers { get; set; }</pre>
<pre><span class="lnum">   6:  </span>        <span class="kwrd">void</span> Borrow();</pre>
<pre><span class="lnum">   7:  </span>    }</pre>
<pre><span class="lnum">   8:  </span>&#160;</pre>
<pre><span class="lnum">   9:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> Shooter : IGame</pre>
<pre><span class="lnum">  10:  </span>    {</pre>
<pre><span class="lnum">  11:  </span>        <span class="kwrd">public</span> <span class="kwrd">string</span> Name { get; set; }</pre>
<pre><span class="lnum">  12:  </span>&#160;</pre>
<pre><span class="lnum">  13:  </span>        <span class="kwrd">public</span> <span class="kwrd">string</span> ReleaseDate { get; set; }</pre>
<pre><span class="lnum">  14:  </span>&#160;</pre>
<pre><span class="lnum">  15:  </span>        <span class="kwrd">public</span> <span class="kwrd">int</span> MaxPlayers { get; set; }</pre>
<pre><span class="lnum">  16:  </span>&#160;</pre>
<pre><span class="lnum">  17:  </span>        <span class="kwrd">public</span> <span class="kwrd">bool</span> HasZombies { get; set; }</pre>
<pre><span class="lnum">  18:  </span>&#160;</pre>
<pre><span class="lnum">  19:  </span>        <span class="kwrd">public</span> <span class="kwrd">bool</span> IsHalo { get; set; }</pre>
<pre><span class="lnum">  20:  </span>&#160;</pre>
<pre><span class="lnum">  21:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> Borrow()</pre>
<pre><span class="lnum">  22:  </span>        {</pre>
<pre><span class="lnum">  23:  </span>            <span class="rem">//TODO: Implement borrow logic.</span></pre>
<pre><span class="lnum">  24:  </span>        }</pre>
<pre><span class="lnum">  25:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><em></em></p>
<p><em>Happy coding!</em></p>
<p>&#160;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:964ace36-7c8d-484f-8db8-1d7a61162120" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/resharper" rel="tag">resharper</a>,<a href="http://del.icio.us/popular/visual+studio" rel="tag">visual studio</a>,<a href="http://del.icio.us/popular/refactoring" rel="tag">refactoring</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.alvinashcraft.com/2012/01/09/c-resharper-awesome-tip-6-extract-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# + ReSharper = Awesome: Tip #5 &#8211; Replace Constructor with Factory Method</title>
		<link>http://www.alvinashcraft.com/2011/12/22/c-resharper-awesome-tip-5-replace-constructor-with-factory-method/</link>
		<comments>http://www.alvinashcraft.com/2011/12/22/c-resharper-awesome-tip-5-replace-constructor-with-factory-method/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 16:19:35 +0000</pubDate>
		<dc:creator>Alvin Ashcraft</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.alvinashcraft.com/?p=2055</guid>
		<description><![CDATA[This is the fifth in a series of quick how-to articles on ReSharper. Tip #5 – Replace Constructor with Factory Method Use: If an application must control how or when new instances of classes are created, a factory method can achieve this. ReSharper makes it simple to wrap a constructor with a static factory method. [...]]]></description>
			<content:encoded><![CDATA[<p>This is the fifth in a series of quick how-to articles on <a href="http://www.jetbrains.com/resharper/" target="_blank">ReSharper</a>.</p>
<h3>Tip #5 – Replace Constructor with Factory Method</h3>
<p><strong>Use: </strong>If an application must control how or when new instances of classes are created, a factory method can achieve this. ReSharper makes it simple to wrap a constructor with a static factory method.</p>
<h5>Before</h5>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> Car</pre>
<pre><span class="lnum">   2:  </span>    {</pre>
<pre><span class="lnum">   3:  </span>        <span class="kwrd">private</span> IList&lt;IPart&gt; _parts;</pre>
<pre><span class="lnum">   4:  </span> </pre>
<pre><span class="lnum">   5:  </span>         <span class="kwrd">public</span> Car(IList&lt;IPart&gt; parts)</pre>
<pre><span class="lnum">   6:  </span>         {</pre>
<pre><span class="lnum">   7:  </span>             _parts = parts;</pre>
<pre><span class="lnum">   8:  </span>         }</pre>
<pre><span class="lnum">   9:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<h5>Right-click the constructor</h5>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/image15.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.alvinashcraft.com/wp-content/uploads/image_thumb4.png" width="644" height="130" /></a></p>
<h5>Name your method or accept the default</h5>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/SNAGHTML1ecbd865.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML1ecbd865" border="0" alt="SNAGHTML1ecbd865" src="http://www.alvinashcraft.com/wp-content/uploads/SNAGHTML1ecbd865_thumb.png" width="484" height="199" /></a></p>
<h5>After</h5>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> Car</pre>
<pre><span class="lnum">   2:  </span>    {</pre>
<pre><span class="lnum">   3:  </span>        <span class="kwrd">public</span> <span class="kwrd">static</span> Car CreateCar(IList&lt;IPart&gt; parts)</pre>
<pre><span class="lnum">   4:  </span>        {</pre>
<pre><span class="lnum">   5:  </span>            <span class="kwrd">return</span> <span class="kwrd">new</span> Car(parts);</pre>
<pre><span class="lnum">   6:  </span>        }</pre>
<pre><span class="lnum">   7:  </span>&#160;</pre>
<pre><span class="lnum">   8:  </span>        <span class="kwrd">private</span> IList&lt;IPart&gt; _parts;</pre>
<pre><span class="lnum">   9:  </span>&#160;</pre>
<pre><span class="lnum">  10:  </span>        <span class="kwrd">private</span> Car(IList&lt;IPart&gt; parts)</pre>
<pre><span class="lnum">  11:  </span>         {</pre>
<pre><span class="lnum">  12:  </span>             _parts = parts;</pre>
<pre><span class="lnum">  13:  </span>         }</pre>
<pre><span class="lnum">  14:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p><em>Happy coding!</em></p>
<p>&#160;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c11c88e7-371b-4d6b-8034-f6d4050614ac" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/resharper" rel="tag">resharper</a>,<a href="http://del.icio.us/popular/visual+studio" rel="tag">visual studio</a>,<a href="http://del.icio.us/popular/refactoring" rel="tag">refactoring</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.alvinashcraft.com/2011/12/22/c-resharper-awesome-tip-5-replace-constructor-with-factory-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# + ReSharper = Awesome: Tip #4 &#8211; Convert Abstract Class to Interface</title>
		<link>http://www.alvinashcraft.com/2011/12/20/c-resharper-awesome-tip-4-convert-abstract-class-to-interface/</link>
		<comments>http://www.alvinashcraft.com/2011/12/20/c-resharper-awesome-tip-4-convert-abstract-class-to-interface/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 18:09:07 +0000</pubDate>
		<dc:creator>Alvin Ashcraft</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.alvinashcraft.com/?p=2044</guid>
		<description><![CDATA[This is the fourth in a series of quick how-to articles on ReSharper. Tip #4 – Convert Abstract Class to Interface Use: This is used when the class(es) that will be inheriting from a base class also need to inherit from another base class. Derived types can inherit from only one base class but can [...]]]></description>
			<content:encoded><![CDATA[<p>This is the fourth in a series of quick how-to articles on <a href="http://www.jetbrains.com/resharper/" target="_blank">ReSharper</a>.</p>
<h3>Tip #4 – Convert Abstract Class to Interface</h3>
<p><strong>Use:</strong> This is used when the class(es) that will be inheriting from a base class also need to inherit from another base class. Derived types can inherit from only one base class but can implement multiple interfaces.</p>
<h5>Before</h5>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">class</span> Book</pre>
<pre><span class="lnum">   2:  </span>    {</pre>
<pre><span class="lnum">   3:  </span>        <span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">string</span> Title { get; set; }</pre>
<pre><span class="lnum">   4:  </span>&#160;</pre>
<pre><span class="lnum">   5:  </span>        <span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">string</span> Year { get; set; }</pre>
<pre><span class="lnum">   6:  </span>&#160;</pre>
<pre><span class="lnum">   7:  </span>        <span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">string</span> Author { get; set; }</pre>
<pre><span class="lnum">   8:  </span>&#160;</pre>
<pre><span class="lnum">   9:  </span>        <span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">void</span> Lend();</pre>
<pre><span class="lnum">  10:  </span>&#160;</pre>
<pre><span class="lnum">  11:  </span>        <span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">void</span> AddToInventory();</pre>
<pre><span class="lnum">  12:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<h5>Right-click the class</h5>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/image14.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.alvinashcraft.com/wp-content/uploads/image_thumb3.png" width="644" height="110" /></a></p>
<h5>After</h5>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">interface</span> Book</pre>
<pre><span class="lnum">   2:  </span>    {</pre>
<pre><span class="lnum">   3:  </span>        <span class="kwrd">string</span> Title { get; set; }</pre>
<pre><span class="lnum">   4:  </span>        <span class="kwrd">string</span> Year { get; set; }</pre>
<pre><span class="lnum">   5:  </span>        <span class="kwrd">string</span> Author { get; set; }</pre>
<pre><span class="lnum">   6:  </span>        <span class="kwrd">void</span> Lend();</pre>
<pre><span class="lnum">   7:  </span>        <span class="kwrd">void</span> AddToInventory();</pre>
<pre><span class="lnum">   8:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><strong></strong></p>
<p><strong>Note:</strong> Notice that this refactoring does not change the name of the type. At this point, there will be a squiggly line under the interface’s name, Book. Placing the cursor on Book and pressing &lt;Alt+Enter&gt; will prompt ReSharper to rename it to IBook.</p>
<p>&#160;</p>
<p><em>Happy coding!</em></p>
<p>&#160;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:2cd1143e-a9e1-4989-a451-a58ace481cff" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/resharper" rel="tag">resharper</a>,<a href="http://del.icio.us/popular/visual+studio" rel="tag">visual studio</a>,<a href="http://del.icio.us/popular/refactoring" rel="tag">refactoring</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.alvinashcraft.com/2011/12/20/c-resharper-awesome-tip-4-convert-abstract-class-to-interface/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>C# + ReSharper = Awesome: Tip #3 &#8211; Convert Into LINQ Expression</title>
		<link>http://www.alvinashcraft.com/2011/12/16/c-resharper-awesome-tip-3-convert-into-linq-expression/</link>
		<comments>http://www.alvinashcraft.com/2011/12/16/c-resharper-awesome-tip-3-convert-into-linq-expression/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 21:44:33 +0000</pubDate>
		<dc:creator>Alvin Ashcraft</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.alvinashcraft.com/?p=2034</guid>
		<description><![CDATA[This is the third in a series of quick how-to articles on Resharper. Tip #3 – Convert Into LINQ Expression Use: ForEach blocks that perform simple bits of logic can often times be rewritten as lambda expressions. This reduces the number of lines of code and usually makes the code more readable. Before public IList&#60;Album&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>This is the third in a series of quick how-to articles on <a href="http://www.jetbrains.com/resharper/" target="_blank">Resharper</a>.</p>
<h3>Tip #3 – Convert Into LINQ Expression</h3>
<p>Use: ForEach blocks that perform simple bits of logic can often times be rewritten as lambda expressions. This reduces the number of lines of code and usually makes the code more readable.</p>
<h5>Before</h5>
<pre class="csharpcode">         <span class="kwrd">public</span> IList&lt;Album&gt; FindAlbumsToGiveAway(IList&lt;Album&gt; albums)
         {
             var badAlbums = <span class="kwrd">new</span> List&lt;Album&gt;();

             <span class="kwrd">foreach</span> (Album album <span class="kwrd">in</span> albums)
             {
                 <span class="kwrd">if</span> (album.Genre == <span class="str">&quot;Country&quot;</span>)
                     badAlbums.Add(album);
             }

             <span class="kwrd">return</span> badAlbums;
         }</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<h5>Press &lt;Alt+Enter&gt;</h5>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/image13.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.alvinashcraft.com/wp-content/uploads/image_thumb2.png" width="484" height="178" /></a></p>
<h5>After</h5>
<pre class="csharpcode">         <span class="kwrd">public</span> IList&lt;Album&gt; FindAlbumsToGiveAway(IList&lt;Album&gt; albums)
         {
             <span class="kwrd">return</span> albums.Where(album =&gt; album.Genre == <span class="str">&quot;Country&quot;</span>).ToList();
         }</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><em>Happy coding!</em></p>
<p>&#160;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b6393658-a9d7-47da-9a23-170027582297" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/resharper" rel="tag">resharper</a>,<a href="http://del.icio.us/popular/c%23" rel="tag">c#</a>,<a href="http://del.icio.us/popular/visual+studio" rel="tag">visual studio</a>,<a href="http://del.icio.us/popular/linq" rel="tag">linq</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.alvinashcraft.com/2011/12/16/c-resharper-awesome-tip-3-convert-into-linq-expression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# + ReSharper = Awesome: Tip #2 &#8211; Create Field</title>
		<link>http://www.alvinashcraft.com/2011/12/14/c-resharper-awesome-tip-2-create-field/</link>
		<comments>http://www.alvinashcraft.com/2011/12/14/c-resharper-awesome-tip-2-create-field/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 18:54:35 +0000</pubDate>
		<dc:creator>Alvin Ashcraft</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.alvinashcraft.com/?p=2025</guid>
		<description><![CDATA[This is the second in a series of quick how-to posts on ReSharper. Tip #2 – Create Field Use: Within the body of a class or property, you can type the name of a non-existent variable name. When you place your cursor on the variable, ReSharper provides several options to resolve the impending compilation error. [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second in a series of quick how-to posts on <a href="http://www.jetbrains.com/resharper/" target="_blank">ReSharper</a>.</p>
<h5>Tip #2 – Create Field</h5>
<p><strong>Use:</strong> Within the body of a class or property, you can type the name of a non-existent variable name. When you place your cursor on the variable, ReSharper provides several options to resolve the impending compilation error. Create Field is one of the options.</p>
<h5>Before</h5>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> AddAlbum(<span class="kwrd">string</span> album)</pre>
<pre><span class="lnum">   2:  </span>        {</pre>
<pre><span class="lnum">   3:  </span>            <span class="kwrd">if</span> (String.IsNullOrWhiteSpace(album))</pre>
<pre><span class="lnum">   4:  </span>                <span class="kwrd">throw</span> <span class="kwrd">new</span> ArgumentOutOfRangeException(<span class="str">&quot;album&quot;</span>,</pre>
<pre><span class="lnum">   5:  </span>                                                      album,</pre>
<pre><span class="lnum">   6:  </span>                                                      <span class="str">&quot;Please provide an album name.&quot;</span>);</pre>
<pre><span class="lnum">   7:  </span>&#160;</pre>
<pre><span class="lnum">   8:  </span>            <font color="#ff0000">_albums</font>.Add(album);</pre>
<pre><span class="lnum">   9:  </span>        }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<h5>Press &lt;Alt+Enter&gt;</h5>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/image12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.alvinashcraft.com/wp-content/uploads/image_thumb1.png" width="244" height="190" /></a></p>
<h5>After</h5>
<pre class="csharpcode">        <span class="kwrd">private</span> IList&lt;<span class="kwrd">string</span>&gt; _albums = <span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;();

        <span class="kwrd">public</span> <span class="kwrd">void</span> AddAlbum(<span class="kwrd">string</span> album)
        {
            <span class="kwrd">if</span> (String.IsNullOrWhiteSpace(album))
                <span class="kwrd">throw</span> <span class="kwrd">new</span> ArgumentOutOfRangeException(<span class="str">&quot;album&quot;</span>,
                                                      album,
                                                      <span class="str">&quot;Please provide an album name.&quot;</span>);

            _albums.Add(album);
        }</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><strong>Note:</strong> I chose the type IList&lt;string&gt;. The default type selected by ReSharper in this case was object. I also added the initializer to the field to avoid null reference exceptions. Please don’t take any of these examples as best coding practices, they are contrived to demonstrate a particular refactoring.</p>
<p><em>Happy coding!</em></p>
<p>&#160;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:e7b269f4-f697-4e1c-82f7-3e8589274e7f" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/resharper" rel="tag">resharper</a>,<a href="http://del.icio.us/popular/c%23" rel="tag">c#</a>,<a href="http://del.icio.us/popular/visual+studio" rel="tag">visual studio</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.alvinashcraft.com/2011/12/14/c-resharper-awesome-tip-2-create-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# + ReSharper = Awesome: Tip #1 &#8211; To Automatic Property</title>
		<link>http://www.alvinashcraft.com/2011/12/12/c-resharper-awesome-tip-1-to-automatic-property/</link>
		<comments>http://www.alvinashcraft.com/2011/12/12/c-resharper-awesome-tip-1-to-automatic-property/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 02:12:25 +0000</pubDate>
		<dc:creator>Alvin Ashcraft</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[resharper]]></category>

		<guid isPermaLink="false">http://www.alvinashcraft.com/?p=2015</guid>
		<description><![CDATA[This is the first in a series of quick how-to posts on ReSharper. I love ReSharper. It is a tool that I use every day and don’t really realize how much I rely on it until I use a machine without ReSharper installed. Tip #1 – To Automatic Property Use: If a public property does [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first in a series of quick how-to posts on ReSharper. I love ReSharper. It is a tool that I use every day and don’t really realize how much I rely on it until I use a machine without ReSharper installed.</p>
<h3>Tip #1 – To Automatic Property</h3>
<p><strong>Use:</strong> If a public property does not contain any logic, it can be converted to an auto-property, removing the corresponding private field and replacing usages of the private field.</p>
<h5>Before</h5>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>        <span class="kwrd">private</span> <span class="kwrd">string</span> _name;</pre>
<pre><span class="lnum">   2:  </span>        <span class="kwrd">public</span> <span class="kwrd">string</span> Name</pre>
<pre><span class="lnum">   3:  </span>        {</pre>
<pre><span class="lnum">   4:  </span>            get { <span class="kwrd">return</span> _name; }</pre>
<pre><span class="lnum">   5:  </span>            set { _name = <span class="kwrd">value</span>; }</pre>
<pre><span class="lnum">   6:  </span>        }</pre>
<pre><span class="lnum">   7:  </span>&nbsp;</pre>
<pre><span class="lnum">   8:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> CheckName()</pre>
<pre><span class="lnum">   9:  </span>        {</pre>
<pre><span class="lnum">  10:  </span>            <span class="kwrd">if</span> (_name == <span class="str">"Dark Side of the Moon"</span>)</pre>
<pre><span class="lnum">  11:  </span>                Console.WriteLine(<span class="str">"Awesome"</span>);</pre>
<pre><span class="lnum">  12:  </span>        }</pre>
</div>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Place your cursor on the Name property and…</p>
<h5>Press &lt;Alt-Enter&gt;</h5>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/image11.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.alvinashcraft.com/wp-content/uploads/image_thumb.png" width="244" height="126"></a></p>
<h5>After</h5>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>        <span class="kwrd">public</span> <span class="kwrd">string</span> Name { get; set; }</pre>
<pre><span class="lnum">   2:  </span>&nbsp;</pre>
<pre><span class="lnum">   3:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> CheckName()</pre>
<pre><span class="lnum">   4:  </span>        {</pre>
<pre><span class="lnum">   5:  </span>            <span class="kwrd">if</span> (Name == <span class="str">"Dark Side of the Moon"</span>)</pre>
<pre><span class="lnum">   6:  </span>                Console.WriteLine(<span class="str">"Awesome"</span>);</pre>
<pre><span class="lnum">   7:  </span>        }</pre>
<pre>&nbsp;</pre>
</div>
<p><em>Happy coding!</em></p>
<p>&nbsp;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:8f32f3c4-3000-46bb-85fa-28a241285a2b" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/resharper" rel="tag">resharper</a>,<a href="http://del.icio.us/popular/refactoring" rel="tag">refactoring</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.alvinashcraft.com/2011/12/12/c-resharper-awesome-tip-1-to-automatic-property/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Extend a Generic List to Provide Dictionary-Like Lookups</title>
		<link>http://www.alvinashcraft.com/2008/09/22/extend-a-generic-list-to-provide-dictionary-like-lookups/</link>
		<comments>http://www.alvinashcraft.com/2008/09/22/extend-a-generic-list-to-provide-dictionary-like-lookups/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 01:17:11 +0000</pubDate>
		<dc:creator>Alvin Ashcraft</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[how-to]]></category>

		<guid isPermaLink="false">http://www.alvinashcraft.com/2008/09/22/extend-a-generic-list-to-provide-dictionary-like-lookups/</guid>
		<description><![CDATA[&#160; Welcome to a quick and dirty example in which I’ll make use of interfaces, inheritance and generics. I was working with some code that did a lot of iterating over collections to find objects with a particular ID. This is an abstracted example of what I did to simplify and centralize that code in [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>Welcome to a quick and dirty example in which I’ll make use of interfaces, inheritance and generics. I was working with some code that did a lot of iterating over collections to find objects with a particular ID. This is an abstracted example of what I did to simplify and centralize that code in a reusable manner.</p>
<p><em>If you are using Visual Studio 2008, you could achieve the same kind of reuse with an extension method on your generic list. The project I was working on was in .NET 2.0 and Visual Studio 2005.</em></p>
<p>This method returns a student’s course based on its ID. The student object here is a private class member. The CurrentCourses property is a List&lt;Course&gt; collection.</p>
<blockquote><pre class="code"><span style="color: blue">private </span><span style="color: #2b91af">Course </span>FindCourseOld(<span style="color: blue">int </span>id)
{
    <span style="color: blue">foreach </span>(<span style="color: blue">var </span>course <span style="color: blue">in </span>_student.CurrentCourses)
    {
        <span style="color: blue">if </span>(course.ID == id)
        {
            <span style="color: blue">return </span>course;
        }
    }

    <span style="color: blue">return null</span>;
}</pre>
</blockquote>
<pre class="code">&nbsp;</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>It’s pretty simple, but suppose you had a dozen or more types with an ID property that were all queries like this? It smells like an opportunity to do some refactoring. We need to keep all the functionality of the List&lt;T&gt; generic collection, including sorting, index operations, and enumerating, but we want to provide a dictionary-type of lookup on the ID property. Let’s inherit from List&lt;T&gt; and add a method to perform our lookup.</p>
<p>Before an object can be stored in this new collection, our child of List&lt;T&gt;, that we are going to create, we need to ensure it has an ID property on which we can operate. To that end, I present to you the IHasIdentifier interface. I know it’s not grammatically correct, but I think it gets the point across.</p>
<blockquote><pre class="code"><span style="color: blue">public interface </span><span style="color: #2b91af">IHasIdentifier
</span>{
<span style="color: gray">    </span><span style="color: blue">int </span>ID { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
}</pre>
</blockquote>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&nbsp;</p>
<p>The new interface has a single property named ‘ID’, which many of the types you might consider using in our collection may already have. Next up is the IdentityList&lt;T&gt; itself. The implementation I have here is very simple. There is just a single method, GetItemByID, added to the base class, List&lt;T&gt;.</p>
<blockquote><pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">IdentityList</span>&lt;T&gt; : <span style="color: #2b91af">List</span>&lt;T&gt; <span style="color: blue">where </span>T : <span style="color: #2b91af">IHasIdentifier
</span>{
<span style="color: gray">    </span><span style="color: blue">public </span>T GetItemByID(<span style="color: blue">int </span>id)
    {
        <span style="color: blue">foreach </span>(<span style="color: blue">var </span>obj <span style="color: blue">in this</span>)
        {
            <span style="color: blue">if </span>(obj.ID == id)
            {
                <span style="color: blue">return </span>obj;
            }
        }

        <span style="color: blue">return default</span>(T);
    }
}</pre>
</blockquote>
<p>&nbsp;</p>
<p>We’re inheriting from List&lt;T&gt; and specifying that T must implement IHasIdentifier. Now, in the GetItemByID method, we can do our iteration to find the object with the given ID and return it. Finally, let’s take a look at the FindCourseNew method which uses our IdentityList&lt;T&gt; collection.</p>
<pre class="code"><span style="color: blue">private </span><span style="color: #2b91af">Course </span>FindCourseNew(<span style="color: blue">int </span>id)
{
    <span style="color: blue">return </span>_student.CurrentCourses.GetItemByID(id);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a>&nbsp;</p>
<p>The code here is much cleaner, and there could be more opportunity for code reuse with the IdentityList&lt;T&gt;. Many of the dictionary type of methods could be adapted and used within this collection. You can download the sample code <a target="_blank" href="http://www.alvinashcraft.com/code/IdentityListExample.zip">here</a>. As always, any and all feedback is welcome!</p>
<p>&nbsp;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:C16BAC14-9A3D-4c50-9394-FBFEF7A93539:c6dd5048-588f-436d-b6e0-946b0bdaa220" class="wlWriterEditableSmartContent"><a href="http://www.dotnetkicks.com/kick/?url=http://www.alvinashcraft.com/2008/09/22/extend-a-generic-list-to-provide-dictionary-like-lookups/"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://www.alvinashcraft.com/2008/09/22/extend-a-generic-list-to-provide-dictionary-like-lookups/" border="0" alt="kick it on DotNetKicks.com" /></a></div>
<p>&nbsp;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:e2b15131-3d1b-4ff9-b6ef-6322e312684f" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/.net+development" rel="tag">.net development</a>,<a href="http://technorati.com/tags/coding+tips" rel="tag">coding tips</a>,<a href="http://technorati.com/tags/c%23" rel="tag">c#</a>,<a href="http://technorati.com/tags/generics" rel="tag">generics</a>,<a href="http://technorati.com/tags/List+collection" rel="tag">List collection</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.alvinashcraft.com/2008/09/22/extend-a-generic-list-to-provide-dictionary-like-lookups/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Roland Weigelt&#8217;s GhostDoc for Visual Studio</title>
		<link>http://www.alvinashcraft.com/2008/08/23/roland-weigelts-ghostdoc-for-visual-studio/</link>
		<comments>http://www.alvinashcraft.com/2008/08/23/roland-weigelts-ghostdoc-for-visual-studio/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 18:29:06 +0000</pubDate>
		<dc:creator>Alvin Ashcraft</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[how-to]]></category>

		<guid isPermaLink="false">http://www.alvinashcraft.com/2008/08/23/roland-weigelts-ghostdoc-for-visual-studio/</guid>
		<description><![CDATA[&#160; I have been using Roland WeigeIt’s GhostDoc 2.1.3 for both Visual Studio 2005 and 2008 for about six months, and I am hooked. For those of you who have not heard of GhostDoc, here is the summary from Roland’s site: GhostDoc is a free add-in for Visual Studio that automatically generates XML documentation comments [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>&#160;</p>
<p>I have been using <a href="http://www.roland-weigelt.de/ghostdoc/" target="_blank">Roland WeigeIt’s GhostDoc</a> 2.1.3 for both Visual Studio 2005 and 2008 for about six months, and I am hooked. For those of you who have not heard of GhostDoc, here is the summary from Roland’s site:</p>
<blockquote><p>GhostDoc is a free add-in for Visual Studio that automatically generates XML documentation comments for C#. Either by using existing documentation inherited from base classes or implemented interfaces, or by deducing comments from name and type of e.g. methods, properties or parameters.</p>
</blockquote>
</p>
</p>
<p>It saves me so much time writing XML documentation in my code that there is no longer any excuse for any docs being missing. Documenting a piece of code is as simple as right-clicking on it and selcting ‘Document This’ (there is also a keyboard shortcut – CTRL-D is the default). The built-in rules for creating the comments are probably sufficient for most developers, but more advanced users can edit existing rules or add their own.</p>
<p>I have attached a small sample project containing some domain classes representing part of a pharmacy system. Here are a few examples of the XML documentation that is generated using GhostDoc’s default configuration. Some of the code is a bit contrived so that I could demonstrate different types of comments.</p>
</p>
</p>
</p>
<h5>Documenting a Constructor</h5>
<blockquote><pre class="code"><span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Initializes a new instance of the </span><span style="color: gray">&lt;see cref=&quot;Drug&quot;/&gt; </span><span style="color: green">class.
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;id&quot;&gt;</span><span style="color: green">The id.</span><span style="color: gray">&lt;/param&gt;
</span><span style="color: blue">public </span>Drug(<span style="color: blue">int </span>id)
{
    LoadDrug(id);
}</pre>
</blockquote>
<p><a href="http://11011.net/software/vspaste"></a></p>
<h5>Documenting a Dispose Method</h5>
<blockquote>
<pre class="code"><span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
</span><span style="color: gray">/// &lt;/summary&gt;
</span><span style="color: blue">public void </span>Dispose()
{
    <span style="color: green">// TODO: clean up resources
</span>}</pre>
</blockquote>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<h5>Documenting Properties</h5>
<blockquote>
<pre class="code"><span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Gets or sets the therapeutic categories.
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;value&gt;</span><span style="color: green">The therapeutic categories.</span><span style="color: gray">&lt;/value&gt;
</span><span style="color: blue">public </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">DrugCategory</span>&gt; TherapeuticCategories { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }

<span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Gets or sets the NDC.
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;value&gt;</span><span style="color: green">The NDC.</span><span style="color: gray">&lt;/value&gt;
</span><span style="color: blue">public string </span>NDC { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }

<span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Gets or sets a value indicating whether this instance is generic.
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;value&gt;
///     &lt;c&gt;</span><span style="color: green">true</span><span style="color: gray">&lt;/c&gt; </span><span style="color: green">if this instance is generic; otherwise, </span><span style="color: gray">&lt;c&gt;</span><span style="color: green">false</span><span style="color: gray">&lt;/c&gt;</span><span style="color: green">.
</span><span style="color: gray">/// &lt;/value&gt;
</span><span style="color: blue">public bool </span>IsGeneric { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }</pre>
</blockquote>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<h5>Documenting a Method</h5>
<blockquote>
<pre class="code"><span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Loads the drug.
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;id&quot;&gt;</span><span style="color: green">The id.</span><span style="color: gray">&lt;/param&gt;
</span><span style="color: blue">private void </span>LoadDrug(<span style="color: blue">int </span>id)
{
    <span style="color: green">// do nothing... just an example
</span>}</pre>
</blockquote>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<h5>Documenting an Inherited/Implemented Method</h5>
<blockquote>
<pre class="code"><span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Creates a new object that is a copy of the current instance.
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;returns&gt;
/// </span><span style="color: green">A new object that is a copy of this instance.
</span><span style="color: gray">/// &lt;/returns&gt;
</span><span style="color: blue">public object </span>Clone()
{
    <span style="color: blue">return </span>MemberwiseClone();
}</pre>
</blockquote>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<h5>Documenting an Overridden Method</h5>
<blockquote>
<pre class="code"><span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Returns a </span><span style="color: gray">&lt;see cref=&quot;T:System.String&quot;/&gt; </span><span style="color: green">that represents the current </span><span style="color: gray">&lt;see cref=&quot;T:System.Object&quot;/&gt;</span><span style="color: green">.
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;returns&gt;
/// </span><span style="color: green">A </span><span style="color: gray">&lt;see cref=&quot;T:System.String&quot;/&gt; </span><span style="color: green">that represents the current </span><span style="color: gray">&lt;see cref=&quot;T:System.Object&quot;/&gt;</span><span style="color: green">.
</span><span style="color: gray">/// &lt;/returns&gt;
</span><span style="color: blue">public override string </span>ToString()
{
    <span style="color: blue">return </span><span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;{0} {1}&quot;</span>, Name, DoseRoute);
}</pre>
</blockquote>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<h5>Documenting an Event</h5>
</p>
</p>
</p>
</p>
<blockquote>
<pre class="code"><span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Occurs when [allergy detected].
</span><span style="color: gray">/// &lt;/summary&gt;
</span><span style="color: blue">public event </span><span style="color: #2b91af">EventHandler </span>AllergyDetected;</pre>
</blockquote>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>&#160;</p>
<p>As you can see, the default configuration of GhostDoc is pretty intelligent. Here are some shots of the rules configuration options provided by default:</p>
<p>&#160;</p>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/ghostdocconfig1.png"><img title="GhostDoc Rules Config" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="484" alt="GhostDoc Rules Config" src="http://www.alvinashcraft.com/wp-content/uploads/ghostdocconfig1-thumb.png" width="598" border="0" /></a> </p>
<p>&#160;</p>
<p><a href="http://www.alvinashcraft.com/wp-content/uploads/ghostdocconfig1a.png"><img title="GhostDoc Rules Config 2" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="484" alt="GhostDoc Rules Config 2" src="http://www.alvinashcraft.com/wp-content/uploads/ghostdocconfig1a-thumb.png" width="598" border="0" /></a> </p>
<p><em>(I added the shading in the second shot to mask options that were visible in the previous one.)</em></p>
<p>&#160;</p>
<p>Users have the ability to change any of these existing rules or add their own. This post is just a brief overview of the product, so I won’t go into details on how to configure a rule at this time. Let me know if you would be interested in more posts that dive into more details on the configuration of GhostDoc.</p>
<p>If you don’t already use it, I encourage you to download it and give it a try. The learning curve is not steep and the benefits are great. Plus, it’s free! One more quick note, VB support is experimental at this time, and it is turned off by default. To enable it, go to the Options tab on the config screen.</p>
</p>
</p>
</p>
<p>GhostDoc download links are <a href="http://www.roland-weigelt.de/ghostdoc/" target="_blank">here</a>.</p>
<p>My sample project (VS2008) can be downloaded <a href="http://www.alvinashcraft.com/code/GhostDocSample.zip" target="_blank">here</a>.</p>
<p>&#160;</p>
<p><div class="wlWriterSmartContent" id="scid:C16BAC14-9A3D-4c50-9394-FBFEF7A93539:e62d18fd-5122-4db3-a428-a7e167c01b8a" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><a href="http://www.dotnetkicks.com/kick/?url=http://www.alvinashcraft.com/2008/08/23/roland-weigelts-ghostdoc-for-visual-studio/"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://www.alvinashcraft.com/2008/08/23/roland-weigelts-ghostdoc-for-visual-studio/" border="0" alt="kick it on DotNetKicks.com" /></a></div>
</p>
<div class="wlWriterSmartContent" id="scid:d7bf807d-7bb0-458a-811f-90c51817d5c2:1d523341-a33f-434d-9a12-8619e9fc9a8f" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<p><span class="TagSite">Technorati:</span> <a href="http://technorati.com/tag/visual+studio" rel="tag" class="tag">visual studio</a>, <a href="http://technorati.com/tag/add-ins" rel="tag" class="tag">add-ins</a>, <a href="http://technorati.com/tag/ghostdoc" rel="tag" class="tag">ghostdoc</a>, <a href="http://technorati.com/tag/xml+documentation" rel="tag" class="tag">xml documentation</a><br /><!-- StartInsertedTags: visual studio, add-ins, ghostdoc, xml documentation :EndInsertedTags --></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.alvinashcraft.com/2008/08/23/roland-weigelts-ghostdoc-for-visual-studio/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

