本文整理汇总了C#中Route.Routing.Route.MatchesRequestAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Route.Routing.Route.MatchesRequestAsync方法的具体用法?C# Route.Routing.Route.MatchesRequestAsync怎么用?C# Route.Routing.Route.MatchesRequestAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Route.Routing.Route
的用法示例。
在下文中一共展示了Route.Routing.Route.MatchesRequestAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
_generator = new MostMatchingRestrictionsGenerator();
_request = MockRepository.GenerateMock<HttpRequestBase>();
_request.Stub(arg => arg.Url).Return(new Uri("http://localhost"));
_request.Stub(arg => arg.HttpMethod).Return("GET");
_response = MockRepository.GenerateMock<HttpResponseBase>();
_context = MockRepository.GenerateMock<HttpContextBase>();
_context.Stub(arg => arg.Request).Return(_request);
_context.Stub(arg => arg.Response).Return(_response);
_route1Response = new Response(200);
_route1 = new Route.Routing.Route("name1", Guid.NewGuid(), "relative1");
_route1.RestrictByMethods(HttpMethod.Get);
_route1.RespondWith(_route1Response);
_route2Response = new Response(200);
_route2 = new Route.Routing.Route("name2", Guid.NewGuid(), "relative2");
_route2.RestrictByMethods(HttpMethod.Get);
_route2.RestrictByUrl(uri => true);
_route2.RespondWith(_route2Response);
_routeMatchResults = new[]
{
new RouteMatchResult(_route1, _route1.MatchesRequestAsync(_request).Result),
new RouteMatchResult(_route2, _route2.MatchesRequestAsync(_request).Result)
};
}
示例2: SetUp
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.MatchesRequestAsync(_request).Result;
}