forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkGenerationRoute.cs
More file actions
43 lines (37 loc) · 1.51 KB
/
Copy pathLinkGenerationRoute.cs
File metadata and controls
43 lines (37 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Web.Routing;
namespace System.Web.Mvc.Routing
{
/// <summary>
/// Adapts a named direct route into a top-level entry in the route table that can only be used
/// for generating a link (GetVirtualPath). We use these because the subroutes produced by direct
/// routing, don't go into the main collection and so can't be matched by name.
/// </summary>
/// <remarks>
/// Parallel to the Web API implementation of attribute routing in System.Web.Http.Routing.LinkGenerationRoute.
/// </remarks>
internal class LinkGenerationRoute : Route
{
private readonly Route _innerRoute;
public LinkGenerationRoute(Route innerRoute)
: base(innerRoute.Url, innerRoute.Defaults, innerRoute.Constraints, innerRoute.DataTokens,
innerRoute.RouteHandler)
{
if (innerRoute == null)
{
throw Error.ArgumentNull("innerRoute");
}
_innerRoute = innerRoute;
}
public override RouteData GetRouteData(HttpContextBase httpContext)
{
// Claims no routes
return null;
}
public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
{
return _innerRoute.GetVirtualPath(requestContext, values);
}
}
}