diff --git a/samples/InlineConstraintSample.Web/Constraints/IsbnDigitScheme10Constraint.cs b/samples/InlineConstraintSample.Web/Constraints/IsbnDigitScheme10Constraint.cs index 33a2a80633..21099be0df 100644 --- a/samples/InlineConstraintSample.Web/Constraints/IsbnDigitScheme10Constraint.cs +++ b/samples/InlineConstraintSample.Web/Constraints/IsbnDigitScheme10Constraint.cs @@ -22,7 +22,7 @@ namespace InlineConstraintSample.Web.Constraints HttpContext httpContext, IRouter route, string routeKey, - IDictionary values, + RouteValueDictionary values, RouteDirection routeDirection) { object value; diff --git a/samples/InlineConstraintSample.Web/Constraints/IsbnDigitScheme13Constraint.cs b/samples/InlineConstraintSample.Web/Constraints/IsbnDigitScheme13Constraint.cs index b9761742d7..e10e77b71d 100644 --- a/samples/InlineConstraintSample.Web/Constraints/IsbnDigitScheme13Constraint.cs +++ b/samples/InlineConstraintSample.Web/Constraints/IsbnDigitScheme13Constraint.cs @@ -17,7 +17,7 @@ namespace InlineConstraintSample.Web.Constraints HttpContext httpContext, IRouter route, string routeKey, - IDictionary values, + RouteValueDictionary values, RouteDirection routeDirection) { object value; diff --git a/src/Microsoft.AspNet.Mvc.Core/Routing/KnownRouteValueConstraint.cs b/src/Microsoft.AspNet.Mvc.Core/Routing/KnownRouteValueConstraint.cs index 1c7b201bdb..5f165e9ca4 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Routing/KnownRouteValueConstraint.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Routing/KnownRouteValueConstraint.cs @@ -2,7 +2,6 @@ // 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 System.Linq; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.Core; @@ -20,7 +19,7 @@ namespace Microsoft.AspNet.Mvc.Routing HttpContext httpContext, IRouter route, string routeKey, - IDictionary values, + RouteValueDictionary values, RouteDirection routeDirection) { if (httpContext == null) @@ -43,20 +42,20 @@ namespace Microsoft.AspNet.Mvc.Routing throw new ArgumentNullException(nameof(values)); } - object value; - if (values.TryGetValue(routeKey, out value)) + object obj; + if (values.TryGetValue(routeKey, out obj)) { - var valueAsString = value as string; - - if (valueAsString != null) + var value = obj as string; + if (value != null) { var allValues = GetAndCacheAllMatchingValues(routeKey, httpContext); - var match = allValues.Any(existingRouteValue => - existingRouteValue.Equals( - valueAsString, - StringComparison.OrdinalIgnoreCase)); - - return match; + foreach (var existingValue in allValues) + { + if (string.Equals(value, existingValue, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } } } diff --git a/test/Microsoft.AspNet.Mvc.ApiExplorer.Test/DefaultApiDescriptionProviderTest.cs b/test/Microsoft.AspNet.Mvc.ApiExplorer.Test/DefaultApiDescriptionProviderTest.cs index baf6da2b8c..8e5e07d7bb 100644 --- a/test/Microsoft.AspNet.Mvc.ApiExplorer.Test/DefaultApiDescriptionProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.ApiExplorer.Test/DefaultApiDescriptionProviderTest.cs @@ -104,8 +104,8 @@ namespace Microsoft.AspNet.Mvc.Description var action = CreateActionDescriptor(); action.ActionConstraints = new List() { - new HttpMethodConstraint(new string[] { "PUT", "POST" }), - new HttpMethodConstraint(new string[] { "GET" }), + new ActionConstraints.HttpMethodConstraint(new string[] { "PUT", "POST" }), + new ActionConstraints.HttpMethodConstraint(new string[] { "GET" }), }; // Act diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/KnownRouteValueConstraintTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/KnownRouteValueConstraintTests.cs index 8a7a7600bc..92b56c2730 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/KnownRouteValueConstraintTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/KnownRouteValueConstraintTests.cs @@ -28,7 +28,7 @@ namespace Microsoft.AspNet.Mvc.Routing public void RouteKey_DoesNotExist_MatchFails(string keyName, RouteDirection direction) { // Arrange - var values = new Dictionary(); + var values = new RouteValueDictionary(); var httpContext = GetHttpContext(new ActionDescriptor()); var route = Mock.Of(); @@ -57,13 +57,13 @@ namespace Microsoft.AspNet.Mvc.Routing actionDescriptor.RouteConstraints.Add(new RouteDataActionConstraint("randomKey", "testRandom")); var httpContext = GetHttpContext(actionDescriptor); var route = Mock.Of(); - var values = new Dictionary() - { - { "area", "testArea" }, - { "controller", "testController" }, - { "action", "testAction" }, - { "randomKey", "testRandom" } - }; + var values = new RouteValueDictionary() + { + { "area", "testArea" }, + { "controller", "testController" }, + { "action", "testAction" }, + { "randomKey", "testRandom" } + }; // Act var match = _constraint.Match(httpContext, route, keyName, values, direction); @@ -90,13 +90,13 @@ namespace Microsoft.AspNet.Mvc.Routing actionDescriptor.RouteConstraints.Add(new RouteDataActionConstraint("randomKey", "testRandom")); var httpContext = GetHttpContext(actionDescriptor); var route = Mock.Of(); - var values = new Dictionary() - { - { "area", "invalidTestArea" }, - { "controller", "invalidTestController" }, - { "action", "invalidTestAction" }, - { "randomKey", "invalidTestRandom" } - }; + var values = new RouteValueDictionary() + { + { "area", "invalidTestArea" }, + { "controller", "invalidTestController" }, + { "action", "invalidTestAction" }, + { "randomKey", "invalidTestRandom" } + }; // Act var match = _constraint.Match(httpContext, route, keyName, values, direction); @@ -115,10 +115,10 @@ namespace Microsoft.AspNet.Mvc.Routing action: null); var httpContext = GetHttpContext(actionDescriptor); var route = Mock.Of(); - var values = new Dictionary() - { - { "area", 12 }, - }; + var values = new RouteValueDictionary() + { + { "area", 12 }, + }; // Act var match = _constraint.Match(httpContext, route, "area", values, direction); @@ -145,7 +145,7 @@ namespace Microsoft.AspNet.Mvc.Routing httpContext.Object, Mock.Of(), "area", - new Dictionary { { "area", "area" } }, + new RouteValueDictionary { { "area", "area" } }, direction)); var providerName = actionDescriptorCollectionProvider.GetType().FullName; Assert.Equal(