zoukankan      html  css  js  c++  java
  • spring.net泛型的配置以及使用方法

    下面是泛型的类定义:
    代码
    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&lt;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.泛型类的对象创建

  • 相关阅读:
    统计中的精度和召回率的解释
    人工智能在医疗行业中的应用
    解决Myeclipse在调试(debug)时无法显示变量值问题(转载)
    溢出的问题
    返回引用和对象遇到的坑
    vmWare上网配置(转载)
    linux内核相关的术语(转载)
    一个死锁问题
    Ethernet,token ring,FDDI,ATM,WLAN(转载)
    kmalloc与vmalloc
  • 原文地址:https://www.cnblogs.com/kfarvid/p/1836026.html
Copyright © 2011-2022 走看看