public IHttpVirtualPathData GetVirtualPath( HttpRequestMessage request, IDictionary <string, object> values ) { return(_innerRoute.GetVirtualPath(request, values)); }
public void IgnoreRouteInternalNeverMatchesUrlGeneration() { // Arrange HttpRouteCollection routes = new HttpRouteCollection(); IHttpRoute route = routes.IgnoreRoute("Foo", "SomeRouteTemplate"); // Act IHttpVirtualPathData vpd = route.GetVirtualPath(new HttpRequestMessage(HttpMethod.Get, "SomeRouteTemplate"), null); // Assert Assert.Null(vpd); }
public Dictionary <string, string> GenerateVirtualPath() { Dictionary <string, string> result = new Dictionary <string, string>(); IHttpRoute defaultApi = RequestContext.Configuration.Routes["DefaultApi"]; IHttpRoute customerApi = RequestContext.Configuration.Routes["CustomerApi"]; HttpRouteValueDictionary vals = new HttpRouteValueDictionary(); vals.Add("controller", "Demo"); vals.Add("action", "Get"); vals.Add(HttpRoute.HttpRouteKey, true);//可能是必须 var defaultPath = defaultApi.GetVirtualPath(Request, vals); var customerPath = customerApi.GetVirtualPath(Request, vals); result.Add("DefaultApi", defaultPath.VirtualPath); result.Add("CustomerApi", customerPath.VirtualPath); return(result); }
public void GetVirtualPath_MatchesHttpRoute(string odataPath) { HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/vpath/prefix/Customers"); HttpConfiguration config = new HttpConfiguration(new HttpRouteCollection("http://localhost/vpath")); request.SetConfiguration(config); IHttpRoute httpRoute = config.Routes.CreateRoute("prefix/{*odataPath}", defaults: null, constraints: null); ODataRoute odataRoute = new ODataRoute("prefix", pathConstraint: null); // Test that the link generated by ODataRoute matches the one generated by HttpRoute Assert.Equal( httpRoute.GetVirtualPath(request, new HttpRouteValueDictionary { { "odataPath", odataPath }, { "httproute", true } }).VirtualPath, odataRoute.GetVirtualPath(request, new HttpRouteValueDictionary { { "odataPath", odataPath }, { "httproute", true } }).VirtualPath); }
public IHttpVirtualPathData GetVirtualPath(HttpRequestMessage request, IDictionary <string, object> values) { string currentCulture = Thread.CurrentThread.CurrentUICulture.Name; // If specific path is requested, override culture and remove RouteValue if (values.ContainsKey("culture")) { currentCulture = (string)values["culture"]; } IHttpRoute localizationRoute = GetLocalizedOrDefaultRoute(currentCulture); if (localizationRoute == null) { return(null); } // Get translated route from child route IHttpVirtualPathData pathData = localizationRoute.GetVirtualPath(request, CopyAndRemoveFromValueDictionary(values)); return(pathData); }
private IHttpVirtualPathData GetVirtualPath(IHttpRoute odataRoute, HttpRequestMessage request, IDictionary <string, object> values) { return(odataRoute.GetVirtualPath( request, new HttpRouteValueDictionary(values))); }