コード例 #1
0
 public override bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
 {
     BindModelOnSuccessOrFail(bindingContext,
                              () => ModelBinderUtils.CreateArgumentMap(DeserializeJsonContent(actionContext)),
                              ModelBinderUtils.CreateArgumentMapForMalformedArgs);
     return(true);
 }
コード例 #2
0
 public override bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
 {
     BindModelOnSuccessOrFail(bindingContext,
                              () => ModelBinderUtils.CreateReservedArguments(actionContext.Request.RequestUri.Query),
                              ModelBinderUtils.CreateReservedArgumentsForMalformedArgs);
     return(true);
 }
コード例 #3
0
 public override bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
 {
     BindModelOnSuccessOrFail(bindingContext,
                              () => ModelBinderUtils.CreateSingleValueArgument(DeserializeQueryString(actionContext)),
                              ModelBinderUtils.CreateSingleValueArgumentForMalformedArgs);
     return(true);
 }
コード例 #4
0
 public override bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
 {
     BindModelOnSuccessOrFail(bindingContext,
                              () => ModelBinderUtils.CreateSimpleArgumentMap(actionContext.Request.RequestUri.Query) ??
                              ModelBinderUtils.CreateArgumentMap(DeserializeQueryString(actionContext)),
                              ModelBinderUtils.CreateArgumentMapForMalformedArgs);
     return(true);
 }
コード例 #5
0
 private static Task BindFromQuery(ModelBindingContext bindingContext) =>
 ModelBinderUtils.BindModelOnSuccessOrFail(bindingContext,
                                           async() => ModelBinderUtils.CreateSingleValueArgument(await ModelBinderUtils.DeserializeQueryString(bindingContext), false),
                                           ModelBinderUtils.CreateMalformedArguments <SingleValueArgument>);
コード例 #6
0
 public Task BindModelAsync(ModelBindingContext bindingContext) =>
 ModelBinderUtils.BindModelOnSuccessOrFail(bindingContext,
                                           async() => ModelBinderUtils.CreatePromptArgMap(await ModelBinderUtils.DeserializeJsonContent(bindingContext), true),
                                           ModelBinderUtils.CreateMalformedArguments <PromptArgumentMap>);
コード例 #7
0
 private static Task BindFromQuery(ModelBindingContext bindingContext) =>
 ModelBinderUtils.BindModelOnSuccessOrFail(bindingContext,
                                           async() => ModelBinderUtils.CreateSimpleArgumentMap(bindingContext.HttpContext.Request.QueryString.ToString()) ??
                                           ModelBinderUtils.CreateArgumentMap(await ModelBinderUtils.DeserializeQueryString(bindingContext), true),
                                           ModelBinderUtils.CreateMalformedArguments <ArgumentMap>);
コード例 #8
0
 private static Task BindFromBody(ModelBindingContext bindingContext) =>
 ModelBinderUtils.BindModelOnSuccessOrFail(bindingContext,
                                           async() => ModelBinderUtils.CreateArgumentMap(await ModelBinderUtils.DeserializeJsonContent(bindingContext), true),
                                           ModelBinderUtils.CreateMalformedArguments <ArgumentMap>);
コード例 #9
0
 protected static JObject DeserializeQueryString(HttpActionContext actionContext)
 {
     using (Stream stream = ModelBinderUtils.QueryStringToStream(actionContext.Request.RequestUri.Query)) {
         return(ModelBinderUtils.DeserializeJsonStream(stream));
     }
 }
コード例 #10
0
        protected static JObject DeserializeJsonContent(HttpActionContext actionContext)
        {
            Stream stream = actionContext.Request.Content.ReadAsStreamAsync().Result;

            return(ModelBinderUtils.DeserializeJsonStream(stream));
        }