title: T4MVC for Web.config <appSettings>
body: <p>The good thing about <a href="http://t4mvc.codeplex.com/" rel="nofollow">T4MVC</a> is that it allows you to get rid of <a href="http://en.wikipedia.org/wiki/Magic_string_%28programming%29" rel="nofollow">literal/magic strings</a>.</p>
  
  <blockquote>
    <p>T4MVC is a T4 template for ASP.NET MVC apps that creates strongly
    typed helpers that eliminate the use of literal strings when referring
    the controllers, actions and views.</p>
  </blockquote>
  
  <p>I'm just wondering if it'd be possible to have something similar when it comes to app settings inside the <code>Web.config</code> file:</p>
  
  <pre><code>&lt;appSettings&gt;
      &lt;add key="SecurityGuardEmailFrom" value="info@email.net" /&gt;
      &lt;add key="PasswordExpiresInDays" value="1" /&gt;
      &lt;add key="NumberOfPasswordsToKeep" value="5" /&gt;
  &lt;/appSettings&gt;
  </code></pre>
  
  <p>So, instead of this:</p>
  
  <pre><code>private static readonly int PasswordExpiresInDays =
  int.Parse(ConfigurationManager.AppSettings["PasswordExpiresInDays"]);
  </code></pre>
  
  <p>We'd have something like this:</p>
  
  <pre><code>MVC.Webconfig.PasswordExpiresInDays
  </code></pre>
  
  <p>or</p>
  
  <pre><code>MVC.AppSettings.PasswordExpiresInDays
  </code></pre>
  
  <p>This would help in compile time to check if the app setting is still there avoiding runtime errors.</p>
  
  <p>Would this be even viable? If yes, do you know if there's already something similar to this implemented somewhere?</p>