Class HttpParameterBinding
- Namespace
- System.Web.Http.Controllers
- Assembly
- System.Web.Http.dll
Describes how a parameter is bound. The binding should be static (based purely on the descriptor) and can be shared across requests.
public abstract class HttpParameterBinding
- Inheritance
-
HttpParameterBinding
- Derived
- Inherited Members
Constructors
HttpParameterBinding(HttpParameterDescriptor)
Initializes a new instance of the HttpParameterBinding class.
protected HttpParameterBinding(HttpParameterDescriptor descriptor)
Parameters
descriptor
HttpParameterDescriptorAn HttpParameterDescriptor that describes the parameters.
Properties
Descriptor
Gets the HttpParameterDescriptor that was used to initialize this instance.
public HttpParameterDescriptor Descriptor { get; }
Property Value
- HttpParameterDescriptor
The HttpParameterDescriptor instance.
ErrorMessage
If the binding is invalid, gets an error message that describes the binding error.
public virtual string ErrorMessage { get; }
Property Value
- string
An error message. If the binding was successful, the value is null.
IsValid
Gets a value that indicates whether the binding was successful.
public bool IsValid { get; }
Property Value
- bool
true if the binding was successful; otherwise, false.
WillReadBody
Returns a value indicating whether this HttpParameterBinding instance will read the entity body of the HTTP message.
public virtual bool WillReadBody { get; }
Property Value
- bool
true if this HttpParameterBinding will read the entity body; otherwise, false.
Methods
ExecuteBindingAsync(ModelMetadataProvider, HttpActionContext, CancellationToken)
Asynchronously executes the binding for the given request.
public abstract Task ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancellationToken)
Parameters
metadataProvider
ModelMetadataProviderMetadata provider to use for validation.
actionContext
HttpActionContextThe action context for the binding. The action context contains the parameter dictionary that will get populated with the parameter.
cancellationToken
CancellationTokenCancellation token for cancelling the binding operation.
Returns
- Task
A task object representing the asynchronous operation.
GetValue(HttpActionContext)
Gets the parameter value from argument dictionary of the action context.
protected object GetValue(HttpActionContext actionContext)
Parameters
actionContext
HttpActionContextThe action context.
Returns
- object
The value for this parameter in the given action context, or null if the parameter has not yet been set.
SetValue(HttpActionContext, object)
Sets the result of this parameter binding in the argument dictionary of the action context.
protected void SetValue(HttpActionContext actionContext, object value)
Parameters
actionContext
HttpActionContextThe action context.
value
objectThe parameter value.