zoukankan      html  css  js  c++  java
  • Spring.NET学习笔记8——集合类型的注入(基础篇) Level 200

      Spring.NET还支持集合类型的注入。而且使用起来也比较方便。

      一、ILIst类型
      使用<list>元素作为ILIst的标签,value为集合中元素的值。也可以注入对象,甚至关联其它对象,使用 <ref/>元素表示关联的对象,object 属性为所关联对象的idname。集合可以为空,用<null/>元素来标记。

      在<list>元素中设置 element-type 属性表示泛型T的类型,例如 element-type="int"  ,代表int型。

      

      二、IDictionary类型

      使用<dictionary>元素来表示IDictionary接口的实现类型。<entry/>表示IDictionary集合的元素。keyvalue属性为元素的键值队,value-ref为关联的元素。

      同理,<dictionary>元素key-typevalue-type属性来表示泛型IDictionary,例如 <dictionary key-type="string" value-type="object">

     

      完整代码如下:

    Domain
    App.config
    Program

      输入结果如下:

     代码下载

      返回目录

  • 相关阅读:
    LeetCode-380 Insert Delete GetRandom O(1)
    LeetCode-378 Kth Smallest Element in a Sorted Matrix
    LeetCode-373 Find K Pairs with Smallest Sums
    LeetCode-372 Super Pow
    LeetCode-365 Water and Jug Problem
    LeetCode-352 Data Stream as Disjoint Intervals
    LeetCode-347 Top K Frequent Elements
    LeetCode-341 Flatten Nested List Iterator
    LeetCode-337 House Robber III
    【问题】win10开机慢 底部任务栏出来慢
  • 原文地址:https://www.cnblogs.com/GoodHelper/p/SpringNet_List.html
Copyright © 2011-2022 走看看