예제 #1
0
        /// <summary>
        /// 根据类型初始化取值策略
        /// </summary>
        /// <param name="type"></param>
        private void InitStrategy(Type type)
        {
            //遍历策略缓存 查找符合类型的处理类
            foreach (GetRequestDataStrategy strategy in _strategyCache)
            {
                if (strategy.IsMatchType(type))
                {
                    this._strategy = strategy;
                    break;
                }
            }

            if (_strategy == null)
            {
                //如果没有得到策略 则报错
                throw new Exception("处理请求参数的策略没有找到!");
            }
        }
예제 #2
0
        /// <summary>
        /// 根据类型初始化取值策略
        /// </summary>
        /// <param name="type"></param>
        private void InitStrategy(Type type)
        {
            //遍历策略缓存 查找符合类型的处理类
            foreach(GetRequestDataStrategy strategy in _strategyCache)
            {
                if (strategy.IsMatchType(type))
                {
                    this._strategy = strategy;
                    break;
                }
            }

             if (_strategy == null)
            {
                //如果没有得到策略 则报错
                throw new Exception("处理请求参数的策略没有找到!");
            }
        }