private static bool RouteMatchedUrlRelativePath(MatchResult matchResult) { return matchResult.MatchedRestrictions != null && matchResult.MatchedRestrictions.Any(arg2 => arg2 is UrlRelativePathRestriction) && matchResult.UnmatchedRestrictions.All(arg2 => !(arg2 is UrlRelativePathRestriction)); }
public RouteMatchResult(Routing.Route route, MatchResult result) { route.ThrowIfNull("route"); result.ThrowIfNull("result"); _route = route; _matchResult = result; }
public void SetUp() { _matchedRestrictions = new[] { new MethodRestriction("GET"), new MethodRestriction("POST") }; _cacheKey = "id"; _matchResult = MatchResult.RouteMatched(_matchedRestrictions, _cacheKey); }
public void SetUp() { _matchedRestrictions = new[] { new MethodRestriction("GET"), new MethodRestriction("POST") }; _unmatchedRestrictions = new[] { new UrlHostRestriction("host1", CaseInsensitivePlainComparer.Instance), new UrlHostRestriction("host2", CaseInsensitivePlainComparer.Instance) }; _matchResult = MatchResult.RouteNotMatched(_matchedRestrictions, _unmatchedRestrictions); }
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))); }
public void SetUp() { _route = new Route.Routing.Route("name", Guid.NewGuid(), "route"); _route.AddRestrictions(new UrlHostRestriction("host", CaseInsensitivePlainComparer.Instance), new UrlPortRestriction(80)); _request = MockRepository.GenerateMock<HttpRequestBase>(); _request.Stub(arg => arg.Url).Return(new Uri("http://host:81")); _matchResult = _route.MatchesRequest(_request); }