// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Mvc.ApplicationModels;
using Microsoft.AspNet.Mvc.Core;
using Microsoft.AspNet.Mvc.OptionDescriptors;
namespace Microsoft.AspNet.Mvc
{
///
/// Provides programmatic configuration for the MVC framework.
///
public class MvcOptions
{
private AntiForgeryOptions _antiForgeryOptions = new AntiForgeryOptions();
private int _maxModelStateErrors = 200;
public MvcOptions()
{
ApplicationModelConventions = new List();
ModelBinders = new List();
ViewEngines = new List();
ValueProviderFactories = new List();
OutputFormatters = new List();
InputFormatters = new List();
Filters = new List();
}
///
/// Provides programmatic configuration for the anti-forgery token system.
///
public AntiForgeryOptions AntiForgeryOptions
{
get
{
return _antiForgeryOptions;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value",
Resources.FormatPropertyOfTypeCannotBeNull("AntiForgeryOptions",
typeof(MvcOptions)));
}
_antiForgeryOptions = value;
}
}
///
/// Gets a list of which are used to construct filters that
/// apply to all actions.
///
public ICollection Filters { get; private set; }
///
/// Gets a list of the which are used to construct
/// a list of by .
///
public List OutputFormatters { get; private set; }
///
/// Gets a list of the which are used to construct
/// a list of by .
///
public List InputFormatters { get; private set; }
///
/// Gets a list of which are used to construct a list
/// of exclude filters by ,
///
public List ValidationExcludeFilters { get; }
= new List();
///
/// Gets or sets the maximum number of validation errors that are allowed by this application before further
/// errors are ignored.
///
public int MaxModelValidationErrors
{
get { return _maxModelStateErrors; }
set
{
if (value < 0)
{
throw new ArgumentOutOfRangeException(nameof(value));
}
_maxModelStateErrors = value;
}
}
///
/// Get a list of the used by the
/// Gets a list of the used by the
/// .
///
public List ModelBinders { get; private set; }
///
/// Gets a list of the s used by
/// .
///
public List ModelValidatorProviders { get; }
= new List();
///
/// Gets a list of descriptors that represent used
/// by this application.
///
public List ViewEngines { get; private set; }
///
/// Gets a list of descriptors that represent
/// used by this application.
///
public List ValueProviderFactories { get; private set; }
///
/// Gets a list of instances that will be applied to
/// the when discovering actions.
///
public List ApplicationModelConventions { get; private set; }
}
}