// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http.Controllers;
using System.Web.Http.Metadata;
using System.Web.Http.Validation;
namespace System.Web.Http.ModelBinding
{
///
/// Parameter binding that will read from the body and invoke the formatters.
///
public class FormatterParameterBinding : HttpParameterBinding
{
private IEnumerable _formatters;
public FormatterParameterBinding(HttpParameterDescriptor descriptor, IEnumerable formatters, IBodyModelValidator bodyModelValidator)
: base(descriptor)
{
Formatters = formatters;
BodyModelValidator = bodyModelValidator;
}
public override bool WillReadBody
{
get { return true; }
}
public IEnumerable Formatters
{
get { return _formatters; }
set
{
if (value == null)
{
throw Error.ArgumentNull("formatters");
}
_formatters = value;
}
}
public IBodyModelValidator BodyModelValidator
{
get;
set;
}
protected virtual Task