Emrys.SuperConfig
Emrys.SuperConfig copied to clipboard
It is easier to use configuration in .Net. 在.net中更容易使用配置文件
Emrys.SuperConfig
It is easier to use configuration in .Net.
在.Net中更加容易的使用配置文件。
Get Started
0. Install Package Emrys.SuperConfig
PM>Install-Package Emrys.SuperConfig
1.A new class name is UserInfo
class UserInfo
{
public string UserName { get; set; }
public string Email { get; set; }
public int Age { get; set; }
public string BlogUrl { get; set; }
public Color FavoriteColor { get; set; }
public Color DislikeColor { get; set; }
public List<string> Language { get; set; }
}
enum Color{Red,Blue,Black}
2.Configuration in Web.config/App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="userInfo" type="Emrys.SuperConfig.Section,Emrys.SuperConfig"></section>
</configSections>
<userInfo userName="Emrys" email="[email protected]" age="27">
<blogUrl>http://www.cnblogs.com/emrys5/</blogUrl>
<favoriteColor>Blue</favoriteColor>
<dislikeColor>2</dislikeColor>
<language>
<value>Putonghua</value>
<value>Huaipu</value>
<value>English</value>
</language>
</userInfo>
</configuration>
3.Get config
var user = SuperConfig<UserInfo>.Value;
Done!!!!!
English wiki
- Get Started
- Support for data types
- Custom config file location
- Custom config file naming rules
- Custom Section format
- Custom location, naming rules, and Section format