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.泛型类的对象创建

  • 相关阅读:
    解决Xcode 7编译错误:does not contain bitcode
    iOS无处不在详解iOS集成第三方登录(SSO授权登录无需密码)
    iOS- 如何集成支付宝
    99.Recover Binary Search Tree
    101.Symmetric Tree
    108.Convert Sorted Array to Binary Search Tree
    242.Valid Anagram
    292.Nim Game
    872.Leaf-Similar Trees
    HDU-1390 Binary Numbers
  • 原文地址:https://www.cnblogs.com/kfarvid/p/1836026.html
Copyright © 2011-2022 走看看