<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>Develop Using .net</title>
    <link>http://developusing.net/</link>
    <description />
    <language>en-us</language>
    <copyright>Dennis Burton</copyright>
    <lastBuildDate>Fri, 27 Jun 2008 18:11:03 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>dennis@developusing.net</managingEditor>
    <webMaster>dennis@developusing.net</webMaster>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/DevelopUsingdotnet" type="application/rss+xml" /><item>
      <trackback:ping>http://developusing.net/Trackback.aspx?guid=03efcbe3-9d1d-41b5-8055-78f19a3f1cd0</trackback:ping>
      <pingback:server>http://developusing.net/pingback.aspx</pingback:server>
      <pingback:target>http://developusing.net/PermaLink,guid,03efcbe3-9d1d-41b5-8055-78f19a3f1cd0.aspx</pingback:target>
      <dc:creator>Dennis Burton</dc:creator>
      <wfw:comment>http://developusing.net/CommentView,guid,03efcbe3-9d1d-41b5-8055-78f19a3f1cd0.aspx</wfw:comment>
      <wfw:commentRss>http://developusing.net/SyndicationService.asmx/GetEntryCommentsRss?guid=03efcbe3-9d1d-41b5-8055-78f19a3f1cd0</wfw:commentRss>
      
      <title>Viewing large database columns with PowerShell</title>
      <guid isPermaLink="false">http://developusing.net/PermaLink,guid,03efcbe3-9d1d-41b5-8055-78f19a3f1cd0.aspx</guid>
      <link>http://feeds.feedburner.com/~r/DevelopUsingdotnet/~3/321362383/ViewingLargeDatabaseColumnsWithPowerShell.aspx</link>
      <pubDate>Fri, 27 Jun 2008 18:11:03 GMT</pubDate>
      <description>&lt;p&gt;&#xD;
What do you do when the limitations of SQL Management Studio will not show all of&#xD;
your results?&lt;br id="chg4"&gt;&lt;br id="chg40"&gt;&#xD;
Our application works with an XML file defined by an external industry specification.&#xD;
We found that a significant portion of this file is not required by our application.&#xD;
So, when loading this file into our system, we remove the portions that we do not&#xD;
care about and stuff the rest into a database. What is left can still be a pretty&#xD;
good sized XML string. Common usage shows the reduced size to still be around 300-500&#xD;
KB. &#xD;
&lt;br id="chg41"&gt;&lt;br id="chg42"&gt;&#xD;
Recently, we needed to investigate the contents of one of these modified files as&#xD;
well as the history of what was loaded. Using the standard developer playbook, the&#xD;
first response is to quickly fire up SQL Management Studio and craft a query&#xD;
to get the ntext column. At that point, the 65K limit on a column in Management Studio&#xD;
yields about a quarter of the file. &#xD;
&lt;br id="chg43"&gt;&lt;br id="chg44"&gt;&#xD;
It would be pretty easy to pull up Visual Studio and put together a quick utility&#xD;
to extract the XML into a file. As a developer, I would likely keep this project around&#xD;
for an excessively long period of time. After all, it is now part of my code toolbox.&#xD;
So, rather than squirrel away a project file, source file, and all the related baggage&#xD;
of a VS project, I chose PowerShell as the hammer for this nail. The C# code that&#xD;
would have been created in Visual Studio, in this case, is simply a language that&#xD;
is accessing the functionality in the .net framework. Since PowerShell has access&#xD;
to the .net framework, it is very similar code simply using a different language. Additionally,&#xD;
the PowerShell script is a single file without the weight of a VS project. The only&#xD;
thing that I keep in my toolbox is the code required to complete the task.&lt;br id="chg45"&gt;&lt;br id="chg46"&gt;&#xD;
What is required is the pretty common code of opening a connection, executing&#xD;
a query, and using the results. This is how this common C# task is represented in&#xD;
PowerShell. We are pulling back several rows that contain this large XML field and&#xD;
tagging the resuts by upload date.&#xD;
&lt;/p&gt;&#xD;
        &lt;pre&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;param(&#xD;
$theId, $server,$db ) $connection &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; New-Object&#xD;
System.Data.SqlClient.SqlConnection(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"data&#xD;
source=$server;initial catalog=$db;Integrated Security=SSPI"&lt;/span&gt;) $command &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; New-Object&#xD;
System.Data.SqlClient.SqlCommand(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"select&#xD;
* from MyTable where theItemId=$theId"&lt;/span&gt;, $connection) $connection.Open() $reader &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; $command.ExecuteReader() &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;while&lt;/span&gt;(&#xD;
$reader.Read() ) { $fileName &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Item_{0}_DateLoaded_{1:yyyy_MM_dd_HH_mm_ss}.xml"&lt;/span&gt; -f&#xD;
$theId,$reader['dStart'] Out-File -FilePath $fileName -InputObject $reader['reallyBigXMLText']&#xD;
} $connection.Close() $reader.Close() &lt;/span&gt;&#xD;
        &lt;/pre&gt;&#xD;
        &lt;p&gt;&#xD;
Save that text into a .ps1 file and that is all that is necessary to extract the large&#xD;
text field. I am not one that has cut over from the classic command line to PowerShell.&#xD;
At the same time, it is important to know when this tool can be helpful. &#xD;
&lt;/p&gt;&#xD;
        &lt;img width="0" height="0" src="http://developusing.net/aggbug.ashx?id=03efcbe3-9d1d-41b5-8055-78f19a3f1cd0"&gt;&lt;/img&gt;&#xD;
      &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DevelopUsingdotnet?a=HzwHNI"&gt;&lt;img src="http://feeds.feedburner.com/~f/DevelopUsingdotnet?i=HzwHNI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DevelopUsingdotnet/~4/321362383" height="1" width="1"/&gt;</description>
      <comments>http://developusing.net/CommentView,guid,03efcbe3-9d1d-41b5-8055-78f19a3f1cd0.aspx</comments>
      <category>powershell</category>
      <category>programming</category>
    <feedburner:origLink>http://developusing.net/2008/06/27/ViewingLargeDatabaseColumnsWithPowerShell.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://developusing.net/Trackback.aspx?guid=aa6c29ac-e47c-428a-b0a1-92b960e3695b</trackback:ping>
      <pingback:server>http://developusing.net/pingback.aspx</pingback:server>
      <pingback:target>http://developusing.net/PermaLink,guid,aa6c29ac-e47c-428a-b0a1-92b960e3695b.aspx</pingback:target>
      <dc:creator>Dennis Burton</dc:creator>
      <wfw:comment>http://developusing.net/CommentView,guid,aa6c29ac-e47c-428a-b0a1-92b960e3695b.aspx</wfw:comment>
      <wfw:commentRss>http://developusing.net/SyndicationService.asmx/GetEntryCommentsRss?guid=aa6c29ac-e47c-428a-b0a1-92b960e3695b</wfw:commentRss>
      <slash:comments>1</slash:comments>
      
      <title>An introduction to Spec# - Part 2</title>
      <guid isPermaLink="false">http://developusing.net/PermaLink,guid,aa6c29ac-e47c-428a-b0a1-92b960e3695b.aspx</guid>
      <link>http://feeds.feedburner.com/~r/DevelopUsingdotnet/~3/318365915/AnIntroductionToSpecPart2.aspx</link>
      <pubDate>Mon, 23 Jun 2008 20:26:17 GMT</pubDate>
      <description>&lt;p&gt;&#xD;
The next topic in this series was supposed to be invariants. While that topic will&#xD;
still be coming up, the topic of nulls was not complete enough. In the &lt;a href="http://developusing.net/2008/06/21/AnIntroductionToSpecPart1.aspx"&gt;last&#xD;
post&lt;/a&gt;, coverage was mostly related to parameters and method signatures. Since parameters&#xD;
are not the only variables in a system that can be null, it makes sense to talk a&#xD;
little about class fields. Consider the following class member from the Sentence class&#xD;
discussed in &lt;a href="http://developusing.net/2008/06/21/AnIntroductionToSpecPart1.aspx"&gt;Part&#xD;
1&lt;/a&gt;.&#xD;
&lt;/p&gt;&#xD;
        &lt;pre&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;List&amp;lt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;&amp;gt;&#xD;
words &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;&amp;gt;(); &lt;/span&gt;&#xD;
        &lt;/pre&gt;&#xD;
        &lt;p&gt;&#xD;
Several methods and properties in the sentence class perform operations on this variable&#xD;
by dereferencing it and calling its methods and properties. &lt;a href="http://research.microsoft.com/specsharp/"&gt;Spec#&lt;/a&gt; notices&#xD;
this and warns of a potential null dereference. At first this seemed like a bit of&#xD;
an inconvenience. But if you think about this a second, this warning is for every&#xD;
location where "object reference not set to instance of an object" can occur. Wow,&#xD;
removing that error from the development cycle would no doubt be a huge boost to productivity.&#xD;
So a simple change to the signature eliminates that warning.&#xD;
&lt;/p&gt;&#xD;
        &lt;pre&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;List&amp;lt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;&amp;gt;!&#xD;
words &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;&amp;gt;(); &lt;/span&gt;&#xD;
        &lt;/pre&gt;&#xD;
        &lt;p&gt;&#xD;
So what if you are not instantiating objects the same way for each class creation.&#xD;
Try removing the new from the declaration, and a whole different error shows up. This&#xD;
time the constructors all get flagged. Spec# notices that the fields that have been&#xD;
marked as non-null have not been assigned in the constructor. New up a sentence object&#xD;
in the constructor on the validation engine is now happy.&#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
There is an impressive depth to the null checks that can lead to a much more solid&#xD;
code base. In the strong typed world where compiler errors are preferred, Spec# strengthens&#xD;
the type checking pushing potential errors earlier in the development cycle to&#xD;
the point of some of them showing up in the editor pre-compile time!&#xD;
&lt;/p&gt;&#xD;
        &lt;img width="0" height="0" src="http://developusing.net/aggbug.ashx?id=aa6c29ac-e47c-428a-b0a1-92b960e3695b"&gt;&lt;/img&gt;&#xD;
      &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DevelopUsingdotnet?a=4b0qHI"&gt;&lt;img src="http://feeds.feedburner.com/~f/DevelopUsingdotnet?i=4b0qHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DevelopUsingdotnet/~4/318365915" height="1" width="1"/&gt;</description>
      <comments>http://developusing.net/CommentView,guid,aa6c29ac-e47c-428a-b0a1-92b960e3695b.aspx</comments>
      <category>programming</category>
      <category>spec#</category>
      <category>SpecSharp</category>
    <feedburner:origLink>http://developusing.net/2008/06/23/AnIntroductionToSpecPart2.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://developusing.net/Trackback.aspx?guid=cf057824-235b-4253-90a7-3aa37a2cc9cd</trackback:ping>
      <pingback:server>http://developusing.net/pingback.aspx</pingback:server>
      <pingback:target>http://developusing.net/PermaLink,guid,cf057824-235b-4253-90a7-3aa37a2cc9cd.aspx</pingback:target>
      <dc:creator>Dennis Burton</dc:creator>
      <wfw:comment>http://developusing.net/CommentView,guid,cf057824-235b-4253-90a7-3aa37a2cc9cd.aspx</wfw:comment>
      <wfw:commentRss>http://developusing.net/SyndicationService.asmx/GetEntryCommentsRss?guid=cf057824-235b-4253-90a7-3aa37a2cc9cd</wfw:commentRss>
      
      <title>An introduction to Spec# - Part 1</title>
      <guid isPermaLink="false">http://developusing.net/PermaLink,guid,cf057824-235b-4253-90a7-3aa37a2cc9cd.aspx</guid>
      <link>http://feeds.feedburner.com/~r/DevelopUsingdotnet/~3/316677043/AnIntroductionToSpecPart1.aspx</link>
      <pubDate>Sat, 21 Jun 2008 03:39:57 GMT</pubDate>
      <description>&lt;p&gt;&#xD;
One of the key characteristics that makes a professional-quality application is defensive&#xD;
coding. While necessary, this can hide the meaningful portions of logic. It can also&#xD;
lead to many tests that are more related to the chosen implementation than the business&#xD;
rules. Take this simple piece of code to add a word to a sentence. &#xD;
&lt;/p&gt;&#xD;
        &lt;pre&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; AddWord(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; word)&#xD;
{ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (word&#xD;
== &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;null&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;throw&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; ArgumentNullException(&lt;span style="FONT-SIZE: 11px; COLOR: rgb(102,102,102); FONT-FAMILY: Courier New; BACKGROUND-COLOR: rgb(228,228,228)"&gt;"word"&lt;/span&gt;); &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (word.Length&#xD;
== 0) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;throw&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; ArgumentException(&lt;span style="FONT-SIZE: 11px; COLOR: rgb(102,102,102); FONT-FAMILY: Courier New; BACKGROUND-COLOR: rgb(228,228,228)"&gt;"word"&lt;/span&gt;);&#xD;
words.Add(word); } &lt;/span&gt;&#xD;
        &lt;/pre&gt;&#xD;
        &lt;p&gt;&#xD;
The validation code dominates this simple function. Additionally it does not provide&#xD;
the consumer of the method with any hints to the parameters constraints. Sure, xml&#xD;
docs can provide some documentation, but that still does not help at design time.&#xD;
A set of tests that check the expected exception would also be common for this block&#xD;
of code. There is plenty to debate about the non-functional tests, but it is safe&#xD;
to assume that this kind of testing is common.&#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
The &lt;a href="http://research.microsoft.com/specsharp/"&gt;Spec#&lt;/a&gt; team is doing some&#xD;
incredible work to make constraints like this either enforced by the language or more&#xD;
visible by placing them within the method signature. &#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
The first parameter check relates to nullness. Spec# provides an operator for forcing&#xD;
non-null. The signature of AddWord would now look like:&#xD;
&lt;/p&gt;&#xD;
        &lt;pre&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; AddWord(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;!&#xD;
word)&lt;/span&gt;&#xD;
        &lt;/pre&gt;&#xD;
        &lt;p&gt;&#xD;
This tells the compiler and Visual Studio that this parameter cannot be null. If you&#xD;
even try to pass a string that can be null to this method, a warning will appear at design&#xD;
time. A compiler error will also result. This really cranks up the visibility of the&#xD;
constraint. The user of this method can also see the constraint right in the signature.&#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
The second parameter check relates to some data constraint on the string. In this&#xD;
case, it is required to be a non-empty string. What is really going on here is that&#xD;
this method has a pre-condition relating to the data it is going to work with. Preconditions&#xD;
in Spec# are specified with the requires keyword. So our method now looks like:&#xD;
&lt;/p&gt;&#xD;
        &lt;pre&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; AddWord(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;!&#xD;
word) &lt;font color="#0000ff"&gt;requires&lt;/font&gt; word.Length &amp;gt; 0; { words.Add(word);&#xD;
} &lt;/span&gt;&#xD;
        &lt;/pre&gt;&#xD;
        &lt;p&gt;&#xD;
Now the requirements are part of the method signature that show up in intellisense.&#xD;
This alone is a big help to the development process. The precondition is validated&#xD;
at runtime kicking out an exception if the condition is not met. It is worth noting&#xD;
that you can map the stock RequiresException back to an argument exception via the&#xD;
otherwise keyword.&#xD;
&lt;/p&gt;&#xD;
        &lt;pre&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&#xD;
            &lt;font color="#0000ff"&gt;requires&lt;/font&gt; word.Length&#xD;
&amp;gt; 0 &lt;font color="#0000ff"&gt;otherwise&lt;/font&gt; ArgumentException; &lt;/span&gt;&#xD;
        &lt;/pre&gt;&#xD;
        &lt;p&gt;&#xD;
It is pretty evident to see the big gain here in the signature of the method containing&#xD;
all of the relevant constraints. Even more assistance can be provided at design&#xD;
and compile time when these constraints are provided in the signature. Even better&#xD;
than all of this is that the body of the method is left with only the required logic&#xD;
the method is responsible for. &#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
There is plenty more to cover with the direction spec# is taking. Next up, validating&#xD;
the internal state of an object as part of the class definition.&lt;br&gt;&lt;/p&gt;&#xD;
        &lt;img width="0" height="0" src="http://developusing.net/aggbug.ashx?id=cf057824-235b-4253-90a7-3aa37a2cc9cd"&gt;&lt;/img&gt;&#xD;
      &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DevelopUsingdotnet?a=8VKGcI"&gt;&lt;img src="http://feeds.feedburner.com/~f/DevelopUsingdotnet?i=8VKGcI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DevelopUsingdotnet/~4/316677043" height="1" width="1"/&gt;</description>
      <comments>http://developusing.net/CommentView,guid,cf057824-235b-4253-90a7-3aa37a2cc9cd.aspx</comments>
      <category>programming</category>
      <category>spec#</category>
      <category>SpecSharp</category>
    <feedburner:origLink>http://developusing.net/2008/06/21/AnIntroductionToSpecPart1.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://developusing.net/Trackback.aspx?guid=ebe121f5-82db-4747-a604-543c2431aafd</trackback:ping>
      <pingback:server>http://developusing.net/pingback.aspx</pingback:server>
      <pingback:target>http://developusing.net/PermaLink,guid,ebe121f5-82db-4747-a604-543c2431aafd.aspx</pingback:target>
      <dc:creator>Dennis Burton</dc:creator>
      <wfw:comment>http://developusing.net/CommentView,guid,ebe121f5-82db-4747-a604-543c2431aafd.aspx</wfw:comment>
      <wfw:commentRss>http://developusing.net/SyndicationService.asmx/GetEntryCommentsRss?guid=ebe121f5-82db-4747-a604-543c2431aafd</wfw:commentRss>
      
      <title>Speaking on PowerShell</title>
      <guid isPermaLink="false">http://developusing.net/PermaLink,guid,ebe121f5-82db-4747-a604-543c2431aafd.aspx</guid>
      <link>http://feeds.feedburner.com/~r/DevelopUsingdotnet/~3/259364216/SpeakingOnPowerShell.aspx</link>
      <pubDate>Fri, 28 Mar 2008 02:13:51 GMT</pubDate>
      <description>&lt;p&gt;&#xD;
At this months &lt;a href="http://glugnet.org/"&gt;GLUGnet&lt;/a&gt; Flint meeting, I will be&#xD;
giving a presentation on PowerShell. What drove me to put this presentation together&#xD;
is all of the recent conversations I have had about PowerShell. It seems to be one&#xD;
of those topics that developers intend to look at but never really get to. This presentation&#xD;
starts from the ground up to several real world examples that have come up in my work&#xD;
environment. I sincerely hope that after this meeting those that have not used PowerShell&#xD;
yet will walk away with another tool in their arsenal.&lt;br&gt;&lt;br&gt;&#xD;
Hope to see you there.&lt;br&gt;&lt;br&gt;&#xD;
UPDATE: Adding files and ppt&#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
          &lt;a href="http://developusing.net/content/binary/glugnet.zip"&gt;glugnet.zip (89.02 KB)&lt;/a&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;img width="0" height="0" src="http://developusing.net/aggbug.ashx?id=ebe121f5-82db-4747-a604-543c2431aafd"&gt;&lt;/img&gt;&#xD;
      &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DevelopUsingdotnet?a=XjexRFF"&gt;&lt;img src="http://feeds.feedburner.com/~f/DevelopUsingdotnet?i=XjexRFF" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DevelopUsingdotnet/~4/259364216" height="1" width="1"/&gt;</description>
      <comments>http://developusing.net/CommentView,guid,ebe121f5-82db-4747-a604-543c2431aafd.aspx</comments>
      <category>community</category>
      <category>powershell</category>
    <feedburner:origLink>http://developusing.net/2008/03/28/SpeakingOnPowerShell.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://developusing.net/Trackback.aspx?guid=ca3dd3d8-0649-48d4-8de4-24f3e6974660</trackback:ping>
      <pingback:server>http://developusing.net/pingback.aspx</pingback:server>
      <pingback:target>http://developusing.net/PermaLink,guid,ca3dd3d8-0649-48d4-8de4-24f3e6974660.aspx</pingback:target>
      <dc:creator>Dennis Burton</dc:creator>
      <wfw:comment>http://developusing.net/CommentView,guid,ca3dd3d8-0649-48d4-8de4-24f3e6974660.aspx</wfw:comment>
      <wfw:commentRss>http://developusing.net/SyndicationService.asmx/GetEntryCommentsRss?guid=ca3dd3d8-0649-48d4-8de4-24f3e6974660</wfw:commentRss>
      
      <title>CodeRush templates for Rhino Mocks</title>
      <guid isPermaLink="false">http://developusing.net/PermaLink,guid,ca3dd3d8-0649-48d4-8de4-24f3e6974660.aspx</guid>
      <link>http://feeds.feedburner.com/~r/DevelopUsingdotnet/~3/235875149/CodeRushTemplatesForRhinoMocks.aspx</link>
      <pubDate>Thu, 14 Feb 2008 04:44:18 GMT</pubDate>
      <description>&lt;p&gt;&#xD;
One of the things I really enjoy about the local developer groups is the sharing of&#xD;
ideas and usage patterns of common tools. At tonight's &lt;a href="http://www.aadnd.org/"&gt;Ann&#xD;
Arbor .net Developers Group&lt;/a&gt;, the topic of &lt;a href="http://www.devexpress.com/Products/NET/IDETools/CodeRush/"&gt;CodeRush&lt;/a&gt; templates&#xD;
came up. I commonly use a set of templates centered around the &lt;a href="http://www.ayende.com/projects/rhino-mocks.aspx"&gt;Rhino&#xD;
Mocks&lt;/a&gt; framework As I was describing these templates &lt;a href="http://jrwren.wrenfam.com/blog/"&gt;Jay&#xD;
Wren&lt;/a&gt; claimed they should be posted. The irony in that is the first time I saw&#xD;
someone using CodeRush was in a presentation Jay was giving on &lt;a href="http://en.wikipedia.org/wiki/Inversion_of_control"&gt;IoC&lt;/a&gt;.&#xD;
As a result of that presentation, we are using &lt;a href="http://www.castleproject.org/container/index.html"&gt;Castle&#xD;
Windsor&lt;/a&gt; in our application and CodeRush as a productivity tool. &#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
          &lt;strong&gt;Creating a Mock Instance&lt;/strong&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
To use Rhino Mock to create a mock instance, you write something like: &#xD;
&lt;/p&gt;&#xD;
        &lt;div style="BACKGROUND-COLOR: rgb(221,221,221)"&gt;MyType myType = (MyType)mocks.DynamicMock(typeof(MyType));&#xD;
&lt;/div&gt;&#xD;
        &lt;p&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
This is an exceptionally redundant exercise that just screams for a Template. The&#xD;
core part of the template takes a string from the Get string provider (named Type)&#xD;
for the type of the instance to create. It will also name the variable with the&#xD;
same name as the type with a slightly different format. Even though this variable&#xD;
name is a linked field, you can break the link by pressing Ctrl-Enter while the cursor&#xD;
is on the variable name. This is commonly required in when creating multiple mock&#xD;
instances in the same scope.&#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
#MockInstance#: Base template not intended to be called directly &#xD;
&lt;br&gt;&lt;/p&gt;&#xD;
        &lt;div style="BACKGROUND-COLOR: rgb(221,221,221)"&gt;«Caret»«Link(«?Get(Type)»)»«BlockAnchor»«Link(«?Get(Type)»,FormatLocalName,PropertyNameFromLocal)»=&#xD;
(«Link(«?Get(Type)»)»)mocks.DynamicMock(typeof(«Link(«?Get(Type)»)»));&#xD;
&lt;/div&gt;&#xD;
        &lt;p&gt;&#xD;
mk: the type name is initialized to MyType &#xD;
&lt;/p&gt;&#xD;
        &lt;div style="BACKGROUND-COLOR: rgb(221,221,221)"&gt;«?Set(Type,MyType)»«:#MockInstance#»&#xD;
&lt;/div&gt;&#xD;
        &lt;p&gt;&#xD;
mk\: the type name is initialized from the Clipboard &#xD;
&lt;/p&gt;&#xD;
        &lt;div style="BACKGROUND-COLOR: rgb(221,221,221)"&gt;«?Set(Type,«?Paste»)»«:#MockInstance#»&#xD;
&lt;/div&gt;&#xD;
        &lt;p&gt;&#xD;
          &lt;strong&gt;Setting up the Tests&lt;/strong&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
The mock instance templates are not much use without having the MockRepository set&#xD;
up and test methods to call. These templates come in handy as well.&#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
mtf: the test fixture&#xD;
&lt;/p&gt;&#xD;
        &lt;div style="BACKGROUND-COLOR: rgb(221,221,221)"&gt;[TestFixture]&lt;br&gt;&#xD;
public class «Caret»My«BlockAnchor»Test&lt;br&gt;&#xD;
{&lt;br&gt;&#xD;
 private MockRepository mocks; &#xD;
&lt;p&gt;&#xD;
 [SetUp]&lt;br&gt;&#xD;
 public void Setup()&lt;br&gt;&#xD;
 {&lt;br&gt;&#xD;
  mocks = new MockRepository();&lt;br&gt;&#xD;
 }&lt;br&gt;&#xD;
 &lt;br&gt;&#xD;
 «Marker»&lt;br&gt;&#xD;
}&#xD;
&lt;/p&gt;&lt;/div&gt;&#xD;
        &lt;p&gt;&#xD;
          &lt;br&gt;&#xD;
mt: the test&#xD;
&lt;/p&gt;&#xD;
        &lt;div style="BACKGROUND-COLOR: rgb(221,221,221)"&gt;[Test]&lt;br&gt;&#xD;
public void «Caret»Test«BlockAnchor»()&lt;br&gt;&#xD;
{&lt;br&gt;&#xD;
 «Marker»&lt;br&gt;&#xD;
 mocks.ReplayAll();&lt;br&gt;&#xD;
}&#xD;
&lt;/div&gt;&#xD;
        &lt;p&gt;&#xD;
Hopefully these templates will be found useful and maybe even kick off some ideas&#xD;
for new ones.&#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
UPDATE: Yea, it would be easier if I added the export file.&lt;br&gt;&lt;/p&gt;&#xD;
        &lt;a href="http://developusing.net/content/binary/CSharp_Custom.xml"&gt;CSharp_Custom.xml&#xD;
(12.45 KB)&lt;/a&gt;&#xD;
        &lt;img width="0" height="0" src="http://developusing.net/aggbug.ashx?id=ca3dd3d8-0649-48d4-8de4-24f3e6974660"&gt;&lt;/img&gt;&#xD;
      &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DevelopUsingdotnet?a=97vLbKE"&gt;&lt;img src="http://feeds.feedburner.com/~f/DevelopUsingdotnet?i=97vLbKE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DevelopUsingdotnet/~4/235875149" height="1" width="1"/&gt;</description>
      <comments>http://developusing.net/CommentView,guid,ca3dd3d8-0649-48d4-8de4-24f3e6974660.aspx</comments>
      <category>CodeRush</category>
      <category>community</category>
      <category>programming</category>
      <category>tdd</category>
    <feedburner:origLink>http://developusing.net/2008/02/14/CodeRushTemplatesForRhinoMocks.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://developusing.net/Trackback.aspx?guid=1c3a7537-8677-4851-90d2-b5e0ca22f7a1</trackback:ping>
      <pingback:server>http://developusing.net/pingback.aspx</pingback:server>
      <pingback:target>http://developusing.net/PermaLink,guid,1c3a7537-8677-4851-90d2-b5e0ca22f7a1.aspx</pingback:target>
      <dc:creator>Dennis Burton</dc:creator>
      <wfw:comment>http://developusing.net/CommentView,guid,1c3a7537-8677-4851-90d2-b5e0ca22f7a1.aspx</wfw:comment>
      <wfw:commentRss>http://developusing.net/SyndicationService.asmx/GetEntryCommentsRss?guid=1c3a7537-8677-4851-90d2-b5e0ca22f7a1</wfw:commentRss>
      
      <title>PowerShell's Perfect Storm</title>
      <guid isPermaLink="false">http://developusing.net/PermaLink,guid,1c3a7537-8677-4851-90d2-b5e0ca22f7a1.aspx</guid>
      <link>http://feeds.feedburner.com/~r/DevelopUsingdotnet/~3/235875150/PowerShellsPerfectStorm.aspx</link>
      <pubDate>Tue, 12 Feb 2008 13:29:01 GMT</pubDate>
      <description>&lt;p&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p style="margin-bottom: 0in;"&gt;&#xD;
          &lt;a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx"&gt;PowerShell&lt;/a&gt; has&#xD;
been a topic of interest for me for the last couple of weeks. I have been squeezing&#xD;
in some reading on it here and there for about a little over a week. Out of the blue&#xD;
pops up one of those issues at work that does not involve making an elegant object&#xD;
model, but rather digging through log files. How cool is that? For more years than&#xD;
I care to mention, it seems like every time I start looking into a new topic, something&#xD;
comes up where that research saves a ton of time. So there I am whipping up this script,&#xD;
when SharpReader pops up toast that says &lt;a href="http://www.hanselman.com/blog/UsingAnIDEToWritePowerShellScripts.aspx"&gt;Using&#xD;
an IDE to write PowerShell Scripts&lt;/a&gt;. If you are doing any PowerShell work at all,&#xD;
go ahead, stop reading this post and go get that tool. The post will be here when&#xD;
you get back. The &lt;a href="http://www.powershell.com/"&gt;PowerShell Suite&lt;/a&gt; has been&#xD;
discounted for 2 weeks associated with Hanselman's post and there is a free version&#xD;
for non-commercial use. &#xD;
&lt;/p&gt;&#xD;
        &lt;p style="margin-bottom: 0in;"&gt;&#xD;
The issue was that users in Germany were getting access denied during a particular&#xD;
time frame. Since this time frame overlapped with with the nightly import of user&#xD;
information, there was some speculation that there was a collision with the import.&#xD;
We wanted to get a list of users that got the access denied and correlate that with&#xD;
the users that were imported. That leaves us with 500MB for 2 hours on each server.&#xD;
8 web servers and a 4 hour period in question yields 16GB worth of log files to mine.&#xD;
Definitely an automation task.&#xD;
&lt;/p&gt;&#xD;
        &lt;p style="margin-bottom: 0in;"&gt;&#xD;
The log file looks like:&#xD;
&lt;/p&gt;&#xD;
        &lt;p style="margin-bottom: 0in; background-color: rgb(221, 221, 221);"&gt;&#xD;
          &lt;font color="#000000" face="Courier New" size="1"&gt;... cut&lt;br&gt;&#xD;
[8364/18416][Tue Feb 07 04:30:27 2008][..\..\..\CSmHttpPlugin.cpp:402][INFO:1] PLUGIN:&#xD;
ProcessResource - Resolved Url '/security/accessdenied.aspx?ReturnUrl=index.aspx'.&lt;br&gt;&#xD;
[8364/18416][Tue Feb 07 04:30:27 2008][..\..\..\CSmHttpPlugin.cpp:515][INFO:1] PLUGIN:&#xD;
ProcessResource - Resolved Method 'GET'.&lt;br&gt;&#xD;
[8364/18416][Tue Feb 07 04:30:27 2008][..\..\..\CSmHttpPlugin.cpp:566][INFO:2] PLUGIN:&#xD;
ProcessResource - Resolved cookie domain '.SITENAMEWASHERE.com'.&lt;br&gt;&#xD;
[8364/18416][Tue Feb 07 04:30:27 2008][..\..\..\CSmHttpPlugin.cpp:3727][INFO:1] PLUGIN:&#xD;
EstablishSession - Decoded SMSESSION cookie -  - User = 'uid=USERIDHERE,dcxdealercode=DEALERCODEWASHERE,ou=dealerships,ou=dealers,o=DOMAINWASHERE.com',&#xD;
IP address = 'IPADDRESSWASHERE'.&lt;br&gt;&#xD;
... cut&lt;/font&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p style="margin-bottom: 0in;"&gt;&#xD;
What we needed was the occurrence of access denied where the source was the home page.&#xD;
A few lines later in the log, the SiteMinder user information was present. The script&#xD;
then needs two modes: looking for access denied and looking for the user info. Get-Content&#xD;
provides reader like functionality kicking out a line of text at a time from the provided&#xD;
file. Piping to a ForEach calls the associated script block for each line of text&#xD;
in the file. Use some Regex magic to find the correct string and extract information&#xD;
from the user information line. The result of the Regex is where I ran into the biggest&#xD;
hang up. PowerShell has an automatic variable $matches that is populated when a match&#xD;
is found (when a match is &lt;em&gt;found&lt;/em&gt; not when a match is &lt;em&gt;attempted&lt;/em&gt;).&#xD;
So I had to clear out the $matches variable after processing a match. The only output&#xD;
was the parsed user information that could be passed off to Brian, who deals with&#xD;
the imports. It is a pretty simple piece of script that looks like:&#xD;
&lt;/p&gt;&#xD;
        &lt;pre style="background-color: rgb(221, 221, 221);"&gt;&#xD;
          &lt;span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;"&gt;param&#xD;
( $infile ) $lookingForSiteMinderCookie &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; $FALSE&#xD;
$matches &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; $&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;null&lt;/span&gt; $Get-Content&#xD;
$infile &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;|&lt;/span&gt; ForEach-Object&#xD;
{   &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt;(&#xD;
$lookingForSiteMinderCookie )   {     &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt; (&#xD;
$_ -match '^.*\[.*\](\[.*\])\[.*\]\[.*\].*uid=([a-zA-Z0-9]&lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;*&lt;/span&gt;).*dcxdealercode=([0-9]&lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;*&lt;/span&gt;).*$'&#xD;
)     {       &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"TimeStamp:&#xD;
{0}`tUser: {1}`tDealer: {2}"&lt;/span&gt; -f $matches[1],$matches[2],$matches[3]       $matches &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; $&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;null&lt;/span&gt;       $lookingForSiteMinderCookie &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; $FALSE&#xD;
    }   }   &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;else&lt;/span&gt;   {&#xD;
    &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt; (&#xD;
$_ -match '^.*accessdenied\.aspx\?ReturnUrl=\%2fhome\%2fmain\.aspx.*$' )     {&#xD;
      $matches &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; $&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;null&lt;/span&gt;       $lookingForSiteMinderCookie &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; $TRUE&#xD;
    }   } } &lt;/span&gt;&#xD;
        &lt;/pre&gt;&#xD;
        &lt;p style="margin-bottom: 0in;"&gt;&#xD;
 &#xD;
&lt;/p&gt;&#xD;
        &lt;p style="margin-bottom: 0in;"&gt;&#xD;
This was saved as LogParse.ps1. &#xD;
&lt;/p&gt;&#xD;
        &lt;p style="margin-bottom: 0in;"&gt;&#xD;
From the PowerShell command line: &#xD;
&lt;/p&gt;&#xD;
        &lt;ul&gt;&#xD;
          &lt;li&gt;&#xD;
            &lt;div style="margin-bottom: 0in;"&gt;Use Get-ChildItem with a filter that matches&#xD;
the log file names to get a list of log files&#xD;
&lt;/div&gt;&#xD;
          &lt;/li&gt;&#xD;
          &lt;li&gt;&#xD;
            &lt;div style="margin-bottom: 0in;"&gt;Iterate through each file using ForEach calling&#xD;
LogParse. &#xD;
&lt;/div&gt;&#xD;
          &lt;/li&gt;&#xD;
          &lt;li&gt;&#xD;
            &lt;div style="margin-bottom: 0in;"&gt;Output to Out-File to save the results&#xD;
&lt;/div&gt;&#xD;
          &lt;/li&gt;&#xD;
        &lt;/ul&gt;&#xD;
        &lt;p style="margin-bottom: 0in; background-color: rgb(221, 221, 221);"&gt;&#xD;
          &lt;font face="Courier New"&gt;Get-ChildItem logfilepattern | ForEach-Object { .\LogParse&#xD;
$_ } | Out-File deniedUsers.results&lt;/font&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p style="margin-bottom: 0in;"&gt;&#xD;
I have found PowerShell to be a very useful tool for doing some quick and dirty tasks.&#xD;
I can certainly see that with a bit more experience with it, a command line .net interpreter&#xD;
could be very handy. Check it out. You can rarely go wrong by having another tool&#xD;
in the toolbox. I do want to point out that this was primarily an exercise in using&#xD;
Powershell because I wanted to learn it better. The power of PowerShell is not going&#xD;
to come in text processing where there are many tools that have been around for a&#xD;
very long time that do that job very well. Many shells use strings when piping between&#xD;
commands. Passing a string object is not that much better. The real power comes when&#xD;
you start using objects and even more when you use objects in the pipeline. That is&#xD;
the feature unique to PowerShell.&lt;br&gt;&lt;/p&gt;&#xD;
        &lt;img width="0" height="0" src="http://developusing.net/aggbug.ashx?id=1c3a7537-8677-4851-90d2-b5e0ca22f7a1"&gt;&lt;/img&gt;&#xD;
      &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DevelopUsingdotnet?a=KIT2uKE"&gt;&lt;img src="http://feeds.feedburner.com/~f/DevelopUsingdotnet?i=KIT2uKE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DevelopUsingdotnet/~4/235875150" height="1" width="1"/&gt;</description>
      <comments>http://developusing.net/CommentView,guid,1c3a7537-8677-4851-90d2-b5e0ca22f7a1.aspx</comments>
      <category>fundamentals</category>
      <category>powershell</category>
      <category>programming</category>
    <feedburner:origLink>http://developusing.net/2008/02/12/PowerShellsPerfectStorm.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://developusing.net/Trackback.aspx?guid=115bf154-aae2-4fb5-95f6-910a30bf1c20</trackback:ping>
      <pingback:server>http://developusing.net/pingback.aspx</pingback:server>
      <pingback:target>http://developusing.net/PermaLink,guid,115bf154-aae2-4fb5-95f6-910a30bf1c20.aspx</pingback:target>
      <dc:creator>Dennis Burton</dc:creator>
      <wfw:comment>http://developusing.net/CommentView,guid,115bf154-aae2-4fb5-95f6-910a30bf1c20.aspx</wfw:comment>
      <wfw:commentRss>http://developusing.net/SyndicationService.asmx/GetEntryCommentsRss?guid=115bf154-aae2-4fb5-95f6-910a30bf1c20</wfw:commentRss>
      <slash:comments>1</slash:comments>
      
      <title>Combining Predicates with logical operators</title>
      <guid isPermaLink="false">http://developusing.net/PermaLink,guid,115bf154-aae2-4fb5-95f6-910a30bf1c20.aspx</guid>
      <link>http://feeds.feedburner.com/~r/DevelopUsingdotnet/~3/235875151/CombiningPredicatesWithLogicalOperators.aspx</link>
      <pubDate>Thu, 17 Jan 2008 15:31:02 GMT</pubDate>
      <description>&lt;p&gt;&#xD;
Predicate: Logic. that which is affirmed or denied concerning the subject of a proposition.&#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
In programming terms, a function that returns true or false taking a subject as a&#xD;
parameter. So, Predicate&amp;lt;T&amp;gt; is really just a specific signature applied to a&#xD;
delegate. A method compliant with this signature looks like:&lt;br&gt;&lt;/p&gt;&#xD;
        &lt;p style="background-color: #dddddd"&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; method(T&#xD;
item)&lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
The collection classes in System.Collections.Generic have several methods that will&#xD;
take a predicate as a parameter. I really like this separation of concerns. The responsibility&#xD;
of iterating through the collection is owned by the collection; the responsibility&#xD;
of making a decision based on data in an object is owned by the object. What seemed&#xD;
to be missing to me was the common operation of combining boolean results with logical&#xD;
operators. What I really wanted to do was to pass a set of predicate functions to&#xD;
the collection methods. Of course, the collection authors could not know how I would&#xD;
want the boolean results combined. This seemed to be the responsibility of something&#xD;
else that could contain a list of predicates, but at the same time return a predicate&#xD;
function that is the logical combination of the results. &#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
The PredicateList class is a container of Predicate&amp;lt;T&amp;gt; delegates. The methods&#xD;
that can be used as a predicate are the logical AND and OR operations. These methods&#xD;
iterate through the contained predicates and short circuit when arriving at a value&#xD;
that determines the result of the operation.&lt;br&gt;&lt;/p&gt;&#xD;
        &lt;p style="background-color: #dddddd"&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System;&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br&gt;&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;namespace&lt;/span&gt; Utilities&lt;br&gt;&#xD;
{&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; &#xD;
public&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; PredicateList&amp;lt;T&amp;gt;&#xD;
: List&amp;lt;Predicate&amp;lt;T&amp;gt;&amp;gt;&lt;br&gt;&#xD;
  {&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;   &#xD;
public&lt;/span&gt; PredicateList(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;params&lt;/span&gt; Predicate&amp;lt;T&amp;gt;[]&#xD;
predicates)&lt;br&gt;&#xD;
    {  AddRange(predicates);  }&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;   &#xD;
public&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; And(T&#xD;
item)&lt;br&gt;&#xD;
    {&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;     &#xD;
foreach&lt;/span&gt; (Predicate&amp;lt;T&amp;gt; pred &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;in&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;)&lt;br&gt;&#xD;
      {&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;       &#xD;
if&lt;/span&gt; (!pred(item)) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;false&lt;/span&gt;;&lt;br&gt;&#xD;
      }&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;     &#xD;
return&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;true&lt;/span&gt;;&lt;br&gt;&#xD;
    }&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;   &#xD;
public&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; Or(T&#xD;
item)&lt;br&gt;&#xD;
    {&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;     &#xD;
foreach&lt;/span&gt; (Predicate&amp;lt;T&amp;gt; pred &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;in&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;)&lt;br&gt;&#xD;
      {&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;       &#xD;
if&lt;/span&gt; (pred(item)) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;true&lt;/span&gt;;&lt;br&gt;&#xD;
      }&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;     &#xD;
return&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;false&lt;/span&gt;;&lt;br&gt;&#xD;
    }&lt;br&gt;&#xD;
  }&lt;br&gt;&#xD;
}&lt;br&gt;&lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
Using this class with one of the collection methods would look like:&lt;br&gt;&lt;/p&gt;&#xD;
        &lt;p style="background-color: #dddddd"&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PredicateList&amp;lt;T&amp;gt;&#xD;
filters &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; PredicateList&amp;lt;T&amp;gt;(IsThis,&#xD;
IsThat, IsTheOtherThing);&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; FindAll(filters.And);&lt;br&gt;&lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;img width="0" height="0" src="http://developusing.net/aggbug.ashx?id=115bf154-aae2-4fb5-95f6-910a30bf1c20"&gt;&lt;/img&gt;&#xD;
      &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DevelopUsingdotnet?a=sRqsqEE"&gt;&lt;img src="http://feeds.feedburner.com/~f/DevelopUsingdotnet?i=sRqsqEE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DevelopUsingdotnet/~4/235875151" height="1" width="1"/&gt;</description>
      <comments>http://developusing.net/CommentView,guid,115bf154-aae2-4fb5-95f6-910a30bf1c20.aspx</comments>
      <category>programming</category>
    <feedburner:origLink>http://developusing.net/2008/01/17/CombiningPredicatesWithLogicalOperators.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://developusing.net/Trackback.aspx?guid=1b6ab92c-4ef9-4627-a50b-eeddda0faf3c</trackback:ping>
      <pingback:server>http://developusing.net/pingback.aspx</pingback:server>
      <pingback:target>http://developusing.net/PermaLink,guid,1b6ab92c-4ef9-4627-a50b-eeddda0faf3c.aspx</pingback:target>
      <dc:creator>Dennis Burton</dc:creator>
      <wfw:comment>http://developusing.net/CommentView,guid,1b6ab92c-4ef9-4627-a50b-eeddda0faf3c.aspx</wfw:comment>
      <wfw:commentRss>http://developusing.net/SyndicationService.asmx/GetEntryCommentsRss?guid=1b6ab92c-4ef9-4627-a50b-eeddda0faf3c</wfw:commentRss>
      
      <title>Parameterized Tests</title>
      <guid isPermaLink="false">http://developusing.net/PermaLink,guid,1b6ab92c-4ef9-4627-a50b-eeddda0faf3c.aspx</guid>
      <link>http://feeds.feedburner.com/~r/DevelopUsingdotnet/~3/235875152/ParameterizedTests.aspx</link>
      <pubDate>Wed, 16 Jan 2008 12:52:11 GMT</pubDate>
      <description>&lt;p&gt;&#xD;
While working on the tests for the next post, I was reminded of how cool &lt;a href="http://www.mbunit.com/"&gt;MbUnit&lt;/a&gt; can&#xD;
be. Most tests have the signature of public void TestMethod(). In some cases, this&#xD;
causes a propagation of tests in order to accomplish running pretty much the same&#xD;
test with different data. MbUnit adds the RowTest attribute to the mix. With the RowTest&#xD;
and Row attributes you can create one parameterized test "template" and the test will&#xD;
run for each data item provided. Running the following code will execute&#xD;
3 different tests, one for each of the Row parameters provided. &#xD;
&lt;/p&gt;&#xD;
        &lt;p style="BACKGROUND-COLOR: #dddddd"&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[RowTest]&lt;br&gt;&#xD;
[Row(2,8)]&lt;br&gt;&#xD;
[Row(5,5)]&lt;br&gt;&#xD;
[Row(8,2)]&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; GreaterValueTest(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; filterValue, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; expectedCount)&lt;br&gt;&#xD;
{&lt;br&gt;&#xD;
  ClassicCollectionBase results &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; col.FilteredCollection(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; GreaterValueFilter(filterValue));&lt;br&gt;&#xD;
  Assert.AreEqual(expectedCount, results.Count);&lt;br&gt;&#xD;
}&lt;br&gt;&lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
This cool feature can help reduce the maintenance time associated with test code.&#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
          &lt;strong&gt;What about NUnit?&lt;/strong&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
With the new features of &lt;a href="http://nunit.com/index.php"&gt;NUnit 2.4&lt;/a&gt;&lt;a href="http://www.andreas-schlapsi.com/2007/08/17/rowtests-with-nunit-24/"&gt;Andreas&#xD;
Schlapsi&lt;/a&gt; has an NUnit extension that allows for RowTests. I would expect this&#xD;
exceptional feature to get rolled into the core in an upcoming release.&#xD;
&lt;/p&gt;&#xD;
        &lt;img width="0" height="0" src="http://developusing.net/aggbug.ashx?id=1b6ab92c-4ef9-4627-a50b-eeddda0faf3c"&gt;&lt;/img&gt;&#xD;
      &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DevelopUsingdotnet?a=iaeNLhE"&gt;&lt;img src="http://feeds.feedburner.com/~f/DevelopUsingdotnet?i=iaeNLhE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DevelopUsingdotnet/~4/235875152" height="1" width="1"/&gt;</description>
      <comments>http://developusing.net/CommentView,guid,1b6ab92c-4ef9-4627-a50b-eeddda0faf3c.aspx</comments>
      <category>tdd</category>
    <feedburner:origLink>http://developusing.net/2008/01/16/ParameterizedTests.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://developusing.net/Trackback.aspx?guid=da4718c9-969c-4162-8a05-d05513687c81</trackback:ping>
      <pingback:server>http://developusing.net/pingback.aspx</pingback:server>
      <pingback:target>http://developusing.net/PermaLink,guid,da4718c9-969c-4162-8a05-d05513687c81.aspx</pingback:target>
      <dc:creator>Dennis Burton</dc:creator>
      <wfw:comment>http://developusing.net/CommentView,guid,da4718c9-969c-4162-8a05-d05513687c81.aspx</wfw:comment>
      <wfw:commentRss>http://developusing.net/SyndicationService.asmx/GetEntryCommentsRss?guid=da4718c9-969c-4162-8a05-d05513687c81</wfw:commentRss>
      
      <title>Certifications for the 2008 product set</title>
      <guid isPermaLink="false">http://developusing.net/PermaLink,guid,da4718c9-969c-4162-8a05-d05513687c81.aspx</guid>
      <link>http://feeds.feedburner.com/~r/DevelopUsingdotnet/~3/235875153/CertificationsForThe2008ProductSet.aspx</link>
      <pubDate>Sun, 13 Jan 2008 19:11:18 GMT</pubDate>
      <description>&lt;p&gt;&#xD;
With the release of VS 2008 and SQL Server 2008, a set of certification updates are&#xD;
in the works. If you are one to keep your certifications up to date, you may be interested&#xD;
in the following webcasts:&#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
          &lt;span id="lblEventTitle"&gt;&#xD;
            &lt;a href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032361415&amp;amp;EventCategory=2&amp;amp;culture=en-US&amp;amp;CountryCode=US"&gt;MCP&#xD;
Live Meeting: Microsoft Certification for Developers&lt;/a&gt;&#xD;
          &lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
          &lt;span&gt;&#xD;
            &lt;span id="lblEventTitle"&gt;&#xD;
              &lt;a href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032357174&amp;amp;EventCategory=2&amp;amp;culture=en-US&amp;amp;CountryCode=US"&gt;MCP&#xD;
Live Meeting: SQL Server 2008 and Your Microsoft Certifications&lt;/a&gt;&#xD;
            &lt;/span&gt;&#xD;
          &lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
          &lt;span&gt;&#xD;
            &lt;span&gt;UPDATE: These were live wecasts on Jan 23 2008. They have not yet been&#xD;
archived for On-Demand use.&lt;/span&gt;&#xD;
          &lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;img width="0" height="0" src="http://developusing.net/aggbug.ashx?id=da4718c9-969c-4162-8a05-d05513687c81"&gt;&lt;/img&gt;&#xD;
      &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DevelopUsingdotnet?a=UM7lUxE"&gt;&lt;img src="http://feeds.feedburner.com/~f/DevelopUsingdotnet?i=UM7lUxE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DevelopUsingdotnet/~4/235875153" height="1" width="1"/&gt;</description>
      <comments>http://developusing.net/CommentView,guid,da4718c9-969c-4162-8a05-d05513687c81.aspx</comments>
      <category>certification</category>
    <feedburner:origLink>http://developusing.net/2008/01/13/CertificationsForThe2008ProductSet.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://developusing.net/Trackback.aspx?guid=e471b4b3-6236-42b5-aeb7-500274ccdb8c</trackback:ping>
      <pingback:server>http://developusing.net/pingback.aspx</pingback:server>
      <pingback:target>http://developusing.net/PermaLink,guid,e471b4b3-6236-42b5-aeb7-500274ccdb8c.aspx</pingback:target>
      <dc:creator>Dennis Burton</dc:creator>
      <wfw:comment>http://developusing.net/CommentView,guid,e471b4b3-6236-42b5-aeb7-500274ccdb8c.aspx</wfw:comment>
      <wfw:commentRss>http://developusing.net/SyndicationService.asmx/GetEntryCommentsRss?guid=e471b4b3-6236-42b5-aeb7-500274ccdb8c</wfw:commentRss>
      
      <title>All things being equal</title>
      <guid isPermaLink="false">http://developusing.net/PermaLink,guid,e471b4b3-6236-42b5-aeb7-500274ccdb8c.aspx</guid>
      <link>http://feeds.feedburner.com/~r/DevelopUsingdotnet/~3/235875154/AllThingsBeingEqual.aspx</link>
      <pubDate>Sat, 12 Jan 2008 21:19:33 GMT</pubDate>
      <description>&lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
Equality comparisons in .net behave differently by default for reference types and&#xD;
value types. Value types are considered equal when the state of the object is equal.&#xD;
Reference types are considered equal when the reference points to the same location&#xD;
in memory. Therefore two different instances of a reference type would not be considered&#xD;
equal even if the internal state is the same. A quick unit test can be used to show&#xD;
this. &#xD;
&lt;/p&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
The class we will be using for comparison:&#xD;
&lt;/p&gt;&#xD;
        &lt;p style="PADDING-LEFT: 15px; BACKGROUND-COLOR: rgb(221,221,221)"&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System;&lt;br&gt;&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;namespace&lt;/span&gt; Equality&lt;br&gt;&#xD;
{&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; &#xD;
class&lt;/span&gt; MyClass&lt;br&gt;&#xD;
  {&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;   &#xD;
public&lt;/span&gt; MyClass(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; id)&lt;br&gt;&#xD;
    { _id &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; id;&#xD;
}&lt;br&gt;&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;   &#xD;
private&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; _id;&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;   &#xD;
public&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; Id&lt;br&gt;&#xD;
    {&lt;br&gt;&#xD;
      get { &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; _id;&#xD;
}&lt;br&gt;&#xD;
      set { _id &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; value;&#xD;
}&lt;br&gt;&#xD;
    }&lt;br&gt;&#xD;
  }&lt;br&gt;&#xD;
}&lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
The test fixture and the first test:&lt;br&gt;&lt;/p&gt;&#xD;
        &lt;p style="PADDING-LEFT: 15px; BACKGROUND-COLOR: rgb(221,221,221)"&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System;&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; MbUnit.Framework;&lt;br&gt;&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;namespace&lt;/span&gt; Equality.Test&lt;br&gt;&#xD;
{&lt;br&gt;&#xD;
  [TestFixture]&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; &#xD;
class&lt;/span&gt; EqualityTest&lt;br&gt;&#xD;
  {&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;   &#xD;
const&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; equalId &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 10;&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;   &#xD;
const&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; notEqualId &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 12;&lt;br&gt;&lt;br&gt;&#xD;
    MyClass testClass &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; MyClass(equalId);&lt;br&gt;&#xD;
    MyClass equalClass &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; MyClass(equalId);&lt;br&gt;&#xD;
    MyClass notEqualClass &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; MyClass(notEqualId);&lt;br&gt;&lt;br&gt;&#xD;
    [Test]&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;   &#xD;
public&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; EqualsMethod_Test()&lt;br&gt;&#xD;
    {&lt;br&gt;&#xD;
      Assert.IsTrue(testClass.Equals(equalClass),&lt;span style="FONT-SIZE: 11px; COLOR: rgb(102,102,102); FONT-FAMILY: Courier New; BACKGROUND-COLOR: rgb(228,228,228)"&gt;"Equal&#xD;
by identity but not by reference"&lt;/span&gt;);&lt;br&gt;&#xD;
      Assert.IsFalse(testClass.Equals(notEqualClass), &lt;span style="FONT-SIZE: 11px; COLOR: rgb(102,102,102); FONT-FAMILY: Courier New; BACKGROUND-COLOR: rgb(228,228,228)"&gt;"Not&#xD;
equal by either identity or reference"&lt;/span&gt;);&lt;br&gt;&#xD;
    }&lt;br&gt;&#xD;
  }&lt;br&gt;&#xD;
}&lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
Test Results:&#xD;
&lt;/p&gt;&#xD;
        &lt;font size="1"&gt;&#xD;
          &lt;p style="PADDING-LEFT: 15px; BACKGROUND-COLOR: rgb(221,221,221)"&gt;&#xD;
------ Test started: Assembly: Equality.exe ------&lt;br&gt;&#xD;
Starting the MbUnit Test Execution&lt;br&gt;&#xD;
Exploring Equality, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&lt;br&gt;&#xD;
MbUnit 1.0.2700.29885 Addin&lt;br&gt;&#xD;
Found 1 tests&lt;br&gt;&#xD;
[failure] EqualityTest.EqualsMethod_Test&lt;br&gt;&#xD;
TestCase 'EqualityTest.EqualsMethod_Test' failed: Equal by identity but not by reference&lt;br&gt;&#xD;
MbUnit.Core.Exceptions.AssertionException&lt;br&gt;&#xD;
Message: Equal by identity but not by reference&lt;br&gt;&#xD;
...&lt;br&gt;&#xD;
0 passed, 1 failed, 0 skipped, took 1.63 seconds.&#xD;
&lt;/p&gt;&#xD;
        &lt;/font&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
Since all reference types derive from System.Object, we can change this behavior by&#xD;
overriding the Equals method to do a comparison that means something to the object.&#xD;
In this case we will use the Id property. In this case we will first test to make&#xD;
sure that the object being compared is of the correct type and then we will compare&#xD;
the Id property. As an interesting excercise, take a look at the override of the Equals&#xD;
method in the System.ValueType class using Reflector. This implementation uses reflection&#xD;
to determine what items can hold state. It then does a comparison for each item (using&#xD;
.Equals in the end so that reference types work correctly). &#xD;
&lt;br&gt;&lt;/p&gt;&#xD;
        &lt;p style="BACKGROUND-COLOR: rgb(221,221,221)"&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; &#xD;
public&lt;/span&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;override&lt;/span&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; Equals(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; obj)&lt;br&gt;&#xD;
  {&lt;br&gt;&#xD;
    MyClass testClass &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; obj &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; MyClass;&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;   &#xD;
return&lt;/span&gt; Id == testClass.Id;&lt;br&gt;&#xD;
  }&lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
Results:&#xD;
&lt;/p&gt;&#xD;
        &lt;font size="1"&gt;&#xD;
        &lt;/font&gt;&#xD;
        &lt;p style="PADDING-LEFT: 15px; BACKGROUND-COLOR: rgb(221,221,221)"&gt;&#xD;
          &lt;font size="1"&gt;------ Test started: Assembly: Equality.exe ------&lt;br&gt;&#xD;
Starting the MbUnit Test Execution&lt;br&gt;&#xD;
Exploring Equality, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&lt;br&gt;&#xD;
MbUnit 1.0.2700.29885 Addin&lt;br&gt;&#xD;
Found 1 tests&lt;br&gt;&#xD;
[success] EqualityTest.EqualsMethod_Test&lt;br&gt;&#xD;
1 passed, 0 failed, 0 skipped, took 1.59 seconds.&lt;/font&gt;&#xD;
          &lt;br&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
Now we have the Equals method expressing a meaning for equality that matches our understanding&#xD;
of the object. This is a nice advantage when using framework classes such as collections.&#xD;
Collection methods like Contains will call the object's Equals method. Simply&#xD;
overriding the Equals method gives us many more tools to work with without much effort.&#xD;
One thing that should be mentioned here is the warning that occurs when you override&#xD;
Equals. You will be greeted with a compiler warning about overriding Equals without&#xD;
overriding GetHashCode. GetHashCode is defined as a method that should return a number&#xD;
unique for a given instance of the object. We are using the Id property for that purpose.&#xD;
&lt;/p&gt;&#xD;
        &lt;p style="PADDING-LEFT: 15px; BACKGROUND-COLOR: rgb(221,221,221)"&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;override&lt;/span&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; GetHashCode()&lt;br&gt;&#xD;
{ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; Id;&#xD;
}&lt;br&gt;&lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
Now it would be really nice to have some consitancy with other mechanims used to compare&#xD;
equality. Another common mechanism for equality testing is the == operator. Lets put&#xD;
together a test that will see if this complies with our objects definition of equality.&#xD;
&lt;/p&gt;&#xD;
        &lt;p style="PADDING-LEFT: 15px; BACKGROUND-COLOR: rgb(221,221,221)"&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[Test]&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; EqualOperator_Test()&lt;br&gt;&#xD;
{&lt;br&gt;&#xD;
  Assert.IsTrue(testClass == equalClass, &lt;span style="FONT-SIZE: 11px; COLOR: rgb(102,102,102); FONT-FAMILY: Courier New; BACKGROUND-COLOR: rgb(228,228,228)"&gt;"Equal&#xD;
by identity but not by reference"&lt;/span&gt;);&lt;br&gt;&#xD;
  Assert.IsFalse(testClass == notEqualClass, &lt;span style="FONT-SIZE: 11px; COLOR: rgb(102,102,102); FONT-FAMILY: Courier New; BACKGROUND-COLOR: rgb(228,228,228)"&gt;"Not&#xD;
equal by either identity or reference"&lt;/span&gt;);&lt;br&gt;&#xD;
}&lt;br&gt;&lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
Results:&#xD;
&lt;/p&gt;&#xD;
        &lt;font size="1"&gt;&#xD;
        &lt;/font&gt;&#xD;
        &lt;p style="PADDING-LEFT: 15px; BACKGROUND-COLOR: rgb(221,221,221)"&gt;&#xD;
          &lt;font size="1"&gt;------ Test started: Assembly: Equality.exe ------&lt;br&gt;&#xD;
Starting the MbUnit Test Execution&lt;br&gt;&#xD;
Exploring Equality, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&lt;br&gt;&#xD;
MbUnit 1.0.2700.29885 Addin&lt;br&gt;&#xD;
Found 2 tests&lt;br&gt;&#xD;
[success] EqualityTest.EqualsMethod_Test&lt;br&gt;&#xD;
[failure] EqualityTest.EqualOperator_Test&lt;br&gt;&#xD;
TestCase 'EqualityTest.EqualOperator_Test' failed: Equal by identity but not by reference&lt;br&gt;&#xD;
Message: Equal by identity but not by reference&lt;br&gt;&#xD;
...&lt;br&gt;&#xD;
1 passed, 1 failed, 0 skipped, took 1.78 seconds.&lt;/font&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
          &lt;br&gt;&#xD;
 &#xD;
&lt;/p&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
Looks like we have a bit more work to do. What we need to do now is provide the operator&#xD;
== method. We will take advantage of the fact that we have already defined equality&#xD;
in the Equals method on our object. (Note that this is a static method that takes&#xD;
two objects as parameters. One side effect of this is that you do not get to make&#xD;
static members virtual and override them.)&#xD;
&lt;/p&gt;&#xD;
        &lt;font size="1"&gt;&#xD;
        &lt;/font&gt;&#xD;
        &lt;p style="PADDING-LEFT: 15px; BACKGROUND-COLOR: rgb(221,221,221)"&gt;&#xD;
          &lt;font color="#0000ff" size="1"&gt;public&lt;/font&gt;&#xD;
          &lt;font size="1"&gt;&#xD;
          &lt;/font&gt;&#xD;
          &lt;font color="#0000ff" size="1"&gt;static&lt;/font&gt;&#xD;
          &lt;font size="1"&gt;&#xD;
          &lt;/font&gt;&#xD;
          &lt;font color="#0000ff" size="1"&gt;bool&lt;/font&gt;&#xD;
          &lt;font size="1"&gt;&#xD;
          &lt;/font&gt;&#xD;
          &lt;font color="#0000ff" size="1"&gt;operator&lt;/font&gt;&#xD;
          &lt;font size="1"&gt;==(&lt;/font&gt;&#xD;
          &lt;font color="#2b91af" size="1"&gt;MyClass&lt;/font&gt;&#xD;
          &lt;font size="1"&gt; lhs, &lt;/font&gt;&#xD;
          &lt;font color="#2b91af" size="1"&gt;MyClass&lt;/font&gt;&#xD;
          &lt;font size="1"&gt; rhs)&lt;br&gt;&#xD;
{ &lt;/font&gt;&#xD;
          &lt;font color="#0000ff" size="1"&gt;return&lt;/font&gt;&#xD;
          &lt;font size="1"&gt; lhs.Equals(rhs);&#xD;
}&lt;/font&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
Now we fire up the test to see where we stand and we are greeted with an error message.&#xD;
The compiler is telling us that when == is implemented that != is required as well.&#xD;
After you finish wondering why someone by default would not implement a != method&#xD;
as an inverse of the == method, implement the != method using our Equals method or&#xD;
the == operator. Of course we need to add some tests to ensure that != is doing what&#xD;
we expect.&#xD;
&lt;/p&gt;&#xD;
        &lt;p style="PADDING-LEFT: 15px; BACKGROUND-COLOR: rgb(221,221,221)"&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[Test]&lt;br&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; NotEqualOperator_EqualTest()&lt;br&gt;&#xD;
{&lt;br&gt;&#xD;
  Assert.IsTrue(testClass !&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; notEqualClass, &lt;span style="FONT-SIZE: 11px; COLOR: rgb(102,102,102); FONT-FAMILY: Courier New; BACKGROUND-COLOR: rgb(228,228,228)"&gt;"Not&#xD;
equal by either identity or reference"&lt;/span&gt;);&lt;br&gt;&#xD;
  Assert.IsFalse(testClass !&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; equalClass, &lt;span style="FONT-SIZE: 11px; COLOR: rgb(102,102,102); FONT-FAMILY: Courier New; BACKGROUND-COLOR: rgb(228,228,228)"&gt;"Equal&#xD;
by identity but not reference"&lt;/span&gt;);&lt;br&gt;&#xD;
}&lt;br&gt;&lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p style="PADDING-LEFT: 15px; BACKGROUND-COLOR: rgb(221,221,221)"&gt;&#xD;
          &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt;&#xD;
            &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;operator&lt;/span&gt; !&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt;(MyClass&#xD;
lhs, MyClass rhs)&lt;br&gt;&#xD;
{ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; !lhs.Equals(rhs);&#xD;
}&lt;br&gt;&lt;/span&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
It can be handy for users of your classes to be able to count on basic functionality&#xD;
such as equality. It also will help leverage the framework for collection operations&#xD;
as well. Another thing very similar in nature to this exercise that will help leverage&#xD;
the framework is implementing the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.icomparable.aspx"&gt;IComparable&lt;/a&gt; or &lt;a href="http://msdn2.microsoft.com/en-us/library/4d7sx9hd.aspx"&gt;IComparable&amp;lt;T&amp;gt;&lt;/a&gt; interface. &#xD;
&lt;/p&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
          &lt;strong&gt;Other Considerations&lt;/strong&gt;&#xD;
        &lt;/p&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
In &lt;a href="http://srtsolutions.com/blogs/billwagner/"&gt;Bill Wagner's&lt;/a&gt; book &lt;a href="http://safari.oreilly.com/0321245660"&gt;Effective&#xD;
C#&lt;/a&gt;, Item 10 mentions some issues with overriding GetHashCode. In short, the framework&#xD;
has a very efficient way to come up with the hash code, in many cases you will not&#xD;
come up with something better. If you do not have something as simple as an identity&#xD;
column that is assigned from the database, consider this advice carefully.&lt;br&gt;&lt;/p&gt;&#xD;
        &lt;p style="MARGIN-BOTTOM: 0in"&gt;&#xD;
 &#xD;
&lt;/p&gt;&#xD;
        &lt;img width="0" height="0" src="http://developusing.net/aggbug.ashx?id=e471b4b3-6236-42b5-aeb7-500274ccdb8c"&gt;&lt;/img&gt;&#xD;
      &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DevelopUsingdotnet?a=IVnnuDE"&gt;&lt;img src="http://feeds.feedburner.com/~f/DevelopUsingdotnet?i=IVnnuDE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DevelopUsingdotnet/~4/235875154" height="1" width="1"/&gt;</description>
      <comments>http://developusing.net/CommentView,guid,e471b4b3-6236-42b5-aeb7-500274ccdb8c.aspx</comments>
      <category>fundamentals</category>
    <feedburner:origLink>http://developusing.net/2008/01/12/AllThingsBeingEqual.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://developusing.net/Trackback.aspx?guid=1f1c4b55-12c2-49c7-b128-4ebb464366f3</trackback:ping>
      <pingback:server>http://developusing.net/pingback.aspx</pingback:server>
      <pingback:target>http://developusing.net/PermaLink,guid,1f1c4b55-12c2-49c7-b128-4ebb464366f3.aspx</pingback:target>
      <dc:creator>Dennis Burton</dc:creator>
      <wfw:comment>http://developusing.net/CommentView,guid,1f1c4b55-12c2-49c7-b128-4ebb464366f3.aspx</wfw:comment>
      <wfw:commentRss>http://developusing.net/SyndicationService.asmx/GetEntryCommentsRss?guid=1f1c4b55-12c2-49c7-b128-4ebb464366f3</wfw:commentRss>
      
      <title>public static void Main( string[] args )</title>
      <guid isPermaLink="false">http://developusing.net/PermaLink,guid,1f1c4b55-12c2-49c7-b128-4ebb464366f3.aspx</guid>
      <link>http://feeds.feedburner.com/~r/DevelopUsingdotnet/~3/235875155/publicStaticVoidMainStringArgs.aspx</link>
      <pubDate>Sat, 12 Jan 2008 19:00:14 GMT</pubDate>
      <description>&lt;p&gt;&#xD;
For it seems like forever, friends and colleges have tried to push me into the exercise&#xD;
of blogging. For it seems like forever, I have resisted because I am horribly slow&#xD;
at writing. Two things are finally driving me to get started. As organizational changes&#xD;
have taken place, the company website is much more focused on the credibility of the&#xD;
Business Development staff and not so much on the Technical Staff. So, I no longer&#xD;
have a professional profile on the company web site. That profile was close to 5 years&#xD;
out of date anyway. More importantly, I hope to improve myself by learning more deeply&#xD;
in order to write about it. &#xD;
&lt;/p&gt;&#xD;
        &lt;p&gt;&#xD;
This is my entry point into creating an up to date professional profile&#xD;
as well as getting better at the writing process. The technical content will probably&#xD;
not be real deep for a little while as I work through the process of writing. Hopefully&#xD;
this will be a fun ride.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&#xD;
        &lt;img width="0" height="0" src="http://developusing.net/aggbug.ashx?id=1f1c4b55-12c2-49c7-b128-4ebb464366f3"&gt;&lt;/img&gt;&#xD;
      &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DevelopUsingdotnet?a=b6dnuVE"&gt;&lt;img src="http://feeds.feedburner.com/~f/DevelopUsingdotnet?i=b6dnuVE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DevelopUsingdotnet/~4/235875155" height="1" width="1"/&gt;</description>
      <comments>http://developusing.net/CommentView,guid,1f1c4b55-12c2-49c7-b128-4ebb464366f3.aspx</comments>
    <feedburner:origLink>http://developusing.net/2008/01/12/publicStaticVoidMainStringArgs.aspx</feedburner:origLink></item>
  </channel>
</rss>
