The good thing about T4MVC is that it allows you to get rid of literal/magic strings.
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.
I'm just wondering if it'd be possible to have something similar when it comes to app settings inside the Web.config
file:
<appSettings>
<add key="SecurityGuardEmailFrom" value="info@email.net" />
<add key="PasswordExpiresInDays" value="1" />
<add key="NumberOfPasswordsToKeep" value="5" />
</appSettings>
So, instead of this:
private static readonly int PasswordExpiresInDays =
int.Parse(ConfigurationManager.AppSettings["PasswordExpiresInDays"]);
We'd have something like this:
MVC.Webconfig.PasswordExpiresInDays
or
MVC.AppSettings.PasswordExpiresInDays
This would help in compile time to check if the app setting is still there avoiding runtime errors.
Would this be even viable? If yes, do you know if there's already something similar to this implemented somewhere?