Api cleanup (remove List and Dictionary in favor of IList and IDictionary)
from the public surface copy header values on registration. Make a copy of the mediatypeheader value in FormatterMappings so it's really immutable.
This commit is contained in:
parent
d2aa55893d
commit
bcbbc58515
|
|
@ -17,20 +17,20 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public virtual string Name { get; set; }
|
public virtual string Name { get; set; }
|
||||||
|
|
||||||
public List<RouteDataActionConstraint> RouteConstraints { get; set; }
|
public IList<RouteDataActionConstraint> RouteConstraints { get; set; }
|
||||||
|
|
||||||
public AttributeRouteInfo AttributeRouteInfo { get; set; }
|
public AttributeRouteInfo AttributeRouteInfo { get; set; }
|
||||||
|
|
||||||
public Dictionary<string, object> RouteValueDefaults { get; private set; }
|
public IDictionary<string, object> RouteValueDefaults { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The set of constraints for this action. Must all be satisfied for the action to be selected.
|
/// The set of constraints for this action. Must all be satisfied for the action to be selected.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<IActionConstraintMetadata> ActionConstraints { get; set; }
|
public IList<IActionConstraintMetadata> ActionConstraints { get; set; }
|
||||||
|
|
||||||
public List<ParameterDescriptor> Parameters { get; set; }
|
public IList<ParameterDescriptor> Parameters { get; set; }
|
||||||
|
|
||||||
public List<FilterDescriptor> FilterDescriptors { get; set; }
|
public IList<FilterDescriptor> FilterDescriptors { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A friendly name for this action.
|
/// A friendly name for this action.
|
||||||
|
|
@ -40,6 +40,6 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores arbitrary metadata properties associated with the <see cref="ActionDescriptor"/>.
|
/// Stores arbitrary metadata properties associated with the <see cref="ActionDescriptor"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IDictionary<object, object> Properties { get; private set; }
|
public IDictionary<object, object> Properties { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,6 @@ namespace Microsoft.AspNet.Mvc
|
||||||
Results = new List<ActionDescriptor>();
|
Results = new List<ActionDescriptor>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ActionDescriptor> Results { get; private set; }
|
public IList<ActionDescriptor> Results { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <param name="controllerModelConvention">The <see cref="IControllerModelConvention"/> which needs to be
|
/// <param name="controllerModelConvention">The <see cref="IControllerModelConvention"/> which needs to be
|
||||||
/// added.</param>
|
/// added.</param>
|
||||||
public static void Add(
|
public static void Add(
|
||||||
[NotNull] this List<IApplicationModelConvention> conventions,
|
[NotNull] this IList<IApplicationModelConvention> conventions,
|
||||||
[NotNull] IControllerModelConvention controllerModelConvention)
|
[NotNull] IControllerModelConvention controllerModelConvention)
|
||||||
{
|
{
|
||||||
conventions.Add(new ControllerApplicationModelConvention(controllerModelConvention));
|
conventions.Add(new ControllerApplicationModelConvention(controllerModelConvention));
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <param name="actionModelConvention">The <see cref="IActionModelConvention"/> which needs to be
|
/// <param name="actionModelConvention">The <see cref="IActionModelConvention"/> which needs to be
|
||||||
/// added.</param>
|
/// added.</param>
|
||||||
public static void Add(
|
public static void Add(
|
||||||
this List<IApplicationModelConvention> conventions,
|
this IList<IApplicationModelConvention> conventions,
|
||||||
IActionModelConvention actionModelConvention)
|
IActionModelConvention actionModelConvention)
|
||||||
{
|
{
|
||||||
conventions.Add(new ActionApplicationModelConvention(actionModelConvention));
|
conventions.Add(new ActionApplicationModelConvention(actionModelConvention));
|
||||||
|
|
|
||||||
|
|
@ -495,7 +495,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool HasConstraint(List<RouteDataActionConstraint> constraints, string routeKey)
|
private static bool HasConstraint(IList<RouteDataActionConstraint> constraints, string routeKey)
|
||||||
{
|
{
|
||||||
return constraints.Any(
|
return constraints.Any(
|
||||||
rc => string.Equals(rc.RouteKey, routeKey, StringComparison.OrdinalIgnoreCase));
|
rc => string.Equals(rc.RouteKey, routeKey, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,11 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public void Invoke(ActionDescriptorProviderContext context, Action callNext)
|
public void Invoke(ActionDescriptorProviderContext context, Action callNext)
|
||||||
{
|
{
|
||||||
context.Results.AddRange(GetDescriptors());
|
foreach (var descriptor in GetDescriptors())
|
||||||
|
{
|
||||||
|
context.Results.Add(descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
callNext();
|
callNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using Microsoft.AspNet.Mvc.Logging;
|
using Microsoft.AspNet.Mvc.Logging;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.Logging;
|
using Microsoft.Framework.Logging;
|
||||||
|
|
@ -60,7 +61,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ActionDescriptorsCollection(actionDescriptorProviderContext.Results, 0);
|
return new ActionDescriptorsCollection(
|
||||||
|
new ReadOnlyCollection<ActionDescriptor>(actionDescriptorProviderContext.Results), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Mvc.Description
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The list of <see cref="ApiParameterDescription"/> for this api.
|
/// The list of <see cref="ApiParameterDescription"/> for this api.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ApiParameterDescription> ParameterDescriptions { get; private set; }
|
public IList<ApiParameterDescription> ParameterDescriptions { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores arbitrary metadata properties associated with the <see cref="ApiDescription"/>.
|
/// Stores arbitrary metadata properties associated with the <see cref="ApiDescription"/>.
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,6 @@ namespace Microsoft.AspNet.Mvc.Description
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The list of resulting <see cref="ApiDescription"/>.
|
/// The list of resulting <see cref="ApiDescription"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ApiDescription> Results { get; private set; }
|
public IList<ApiDescription> Results { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -81,7 +81,11 @@ namespace Microsoft.AspNet.Mvc.Description
|
||||||
var templateParameters = parsedTemplate?.Parameters?.ToList() ?? new List<TemplatePart>();
|
var templateParameters = parsedTemplate?.Parameters?.ToList() ?? new List<TemplatePart>();
|
||||||
|
|
||||||
var parameterContext = new ApiParameterContext(_modelMetadataProvider, action, templateParameters);
|
var parameterContext = new ApiParameterContext(_modelMetadataProvider, action, templateParameters);
|
||||||
apiDescription.ParameterDescriptions.AddRange(GetParameters(parameterContext));
|
|
||||||
|
foreach (var parameter in GetParameters(parameterContext))
|
||||||
|
{
|
||||||
|
apiDescription.ParameterDescriptions.Add(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
var responseMetadataAttributes = GetResponseMetadataAttributes(action);
|
var responseMetadataAttributes = GetResponseMetadataAttributes(action);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public class FilterProviderContext
|
public class FilterProviderContext
|
||||||
{
|
{
|
||||||
public FilterProviderContext([NotNull] ActionContext actionContext, [NotNull] List<FilterItem> items)
|
public FilterProviderContext([NotNull] ActionContext actionContext, [NotNull] IList<FilterItem> items)
|
||||||
{
|
{
|
||||||
ActionContext = actionContext;
|
ActionContext = actionContext;
|
||||||
Results = items;
|
Results = items;
|
||||||
|
|
@ -17,6 +17,6 @@ namespace Microsoft.AspNet.Mvc
|
||||||
public ActionContext ActionContext { get; set; }
|
public ActionContext ActionContext { get; set; }
|
||||||
|
|
||||||
// Results
|
// Results
|
||||||
public List<FilterItem> Results { get; set; }
|
public IList<FilterItem> Results { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
ValidateContentType(contentType);
|
ValidateContentType(contentType);
|
||||||
format = RemovePeriodIfPresent(format);
|
format = RemovePeriodIfPresent(format);
|
||||||
_map[format] = contentType;
|
_map[format] = MediaTypeHeaderValue.Parse(contentType.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
MediaTypeHeaderValue value = null;
|
MediaTypeHeaderValue value = null;
|
||||||
_map.TryGetValue(format, out value);
|
_map.TryGetValue(format, out value);
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,10 +77,10 @@ namespace Microsoft.AspNet.Mvc
|
||||||
throw new ArgumentException(string.Format(Resources.Format_NotValid, format));
|
throw new ArgumentException(string.Format(Resources.Format_NotValid, format));
|
||||||
}
|
}
|
||||||
|
|
||||||
format = format.Substring(1);
|
format = format.Substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -11,10 +11,10 @@ namespace Microsoft.AspNet.Mvc.Internal.DecisionTree
|
||||||
{
|
{
|
||||||
// The list of matches for the current node. This represents a set of items that have had all
|
// The list of matches for the current node. This represents a set of items that have had all
|
||||||
// of their criteria matched if control gets to this point in the tree.
|
// of their criteria matched if control gets to this point in the tree.
|
||||||
public List<TItem> Matches { get; set; }
|
public IList<TItem> Matches { get; set; }
|
||||||
|
|
||||||
// Additional criteria that further branch out from this node. Walk these to fine more items
|
// Additional criteria that further branch out from this node. Walk these to fine more items
|
||||||
// matching the input data.
|
// matching the input data.
|
||||||
public List<DecisionCriterion<TItem>> Criteria { get; set; }
|
public IList<DecisionCriterion<TItem>> Criteria { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.Internal.Routing
|
||||||
new AttributeRouteLinkGenerationEntryClassifier());
|
new AttributeRouteLinkGenerationEntryClassifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LinkGenerationMatch> GetMatches(VirtualPathContext context)
|
public IList<LinkGenerationMatch> GetMatches(VirtualPathContext context)
|
||||||
{
|
{
|
||||||
var results = new List<LinkGenerationMatch>();
|
var results = new List<LinkGenerationMatch>();
|
||||||
Walk(results, context, _root, isFallbackPath: false);
|
Walk(results, context, _root, isFallbackPath: false);
|
||||||
|
|
|
||||||
|
|
@ -51,19 +51,19 @@ namespace Microsoft.AspNet.Mvc.Logging
|
||||||
/// The parameters of the action as <see cref="ParameterDescriptorValues"/>.
|
/// The parameters of the action as <see cref="ParameterDescriptorValues"/>.
|
||||||
/// See <see cref="ActionDescriptor.Parameters"/>.
|
/// See <see cref="ActionDescriptor.Parameters"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ParameterDescriptorValues> Parameters { get; }
|
public IList<ParameterDescriptorValues> Parameters { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The filters of the action as <see cref="FilterDescriptorValues"/>.
|
/// The filters of the action as <see cref="FilterDescriptorValues"/>.
|
||||||
/// See <see cref="ActionDescriptor.FilterDescriptors"/>.
|
/// See <see cref="ActionDescriptor.FilterDescriptors"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<FilterDescriptorValues> FilterDescriptors { get; }
|
public IList<FilterDescriptorValues> FilterDescriptors { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The route constraints of the action as <see cref="RouteDataActionConstraintValues"/>.
|
/// The route constraints of the action as <see cref="RouteDataActionConstraintValues"/>.
|
||||||
/// See <see cref="ActionDescriptor.RouteConstraints"/>
|
/// See <see cref="ActionDescriptor.RouteConstraints"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<RouteDataActionConstraintValues> RouteConstraints { get; }
|
public IList<RouteDataActionConstraintValues> RouteConstraints { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The attribute route info of the action as <see cref="AttributeRouteInfoValues"/>.
|
/// The attribute route info of the action as <see cref="AttributeRouteInfoValues"/>.
|
||||||
|
|
@ -74,23 +74,23 @@ namespace Microsoft.AspNet.Mvc.Logging
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// See <see cref="ActionDescriptor.RouteValueDefaults"/>.
|
/// See <see cref="ActionDescriptor.RouteValueDefaults"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, string> RouteValueDefaults { get; }
|
public IDictionary<string, string> RouteValueDefaults { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The action constraints of the action as <see cref="ActionConstraintValues"/>.
|
/// The action constraints of the action as <see cref="ActionConstraintValues"/>.
|
||||||
/// See <see cref="ActionDescriptor.ActionConstraints"/>.
|
/// See <see cref="ActionDescriptor.ActionConstraints"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ActionConstraintValues> ActionConstraints { get; }
|
public IList<ActionConstraintValues> ActionConstraints { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The http methods this action supports.
|
/// The http methods this action supports.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> HttpMethods { get; }
|
public IList<string> HttpMethods { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// See <see cref="ActionDescriptor.Properties"/>.
|
/// See <see cref="ActionDescriptor.Properties"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, Type> Properties { get; }
|
public IDictionary<string, Type> Properties { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The method info of the action if this is a <see cref="ControllerActionDescriptor"/>.
|
/// The method info of the action if this is a <see cref="ControllerActionDescriptor"/>.
|
||||||
|
|
|
||||||
|
|
@ -52,37 +52,37 @@ namespace Microsoft.AspNet.Mvc.Logging
|
||||||
/// The actions of the controller as <see cref="ActionModelValues"/>.
|
/// The actions of the controller as <see cref="ActionModelValues"/>.
|
||||||
/// See <see cref="ControllerModel.Actions"/>.
|
/// See <see cref="ControllerModel.Actions"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ActionModelValues> Actions { get; }
|
public IList<ActionModelValues> Actions { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="Type"/>s of the controller's attributes.
|
/// The <see cref="Type"/>s of the controller's attributes.
|
||||||
/// See <see cref="ControllerModel.Attributes"/>.
|
/// See <see cref="ControllerModel.Attributes"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<Type> Attributes { get; }
|
public IList<Type> Attributes { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The filters on the controller as <see cref="FilterValues"/>.
|
/// The filters on the controller as <see cref="FilterValues"/>.
|
||||||
/// See <see cref="ControllerModel.Filters"/>.
|
/// See <see cref="ControllerModel.Filters"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<FilterValues> Filters { get; }
|
public IList<FilterValues> Filters { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The action constraints on the controller as <see cref="ActionConstraintValues"/>.
|
/// The action constraints on the controller as <see cref="ActionConstraintValues"/>.
|
||||||
/// See <see cref="ControllerModel.ActionConstraints"/>.
|
/// See <see cref="ControllerModel.ActionConstraints"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ActionConstraintValues> ActionConstraints { get; }
|
public IList<ActionConstraintValues> ActionConstraints { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The route constraints on the controller as <see cref="RouteConstraintProviderValues"/>.
|
/// The route constraints on the controller as <see cref="RouteConstraintProviderValues"/>.
|
||||||
/// See <see cref="ControllerModel.RouteConstraints"/>.
|
/// See <see cref="ControllerModel.RouteConstraints"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<RouteConstraintProviderValues> RouteConstraints { get; set; }
|
public IList<RouteConstraintProviderValues> RouteConstraints { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The attribute routes on the controller as <see cref="AttributeRouteModelValues"/>.
|
/// The attribute routes on the controller as <see cref="AttributeRouteModelValues"/>.
|
||||||
/// See <see cref="ControllerModel.AttributeRoutes"/>.
|
/// See <see cref="ControllerModel.AttributeRoutes"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<AttributeRouteModelValues> AttributeRoutes { get; set; }
|
public IList<AttributeRouteModelValues> AttributeRoutes { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the set of properties associated with the controller <see cref="ControllerModel.Properties"/>.
|
/// Gets the set of properties associated with the controller <see cref="ControllerModel.Properties"/>.
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ namespace Microsoft.AspNet.Mvc.Logging
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A list of interfaces the <see cref="IFilter"/> implements.
|
/// A list of interfaces the <see cref="IFilter"/> implements.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<Type> FilterInterfaces { get; }
|
public IList<Type> FilterInterfaces { get; }
|
||||||
|
|
||||||
public override string Format()
|
public override string Format()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using Microsoft.AspNet.Mvc.ApplicationModels;
|
using Microsoft.AspNet.Mvc.ApplicationModels;
|
||||||
using Microsoft.AspNet.Mvc.Core;
|
using Microsoft.AspNet.Mvc.Core;
|
||||||
using Microsoft.AspNet.Mvc.OptionDescriptors;
|
using Microsoft.AspNet.Mvc.OptionDescriptors;
|
||||||
|
|
@ -30,6 +29,9 @@ namespace Microsoft.AspNet.Mvc
|
||||||
InputFormatters = new List<InputFormatterDescriptor>();
|
InputFormatters = new List<InputFormatterDescriptor>();
|
||||||
Filters = new List<IFilter>();
|
Filters = new List<IFilter>();
|
||||||
FormatterMappings = new FormatterMappings();
|
FormatterMappings = new FormatterMappings();
|
||||||
|
ValidationExcludeFilters = new List<ExcludeValidationDescriptor>();
|
||||||
|
ModelValidatorProviders = new List<ModelValidatorProviderDescriptor>();
|
||||||
|
CacheProfiles = new Dictionary<string, CacheProfile>(StringComparer.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -70,21 +72,20 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// Gets a list of the <see cref="OutputFormatterDescriptor" /> which are used to construct
|
/// Gets a list of the <see cref="OutputFormatterDescriptor" /> which are used to construct
|
||||||
/// a list of <see cref="IOutputFormatter"/> by <see cref="IOutputFormattersProvider"/>.
|
/// a list of <see cref="IOutputFormatter"/> by <see cref="IOutputFormattersProvider"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<OutputFormatterDescriptor> OutputFormatters { get; private set; }
|
public IList<OutputFormatterDescriptor> OutputFormatters { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of the <see cref="InputFormatterDescriptor" /> which are used to construct
|
/// Gets a list of the <see cref="InputFormatterDescriptor" /> which are used to construct
|
||||||
/// a list of <see cref="IInputFormatter"/> by <see cref="IInputFormattersProvider"/>.
|
/// a list of <see cref="IInputFormatter"/> by <see cref="IInputFormattersProvider"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<InputFormatterDescriptor> InputFormatters { get; private set; }
|
public IList<InputFormatterDescriptor> InputFormatters { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of <see cref="ExcludeValidationDescriptor"/> which are used to construct a list
|
/// Gets a list of <see cref="ExcludeValidationDescriptor"/> which are used to construct a list
|
||||||
/// of exclude filters by <see cref="IValidationExcludeFiltersProvider"/>.
|
/// of exclude filters by <see cref="IValidationExcludeFiltersProvider"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ExcludeValidationDescriptor> ValidationExcludeFilters { get; }
|
public IList<ExcludeValidationDescriptor> ValidationExcludeFilters { get; }
|
||||||
= new List<ExcludeValidationDescriptor>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the maximum number of validation errors that are allowed by this application before further
|
/// Gets or sets the maximum number of validation errors that are allowed by this application before further
|
||||||
/// errors are ignored.
|
/// errors are ignored.
|
||||||
|
|
@ -108,44 +109,42 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// Gets a list of the <see cref="ModelBinderDescriptor" /> used by the
|
/// Gets a list of the <see cref="ModelBinderDescriptor" /> used by the
|
||||||
/// <see cref="ModelBinding.CompositeModelBinder" />.
|
/// <see cref="ModelBinding.CompositeModelBinder" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ModelBinderDescriptor> ModelBinders { get; private set; }
|
public IList<ModelBinderDescriptor> ModelBinders { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of the <see cref="ModelValidatorProviderDescriptor" />s used by
|
/// Gets a list of the <see cref="ModelValidatorProviderDescriptor" />s used by
|
||||||
/// <see cref="ModelBinding.CompositeModelValidatorProvider"/>.
|
/// <see cref="ModelBinding.CompositeModelValidatorProvider"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ModelValidatorProviderDescriptor> ModelValidatorProviders { get; }
|
public IList<ModelValidatorProviderDescriptor> ModelValidatorProviders { get; }
|
||||||
= new List<ModelValidatorProviderDescriptor>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of descriptors that represent <see cref="Rendering.IViewEngine"/> used
|
/// Gets a list of descriptors that represent <see cref="Rendering.IViewEngine"/> used
|
||||||
/// by this application.
|
/// by this application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ViewEngineDescriptor> ViewEngines { get; private set; }
|
public IList<ViewEngineDescriptor> ViewEngines { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of descriptors that represent
|
/// Gets a list of descriptors that represent
|
||||||
/// <see cref="ModelBinding.IValueProviderFactory"/> used by this application.
|
/// <see cref="ModelBinding.IValueProviderFactory"/> used by this application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ValueProviderFactoryDescriptor> ValueProviderFactories { get; private set; }
|
public IList<ValueProviderFactoryDescriptor> ValueProviderFactories { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of <see cref="IApplicationModelConvention"/> instances that will be applied to
|
/// Gets a list of <see cref="IApplicationModelConvention"/> instances that will be applied to
|
||||||
/// the <see cref="ApplicationModel"/> when discovering actions.
|
/// the <see cref="ApplicationModel"/> when discovering actions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<IApplicationModelConvention> Conventions { get; private set; }
|
public IList<IApplicationModelConvention> Conventions { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the flag which causes content negotiation to ignore Accept header
|
/// Gets or sets the flag which causes content negotiation to ignore Accept header
|
||||||
/// when it contains the media type */*. <see langword="false"/> by default.
|
/// when it contains the media type */*. <see langword="false"/> by default.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool RespectBrowserAcceptHeader { get; set; } = false;
|
public bool RespectBrowserAcceptHeader { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a Dictionary of CacheProfile Names, <see cref="CacheProfile"/> which are pre-defined settings for
|
/// Gets a Dictionary of CacheProfile Names, <see cref="CacheProfile"/> which are pre-defined settings for
|
||||||
/// <see cref="ResponseCacheFilter"/>.
|
/// <see cref="ResponseCacheFilter"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, CacheProfile> CacheProfiles { get; }
|
public IDictionary<string, CacheProfile> CacheProfiles { get; }
|
||||||
= new Dictionary<string, CacheProfile>(StringComparer.OrdinalIgnoreCase);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9,7 +9,6 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
{
|
{
|
||||||
public class InjectChunkVisitor : MvcCSharpCodeVisitor
|
public class InjectChunkVisitor : MvcCSharpCodeVisitor
|
||||||
{
|
{
|
||||||
private readonly List<InjectChunk> _injectChunks = new List<InjectChunk>();
|
|
||||||
private readonly string _activateAttribute;
|
private readonly string _activateAttribute;
|
||||||
|
|
||||||
public InjectChunkVisitor([NotNull] CSharpCodeWriter writer,
|
public InjectChunkVisitor([NotNull] CSharpCodeWriter writer,
|
||||||
|
|
@ -20,10 +19,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
_activateAttribute = "[" + activateAttributeName + "]";
|
_activateAttribute = "[" + activateAttributeName + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<InjectChunk> InjectChunks
|
public IList<InjectChunk> InjectChunks { get; } = new List<InjectChunk>();
|
||||||
{
|
|
||||||
get { return _injectChunks; }
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Visit([NotNull] InjectChunk chunk)
|
protected override void Visit([NotNull] InjectChunk chunk)
|
||||||
{
|
{
|
||||||
|
|
@ -53,7 +49,8 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
.Write(chunk.MemberName)
|
.Write(chunk.MemberName)
|
||||||
.WriteLine(" { get; private set; }");
|
.WriteLine(" { get; private set; }");
|
||||||
}
|
}
|
||||||
_injectChunks.Add(chunk);
|
|
||||||
|
InjectChunks.Add(chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -58,12 +58,12 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the sections that can be rendered by this page.
|
/// Gets or sets the sections that can be rendered by this page.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Dictionary<string, RenderAsyncDelegate> PreviousSectionWriters { get; set; }
|
IDictionary<string, RenderAsyncDelegate> PreviousSectionWriters { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the sections that are defined by this page.
|
/// Gets the sections that are defined by this page.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Dictionary<string, RenderAsyncDelegate> SectionWriters { get; }
|
IDictionary<string, RenderAsyncDelegate> SectionWriters { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Renders the page and writes the output to the <see cref="ViewContext.Writer"/>.
|
/// Renders the page and writes the output to the <see cref="ViewContext.Writer"/>.
|
||||||
|
|
|
||||||
|
|
@ -108,10 +108,10 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
public bool IsLayoutBeingRendered { get; set; }
|
public bool IsLayoutBeingRendered { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Dictionary<string, RenderAsyncDelegate> PreviousSectionWriters { get; set; }
|
public IDictionary<string, RenderAsyncDelegate> PreviousSectionWriters { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Dictionary<string, RenderAsyncDelegate> SectionWriters { get; private set; }
|
public IDictionary<string, RenderAsyncDelegate> SectionWriters { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public abstract Task ExecuteAsync();
|
public abstract Task ExecuteAsync();
|
||||||
|
|
|
||||||
|
|
@ -1979,8 +1979,14 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var filterProvider = new Mock<INestedProviderManager<FilterProviderContext>>(MockBehavior.Strict);
|
var filterProvider = new Mock<INestedProviderManager<FilterProviderContext>>(MockBehavior.Strict);
|
||||||
filterProvider
|
filterProvider
|
||||||
.Setup(fp => fp.Invoke(It.IsAny<FilterProviderContext>()))
|
.Setup(fp => fp.Invoke(It.IsAny<FilterProviderContext>()))
|
||||||
.Callback<FilterProviderContext>(
|
.Callback<FilterProviderContext>(context =>
|
||||||
context => context.Results.AddRange(filters.Select(f => new FilterItem(null, f))));
|
{
|
||||||
|
foreach (var filter in filters.Select(f => new FilterItem(null, f)))
|
||||||
|
{
|
||||||
|
context.Results.Add(filter);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
|
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
|
||||||
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
||||||
.Returns(new List<IInputFormatter>());
|
.Returns(new List<IInputFormatter>());
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -925,7 +926,7 @@ namespace Microsoft.AspNet.Mvc.Description
|
||||||
modelMetadataProvider);
|
modelMetadataProvider);
|
||||||
|
|
||||||
provider.Invoke(context, () => { });
|
provider.Invoke(context, () => { });
|
||||||
return context.Results;
|
return new ReadOnlyCollection<ApiDescription>(context.Results);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<MockFormatter> CreateFormatters()
|
private List<MockFormatter> CreateFormatters()
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ using Microsoft.AspNet.Mvc.ApplicationModels;
|
||||||
|
|
||||||
namespace ApplicationModelWebSite
|
namespace ApplicationModelWebSite
|
||||||
{
|
{
|
||||||
public class ControllerLisenceConvention : IControllerModelConvention
|
public class ControllerLicenseConvention : IControllerModelConvention
|
||||||
{
|
{
|
||||||
public void Apply(ControllerModel controller)
|
public void Apply(ControllerModel controller)
|
||||||
{
|
{
|
||||||
|
|
@ -20,7 +20,7 @@ namespace ApplicationModelWebSite
|
||||||
services.Configure<MvcOptions>(options =>
|
services.Configure<MvcOptions>(options =>
|
||||||
{
|
{
|
||||||
options.Conventions.Add(new ApplicationDescription("Common Application Description"));
|
options.Conventions.Add(new ApplicationDescription("Common Application Description"));
|
||||||
options.Conventions.Add(new ControllerLisenceConvention());
|
options.Conventions.Add(new ControllerLicenseConvention());
|
||||||
options.Conventions.Add(new FromHeaderConvention());
|
options.Conventions.Add(new FromHeaderConvention());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue