SimpleConfig.net

Simple, dynamic configuration for .NET 4.0 +

View the Project on GitHub alexgit/SimpleConfig.net

1. Add a reference to the DynamicConfig.dll

No other dependencies

2. Add a new config section to your web.config file

  <configSections>
    <section name="mySection"
                type="DynamicConfig.DynamicConfigSectionHandler" />
  </configSections>

  <mySection>
    <car make="BMW" team="Sauber">
      <raceType name="F1 Gran Prix" />
      <balance frontAntiRollBar="3" rearAntiRollbBar="9" />
      <brakes>
        <balance front="0.5" rear="0.5" />
        <pressure level="high" />
        <brakeSize value="Standard" />
      </brakes>
      <suspension>
        <rideHeight front="2" rear="2" />
        <springStiffness front="5" rear="7" />
      </suspension>
      ...
    </car>
  </mySection>

3. Start using it

 dynamic config = new SimpleConfig("mySection");

 // 0.5
 double breakingBalanceFront = config.Car.Brakes.Balance.front.Value;

 // "high"        
 string breakingPressureLevel = config.Car.Brakes.Pressure.level.Value;

 // 2
 int rideHeightRear = config.Car.Suspension.RideHeight.rear.Value;

That's it. You're done.