Skip to content

Let ConfigureMe ConfigureYou. ConfigureMe provides a simple way to extract the value of config entries in web.config and app.config files in a strongly typed fashion.

License

Notifications You must be signed in to change notification settings

gtaylor44/ConfigureMe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#ConfigureMe

ConfigureMe provides a simple way to extract the value of config entries in web.config and app.config files in a strongly typed fashion.

####Getting started

using ConfigureMe;

The name of each enumeration must match the configuration entry in app/web.config. Store your enumerations in some configuration namespace.

e.g. BabySubscription in web.config would be:

<configuration> 
  <appSettings>
	<add key="BabySubscription" value="4.95"/>
	<add key="BlogsEnabled" value="true"/>
  </appSettings> 
</configuration>
[Serializable]
public enum AdminConfig
{
	[EnumMember]BabySubscription,
    [EnumMember]StandardSubscription,
    [EnumMember]PremiumSubscription,
    [EnumMember]PeopleWithPower
}

[Serializable]
public enum BlogConfig
{
	[EnumMember] BlogsEnabled
    [EnumMember] MaxBlogsPerPage
}   

[Serializable]
public enum CoreConfig
{
    [EnumMember] ServerErrorMessage
}

###Example usage

// If the key does not exist or the value can't be parsed, a detailed exception is raised. 
	
string errorMessage = AppSettings.GetString(CoreConfig.ServerErrorMessage);

int blogsPerPage = AppSettings.GetInt(BlogConfig.MaxBlogsPerPage);

decimal babySubscription = AppSettings.GetDecimal(AdminConfig.BabySubscription);

bool blogsEnabled = AppSettings.GetBool(BlogConfig.BlogsEnabled);

About

Let ConfigureMe ConfigureYou. ConfigureMe provides a simple way to extract the value of config entries in web.config and app.config files in a strongly typed fashion.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages