Tag: 配置部分

将web.config部分读取到List

我在web.config中有这个: 我想读取所有部分“MySection”并获取List所有值(例如:“10”,“20”,“30”) 谢谢,

我可以在自定义ConfigurationSection上指定具有IntegerValidator属性的范围吗?

我有一个包含以下ConfigurationSection的类: namespace DummyConsole { class TestingComponentSettings: ConfigurationSection { [ConfigurationProperty(“waitForTimeSeconds”, IsRequired=true)] [IntegerValidator(MinValue = 1, MaxValue = 100, ExcludeRange = false)] public int WaitForTimeSeconds { get { return (int)this[“waitForTimeSeconds”]; } set { this[“waitForTimeSeconds”] = value; } } [ConfigurationProperty(“loginPage”, IsRequired = true, IsKey=false)] public string LoginPage { get { return (string)this[“loginPage”]; } set { this[“loginPage”] = value; } […]

循环通过configrationsection使用C#读取它的元素

我有一个配置文件,如: DEV http://login.dev.server.com/Logon.asmx http://login.ide.server.com/Logon.asmx abc 123 如何读取配置以获取传递的keyname的值。 这是我写的方法: private static string GetKeyValue(string keyname) { string rtnvalue = String.Empty; try { ConfigurationSectionGroup sectionGroup = config.GetSectionGroup(“logonurls”); foreach (ConfigurationSection section in sectionGroup.Sections) { //I want to loop through all the settings element of the section } } catch (Exception e) { } return rtnvalue; } config是配置变量,其中包含配置文件中的数据。

自定义ConfigurationSection

我使用IConfigurationSectionHandler接口来获取有关我的自定义配置部分的信息。 但它已被弃用,我想改用ConfigurationSection。 如何使用此视图创建自定义ConfigurationSection并使用ConfigurationSection而不是IConfigurationSectionHandler: …