SPRING.NET 1.3.2 学习9--设置泛型集合的值
来源:互联网 发布:mac 图标大小不一样 编辑:程序博客网 时间:2024/04/30 06:12
下面举例,一个类中包含了一个泛型集合类型
public class LotteryTicket { List<int> list; DateTime date; public List<int> Numbers { set { list = value; } get { return list; } } public DateTime Date { get { return date; } set { date = value; } } }配置这个泛型集合
<object id="MyLotteryTicket" type="GenericsPlay.Lottery.LotteryTicket, GenericsPlay"> <property name="Numbers"> <list element-type="int"> <value>11</value> <value>21</value> <value>23</value> <value>34</value> <value>36</value> <value>38</value> </list> </property> <property name="Date" value="4/16/2006"/></object>下面是一个更复杂的例子
public class GenericExpressionHolder { private System.Collections.Generic.IList<IExpression> expressionsList; private System.Collections.Generic.IDictionary<string,IExpression> expressionsDictionary; public System.Collections.Generic.IList<IExpression> ExpressionsList { set { this.expressionsList = value; } } public System.Collections.Generic.IDictionary<string, IExpression> ExpressionsDictionary { set { this.expressionsDictionary = value; } } public IExpression this[int index] { get { return this.expressionsList[index]; } } public IExpression this[string key] { get { return this.expressionsDictionary[key]; } } }下面的XML配置文件使用了Spring.Expressions.IExpression,它用来协助类型转换,Spring.Objects.TypeConverters.ExpressionConverter已经预注册在Spring框架中,不用手动注册它
<object id="genericExpressionHolder" type="Spring.Objects.Factory.Xml.GenericExpressionHolder, Spring.Core.Tests"> <property name="ExpressionsList"> <list element-type="Spring.Expressions.IExpression, Spring.Core"> <value>1 + 1</value> <value>date('1856-7-9').Month</value> <value>'Nikola Tesla'.ToUpper()</value> <value>DateTime.Today > date('1856-7-9')</value> </list> </property> <property name="ExpressionsDictionary"> <dictionary key-type="string" value-type="Spring.Expressions.IExpression, Spring.Core"> <entry key="zero"> <value>1 + 1</value> </entry> <entry key="one"> <value>date('1856-7-9').Month</value> </entry> <entry key="two"> <value>'Nikola Tesla'.ToUpper()</value> </entry> <entry key="three"> <value>DateTime.Today > date('1856-7-9')</value> </entry> </dictionary> </property></object>
- SPRING.NET 1.3.2 学习9--设置泛型集合的值
- SPRING.NET 1.3.2 学习8--设置集合对象的值
- SPRING.NET 1.3.2 学习10--合并集合对象
- SPRING.NET 1.3.2 学习11--设置空值和Null值
- asp.net泛型集合学习
- Spring.NET学习笔记8——集合类型的注入(基础篇) Level 200
- Spring.NET学习笔记8——集合类型的注入(基础篇)
- Spring.NET学习笔记8——集合类型的注入(基础篇)
- Spring.NET学习笔记8——集合类型的注入(基础篇)
- Spring.NET学习笔记8——集合类型的注入(基础篇) Level 200
- SPRING.NET 1.3.2 学习25--自定义对象的行为
- SPRING.NET 1.3.2 学习21--使用对象或类的属性值进行注入
- SPRING.NET 1.3.2 学习23--使用方法的返回值进行注入
- Spring学习,集合类的自动注入
- SPRING.NET 1.3.2 学习14--复合属性名称和Spring表达式的引用
- Spring.net Framework 的学习
- .net学习资源集合
- .net学习资料集合
- 利用 spring+freemarker 发送邮件
- RCP项目_poi下载Excel
- c#使用ExifLib 提取图像的 EXIF信息
- android 横竖屏问题解析
- 百度地图自定义弹窗(PopupOverlay)Android篇
- SPRING.NET 1.3.2 学习9--设置泛型集合的值
- Uboot
- 获取随机数函数sand()的总结
- termios 系列函数分析
- 从AlertView例解设置view背景的几种方法
- windows 获取操作系统版本信息
- C,C++宏中#与##的讲解
- 获取ios系统中已安装程序(MobileInstallation方式)
- Android ListView 分页加载