<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>Dave Kehring</title>
  <link rel="alternate" type="text/html" href="http://blog.whconsult.com/" />
  <link rel="self" href="http://blog.whconsult.com/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2009-04-07T18:04:30.040125-04:00</updated>
  <author>
    <name>Dave Kehring</name>
  </author>
  <subtitle>partial class DaveKehring : IProgrammer { } </subtitle>
  <id>http://blog.whconsult.com/</id>
  <generator uri="http://dasblog.info/" version="2.1.8102.813">DasBlog</generator>
  <entry>
    <title>Unrecognized attribute configProtectionProvider</title>
    <link rel="alternate" type="text/html" href="http://blog.whconsult.com/2009/04/07/UnrecognizedAttributeConfigProtectionProvider.aspx" />
    <id>http://blog.whconsult.com/PermaLink,guid,0b1b7f79-3c6f-4fa5-be2d-5bf8d924c3f1.aspx</id>
    <published>2009-04-07T18:03:41.258-04:00</published>
    <updated>2009-04-07T18:04:30.040125-04:00</updated>
    <category term="Configuration" label="Configuration" scheme="http://blog.whconsult.com/CategoryView,category,Configuration.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Don't you just love those days when you come to work full of energy and ideas, ready
to have a productive day only to be stumped by a seemingly simple problem that ends
up wasting the entire day? Today was one of those days. My only consolation is that
this blog post reports the solution, hopefully saving some other poor soul their time
and their sanity.
</p>
        <p>
The need was simple. Write out connection strings to the app.config file of an application
and encrypt them. Sound easy? Sure. There are lots of examples out there about how
to do this, but there's a problem no one seems to mention. You can't just update a
config file at runtime and expect those changes to stick. I ran into that problem
the other day and solved it <a href="http://blog.whconsult.com/2009/04/01/ConfigurationFileChangesWontPersist.aspx">here</a>.
But there's a more sinister problem. Let me explain.
</p>
        <p>
First, here's what I'm doing:
</p>
        <p>
          <img src="http://blog.whconsult.com/content/binary/4-7-2009 5-41-37 PM.png" border="0" />
        </p>
        <p>
I have an array of connection strings (as strings) from an external service that I
want to add to the app.config file of the current application. I write them out to
the &lt;connectionStrings&gt; section and then save the file, taking care to make
sure I tell the System.Configuration.ConfigurationManager to refresh the section,
meaning it should reload the section from disk the next time it's accessed.
</p>
        <p>
When this happens further along in the program on this line ...
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ConnectionStringSettings
dbConn <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> System.Configuration.ConfigurationManager.ConnectionStrings[DefaultDatabaseKey]; </span>
        </pre>
        <p>
... I get this error message:
</p>
        <p>
          <em>Unrecognized attribute 'configProtectionProvider'.</em>
        </p>
        <p>
I did the usual searches and came up with no solutions. Some folks suggested loading
two AppDomains, restarting the app, etc. I can't believe you'd have to restart an
app just to pick up configuration changes! After all, I can to this now. The problem
comes when I try to encrypt the section.
</p>
        <p>
          <img src="http://blog.whconsult.com/content/binary/4-7-2009 5-41-37 PM1.png" border="0" />
        </p>
        <p>
When you successfully encrpyt a section, a new attribute "configProtectionProvider"
is added to the &lt;connectionStrings&gt; element. It appears that when ConfigurationManager
tries to reload this section, it can't digest this new attribute.
</p>
        <p>
Okay, let's just get to the solution before I waste even more of my day...
</p>
        <p>
The answer turned out to be simple. Instead of telling ConfigurationManager to refresh
the "connectionStrings" section, have it refresh the next level up which would be
the &lt;configuration&gt; section itself:
</p>
        <p>
          <img src="http://blog.whconsult.com/content/binary/4-7-2009 6-01-44 PM1.png" border="0" />
        </p>
        <p>
Oh happy day.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=0b1b7f79-3c6f-4fa5-be2d-5bf8d924c3f1" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Configuration File Changes Won't Persist</title>
    <link rel="alternate" type="text/html" href="http://blog.whconsult.com/2009/04/01/ConfigurationFileChangesWontPersist.aspx" />
    <id>http://blog.whconsult.com/PermaLink,guid,a6c00bb4-493c-43cb-bcb4-71b032d76e04.aspx</id>
    <published>2009-04-01T12:21:45.75-04:00</published>
    <updated>2009-04-01T14:13:44.3755-04:00</updated>
    <category term="Configuration" label="Configuration" scheme="http://blog.whconsult.com/CategoryView,category,Configuration.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was running into a problem when trying to modify the app.config file for an application
at runtime. Specifically, I was adding connection strings to the &lt;connectionStrings&gt;
section but further along in my code the changes were not visible. However, the configuration
file was changed! How could this be? After much head scratching and research, I find
the problem.
</p>
        <p>
To change the app.config file I was opening the config file like this:
</p>
        <font size="2">
          <p>
     System.Configuration.
</p>
        </font>
        <font color="#2b91af" size="2">
          <font color="#2b91af" size="2">ConfigurationManager</font>
        </font>
        <font size="2">.OpenExeConfiguration(</font>
        <font color="#2b91af" size="2">
          <font color="#2b91af" size="2">ConfigurationUserLevel</font>
        </font>
        <font size="2">.None);
</font>
        <p>
I then add or update individual connection strings as need (that code's not important).
Finally, I save the changes:
</p>
        <font size="2">
          <p>
     config.Save(System.Configuration.
</p>
        </font>
        <font color="#2b91af" size="2">
          <font color="#2b91af" size="2">ConfigurationSaveMode</font>
        </font>
        <font size="2">.Modified);</font>
        <p>
          <font size="2">Further on in the code I then attempt to access the connection strings,
but instead I use the ConfigurationManager class like this:</font>
        </p>
        <font size="2">
          <font size="2">
            <font color="#2b91af" size="2">
              <font color="#2b91af" size="2">
                <p>
     ConnectionStringSettings
</p>
              </font>
            </font>
            <font color="#000000" size="2"> dbConn = System.Configuration.</font>
            <font color="#2b91af" size="2">
              <font color="#2b91af" size="2">ConfigurationManager</font>
            </font>
            <font size="2">
              <font color="#000000">.ConnectionStrings[DefaultDatabaseKey];</font>
            </font>
            <p>
The problem is that the ConfigurationManager - which is a static class - already
has a stored copy of the configuration file in its internals. The answer is to
call RefreshSection("...") after saving changes to the config file:
</p>
            <font size="2">
              <p>
   config.Save(System.Configuration.
</p>
            </font>
            <font color="#2b91af" size="2">
              <font color="#2b91af" size="2">ConfigurationSaveMode</font>
            </font>
            <font size="2">.Modified);<br />
   System.Configuration.</font>
            <font color="#2b91af" size="2">
              <font color="#2b91af" size="2">ConfigurationManager</font>
            </font>
            <font size="2">.RefreshSection(</font>
            <font color="#a31515" size="2">
              <font color="#a31515" size="2">"connectionStrings"</font>
            </font>
            <font size="2">);
</font>
            <p>
              <font size="2">
                <font color="#000000">
                </font> 
</font>
            </p>
          </font>
        </font>
        <img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=a6c00bb4-493c-43cb-bcb4-71b032d76e04" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Code Snippet for Prism DelegateCommand</title>
    <link rel="alternate" type="text/html" href="http://blog.whconsult.com/2009/02/01/CodeSnippetForPrismDelegateCommand.aspx" />
    <id>http://blog.whconsult.com/PermaLink,guid,5f0c8e2f-7c85-45ad-b214-6ddf2e285288.aspx</id>
    <published>2009-02-01T10:41:42.884-05:00</published>
    <updated>2009-02-07T10:46:10.916-05:00</updated>
    <category term="Visual Studio" label="Visual Studio" scheme="http://blog.whconsult.com/CategoryView,category,VisualStudio.aspx" />
    <content type="html">&lt;p&gt;
Code snippets in Visual Studio are very helpful when you have to type the same old
code structure again and again. I found myself doing this on a recent project and
decided to create a code snippet for it. I'm using Microsofts Composite Application
Guidance (a.k.a. Prism) and the Model-View-ViewModel pattern (M-V-VM). My ViewModels
implement commands that are hooked into from the Xaml View. The command type is DelegateCommand&amp;lt;T&amp;gt;,
a class provided by the Composite WPF library that comes with Prism. Here's my snippet:
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;xml&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"&gt;version&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;span style="COLOR: blue"&gt;1.0&lt;/span&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;encoding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;span style="COLOR: blue"&gt;utf-8&lt;/span&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;?&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;CodeSnippets&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"&gt;xmlns&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&lt;a href="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&gt;&lt;font color=#0000ff&gt;http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;CodeSnippet&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"&gt;Format&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;span style="COLOR: blue"&gt;1.0.0&lt;/span&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Header&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Title&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;DelegateCommand&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Title&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Shortcut&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;delcom&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Shortcut&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Author&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;Dave
Kehring&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Author&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Description&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;Creates
a Prism DelegateCommand.&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Description&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;SnippetTypes&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;SnippetType&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;Expansion&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;SnippetType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;SnippetTypes&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Header&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Snippet&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Imports&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Import&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Namespace&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;Microsoft.Practices.Composite.Wpf.Commands&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Namespace&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Import&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Imports&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Declarations&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Literal&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;ID&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;type&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ID&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;ToolTip&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;Parameter
type&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ToolTip&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Default&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;int&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Default&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Literal&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Literal&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;ID&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;name&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ID&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;ToolTip&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;Command
name&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ToolTip&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Default&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;MyCommand&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Default&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Literal&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Declarations&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Code&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"&gt;Language&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;span style="COLOR: blue"&gt;csharp&lt;/span&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;![CDATA[&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
DelegateCommand&amp;lt;$type$&amp;gt; _$name$Command;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
public DelegateCommand&amp;lt;$type$&amp;gt; $name$Command&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
get&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
if (_$name$Command == null)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
_$name$Command = new DelegateCommand&amp;lt;$type$&amp;gt;($name$, Can$name$);&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
return _$name$Command;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
public bool Can$name$($type$ param)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
public void $name$($type$ param)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;]]&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Code&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;Snippet&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;CodeSnippet&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: Consolas"&gt;CodeSnippets&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
This produces the following example property declaration:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; DelegateCommand&amp;lt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt;&amp;gt;
_SaveCommand; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; DelegateCommand&amp;lt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt;&amp;gt;
SaveCommand { get { &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (_SaveCommand
== &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;null&lt;/span&gt;)
_SaveCommand &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; DelegateCommand&amp;lt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt;&amp;gt;(Save,
CanSave); &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; _SaveCommand;
} } &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;bool&lt;/span&gt; CanSave(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; param)
{ } &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; Save(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; param)
{ } &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
The code snippet creates a private DelegateCommand member and a standard property
declaration with only a getter. The command is lazy-initialized. The two methods stubs
are called by the DelegateCommand during runtime execution.
&lt;/p&gt;
&lt;p&gt;
To use this snippet, save it in a file with the .snippet extension into %\My Documents\Visual
Studio 2008\Snippets\Visual C#\My Code Snippets. Then, in Visual Studio, you simply
type "delcom" to run the snippet:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blog.whconsult.com/content/binary/2-7-2009 10-38-37 AM1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Hit Tab to insert the snippet code into the IDE. Then, you provide replacement values
for the DelegateCommand's type value (this is the type of the parameter passed to
the command methods) and the name of the command:
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img src="http://blog.whconsult.com/content/binary/2-7-2009 10-42-03 AM.png" border=0&gt;&lt;img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=5f0c8e2f-7c85-45ad-b214-6ddf2e285288" /&gt;</content>
  </entry>
  <entry>
    <title>Adding Intellisense to Visual Studio for Custom Configuration Sections</title>
    <link rel="alternate" type="text/html" href="http://blog.whconsult.com/2008/11/20/AddingIntellisenseToVisualStudioForCustomConfigurationSections.aspx" />
    <id>http://blog.whconsult.com/PermaLink,guid,1978f9ec-2e78-4d4d-af60-6507d3a91698.aspx</id>
    <published>2008-11-20T08:57:11.987-05:00</published>
    <updated>2008-11-20T08:57:11.9875-05:00</updated>
    <category term="Configuration" label="Configuration" scheme="http://blog.whconsult.com/CategoryView,category,Configuration.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Intellisense is wonderful. It's so useful it's actually scary because it doesn't force
you to remember a lot class names, enum values, etc. This is good for productivity
but bad when you need to recall something without the Visual Studio IDE!
</p>
        <p>
In any case, I like to get Intellisense whenever I can. One area that I kept putting
off was adding Intellisense for custom configuration sections I create. I dislike
loads of &lt;add&gt; tags in the &lt;appSettings&gt; section because it becomes hard
to navigate. I prefer to create custom config sections. However, I don't get the benefit
- out of the box - of Intellisense and schema validation. To get this, you need to
create your own XSD file to support your custom config sections.
</p>
        <p>
XSDs for config sections are not hard to write. In fact, its best to just take a look
at the XSD file for the .NET config file which can be found in your Visual Studio
installation folder. For example, on my machine for VS 2008, I navigate to:
</p>
        <p>
C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas
</p>
        <p>
Here you'll find loads of XSD files for all sorts of things. The most important one
however is called DotNetConfig.xsd. This contains the schema definitions for the base
.NET config file. There are also supplimental files for .NET 2.0 and 3.0 config sections
in DotNetConfig20.xsd and DotNetConfig30.xsd respectively.
</p>
        <p>
Here's a simple example of a config section:
</p>
        <font color="#0000ff" size="3">
          <font color="#0000ff" size="3">
            <p>
              <font size="2">&lt;</font>
            </p>
          </font>
        </font>
        <font color="#a31515">
          <font color="#a31515">fileRepositories</font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">&gt;<br />
    </font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">&lt;</font>
        </font>
        <font color="#a31515">
          <font color="#a31515">fileRepository</font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">
          </font>
        </font>
        <font color="#ff0000">
          <font color="#ff0000">id</font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">=</font>
        </font>
        <font color="#000000">"</font>
        <font color="#0000ff">
          <font color="#0000ff">MainLib</font>
        </font>
        <font color="#000000">"</font>
        <font color="#0000ff">
          <font color="#0000ff">
          </font>
        </font>
        <font color="#ff0000">
          <font color="#ff0000">isDefault</font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">=</font>
        </font>
        <font color="#000000">"</font>
        <font color="#0000ff">
          <font color="#0000ff">true</font>
        </font>
        <font color="#000000">"</font>
        <font color="#0000ff">
          <font color="#0000ff">
          </font>
        </font>
        <font color="#ff0000">
          <font color="#ff0000">connectionString</font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">=</font>
        </font>
        <font color="#000000">"</font>
        <font color="#0000ff">
          <font color="#0000ff">\\JUPITER\MainLib</font>
        </font>
        <font color="#000000">"</font>
        <font color="#0000ff">
          <font color="#0000ff"> /&gt;<br /></font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">&lt;/</font>
        </font>
        <font color="#a31515">
          <font color="#a31515">fileRepositories</font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">&gt;</font>
        </font>
        <p>
          <font color="#0000ff" size="3">
            <font color="#0000ff" size="3">
              <font color="#000000" size="2">The
xsd schema (MyConfig.xsd) for this config section is:</font>
            </font>
          </font>
        </p>
        <font color="#0000ff" size="3">
          <font color="#0000ff" size="3">
            <font color="#000000" size="2">
              <font color="#0000ff" size="3">
                <font color="#0000ff" size="3">
                  <p>
                    <font size="2">&lt;?</font>
                  </p>
                </font>
              </font>
              <font color="#a31515">
                <font color="#a31515">xml</font>
              </font>
              <font color="#0000ff">
                <font color="#0000ff">
                </font>
              </font>
              <font color="#ff0000">
                <font color="#ff0000">version</font>
              </font>
              <font color="#0000ff">
                <font color="#0000ff">=</font>
              </font>"<font color="#0000ff"><font color="#0000ff">1.0</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">encoding</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">us-ascii</font></font>"<font color="#0000ff"><font color="#0000ff">?&gt;<br />
   </font></font><font color="#0000ff"><font color="#0000ff">&lt;</font></font><font color="#a31515"><font color="#a31515">xs:schema</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">xmlns:xs</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">http://www.w3.org/2001/XMLSchema</font></font>"<font color="#0000ff"><font color="#0000ff"> <br />
                     </font></font><font color="#ff0000"><font color="#ff0000">xmlns:vs</font></font><font color="#0000ff"><font color="#0000ff">=</font></font><font color="#0000ff"><font color="#0000ff"><a href="http://schemas.microsoft.com/Visual-Studio-Intellisense">http://schemas.microsoft.com/Visual-Studio-Intellisense</a></font></font><font color="#0000ff"><font color="#0000ff"> <br />
                     </font></font><font color="#ff0000"><font color="#ff0000">elementFormDefault</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">qualified</font></font>"<font color="#0000ff"><font color="#0000ff"> <br />
                     </font></font><font color="#ff0000"><font color="#ff0000">attributeFormDefault</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">unqualified</font></font>"<font color="#0000ff"><font color="#0000ff">&gt;
<p></p></font></font><font color="#0000ff"><font color="#0000ff"><p>
   &lt;
</p></font></font><font color="#a31515"><font color="#a31515">xs:element</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">name</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">fileRepositories</font></font>"<font color="#0000ff"><font color="#0000ff">&gt;<br />
      &lt;</font></font><font color="#a31515"><font color="#a31515">xs:complexType</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
         &lt;</font></font><font color="#a31515"><font color="#a31515">xs:choice</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">minOccurs</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">0</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">maxOccurs</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">unbounded</font></font>"<font color="#0000ff"><font color="#0000ff">&gt;<br />
            &lt;</font></font><font color="#a31515"><font color="#a31515">xs:element</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">name</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">fileRepository</font></font>"<font color="#0000ff"><font color="#0000ff">&gt;<br />
               &lt;</font></font><font color="#a31515"><font color="#a31515">xs:complexType</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
                  &lt;</font></font><font color="#a31515"><font color="#a31515">xs:attribute</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">name</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">id</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">type</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">xs:string</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">use</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">required</font></font>"<font color="#0000ff"><font color="#0000ff"> /&gt;<br />
                  &lt;</font></font><font color="#a31515"><font color="#a31515">xs:attribute</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">name</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">isDefault</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">type</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">xs:boolean</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">default</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">false</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">use</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">optional</font></font>"<font color="#0000ff"><font color="#0000ff">/&gt;<br />
                  &lt;</font></font><font color="#a31515"><font color="#a31515">xs:attribute</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">name</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">connectionString</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">type</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">xs:string</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">use</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">required</font></font>"<font color="#0000ff"><font color="#0000ff">/&gt;<br />
               &lt;/</font></font><font color="#a31515"><font color="#a31515">xs:complexType</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
            &lt;/</font></font><font color="#a31515"><font color="#a31515">xs:element</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
         &lt;/</font></font><font color="#a31515"><font color="#a31515">xs:choice</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
      &lt;/</font></font><font color="#a31515"><font color="#a31515">xs:complexType</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
   &lt;/</font></font><font color="#a31515"><font color="#a31515">xs:element</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
&lt;/</font></font><font color="#a31515"><font color="#a31515">xs:schema</font></font><font color="#0000ff"><font color="#0000ff">&gt;
</font></font></font>
          </font>
        </font>
        <p>
          <font color="#0000ff" size="3">
            <font color="#0000ff" size="3">
              <font color="#000000" size="2">I
placed this file in the ...\Xml\Schemas folder in the Visual Studio installation folder
as noted above. Now, to hook this into VS, you need to add it to the xsd catalog.
You do this by editing the file <strong>catalog.xml</strong>. Add the following line
to the bottom of this file before the closing &lt;schemaCatalog&gt; tag:</font>
            </font>
          </font>
        </p>
        <p>
          <font color="#0000ff" size="3">
            <font color="#0000ff" size="3">
              <font color="#000000" size="2"> 
&lt;Association extension="config" schema="%InstallRoot%/xml/schemas/MyConfig.xsd"
condition="%TargetFrameworkVersion% != 2.0 and %TargetFrameworkVersion% != 3.0" /&gt;<br /></font>
            </font>
          </font>
        </p>
        <p>
          <font color="#0000ff" size="3">
            <font color="#0000ff" size="3">
              <font color="#000000" size="2">That's
it! Now when you go into VS and edit a config file, you'll get Intellisense!</font>
            </font>
          </font>
        </p>
        <p>
          <font color="#0000ff" size="3">
            <font color="#0000ff" size="3">
              <font color="#000000" size="2"> 
</font>
            </font>
          </font>
        </p>
        <img src="http://blog.whconsult.com/content/binary/configIntellisense.png" border="0" />
        <img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=1978f9ec-2e78-4d4d-af60-6507d3a91698" />
      </div>
    </content>
  </entry>
  <entry>
    <title>How to Unit Test Events</title>
    <link rel="alternate" type="text/html" href="http://blog.whconsult.com/2008/10/06/HowToUnitTestEvents.aspx" />
    <id>http://blog.whconsult.com/PermaLink,guid,352b8213-afb4-48e8-86b4-13444e3c4137.aspx</id>
    <published>2008-10-06T11:35:17.269-04:00</published>
    <updated>2008-10-06T11:35:17.269-04:00</updated>
    <category term="NUnit" label="NUnit" scheme="http://blog.whconsult.com/CategoryView,category,NUnit.aspx" />
    <category term="Unit Testing" label="Unit Testing" scheme="http://blog.whconsult.com/CategoryView,category,UnitTesting.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you have a class that contains an event, you'll want to write a unit test to test
that the event gets fired at the right time and under the right conditions. The problem
is that you would typically hook up an event handler in your unit test class that
can run an assert to check if the event gets fired:
</p>
        <font size="2">
          <pre>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span>
              <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">bool</span> _fired;
[Test] <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> CheckVisiblityEvent()
{ _fired <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">false</span>;
ImageGroupListItemViewModel vm <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> ImageGroupListItemViewModelFactory.Build();
vm.VisibilityChanged += <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> ImageGroupListItemViewModel.ImageGroupVisibilityChangedEventHandler(vm_VisibilityChanged);<br /><br />
vm.Visible = true;</span>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> Assert.IsTrue(_fired);
} <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> vm_VisibilityChanged(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> sender,
ImageGroupVisibilityEventArgs args) { _fired <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">true</span>;
} </span>
          </pre>
          <p>
This is a bit sloppy. Instead, we could improve on this by using and anonymous method:
</p>
          <pre>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">[Test] <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> CheckVisiblityEvent()
{ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">bool</span> fired <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">false</span>;
ImageGroupListItemViewModel vm <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> ImageGroupListItemViewModelFactory.Build();
vm.VisibilityChanged += <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">delegate</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> sender,
ImageGroupVisibilityEventArgs e) { fired <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">true</span>;
}; vm.IsVisible <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">true</span>;
Assert.IsTrue(fired); } </span>
          </pre>
          <p>
More compact and easier to follow. Plus, the test code is all in one place. We can
improve this even more with a lambda expression:
</p>
          <pre>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">[Test] <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> CheckVisiblityEvent()
{ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">bool</span> fired <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">false</span>;
ImageGroupListItemViewModel vm <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> ImageGroupListItemViewModelFactory.Build();
vm.VisibilityChanged += (s, e) =&gt; fired <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">true</span>;
vm.IsVisible <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">true</span>;
Assert.IsTrue(fired); } </span>
          </pre>
          <p>
          </p>
        </font> 
<img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=352b8213-afb4-48e8-86b4-13444e3c4137" /></div>
    </content>
  </entry>
  <entry>
    <title>Handling MouseDoubleClick on a WPF Image Control</title>
    <link rel="alternate" type="text/html" href="http://blog.whconsult.com/2008/09/24/HandlingMouseDoubleClickOnAWPFImageControl.aspx" />
    <id>http://blog.whconsult.com/PermaLink,guid,82398b9c-e9c0-4232-ab2c-6fedf9ae1560.aspx</id>
    <published>2008-09-24T11:39:48.18-04:00</published>
    <updated>2008-09-24T11:39:48.180375-04:00</updated>
    <category term="M-V-VM" label="M-V-VM" scheme="http://blog.whconsult.com/CategoryView,category,MVVM.aspx" />
    <category term="WPF" label="WPF" scheme="http://blog.whconsult.com/CategoryView,category,WPF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Here's a nice way to bind to mouse events to a RoutedCommand. My RoutedCommand is
defined in a ViewModel (in the Model-View-ViewModel pattern):
</p>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">
            <p>
            </p>
          </font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&lt;</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">Image</font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2"> Name</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">="Image"</font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2"> Grid.Row</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">="0"</font>
        </font>
        <font size="2">
          <font color="#000000">
            <br />
           </font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2">Source</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">="{</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">Binding</font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2"> DataModel</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">.</font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2">Thumbnail</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">,</font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2"> Converter</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">={</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">StaticResource<br />
                        </font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2">ImageConverter</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">}}"&gt;<br />
    </font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&lt;</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">Image.InputBindings</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;<br />
        </font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&lt;</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">MouseBinding</font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2"> MouseAction</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">="LeftDoubleClick"<br />
                            </font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2">Command</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">="vm:ThumbnailViewModel.PreviewCommand"/&gt;<br />
    </font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&lt;/</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">Image.InputBindings</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;<br /></font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&lt;/</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">Image</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;
</font>
        </font>
        <img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=82398b9c-e9c0-4232-ab2c-6fedf9ae1560" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Error "The calling thread must be STA, because many UI components require this" in NUnit for WPF apps</title>
    <link rel="alternate" type="text/html" href="http://blog.whconsult.com/2008/08/12/ErrorTheCallingThreadMustBeSTABecauseManyUIComponentsRequireThisInNUnitForWPFApps.aspx" />
    <id>http://blog.whconsult.com/PermaLink,guid,20c8c370-3b07-49c0-89df-1c0e403b43cf.aspx</id>
    <published>2008-08-12T09:52:59.579-04:00</published>
    <updated>2008-08-13T09:53:25.063375-04:00</updated>
    <category term="M-V-VM" label="M-V-VM" scheme="http://blog.whconsult.com/CategoryView,category,MVVM.aspx" />
    <category term="NUnit" label="NUnit" scheme="http://blog.whconsult.com/CategoryView,category,NUnit.aspx" />
    <category term="Unit Testing" label="Unit Testing" scheme="http://blog.whconsult.com/CategoryView,category,UnitTesting.aspx" />
    <category term="WPF" label="WPF" scheme="http://blog.whconsult.com/CategoryView,category,WPF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
While trying to create unit tests for view models (using the Model-View-ViewModel
pattern), I came across a problem while trying to execute unit tests from NUnit. The
error I recevied was:
</p>
        <p>
          <em>The calling thread must be STA, because many UI components require this.</em>
        </p>
        <p>
A quick search on Google yielded an <a href="http://www.hedgate.net/articles/2007/01/08/instantiating-a-wpf-control-from-an-nunit-test/">answer</a>.
</p>
        <p>
However, the configuration file in the post was incorrect and was noted by a commentor.
For expediency, I have included the correct configuration text below:
</p>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
            <p>
&lt;
</p>
          </font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">configSections</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;<br />
   &lt;</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">sectionGroup</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
          </font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2">name</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">=</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">NUnit</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;<br />
      </font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&lt;</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">section</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
          </font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2">type</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">=</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">System.Configuration.NameValueSectionHandler</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
          </font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2">name</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">=</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">TestRunner</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&lt;/</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">section</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;<br />
   </font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&lt;/</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">sectionGroup</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;<br />
&lt;/</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">configSections</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;
</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
            <p>
&lt;
</p>
          </font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">NUnit</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;<br />
   &lt;</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">TestRunner</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;<br />
      </font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&lt;</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">add</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
          </font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2">value</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">=</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">STA</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
          </font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2">key</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">=</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">ApartmentState</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;&lt;/</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">add</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;<br />
   &lt;/</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">TestRunner</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;<br />
&lt;/</font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">NUnit</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">&gt;</font>
        </font>
        <p>
          <font color="#0000ff" size="2">
            <font color="#0000ff" size="2"> 
</font>
          </font>
        </p>
        <img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=20c8c370-3b07-49c0-89df-1c0e403b43cf" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Creating a Client-side Validator for the DropDownList</title>
    <link rel="alternate" type="text/html" href="http://blog.whconsult.com/2007/10/23/CreatingAClientsideValidatorForTheDropDownList.aspx" />
    <id>http://blog.whconsult.com/PermaLink,guid,3eb096ba-079a-451a-9fad-0ae4a2a2587e.aspx</id>
    <published>2007-10-23T08:34:45.348-04:00</published>
    <updated>2008-05-30T08:34:45.34825-04:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="http://blog.whconsult.com/CategoryView,category,ASPNET.aspx" />
    <content type="html">&lt;div&gt;I like using Guids. Sure, they're a bit long and difficult to decipher in a database
but they have their uses. I typically use them as the primary key for database tables.
I often have the need to display a list of values from a database table in a DropDownList
control on a WebForm. The value of each entry is the Guid while the text value comes
from a description field in each record. When the user selects an item from the DropDownList,
I retreive the Guid from the SelectedValue property which is typically used to set
a field on a business object, thus creating a reference. Typically the first item
in the DropDownList reads "--Select One--" or "-- None --", indicating the the user
must select a value (this is represented by the value for Guid.Empty). Consequently
the field is "required" - a user must select a value from the list. I do this because
I don't want to presume a default value (such as the first item). 
&lt;br&gt;
&lt;br&gt;
The problem them becomes how to validate the DropDownList on the client side such
that if the user does not select an item other than the default "--Select One--" item
a message is display. 
&lt;br&gt;
&lt;br&gt;
I found a &lt;a href="http://www.netomatix.com/development/DropDownCustomValidator.aspx"&gt;post &lt;/a&gt;that
shows how to use the CustomValidator control to validate a DropDownList. The problem
with this solution is that it does not take into account when a control is embedded
within other controls that are tagged with the INamingContainer interface. This interface
tells ASP.NET to automatically generate unique "id" attribute values on the ensuing
HTML tags generated for a control. This unique id is prepended with the id of each
parent control up to the root control. For example, a DropDownList embedded in a Panel
control might have the id "ctl00$ddlMyDropDown". Therefore, in the solution mentioned
above, we can't simply us "document.getElementById" Javascript function to locate
the DropDownList control. 
&lt;br&gt;
&lt;br&gt;
A better solution is to utilize the ControlToValidate property of the CustomValidator
control. When this is set at design-time ASP.NET will generate Javascript code to
add this value as an attribute of the validator control in the HTML DOM. For instance,
looking at the source of the page I'm working on the following code is generated: 
&lt;br&gt;
&lt;br&gt;
&lt;font face="courier new" size=2&gt;var ctl00_MainContent_CustomValidator1 = document.all
? document.all["ctl00_MainContent_CustomValidator1"] : document.getElementById("ctl00_MainContent_CustomValidator1");&lt;/font&gt; 
&lt;br&gt;
&lt;font face="courier new" size=2&gt;&lt;strong&gt;ctl00_MainContent_CustomValidator1.controltovalidate
= "ctl00_MainContent_ddlFeedbackType";&lt;/strong&gt;&lt;/font&gt; 
&lt;br&gt;
&lt;font face="Courier New" size=2&gt;&lt;/font&gt;
&lt;br&gt;
&lt;font size=2&gt;The property "controltovalidate" contains the fully-qualified unique
id of the target control we're validating. We can use the "controltovalidate" property
in our Javascript function that is used to validate the DropDownList:&lt;/font&gt; 
&lt;br&gt;
&lt;font size=2&gt;&lt;/font&gt;
&lt;br&gt;
&lt;script type=text/javascript&gt;    &lt;/font&gt;
&lt;br /&gt;&lt;font face="courier new" size="2"&gt;function ValidateFeedbackType(source, arguments)    &lt;/font&gt;
&lt;br /&gt;&lt;font face="courier new" size="2"&gt;{&lt;/font&gt;
&lt;br /&gt;&lt;font face="courier new" size="2"&gt;    var ddl = document.getElementById(source.controltovalidate);&lt;/font&gt;
&lt;br /&gt;&lt;font face="courier new" size="2"&gt;    if (null != ddl)        &lt;/font&gt;
&lt;br /&gt;&lt;font face="courier new" size="2"&gt;    {            &lt;/font&gt;
&lt;br /&gt;&lt;font face="courier new" size="2"&gt;        var value = ddl[ddl.selectedIndex].value;            &lt;/font&gt;
&lt;br /&gt;&lt;font face="courier new" size="2"&gt;        arguments.IsValid = (value != "00000000-0000-0000-0000-000000000000");&lt;/font&gt;
&lt;br /&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;    &lt;font size="+0"&gt;}        &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;br /&gt;&lt;font face="courier new" size="2"&gt;    else        &lt;/font&gt;
&lt;br /&gt;&lt;font face="courier new" size="2"&gt;    {            &lt;/font&gt;
&lt;br /&gt;&lt;font face="courier new" size="2"&gt;        arguments.IsValid = false;        &lt;/font&gt;
&lt;br /&gt;&lt;font face="courier new" size="2"&gt;    }    &lt;/font&gt;
&lt;br /&gt;&lt;font face="courier new" size="2"&gt;}    &lt;/font&gt;
&lt;br /&gt;&lt;font face="courier new" size="2"&gt;&lt;/script&gt;
&lt;font face="courier new" size=2&gt;function ValidateFeedbackType(source, arguments) &lt;/font&gt;
&lt;br&gt;
&lt;font face="courier new" size=2&gt;{ &lt;/font&gt;
&lt;br&gt;
&lt;font face="courier new" size=2&gt;var ddl = document.getElementById(source.controltovalidate); &lt;/font&gt;
&lt;br&gt;
&lt;font face="courier new" size=2&gt;if (null != ddl) &lt;/font&gt;
&lt;br&gt;
&lt;font face="courier new" size=2&gt;{ &lt;/font&gt;
&lt;br&gt;
&lt;font face="courier new" size=2&gt;var value = ddl[ddl.selectedIndex].value; &lt;/font&gt;
&lt;br&gt;
&lt;font face="courier new" size=2&gt;arguments.IsValid = (value != "00000000-0000-0000-0000-00000000000"); &lt;/font&gt;
&lt;br&gt;
&lt;font face="courier new" size=2&gt;} &lt;/font&gt;
&lt;br&gt;
&lt;font face="courier new" size=2&gt;else &lt;/font&gt;
&lt;br&gt;
&lt;font face="courier new" size=2&gt;{ &lt;/font&gt;
&lt;br&gt;
&lt;font face="courier new" size=2&gt;arguments.IsValid = false; &lt;/font&gt;
&lt;br&gt;
&lt;font face="courier new" size=2&gt;} &lt;/font&gt;
&lt;br&gt;
&lt;font face="courier new" size=2&gt;}&lt;/font&gt; 
&lt;br&gt;
&lt;p&gt;
&lt;font face="courier new" size=2&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="courier new" size=2&gt;
&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=3eb096ba-079a-451a-9fad-0ae4a2a2587e" /&gt;</content>
  </entry>
  <entry>
    <title>Creating a Simple ASP.NET "Click Once" Submit Button</title>
    <link rel="alternate" type="text/html" href="http://blog.whconsult.com/2007/06/25/CreatingASimpleASPNETClickOnceSubmitButton.aspx" />
    <id>http://blog.whconsult.com/PermaLink,guid,3ee3e7f3-3729-46ef-99d6-ea25ef24982a.aspx</id>
    <published>2007-06-25T09:09:56.113-04:00</published>
    <updated>2008-05-30T09:27:26.270125-04:00</updated>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I often run into a situation where a user tries to click a Submit button more than
once on a page when processing takes more than a few seconds. To remedy this, I created
a very simple control based on the standard ASP.NET Button control (System.Web.UI.WebControls.Button).
I created a new WebControl and inherit from System.Web.UI.WebControls.Button to retain
all of the aspects of a standard button. Next, I override the AddAttributesToRender
method and include the following code:
</p>
        <p>
          <br />
protected override void AddAttributesToRender(HtmlTextWriter writer)<br />
{<br />
    base.AddAttributesToRender(writer);<br />
    writer.AddAttribute("onclick", "this.disabled=true;" 
<br />
        + this.Page.ClientScript.GetPostBackEventReference(this,
""));<br />
}
</p>
        <p>
          <br />
The first line calls the base classes implementation and then the second line adds
a client-side event handler for the "onclick" event of the button. When the button
is clicked, it is disabled and then a postback is initiated. This is important because
if you just try to disabled the button, it will not be part of the postback and its
server-side processing will not fire. That's why you need to include the postback
callback function for the button that can be obtained from the call to ClientScript.GetPostBackEventReference.
</p>
        <img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=3ee3e7f3-3729-46ef-99d6-ea25ef24982a" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Error Creating ASP.NET Application</title>
    <link rel="alternate" type="text/html" href="http://blog.whconsult.com/2007/05/30/ErrorCreatingASPNETApplication.aspx" />
    <id>http://blog.whconsult.com/PermaLink,guid,088891c0-bfeb-4795-b5f3-9aafa655eaff.aspx</id>
    <published>2007-05-30T13:30:52-04:00</published>
    <updated>2008-05-30T09:26:43.988875-04:00</updated>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was tring to create an ASP.NET website using Visual Studio.NET 2003 and got the
following error that in part says:<br /><br />
"<em>Unable to create web project ... The two need to map to the same server location</em>".<br /><br />
I found so many threads about this with few answers. Here's how I solved my problem.<br /><br />
I was trying to create an ASP.NET website on one of my servers from Visual Studio.NET
2003 on my development machine. The problem was that the directory location of the
"Default Web Site" node in IIS on the server did not map to the location where I was
trying to create the new application based on the UNC path. For example, I was trying
to create the application on the following path: 
<br /><br /><em><a href="file://\\myserver\inetpub$\myapplication">\\myserver\inetpub$\myapplication</a><br /></em><br />
This mapped to the physical location:<br /><br /><em>G:\Inetpub<br /></em><br />
... and translates to the URL<br /><br /><em><a href="http://myserver/myapplication">http://myserver/myapplication</a></em><em><br /></em><br />
In IIS on the server I looked at the "Default Web Site" node as this is where IIS
will try to create the ASP.NET application because <em>http://myserver</em> translates
to this location. Looking at the <em>Home Directory</em> tab at the <em>Local Path</em> parameter
I noticed it was pointing to the physical location 
<br /><br /><em>C:\Inetpub\wwwroot<br /></em><br />
So, I simply changed this path to <em>G:\Inetpub</em> and it worked. So this is what
the message means by "the two need to map to the same server location".<br /><br />
Don't forget of course that I had to create a UNC share with the appropriate permissions
for this to work.<br /><br />
Hope this saves someone some time.
</p>
        <img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=088891c0-bfeb-4795-b5f3-9aafa655eaff" />
      </div>
    </content>
  </entry>
</feed>