码迷,mamicode.com
首页 > Web开发 > 详细

web.config configSections示例

时间:2014-08-29 10:47:17      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:des   io   ar   for   cti   sp   on   new   ad   

<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>;
 

web.config configSections示例

标签:des   io   ar   for   cti   sp   on   new   ad   

原文地址:http://www.cnblogs.com/Rannie/p/3944269.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!