예제 #1
0
        public override async Task <object> BindModelAsync(HttpBindingContext httpBindingContext)
        {
            var model   = Activator.CreateInstance(httpBindingContext.TargetType);
            var content = await httpBindingContext.Request.Content.ReadAsStringAsync();

            var pairs = content.Split('&');

            foreach (var pair in pairs)
            {
                var kv = pair.Split('=');

                var property =
                    httpBindingContext.TargetType.GetProperty(kv[0], BindingFlags.Instance | BindingFlags.Public);

                if (property == null)
                {
                    continue;
                }

                property.SetValue(model, kv[1]);
            }

            return(model);
        }
예제 #2
0
 public abstract Task <object> BindModelAsync(HttpBindingContext httpBindingContext);