Пример #1
0
        internal override HttpContent Bindbody(RequestCreContext requestCreContext)
        {
            List <KeyValuePair <String, String> > keyValues = new List <KeyValuePair <String, String> >();

            if (this.parameterWraps.Count == 0)
            {
            }
            this.parameterWraps.ForEach(x =>
            {
                string valueStr;
                if (TypeReflector.IsComplextClass(x.Parameter.ParameterType))
                {
                    List <KeyValuePair <string, object> > valuePairs =
                        DeconstructUtil.Deconstruct(requestCreContext.ParameterValues.Value[x.Parameter.Position]);
                    valuePairs.ForEach(kp =>
                    {
                        valueStr = x.Serial(kp.Value);
                        keyValues.Add(new KeyValuePair <string, string>(kp.Key, valueStr));
                    });
                }
                else
                {
                    valueStr = x.Serial(requestCreContext);
                    valueStr = valueStr ?? "";
                    keyValues.Add(new KeyValuePair <string, string>(x.DataName, valueStr));
                }
            });

            FormUrlEncodedContent formContent = new FormUrlEncodedContent(keyValues);

            return(formContent);
        }
Пример #2
0
        public void Test1()
        {
            List <KeyValuePair <string, object> > values = DeconstructUtil.Deconstruct(new Student()
            {
                ID = 2, Name = "nnnnn", rank = 234
            });

            System.Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(values));
        }