// 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.Collections.Generic; using Microsoft.AspNet.Http; namespace Microsoft.AspNet.Routing { /// /// Constrains a route by several child constraints. /// public class CompositeRouteConstraint : IRouteConstraint { /// /// Initializes a new instance of the class. /// /// The child constraints that must match for this constraint to match. public CompositeRouteConstraint([NotNull] IEnumerable constraints) { Constraints = constraints; } /// /// Gets the child constraints that must match for this constraint to match. /// public IEnumerable Constraints { get; private set; } /// public bool Match([NotNull] HttpContext httpContext, [NotNull] IRouter route, [NotNull] string routeKey, [NotNull] IDictionary values, RouteDirection routeDirection) { foreach (var constraint in Constraints) { if (!constraint.Match(httpContext, route, routeKey, values, routeDirection)) { return false; } } return true; } } }