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

  • 相关阅读:
    MySQL高可用之MHA的搭建
    MySQL MGR 集群搭建(单主模式&多主模式)
    ansible-playbook定义变量与使用
    linux LVM逻辑卷管理
    Oracle 19C RAC 静默(silent)安装on RHEL7.x
    Python语言基础02-变量和运算
    Python之路,Day6
    Python 之路 Day5
    Python之路,Day4
    Python之路,Day3
  • 原文地址:https://www.cnblogs.com/kfarvid/p/1836026.html
Copyright © 2020-2023  润新知