This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 126
/
Route.cs
76 lines (67 loc) · 2.3 KB
/
Route.cs
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// 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;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Routing
{
public class Route : RouteBase
{
private readonly IRouter _target;
public Route(
IRouter target,
string routeTemplate,
IInlineConstraintResolver inlineConstraintResolver)
: this(
target,
routeTemplate,
defaults: null,
constraints: null,
dataTokens: null,
inlineConstraintResolver: inlineConstraintResolver)
{
}
public Route(
IRouter target,
string routeTemplate,
RouteValueDictionary defaults,
IDictionary<string, object> constraints,
RouteValueDictionary dataTokens,
IInlineConstraintResolver inlineConstraintResolver)
: this(target, null, routeTemplate, defaults, constraints, dataTokens, inlineConstraintResolver)
{
}
public Route(
IRouter target,
string routeName,
string routeTemplate,
RouteValueDictionary defaults,
IDictionary<string, object> constraints,
RouteValueDictionary dataTokens,
IInlineConstraintResolver inlineConstraintResolver)
: base(
routeTemplate,
routeName,
inlineConstraintResolver,
defaults,
constraints,
dataTokens)
{
if (target == null)
{
throw new ArgumentNullException(nameof(target));
}
_target = target;
}
public string RouteTemplate => ParsedTemplate.TemplateText;
protected override Task OnRouteMatched(RouteContext context)
{
context.RouteData.Routers.Add(_target);
return _target.RouteAsync(context);
}
protected override VirtualPathData OnVirtualPathGenerated(VirtualPathContext context)
{
return _target.GetVirtualPath(context);
}
}
}