zoukankan      html  css  js  c++  java
  • .config 自定义配置节 【转载】

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <configSections>    
        <section name="EncryptionMethod"  type="System.Configuration.DictionarySectionHandler, System,  Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" restartOnExternalChanges="false" />   <!--此处配置信息注意写全-->

        <section name="Mod"  type="System.Configuration.DictionarySectionHandler, System,  Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" restartOnExternalChanges="false" />  <!--此处配置信息注意写全-->
        
        <sectionGroup name="mySectionGroup"> <!--多了组的概念-->
          <section name="mySection" type="System.Configuration.NameValueSectionHandler" />         
        </sectionGroup>

     </configSections>

      <EncryptionMethod>
          <add key="Decrypt" value = "0"/>
          <add key="Encrypt" value = "1"/>
      </EncryptionMethod>

      <Mod>
        <add key="a" value = "0"/>
        <add key="b" value = "1"/>    
      </Mod>

      <mySectionGroup>
        <mySection>
          <add key="c" value = "0"/>
          <add key="d" value = "1"/>
        </mySection>    
      </mySectionGroup>

    </configuration>


        //使用 NameValueSectionHandler 或 DictionarySectionHandler 类的自定义配置节定义设置
        //NameValueCollection 的读取
        NameValueCollection config = (NameValueCollection)ConfigurationManager.GetSection("mySectionGroup/mySection");
        //DictionarySectionHandler 的读取 
        IDictionary dict = ConfigurationManager.GetSection("EncryptionMethod") as IDictionary;
    DictionarySectionHandler的工作方式与NameValueFileSectionHandler几乎相同,其区别是DictionarySectionHandler返回HashTable对象,而不是Object。
  • 相关阅读:
    php 服务器部署 500错误
    myeclipse 安装phpeclipse插件
    mysql修改引擎
    linux ftp命令
    jquery datepicker使用
    写一个函数代替php自带的include_once
    mysql 数据类型
    jquery option:last各浏览器支持不是很好
    html编辑器 学习
    今天去康盛面试,好歹我也工作3年了,还说我是初级选手,KAO
  • 原文地址:https://www.cnblogs.com/haibin168/p/2032126.html
Copyright © 2011-2022 走看看