如何从app.config读取 - LibraryConfigUtilities

时间:2012-08-01 20:29:57

标签: c# .net app-config

如何从下面的app.config文件中读取文化等值。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="LibrarySetting" type="LibraryConfigUtilities.ConfigurationSectionHandler, LibraryConfigUtilities" />
  </configSections>

  <LibrarySetting>
    <Country Culture="tr-TR" Currency="TRY" DailyPenaltyFee="5,25" PenaltyAppliesAfter="3">
      <WeekendSetting>
        <Weekend Day="6"/>
        <Weekend Day="0"/>
      </WeekendSetting>
      <HolidaySetting>
        <Holiday Date="25.11.2009"/>
        <Holiday Date="26.11.2009"/>
        <Holiday Date="27.11.2009"/>
      </HolidaySetting>
    </Country>
    <Country Culture="ar-AE" Currency="AED" DailyPenaltyFee="8.00" PenaltyAppliesAfter="4">
      <WeekendSetting>
        <Weekend Day="5"/>
        <Weekend Day="6"/>
      </WeekendSetting>
      <HolidaySetting>
        <Holiday Date="25.11.2009"/>
        <Holiday Date="26.11.2009"/>
        <Holiday Date="27.11.2009"/>
      </HolidaySetting>
    </Country>
  </LibrarySetting>
</configuration>

我的程序中有以下代码。我想从上面的app.config中读取值。

private List<Country> settingList = new LibrarySetting().LibrarySettingList;

我加了

using LibraryConfigUtilities;

1 个答案:

答案 0 :(得分:0)

使用ConfigurationManager.GetSection("LibrarySetting");

怎么样?

看看这是否有助于您到达目的地。

使用此链接作为参考,有一些很好的帮助。 App Config Group Help