zoukankan      html  css  js  c++  java
  • 实现IConfigurationSectionHandler来获取自定义配置结构

    一 创建类AddinSectionHandler ,实现IConfigurationSectionHandler接口的Create方法
       public  class AddinSectionHandler : IConfigurationSectionHandler {
           
    IConfigurationSectionHandler 成员
       }

    二 增加一个这样的类

      public class AddinConfigItem {

            
    private string _addInClass;
            
    /// <summary>
            
    /// 添加服务类名称
            
    /// </summary>

            public string AddInClass {
                
    get return _addInClass; }
                
    set { _addInClass = value; }
            }


            
    private string _dllFile;
            
    /// <summary>
            
    /// 添加服务数据集名称
            
    /// </summary>

            public string DllFile {
                
    get return _dllFile; }
                
    set { _dllFile = value; }
            }


        }


    三 App.config中配置
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <section name="ServerAssemblys" type="ConfigLoad.AddinSectionHandler,ConfigLoad"/>
      </configSections>
      <ServerAssemblys>
        <Assembly dllFile="111.dll" addinClass="aaa" />
        <Assembly dllFile="222.dll" addinClass="bbb" />
      </ServerAssemblys>
    </configuration>


    四 程序调用
     class Program {
            
    static void Main(string[] args) {
              
                
    //读取XML中服务节点的内容
                List<AddinConfigItem> lists = ConfigurationManager.GetSection("ServerAssemblys"as List<AddinConfigItem>;
                
    //加裁所有服务 
                foreach (AddinConfigItem item in lists) {

                }

            }

        }

    源码
  • 相关阅读:
    Android中Context具体解释 ---- 你所不知道的Context
    JDK6、Oracle11g、Weblogic10 For Linux64Bit安装部署说明
    matplotlib 可视化 —— 定制 matplotlib
    matplotlib 可视化 —— 移动坐标轴(中心位置)
    matplotlib 可视化 —— 移动坐标轴(中心位置)
    matplotlib 可视化 —— 定制画布风格 Customizing plots with style sheets(plt.style)
    matplotlib 可视化 —— 定制画布风格 Customizing plots with style sheets(plt.style)
    指数函数的研究
    指数函数的研究
    指数分布的研究
  • 原文地址:https://www.cnblogs.com/qiba78/p/1228540.html
Copyright © 2011-2022 走看看