private static bool RouteMatchedUrlRelativePath(MatchResult matchResult)
		{
			return
				matchResult.MatchedRestrictions != null &&
				matchResult.MatchedRestrictions.Any(arg2 => arg2 is UrlRelativePathRestriction) &&
				matchResult.UnmatchedRestrictions.All(arg2 => !(arg2 is UrlRelativePathRestriction));
		}
Exemplo n.º 2
0
        public RouteMatchResult(Routing.Route route, MatchResult result)
        {
            route.ThrowIfNull("route");
            result.ThrowIfNull("result");

            _route = route;
            _matchResult = result;
        }
Exemplo n.º 3
0
 public void SetUp()
 {
     _matchedRestrictions = new[]
         {
             new MethodRestriction("GET"),
             new MethodRestriction("POST")
         };
     _cacheKey = "id";
     _matchResult = MatchResult.RouteMatched(_matchedRestrictions, _cacheKey);
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
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)));
        }
Exemplo n.º 6
0
 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);
 }