aspnetcore/src/Microsoft.AspNet.Mvc.Core/MvcOptions.cs

114 lines
4.5 KiB
C#

// 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.Core;
using Microsoft.AspNet.Mvc.OptionDescriptors;
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
namespace Microsoft.AspNet.Mvc
{
/// <summary>
/// Provides programmatic configuration for the MVC framework.
/// </summary>
public class MvcOptions
{
private AntiForgeryOptions _antiForgeryOptions = new AntiForgeryOptions();
private RazorViewEngineOptions _viewEngineOptions = new RazorViewEngineOptions();
public MvcOptions()
{
ApplicationModelConventions = new List<IReflectedApplicationModelConvention>();
ModelBinders = new List<ModelBinderDescriptor>();
ViewEngines = new List<ViewEngineDescriptor>();
ValueProviderFactories = new List<ValueProviderFactoryDescriptor>();
OutputFormatters = new List<OutputFormatterDescriptor>();
InputFormatters = new List<InputFormatterDescriptor>();
}
/// <summary>
/// Provides programmatic configuration for the anti-forgery token system.
/// </summary>
public AntiForgeryOptions AntiForgeryOptions
{
get
{
return _antiForgeryOptions;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value",
Resources.FormatPropertyOfTypeCannotBeNull("AntiForgeryOptions",
typeof(MvcOptions)));
}
_antiForgeryOptions = value;
}
}
/// <summary>
/// Get a list of the <see cref="OutputFormatterDescriptor" /> which are used to construct
/// a list of <see cref="IOutputFormatter"/> by <see cref="IOutputFormattersProvider"/>.
/// </summary>
public List<OutputFormatterDescriptor> OutputFormatters { get; private set; }
/// <summary>
/// Get a list of the <see cref="InputFormatterDescriptor" /> which are used to construct
/// a list of <see cref="IInputFormatter"/> by <see cref="IInputFormattersProvider"/>.
/// </summary>
public List<InputFormatterDescriptor> InputFormatters { get; private set; }
/// <summary>
/// Provides programmatic configuration for the default <see cref="Rendering.IViewEngine" />.
/// </summary>
public RazorViewEngineOptions ViewEngineOptions
{
get
{
return _viewEngineOptions;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value",
Resources.FormatPropertyOfTypeCannotBeNull("ViewEngineOptions",
typeof(MvcOptions)));
}
_viewEngineOptions = value;
}
}
/// <summary>
/// Get a list of the <see cref="ModelBinderDescriptor" /> used by the
/// <see cref="ModelBinding.CompositeModelBinder" />.
/// </summary>
public List<ModelBinderDescriptor> ModelBinders { get; private set; }
/// <summary>
/// Get a list of the <see cref="IModelValidatorProvider" />s used by this application.
/// </summary>
public List<ModelValidatorProviderDescriptor> ModelValidatorProviders { get; } =
new List<ModelValidatorProviderDescriptor>();
/// <summary>
/// Gets a list of descriptors that represent <see cref="Rendering.IViewEngine"/> used
/// by this application.
/// </summary>
public List<ViewEngineDescriptor> ViewEngines { get; private set; }
/// <summary>
/// Gets a list of descriptors that represent
/// <see cref="ModelBinding.IValueProviderFactory"/> used by this application.
/// </summary>
public List<ValueProviderFactoryDescriptor> ValueProviderFactories { get; private set; }
public List<IReflectedApplicationModelConvention> ApplicationModelConventions { get; private set; }
}
}