/Emrys.SuperConfig

It is easier to use configuration in .Net. 在.net中更容易使用配置文件

Primary LanguageC#MIT LicenseMIT

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="i@emrys.me" 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

  1. Get Started
  2. Support for data types
  3. Custom config file location
  4. Custom config file naming rules
  5. Custom Section format
  6. Custom location, naming rules, and Section format

Chinese wiki

  1. 开始使用 入门
  2. 支持数据类型
  3. 自定义配置文件位置
  4. 自定义配置文件命名规则
  5. 自定义Section格式
  6. 同时自定义位置、命名规则和Section格式