zoukankan      html  css  js  c++  java
  • Web.config或App.config下section

    1.为什么使用section

    在web.config中不能直接使用用户自定义的配置信息,但定义配置节处理程序与配置元素之间的关联来获取配置信息,具体查看msdn。

    如log4net,NHibernate等很多程序集,在使用时,用户自己配置section信息,程序集通过配置信息来处理逻辑,增加应用程序的可移植性。

    2.注意

    <?xml version="1.0"?>
    <configuration>
      <configSections>
        <sectionGroup name="myCustomGroup">
          <section name="myCustomSection" type="ExampleSectionHandler.Handler.MyHandler,ExampleSectionHandler"/>
        </sectionGroup>
      </configSections>
      <myCustomGroup>
        <myCustomSection myAttrib1="Clowns">
          <myChildSection myChildAttrib1="Zippy" myChildAttrib2="Michael Zawondy "/>
        </myCustomSection>
      </myCustomGroup>
      <system.web>
      </system.web>
    </configuration>
    

    System.Configuration.ConfigurationSettings.GetConfig("myCustomGroup/myCustomSection")返回object

    程序中,通过GetConfig来查找对应的sectionGroup和section,执行type对应的节点处理程序,它返回Object类型(任意数据结构)

    3.疑问

    访问某一节,可使用GetConfig(string sectionName),如何遍历所有Section呢

  • 相关阅读:
    Apache TomEE 入门指南
    Windows 7运行命令大全
    hibernate hql 大全
    maven常用命令
    php编译安装php-5.6
    nginx编译安装
    apache通过AD验证
    apache编译安装 httpd 2.2 httpd 2.4
    DC 辅域转主域
    tomcat安装配置
  • 原文地址:https://www.cnblogs.com/goahead777/p/2784422.html
Copyright © 2011-2022 走看看