web.config configSections示例
<configuration>
<configSections> <section name="Tab" type="Test.Server.TabHandler,Test.Server"/> </configSections>
<Tab>
<add key="tab1" value="标题1"/>
<add key="tab2" value="标题2"/>
</Tab>
</configuration>
public class TabHandler : IConfigurationSectionHandler { public object Create(object parent, object configContext, System.Xml.XmlNode section) { var profileList = new List<TabModel>(); foreach (XmlNode xn in section.ChildNodes) { if (xn.Attributes == null) continue; profileList.Add(new TabModel
{
Key = xn.Attributes["key"] == null ? string.Empty : xn.Attributes["key"].Value,
Value = xn.Attributes["value"] == null ? string.Empty : xn.Attributes["value"].Value
});
}
return profileList;
}
}
private static List<TabModel> list = ConfigurationManager.GetSection("Tab") as List<TabModel>;
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。