在泛型类中写一个Dictionary属性,用来接收附加参数

protected IDictionary<string, object> _outputValues = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);



        /// <summary>

        /// 附加参数

        /// </summary>

        public IDictionary<string, object> OutputValues

        {

            get

            {

                return _outputValues;

            }

        }



        /// <summary>

        /// 获取返回值的附加参数

        /// </summary>

        /// <param name="key"></param>

        /// <returns></returns>

        public TM GetOutputValue<TM>(string key)

        {

            TM temp = default(TM);

            if (!OutputValues.IsNullOrEmpty() && OutputValues.ContainsKey(key))

            {

                temp = (TM)OutputValues[key];

            }

            return temp;

        }



        /// <summary>

        /// 设置返回值的附加参数

        /// </summary>

        /// <param name="key"></param>

        /// <param name="value"></param>

        public void SetOutputValue<TM>(string key, TM value)

        {

            OutputValues[key] = value;

        }

 

你可能感兴趣的:(泛型类)