zoukankan      html  css  js  c++  java
  • ConfigurationElementCollection.ElementName详解

    ConfigurationElementCollection.ElementName属性在MSDN的解释是这样:

    Gets the name used to identify this collection of elements in the configuration file when overridden in a derived class.

    获取在派生的类中重写时用于标识配置文件中此元素集合的名称。

    接着没有任何代码示例……根本看不懂了啊!!!

    后经过研究发现功能类似ConfigurationElementCollection.AddElementName属性(这个得在ConfigurationCollectionAttribute中设置),只不过他是只针对BasicMap和BasicMapAlternate的。从名字上也可以看出来:AddElementName,RemoveElementName和ClearElementName是为AddRemoveClearMap服务的。

    比如:下面这个简单的不能再简单的ConfigurationElementCollection类的代码:


    由于设置了AddElementName,因此在配置文件上我们可以这样写:


    输出:23和34

    此时ConfigurationElementCollection的类型是默认的AddRemoveClearMap,可当ConfigurationElementCollection的类型被改成BasicMap或BasicMapAlternate后,AddElementName就不好使了,会有异常抛出(无法识别的元素'ele')。

    此时不用设置AddElementName,直接改写ElementName属性就可以了。




  • 相关阅读:
    VBS获取系统路径
    悟透LoadRunner 如何让多个场景顺序执行?
    Python天天美味(7) 连接字符串(join %)
    Python天天美味(5) ljust rjust center
    悟透LoadRunner 调用外部DLL的点点滴滴
    Python天天美味(2) 字符遍历的艺术
    2008到了!我的博客由原来的DeViL→Ivy改名为EverGreen!
    Python天天美味(1) 交换变量
    分享Silverlight/WPF/Windows Phone一周学习导读(10月1日10月15日)
    分享Silverlight/WPF/Windows Phone一周学习导读(08月01日08月06日)
  • 原文地址:https://www.cnblogs.com/wmlunge/p/2299268.html
Copyright © 2011-2022 走看看