public static HttpActionContext WithBoundArguments(this HttpActionContext context) { var cancellationToken = new CancellationToken(); var binder = new DefaultActionValueBinder(); var binding = binder.GetBinding(context.ActionDescriptor); binding.ExecuteBindingAsync(context, cancellationToken).Wait(cancellationToken); return(context); }
/// <summary> /// Initializes a new instance of the <see cref="HttpConfiguration"/> class. /// </summary> /// <param name="routes">The <see cref="HttpRouteCollection"/> to associate with this instance.</param> public HttpConfiguration(HttpRouteCollection routes) { if (routes == null) { throw Error.ArgumentNull("routes"); } _routes = routes; Services = new DefaultServices(this); ParameterBindingRules = DefaultActionValueBinder.GetDefaultParameterBinders(); }
public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext) { bindingContext.ModelMetadata.AdditionalValues.Add(key, this); //this is the default webapi model binder provider var provider = new CompositeModelBinderProvider(actionContext.ControllerContext.Configuration.Services.GetModelBinderProviders()); //the default webapi model binder var binder = provider.GetBinder(actionContext.ControllerContext.Configuration, bindingContext.ModelType); var a = new DefaultActionValueBinder().GetBinding(actionContext.ActionDescriptor); a.ExecuteBindingAsync(actionContext, new System.Threading.CancellationToken()).Wait(); //let the default binder do it's thing var result = binder.BindModel(actionContext, bindingContext); bindingContext.ModelMetadata.AdditionalValues.Remove(key); return(result); }