RouteMatched() public static method

public static RouteMatched ( IEnumerable matchedRestrictions, string cacheKey ) : MatchResult
matchedRestrictions IEnumerable
cacheKey string
return MatchResult
Example #1
0
        public MatchResult MatchesRequest(HttpRequestBase request)
        {
            request.ThrowIfNull("request");

            Restrictions.MatchResult matchResult = new AndRestriction(_restrictions).MatchesRequest(request);

            return(matchResult.ResultType == Restrictions.MatchResultType.RestrictionMatched
                                ? MatchResult.RouteMatched(matchResult.MatchedRestrictions, _id.ToString())
                                : MatchResult.RouteNotMatched(matchResult.MatchedRestrictions, matchResult.UnmatchedRestrictions));
        }
Example #2
0
        public async Task <MatchResult> MatchesRequestAsync(HttpRequestBase request)
        {
            request.ThrowIfNull("request");

            IRestriction[] restrictions         = GetRestrictions().ToArray();
            var            matchingRestrictions = new List <IRestriction>();

            foreach (IRestriction restriction in restrictions)
            {
                if (await restriction.MatchesRequestAsync(request))
                {
                    matchingRestrictions.Add(restriction);
                }
            }

            return(restrictions.Length == matchingRestrictions.Count ? MatchResult.RouteMatched(matchingRestrictions, _id.ToString()) : MatchResult.RouteNotMatched(matchingRestrictions, restrictions.Except(matchingRestrictions)));
        }