您的位置:首页 > 编程语言 > Java开发

spring.net泛型的配置以及使用方法

2011-09-08 16:47 441 查看
下面是泛型的类定义:

using System.Collections.Generic;
using System;

namespace piggyWinFormTemplet
public class SpringGenericTest <T>
{
private List<T> list;

private String name;

public List<T> Contents
{
get { return list; }
set { list = value; }
}

public String TypeName
{
get
{
Type type = typeof(T);
return type.Name;
}
}

public String Name
{
get { return name; }
set { name = value; }
}

public List<T> ApplyFilter(String filterExpression)
{
/// should really apply filter to list ;)
return new List<T>();
}
}
在配置中是这样配置的:

<object id="springGenericTest" type="piggyWinFormTemplet.SpringGenericTest<int>, piggyWinForm">
<property name="Name" value="My Integer List"/>
</object>
调用的方法:

//spring.net泛型测试
SpringGenericTest<int> myGenericTest=(SpringGenericTest<int>)SpringTool.Context.GetObject("springGenericTest");
LogTool.Log.Error("spring.net泛型测试结果:" + myGenericTest.TypeName);


参考资料:4.2.4.泛型类的对象创建

原创作品出自努力偷懒,转载请说明文章出处:http://blog.csdn.net/kfarvidhttp://www.cnblogs.com/kfarvid/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐