CR Feedback
This commit is contained in:
parent
7d9a6297f9
commit
227121b3f9
|
|
@ -17,40 +17,37 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var removalConstraints = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
var removalConstraints = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
// Iterate all the Reflected Action Descriptor providers and add area or other route constraints
|
// Iterate all the Reflected Action Descriptor providers and add area or other route constraints
|
||||||
if (context.Results != null)
|
foreach (var actionDescriptor in context.Results.OfType<ReflectedActionDescriptor>())
|
||||||
{
|
{
|
||||||
foreach (var actionDescriptor in context.Results.OfType<ReflectedActionDescriptor>())
|
var routeConstraints = actionDescriptor.
|
||||||
|
ControllerDescriptor.
|
||||||
|
ControllerTypeInfo.
|
||||||
|
GetCustomAttributes<RouteConstraintAttribute>().
|
||||||
|
ToArray();
|
||||||
|
|
||||||
|
foreach (var routeConstraint in routeConstraints)
|
||||||
{
|
{
|
||||||
var routeConstraints = actionDescriptor.
|
if (routeConstraint.BlockNonAttributedActions)
|
||||||
ControllerDescriptor.
|
|
||||||
ControllerTypeInfo.
|
|
||||||
GetCustomAttributes<RouteConstraintAttribute>().
|
|
||||||
ToArray();
|
|
||||||
|
|
||||||
foreach (var routeConstraint in routeConstraints)
|
|
||||||
{
|
{
|
||||||
if (routeConstraint.BlockNonAttributedActions)
|
removalConstraints.Add(routeConstraint.RouteKey);
|
||||||
{
|
}
|
||||||
removalConstraints.Add(routeConstraint.RouteKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip on duplicates
|
// Skip duplicates
|
||||||
if (!ContainsKey(actionDescriptor, routeConstraint.RouteKey))
|
if (!HasConstraint(actionDescriptor, routeConstraint.RouteKey))
|
||||||
{
|
{
|
||||||
actionDescriptor.RouteConstraints.Add(new RouteDataActionConstraint(
|
actionDescriptor.RouteConstraints.Add(new RouteDataActionConstraint(
|
||||||
routeConstraint.RouteKey, routeConstraint.RouteValue));
|
routeConstraint.RouteKey, routeConstraint.RouteValue));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var actionDescriptor in context.Results.OfType<ReflectedActionDescriptor>())
|
foreach (var actionDescriptor in context.Results.OfType<ReflectedActionDescriptor>())
|
||||||
|
{
|
||||||
|
foreach (var key in removalConstraints)
|
||||||
{
|
{
|
||||||
foreach (var key in removalConstraints)
|
if (!HasConstraint(actionDescriptor, key))
|
||||||
{
|
{
|
||||||
if (!ContainsKey(actionDescriptor, key))
|
actionDescriptor.RouteConstraints.Add(new RouteDataActionConstraint(key, RouteKeyHandling.DenyKey));
|
||||||
{
|
|
||||||
actionDescriptor.RouteConstraints.Add(new RouteDataActionConstraint(key, RouteKeyHandling.DenyKey));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -58,7 +55,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
callNext();
|
callNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ContainsKey(ActionDescriptor actionDescript, string routeKey)
|
private bool HasConstraint(ActionDescriptor actionDescript, string routeKey)
|
||||||
{
|
{
|
||||||
return actionDescript.RouteConstraints.Any(rc => string.Equals(rc.RouteKey, routeKey, StringComparison.OrdinalIgnoreCase));
|
return actionDescript.RouteConstraints.Any(rc => string.Equals(rc.RouteKey, routeKey, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ using System.Reflection;
|
||||||
using Microsoft.AspNet.Abstractions;
|
using Microsoft.AspNet.Abstractions;
|
||||||
using Microsoft.AspNet.DependencyInjection;
|
using Microsoft.AspNet.DependencyInjection;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Routing;
|
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
var searchedLocations = new List<string>(_viewLocationFormats.Length);
|
var searchedLocations = new List<string>(_viewLocationFormats.Length);
|
||||||
for (int i = 0; i < _viewLocationFormats.Length; i++)
|
for (int i = 0; i < _viewLocationFormats.Length; i++)
|
||||||
{
|
{
|
||||||
string path = String.Format(CultureInfo.InvariantCulture, _viewLocationFormats[i], viewName, controllerName, areaName);
|
var path = String.Format(CultureInfo.InvariantCulture, _viewLocationFormats[i], viewName, controllerName, areaName);
|
||||||
IView view = await _virtualPathFactory.CreateInstance(path);
|
IView view = await _virtualPathFactory.CreateInstance(path);
|
||||||
if (view != null)
|
if (view != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue