예제 #1
0
        /// <summary>
        /// 追加 Json 对象到 Http 参数
        /// </summary>
        /// <param name="param"> 参数将被追加到的参数集合 </param>
        /// <param name="json"> 需要解析的 Json 字符串 </param>
        public static void AddJson(this HttpParamsBase <object> param, string json)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(json))
            {
                return;
            }

            var dict = (Dictionary <string, object>)ComponentServices.ToJsonObject(typeof(Dictionary <string, object>), json);

            foreach (var item in dict)
            {
                param[item.Key] = item.Value;
            }
        }
예제 #2
0
        /// <summary>
        /// 追加实体对象到 Http 参数
        /// </summary>
        /// <param name="param"> 参数将被追加到的参数集合 </param>
        /// <param name="model"> 需要追加到 Http 参数的实体对象 </param>
        public static void AddModel(this HttpParamsBase <object> param, object model)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (model == null)
            {
                return;
            }
            var props = PropertyHandlerCollection.Get(model.GetType());

            for (int i = 0, length = props.Count; i < length; i++)
            {
                var p = props[i];
                param[p.Name] = p.GetValue(model);
            }
        }
예제 #3
0
        /// <summary>
        /// 追加 Url 查询参数字符串到 Http 参数
        /// </summary>
        /// <param name="param"> 参数将被追加到的参数集合 </param>
        /// <param name="query"> 需要解析的 Url 查询参数字符串 </param>
        public static void AddQuery(this HttpParamsBase <object> param, string query)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(query))
            {
                return;
            }
            var nv = HttpUtility.ParseQueryString(query);

            for (int i = 0, length = nv.Count; i < length; i++)
            {
                var key = nv.GetKey(i);
                var val = nv[i];
                param[key] = val;
            }
        }
예제 #4
0
        /// <summary>
        /// 追加 Json 对象到 Http 参数
        /// </summary>
        /// <param name="param"> 参数将被追加到的参数集合 </param>
        /// <param name="json"> 需要解析的 Json 字符串 </param>
        public static void AddJson(this HttpParamsBase <string> param, string json)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(json))
            {
                return;
            }

            var nv = (NameValueCollection)ComponentServices.ToJsonObject(typeof(NameValueCollection), json);

            for (int i = 0, length = nv.Count; i < length; i++)
            {
                var key = nv.GetKey(i);
                var val = nv[i];
                param[key] = val;
            }
        }
예제 #5
0
 public InnerDictionary(HttpParamsBase <T> @params)
 {
     _params = @params;
 }