Rename GlobalModel -> ApplicationModel

This also comes with a rename of the namespace
Microsoft.AspNet.Mvc.ApplicationModel to
Microsoft.AspNet.Mvc.ApplicationModels.

Also tuned up some parameter and variable names for increased
understandability.
This commit is contained in:
Ryan Nowak 2014-10-23 13:18:38 -07:00
parent 7012b3fc2b
commit 0a3ad09466
39 changed files with 110 additions and 106 deletions

View File

@ -2,7 +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 Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
namespace MvcSample.Web namespace MvcSample.Web
{ {

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
public class ActionModel public class ActionModel
{ {

View File

@ -3,11 +3,11 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
public class GlobalModel public class ApplicationModel
{ {
public GlobalModel() public ApplicationModel()
{ {
Controllers = new List<ControllerModel>(); Controllers = new List<ControllerModel>();
Filters = new List<IFilter>(); Filters = new List<IFilter>();

View File

@ -4,21 +4,21 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
/// <summary> /// <summary>
/// Applies conventions to a <see cref="GlobalModel"/>. /// Applies conventions to a <see cref="ApplicationModel"/>.
/// </summary> /// </summary>
public static class ApplicationModelConventions public static class ApplicationModelConventions
{ {
/// <summary> /// <summary>
/// Applies conventions to a <see cref="GlobalModel"/>. /// Applies conventions to a <see cref="ApplicationModel"/>.
/// </summary> /// </summary>
/// <param name="applicationModel">The <see cref="GlobalModel"/>.</param> /// <param name="applicationModel">The <see cref="ApplicationModel"/>.</param>
/// <param name="conventions">The set of conventions.</param> /// <param name="conventions">The set of conventions.</param>
public static void ApplyConventions( public static void ApplyConventions(
[NotNull] GlobalModel applicationModel, [NotNull] ApplicationModel applicationModel,
[NotNull] IEnumerable<IGlobalModelConvention> conventions) [NotNull] IEnumerable<IApplicationModelConvention> conventions)
{ {
// Conventions are applied from the outside-in to allow for scenarios where an action overrides // Conventions are applied from the outside-in to allow for scenarios where an action overrides
// a controller, etc. // a controller, etc.

View File

@ -7,7 +7,7 @@ using System.Text;
using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Core;
using Microsoft.AspNet.Mvc.Routing; using Microsoft.AspNet.Mvc.Routing;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
public class AttributeRouteModel public class AttributeRouteModel
{ {

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
public class ControllerModel public class ControllerModel
{ {
@ -47,7 +47,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModel
public List<ActionModel> Actions { get; private set; } public List<ActionModel> Actions { get; private set; }
public GlobalModel Application { get; set; } public ApplicationModel Application { get; set; }
public List<object> Attributes { get; private set; } public List<object> Attributes { get; private set; }

View File

@ -8,7 +8,7 @@ using Microsoft.AspNet.Mvc.Description;
using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Routing; using Microsoft.AspNet.Mvc.Routing;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
/// <summary> /// <summary>
/// A default implementation of <see cref="IActionModelBuilder"/>. /// A default implementation of <see cref="IActionModelBuilder"/>.

View File

@ -7,7 +7,7 @@ using System.Reflection;
using Microsoft.AspNet.Mvc.Description; using Microsoft.AspNet.Mvc.Description;
using Microsoft.AspNet.Mvc.Routing; using Microsoft.AspNet.Mvc.Routing;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
/// <summary> /// <summary>
/// A default implementation of <see cref="IControllerModelBuilder"/>. /// A default implementation of <see cref="IControllerModelBuilder"/>.

View File

@ -4,7 +4,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
/// <summary> /// <summary>
/// Creates a set of <see cref="ActionModel"/> for a method. /// Creates a set of <see cref="ActionModel"/> for a method.

View File

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
/// <summary> /// <summary>
/// Allows customization of the of the <see cref="ActionModel"/>. /// Allows customization of the of the <see cref="ActionModel"/>.
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModel
/// <summary> /// <summary>
/// Called to apply the convention to the <see cref="ActionModel"/>. /// Called to apply the convention to the <see cref="ActionModel"/>.
/// </summary> /// </summary>
/// <param name="model">The <see cref="ActionModel"/>.</param> /// <param name="action">The <see cref="ActionModel"/>.</param>
void Apply([NotNull] ActionModel model); void Apply([NotNull] ActionModel action);
} }
} }

View File

@ -1,24 +1,24 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
/// <summary> /// <summary>
/// Allows customization of the of the <see cref="GlobalModel"/>. /// Allows customization of the of the <see cref="ApplicationModel"/>.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Implementaions of this interface can be registered in <see cref="MvcOptions.ApplicationModelConventions"/> /// Implementaions of this interface can be registered in <see cref="MvcOptions.ApplicationModelConventions"/>
/// to customize metadata about the application. /// to customize metadata about the application.
/// ///
/// <see cref="IGlobalModelConvention"/> run before other types of customizations to the /// <see cref="IApplicationModelConvention"/> run before other types of customizations to the
/// reflected model. /// reflected model.
/// </remarks> /// </remarks>
public interface IGlobalModelConvention public interface IApplicationModelConvention
{ {
/// <summary> /// <summary>
/// Called to apply the convention to the <see cref="GlobalModel"/>. /// Called to apply the convention to the <see cref="ApplicationModel"/>.
/// </summary> /// </summary>
/// <param name="model">The <see cref="GlobalModel"/>.</param> /// <param name="application">The <see cref="ApplicationModel"/>.</param>
void Apply([NotNull] GlobalModel model); void Apply([NotNull] ApplicationModel application);
} }
} }

View File

@ -3,7 +3,7 @@
using System.Reflection; using System.Reflection;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
/// <summary> /// <summary>
/// Creates a set of <see cref="ControllerModel"/> for a type. /// Creates a set of <see cref="ControllerModel"/> for a type.

View File

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
/// <summary> /// <summary>
/// Allows customization of the of the <see cref="ControllerModel"/>. /// Allows customization of the of the <see cref="ControllerModel"/>.
@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModel
/// place it on a controller class. /// place it on a controller class.
/// ///
/// <see cref="IControllerModelConvention"/> customizations run after /// <see cref="IControllerModelConvention"/> customizations run after
/// <see cref="IGlobalModelConvention"/> customizations and before /// <see cref="IApplicationModelConvention"/> customizations and before
/// <see cref="IActionModelConvention"/> customizations. /// <see cref="IActionModelConvention"/> customizations.
/// </remarks> /// </remarks>
public interface IControllerModelConvention public interface IControllerModelConvention
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModel
/// <summary> /// <summary>
/// Called to apply the convention to the <see cref="ControllerModel"/>. /// Called to apply the convention to the <see cref="ControllerModel"/>.
/// </summary> /// </summary>
/// <param name="model">The <see cref="ControllerModel"/>.</param> /// <param name="controller">The <see cref="ControllerModel"/>.</param>
void Apply([NotNull] ControllerModel model); void Apply([NotNull] ControllerModel controller);
} }
} }

View File

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
/// <summary> /// <summary>
/// Allows customization of the of the <see cref="ControllerModel"/>. /// Allows customization of the of the <see cref="ControllerModel"/>.
@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModel
/// <summary> /// <summary>
/// Called to apply the convention to the <see cref="ParameterModel"/>. /// Called to apply the convention to the <see cref="ParameterModel"/>.
/// </summary> /// </summary>
/// <param name="model">The <see cref="ParameterModel"/>.</param> /// <param name="parameter">The <see cref="ParameterModel"/>.</param>
void Apply([NotNull] ParameterModel model); void Apply([NotNull] ParameterModel parameter);
} }
} }

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.ModelBinding;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
public class ParameterModel public class ParameterModel
{ {

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Core;
using Microsoft.AspNet.Mvc.Description; using Microsoft.AspNet.Mvc.Description;
using Microsoft.AspNet.Mvc.Routing; using Microsoft.AspNet.Mvc.Routing;
@ -14,7 +14,7 @@ using Microsoft.AspNet.Mvc.Routing;
namespace Microsoft.AspNet.Mvc namespace Microsoft.AspNet.Mvc
{ {
/// <summary> /// <summary>
/// Creates instances of <see cref="ControllerActionDescriptor"/> from <see cref="GlobalModel"/>. /// Creates instances of <see cref="ControllerActionDescriptor"/> from <see cref="ApplicationModel"/>.
/// </summary> /// </summary>
public static class ControllerActionDescriptorBuilder public static class ControllerActionDescriptorBuilder
{ {
@ -23,11 +23,11 @@ namespace Microsoft.AspNet.Mvc
private const int DefaultAttributeRouteOrder = 0; private const int DefaultAttributeRouteOrder = 0;
/// <summary> /// <summary>
/// Creates instances of <see cref="ControllerActionDescriptor"/> from <see cref="GlobalModel"/>. /// Creates instances of <see cref="ControllerActionDescriptor"/> from <see cref="ApplicationModel"/>.
/// </summary> /// </summary>
/// <param name="application">The <see cref="GlobalModel"/>.</param> /// <param name="application">The <see cref="ApplicationModel"/>.</param>
/// <returns>The list of <see cref="ControllerActionDescriptor"/>.</returns> /// <returns>The list of <see cref="ControllerActionDescriptor"/>.</returns>
public static IList<ControllerActionDescriptor> Build(GlobalModel application) public static IList<ControllerActionDescriptor> Build(ApplicationModel application)
{ {
var actions = new List<ControllerActionDescriptor>(); var actions = new List<ControllerActionDescriptor>();
@ -176,7 +176,7 @@ namespace Microsoft.AspNet.Mvc
} }
private static IList<ControllerActionDescriptor> CreateActionDescriptors( private static IList<ControllerActionDescriptor> CreateActionDescriptors(
GlobalModel application, ApplicationModel application,
ControllerModel controller, ControllerModel controller,
ActionModel action) ActionModel action)
{ {

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Microsoft.AspNet.Mvc.Filters; using Microsoft.AspNet.Mvc.Filters;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
using Microsoft.Framework.OptionsModel; using Microsoft.Framework.OptionsModel;
namespace Microsoft.AspNet.Mvc namespace Microsoft.AspNet.Mvc
@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Mvc
private readonly IControllerModelBuilder _applicationModelBuilder; private readonly IControllerModelBuilder _applicationModelBuilder;
private readonly IAssemblyProvider _assemblyProvider; private readonly IAssemblyProvider _assemblyProvider;
private readonly IReadOnlyList<IFilter> _globalFilters; private readonly IReadOnlyList<IFilter> _globalFilters;
private readonly IEnumerable<IGlobalModelConvention> _modelConventions; private readonly IEnumerable<IApplicationModelConvention> _modelConventions;
public ControllerActionDescriptorProvider(IAssemblyProvider assemblyProvider, public ControllerActionDescriptorProvider(IAssemblyProvider assemblyProvider,
IControllerModelBuilder applicationModelBuilder, IControllerModelBuilder applicationModelBuilder,
@ -47,9 +47,9 @@ namespace Microsoft.AspNet.Mvc
return ControllerActionDescriptorBuilder.Build(applicationModel); return ControllerActionDescriptorBuilder.Build(applicationModel);
} }
public GlobalModel BuildModel() public ApplicationModel BuildModel()
{ {
var applicationModel = new GlobalModel(); var applicationModel = new ApplicationModel();
applicationModel.Filters.AddRange(_globalFilters); applicationModel.Filters.AddRange(_globalFilters);
var assemblies = _assemblyProvider.CandidateAssemblies; var assemblies = _assemblyProvider.CandidateAssemblies;

View File

@ -3,7 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Core;
using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.OptionDescriptors; using Microsoft.AspNet.Mvc.OptionDescriptors;
@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc
public MvcOptions() public MvcOptions()
{ {
ApplicationModelConventions = new List<IGlobalModelConvention>(); ApplicationModelConventions = new List<IApplicationModelConvention>();
ModelBinders = new List<ModelBinderDescriptor>(); ModelBinders = new List<ModelBinderDescriptor>();
ViewEngines = new List<ViewEngineDescriptor>(); ViewEngines = new List<ViewEngineDescriptor>();
ValueProviderFactories = new List<ValueProviderFactoryDescriptor>(); ValueProviderFactories = new List<ValueProviderFactoryDescriptor>();
@ -121,6 +121,10 @@ namespace Microsoft.AspNet.Mvc
/// </summary> /// </summary>
public List<ValueProviderFactoryDescriptor> ValueProviderFactories { get; private set; } public List<ValueProviderFactoryDescriptor> ValueProviderFactories { get; private set; }
public List<IGlobalModelConvention> ApplicationModelConventions { get; private set; } /// <summary>
/// Gets a list of <see cref="IApplicationModelConvention"/> instances that will be applied to
/// the <see cref="ApplicationModel"/> when discovering actions.
/// </summary>
public List<IApplicationModelConvention> ApplicationModelConventions { get; private set; }
} }
} }

View File

@ -4,11 +4,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
namespace Microsoft.AspNet.Mvc.WebApiCompatShim namespace Microsoft.AspNet.Mvc.WebApiCompatShim
{ {
public class WebApiActionConventionsGlobalModelConvention : IGlobalModelConvention public class WebApiActionConventionsApplicationModelConvention : IApplicationModelConvention
{ {
private static readonly string[] SupportedHttpMethodConventions = new string[] private static readonly string[] SupportedHttpMethodConventions = new string[]
{ {
@ -21,9 +21,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim
"OPTIONS", "OPTIONS",
}; };
public void Apply(GlobalModel model) public void Apply(ApplicationModel application)
{ {
foreach (var controller in model.Controllers) foreach (var controller in application.Controllers)
{ {
if (IsConventionApplicable(controller)) if (IsConventionApplicable(controller))
{ {
@ -37,11 +37,11 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim
return controller.Attributes.OfType<IUseWebApiActionConventions>().Any(); return controller.Attributes.OfType<IUseWebApiActionConventions>().Any();
} }
private void Apply(ControllerModel model) private void Apply(ControllerModel controller)
{ {
var newActions = new List<ActionModel>(); var newActions = new List<ActionModel>();
foreach (var action in model.Actions) foreach (var action in controller.Actions)
{ {
SetHttpMethodFromConvention(action); SetHttpMethodFromConvention(action);
@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim
} }
} }
model.Actions.AddRange(newActions); controller.Actions.AddRange(newActions);
} }
private bool IsActionAttributeRouted(ActionModel action) private bool IsActionAttributeRouted(ActionModel action)

View File

@ -2,15 +2,15 @@
// 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.Linq; using System.Linq;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
namespace Microsoft.AspNet.Mvc.WebApiCompatShim namespace Microsoft.AspNet.Mvc.WebApiCompatShim
{ {
public class WebApiOverloadingGlobalModelConvention : IGlobalModelConvention public class WebApiOverloadingApplicationModelConvention : IApplicationModelConvention
{ {
public void Apply(GlobalModel model) public void Apply(ApplicationModel application)
{ {
foreach (var controller in model.Controllers) foreach (var controller in application.Controllers)
{ {
if (IsConventionApplicable(controller)) if (IsConventionApplicable(controller))
{ {
@ -24,9 +24,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim
return controller.Attributes.OfType<IUseWebApiOverloading>().Any(); return controller.Attributes.OfType<IUseWebApiOverloading>().Any();
} }
private void Apply(ControllerModel model) private void Apply(ControllerModel controller)
{ {
foreach (var action in model.Actions) foreach (var action in controller.Actions)
{ {
action.ActionConstraints.Add(new OverloadActionConstraint()); action.ActionConstraints.Add(new OverloadActionConstraint());
} }

View File

@ -3,16 +3,16 @@
using System.Linq; using System.Linq;
using System.Web.Http; using System.Web.Http;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.ModelBinding;
namespace Microsoft.AspNet.Mvc.WebApiCompatShim namespace Microsoft.AspNet.Mvc.WebApiCompatShim
{ {
public class WebApiParameterConventionsGlobalModelConvention : IGlobalModelConvention public class WebApiParameterConventionsApplicationModelConvention : IApplicationModelConvention
{ {
public void Apply(GlobalModel model) public void Apply(ApplicationModel application)
{ {
foreach (var controller in model.Controllers) foreach (var controller in application.Controllers)
{ {
if (IsConventionApplicable(controller)) if (IsConventionApplicable(controller))
{ {
@ -26,9 +26,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim
return controller.Attributes.OfType<IUseWebApiParameterConventions>().Any(); return controller.Attributes.OfType<IUseWebApiParameterConventions>().Any();
} }
private void Apply(ControllerModel model) private void Apply(ControllerModel controller)
{ {
foreach (var action in model.Actions) foreach (var action in controller.Actions)
{ {
foreach (var parameter in action.Parameters) foreach (var parameter in action.Parameters)
{ {

View File

@ -2,22 +2,22 @@
// 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.Linq; using System.Linq;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
namespace Microsoft.AspNet.Mvc.WebApiCompatShim namespace Microsoft.AspNet.Mvc.WebApiCompatShim
{ {
public class WebApiRoutesGlobalModelConvention : IGlobalModelConvention public class WebApiRoutesApplicationModelConvention : IApplicationModelConvention
{ {
private readonly string _area; private readonly string _area;
public WebApiRoutesGlobalModelConvention(string area) public WebApiRoutesApplicationModelConvention(string area)
{ {
_area = area; _area = area;
} }
public void Apply(GlobalModel model) public void Apply(ApplicationModel application)
{ {
foreach (var controller in model.Controllers) foreach (var controller in application.Controllers)
{ {
if (IsConventionApplicable(controller)) if (IsConventionApplicable(controller))
{ {
@ -31,9 +31,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim
return controller.Attributes.OfType<IUseWebApiRoutes>().Any(); return controller.Attributes.OfType<IUseWebApiRoutes>().Any();
} }
private void Apply(ControllerModel model) private void Apply(ControllerModel controller)
{ {
model.RouteConstraints.Add(new AreaAttribute(_area)); controller.RouteConstraints.Add(new AreaAttribute(_area));
} }
} }
} }

View File

@ -21,10 +21,10 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim
public void Configure(MvcOptions options, string name = "") public void Configure(MvcOptions options, string name = "")
{ {
// Add webapi behaviors to controllers with the appropriate attributes // Add webapi behaviors to controllers with the appropriate attributes
options.ApplicationModelConventions.Add(new WebApiActionConventionsGlobalModelConvention()); options.ApplicationModelConventions.Add(new WebApiActionConventionsApplicationModelConvention());
options.ApplicationModelConventions.Add(new WebApiParameterConventionsGlobalModelConvention()); options.ApplicationModelConventions.Add(new WebApiParameterConventionsApplicationModelConvention());
options.ApplicationModelConventions.Add(new WebApiOverloadingGlobalModelConvention()); options.ApplicationModelConventions.Add(new WebApiOverloadingApplicationModelConvention());
options.ApplicationModelConventions.Add(new WebApiRoutesGlobalModelConvention(area: DefaultAreaName)); options.ApplicationModelConventions.Add(new WebApiRoutesApplicationModelConvention(area: DefaultAreaName));
// Add an action filter for handling the HttpResponseException. // Add an action filter for handling the HttpResponseException.
options.Filters.Add(new HttpResponseExceptionActionFilter()); options.Filters.Add(new HttpResponseExceptionActionFilter());

View File

@ -2,7 +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.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
using Microsoft.AspNet.Mvc.Description; using Microsoft.AspNet.Mvc.Description;
using Microsoft.AspNet.Mvc.Filters; using Microsoft.AspNet.Mvc.Filters;
using Microsoft.AspNet.Mvc.Internal; using Microsoft.AspNet.Mvc.Internal;

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
public class ActionModelTest public class ActionModelTest
{ {

View File

@ -6,7 +6,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
public class AttributeRouteModelTests public class AttributeRouteModelTests
{ {

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
public class ControllerModelTest public class ControllerModelTest
{ {
@ -46,7 +46,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModel
controller.ActionConstraints.Add(new HttpMethodConstraint(new string[] { "GET" })); controller.ActionConstraints.Add(new HttpMethodConstraint(new string[] { "GET" }));
controller.ApiExplorerGroupName = "group"; controller.ApiExplorerGroupName = "group";
controller.ApiExplorerIsVisible = true; controller.ApiExplorerIsVisible = true;
controller.Application = new GlobalModel(); controller.Application = new ApplicationModel();
controller.Attributes.Add(new HttpGetAttribute()); controller.Attributes.Add(new HttpGetAttribute());
controller.ControllerName = "cool"; controller.ControllerName = "cool";
controller.Filters.Add(new AuthorizeAttribute()); controller.Filters.Add(new AuthorizeAttribute());

View File

@ -7,7 +7,7 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
public class DefaultActionModelBuilderTest public class DefaultActionModelBuilderTest
{ {

View File

@ -2,10 +2,10 @@
// 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.Reflection; using System.Reflection;
using Microsoft.AspNet.Mvc.ApplicationModel.DefaultControllerModelBuilderTestControllers; using Microsoft.AspNet.Mvc.ApplicationModels.DefaultControllerModelBuilderTestControllers;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
public class DefaultControllerModelBuilderTest public class DefaultControllerModelBuilderTest
{ {
@ -183,7 +183,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModel
// implementation of this class to test it, they are just top level classes. Don't reuse // implementation of this class to test it, they are just top level classes. Don't reuse
// these outside this test - find a better way or use nested classes to keep the tests // these outside this test - find a better way or use nested classes to keep the tests
// independent. // independent.
namespace Microsoft.AspNet.Mvc.ApplicationModel.DefaultControllerModelBuilderTestControllers namespace Microsoft.AspNet.Mvc.ApplicationModels.DefaultControllerModelBuilderTestControllers
{ {
public abstract class AbstractController : Mvc.Controller public abstract class AbstractController : Mvc.Controller
{ {

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.ModelBinding;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
public class ParameterModelTest public class ParameterModelTest
{ {

View File

@ -7,7 +7,7 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using Microsoft.AspNet.Mvc.Description; using Microsoft.AspNet.Mvc.Description;
using Microsoft.AspNet.Mvc.Routing; using Microsoft.AspNet.Mvc.Routing;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
using Microsoft.Framework.OptionsModel; using Microsoft.Framework.OptionsModel;
using Moq; using Moq;
using Xunit; using Xunit;
@ -1114,9 +1114,9 @@ namespace Microsoft.AspNet.Mvc.Test
// Arrange // Arrange
var sequence = 0; var sequence = 0;
var applicationConvention = new Mock<IGlobalModelConvention>(); var applicationConvention = new Mock<IApplicationModelConvention>();
applicationConvention applicationConvention
.Setup(c => c.Apply(It.IsAny<GlobalModel>())) .Setup(c => c.Apply(It.IsAny<ApplicationModel>()))
.Callback(() => { Assert.Equal(0, sequence++); }); .Callback(() => { Assert.Equal(0, sequence++); });
var controllerConvention = new Mock<IControllerModelConvention>(); var controllerConvention = new Mock<IControllerModelConvention>();

View File

@ -8,7 +8,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Reflection; using System.Reflection;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
using Microsoft.AspNet.Mvc.Logging; using Microsoft.AspNet.Mvc.Logging;
using Microsoft.AspNet.Mvc.Routing; using Microsoft.AspNet.Mvc.Routing;
using Microsoft.AspNet.PipelineCore; using Microsoft.AspNet.PipelineCore;

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
namespace Microsoft.AspNet.Mvc.ApplicationModel namespace Microsoft.AspNet.Mvc.ApplicationModels
{ {
/// <summary> /// <summary>
/// An implementation of StaticControllerModelBuilder that only allows controllers /// An implementation of StaticControllerModelBuilder that only allows controllers

View File

@ -7,7 +7,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
using Microsoft.AspNet.Mvc.Filters; using Microsoft.AspNet.Mvc.Filters;
using Microsoft.AspNet.Mvc.WebApiCompatShim; using Microsoft.AspNet.Mvc.WebApiCompatShim;
using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.DependencyInjection;

View File

@ -3,14 +3,14 @@
using System; using System;
using System.Reflection; using System.Reflection;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
namespace ApiExplorer namespace ApiExplorer
{ {
// Disables ApiExplorer for a specific controller type. // Disables ApiExplorer for a specific controller type.
// This is part of the test that validates that ApiExplorer can be configured via // This is part of the test that validates that ApiExplorer can be configured via
// convention // convention
public class ApiExplorerVisibilityDisabledConvention : IGlobalModelConvention public class ApiExplorerVisibilityDisabledConvention : IApplicationModelConvention
{ {
private readonly TypeInfo _type; private readonly TypeInfo _type;
@ -19,9 +19,9 @@ namespace ApiExplorer
_type = type.GetTypeInfo(); _type = type.GetTypeInfo();
} }
public void Apply(GlobalModel model) public void Apply(ApplicationModel application)
{ {
foreach (var controller in model.Controllers) foreach (var controller in application.Controllers)
{ {
if (controller.ControllerType == _type) if (controller.ControllerType == _type)
{ {

View File

@ -1,18 +1,18 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
namespace ApiExplorer namespace ApiExplorer
{ {
// Enables ApiExplorer for controllers that haven't explicitly configured it. // Enables ApiExplorer for controllers that haven't explicitly configured it.
// This is part of the test that validates that ApiExplorer can be configured via // This is part of the test that validates that ApiExplorer can be configured via
// convention // convention
public class ApiExplorerVisibilityEnabledConvention : IGlobalModelConvention public class ApiExplorerVisibilityEnabledConvention : IApplicationModelConvention
{ {
public void Apply(GlobalModel model) public void Apply(ApplicationModel application)
{ {
foreach (var controller in model.Controllers) foreach (var controller in application.Controllers)
{ {
if (controller.ApiExplorerIsVisible == null) if (controller.ApiExplorerIsVisible == null)
{ {

View File

@ -3,7 +3,7 @@
using System; using System;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
namespace ApplicationModelWebSite namespace ApplicationModelWebSite
{ {

View File

@ -3,7 +3,7 @@
using System; using System;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
namespace ApplicationModelWebSite namespace ApplicationModelWebSite
{ {

View File

@ -3,7 +3,7 @@
using System; using System;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.ApplicationModel; using Microsoft.AspNet.Mvc.ApplicationModels;
namespace ApplicationModelWebSite namespace ApplicationModelWebSite
{ {