//定义

public static Dictionary<string, object> dict =new Dictionary<string, object>();

//主方法

public void Test()

        {
          
            IList<Entity> kpi = new List<Entity>();           
            string key="kpi";
            AddPriviledge(key, kpi);
           
            
            IList<Entity> kpiResult = GetData<Entity>("kpi");

}

public void AddData<T>(string key,T value)
        {
            //验证如果已经存在,则覆盖
            if (dict.ContainsKey(key))
            {
                dict[key] = value;
            }
            else 
            {
                //否则新增
                dict.Add(key, value);
            }
            
        }

public IList<T> GetData<T>(string key)
        {
            return (IList<T>)dict[key];                              
        }

 
例子别介意
05-11 11:21