使用 ConfigurationSection 创建自定义配置节

时间:2016-01-14 11:41:10
【文件属性】:
文件名称:使用 ConfigurationSection 创建自定义配置节
文件大小:25KB
文件格式:RAR
更新时间:2016-01-14 11:41:10
app.config 您可以用自己的 XML 配置元素来扩展标准的 ASP.NET 配置设置集。若要完成该操作,您必须创建自己的配置节处理程序。 app.config
注:section.type="path,程序集名称" namespace CustomConfigSection { public class MySectionHandler : IConfigurationSectionHandler { #region IConfigurationSectionHandler Members public object Create(object parent, object configContext, XmlNode section) { List addressList = new List(); string address; foreach (XmlNode childNode in section.ChildNodes) { if (childNode.Attributes["MailAddress"] != null) { address = childNode.Attributes["MailAddress"].Value; if (!string.IsNullOrEmpty(address)) { addressList.Add(address); } } } return addressList; } #endregion } }
【文件预览】:
CustomConfigSection.sln
CustomConfigSection.suo
CustomConfigSection
----Program.cs(600B)
----CustomConfigSectionTest.csproj(3KB)
----Properties()
--------AssemblyInfo.cs(1KB)
----MySectionHandler.cs(989B)
----App.config(438B)
----obj()
--------x86()
----bin()
--------Debug()
--------Release()

网友评论

  • 好吧,并不是我想要的。
  • 资源不错 有一定的借鉴意义