• 配置节处理程序声明


    <configSections>
    <section name="ApplicationConfiguration" type="Duwamish7.SystemFramework.ApplicationConfiguration, Duwamish7.SystemFramework" />
    <section name="DuwamishConfiguration" type="Duwamish7.Common.DuwamishConfiguration, Duwamish7.Common" />
    </configSections>

             配置节处理程序声明(Section),必须出现在配置文件顶部 <configSections> 和 </configSections> 标记之间,在这里,它们只用到了name和type属性,其中,name属性定义了指定配置节的名称,而type属性则规定了指定从配置文件中读取节的配置节处理程序类的名称,有两个部分,前面为处理程序的类名,后面为Assembly名(Assembly必须位于bin目录中)以及版本号,公匙等信息

            按照上述配置节信息可以知道:Duwamish7.SystemFramework.ApplicationConfiguration和Duwamish7.Common.DuwamishConfiguration,他们分别位于SystemFramework和Common项目中

           .net规定,所有能够处理配置节的类必须要实现IConfigurationSectionHandler接口,而IConfigurationSectionHandler接口很简单,只有一个object Create(object parent,object configContext,XmlNode section)方法,这个方法不需要主动调用,它是在ConfigurationSettings.GetConfig这个静态方法的时候自动调用的,也就是说,当你在程序中使用ConfigurationSettings.GetConfig来获取配置节的时候,.net会根据改配置节声明中所定义的类名和路径自动实例化配置节处理类,并调用Create方法

           
    使用:System.Configuration.ConfigurationSettings.GetConfig("ApplicationConfiguration");

     
  • 相关阅读:
    OA系统
    高考
    眼压高
    国家职业资格目录,即“专业技术人员职业资格项目”和“技能人员职业资格项目”,介绍
    hexo 添加图床
    《漂向北方》Namewee
    mysql主从架构
    【20220621】稻花香
    【20220614】生活目标变了
    【20220615】连岳摘抄
  • 原文地址:https://www.cnblogs.com/xiang/p/583705.html
Copyright © 2020-2023  润新知