parent
6c8af17e3a
commit
7f8ba171f4
|
|
@ -2,7 +2,8 @@
|
||||||
"adx-nonshipping": {
|
"adx-nonshipping": {
|
||||||
"rules": [],
|
"rules": [],
|
||||||
"packages": {
|
"packages": {
|
||||||
"Microsoft.AspNetCore.Routing.DecisionTree.Sources": {}
|
"Microsoft.AspNetCore.Routing.DecisionTree.Sources": {},
|
||||||
|
"Microsoft.AspNetCore.Routing.UrlMatchingTree.Sources": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Default": {
|
"Default": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 15.0.26927.0
|
VisualStudioVersion = 15.0.27106.3000
|
||||||
MinimumVisualStudioVersion = 15.0.26730.03
|
MinimumVisualStudioVersion = 15.0.26730.03
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0E966C37-7334-4D96-AAF6-9F49FBD166E3}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0E966C37-7334-4D96-AAF6-9F49FBD166E3}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
|
@ -57,7 +57,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DispatcherSample", "samples
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Dispatcher.Performance", "benchmarks\Microsoft.AspNetCore.Dispatcher.Performance\Microsoft.AspNetCore.Dispatcher.Performance.csproj", "{30AF355D-E3AB-4FF5-8A59-A253AFEBA26A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Dispatcher.Performance", "benchmarks\Microsoft.AspNetCore.Dispatcher.Performance\Microsoft.AspNetCore.Dispatcher.Performance.csproj", "{30AF355D-E3AB-4FF5-8A59-A253AFEBA26A}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Dispatcher.FunctionalTest", "test\Microsoft.AspNetCore.Dispatcher.FunctionalTest\Microsoft.AspNetCore.Dispatcher.FunctionalTest.csproj", "{32107601-C9BE-467B-894C-C9F2E35F03E4}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Dispatcher.FunctionalTest", "test\Microsoft.AspNetCore.Dispatcher.FunctionalTest\Microsoft.AspNetCore.Dispatcher.FunctionalTest.csproj", "{32107601-C9BE-467B-894C-C9F2E35F03E4}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,42 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
#if ROUTING
|
||||||
using Microsoft.AspNetCore.Routing.Template;
|
using Microsoft.AspNetCore.Routing.Template;
|
||||||
|
#elif DISPATCHER
|
||||||
|
using Microsoft.AspNetCore.Dispatcher;
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ROUTING
|
||||||
namespace Microsoft.AspNetCore.Routing.Tree
|
namespace Microsoft.AspNetCore.Routing.Tree
|
||||||
|
#elif DISPATCHER
|
||||||
|
namespace Microsoft.AspNetCore.Dispatcher
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#if ROUTING
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A candidate route to match incoming URLs in a <see cref="TreeRouter"/>.
|
/// A candidate route to match incoming URLs in a <see cref="TreeRouter"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
||||||
public class InboundMatch
|
public
|
||||||
|
#elif DISPATCHER
|
||||||
|
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
||||||
|
internal
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
class InboundMatch
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the <see cref="InboundRouteEntry"/>.
|
/// Gets or sets the <see cref="InboundRouteEntry"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InboundRouteEntry Entry { get; set; }
|
public InboundRouteEntry Entry { get; set; }
|
||||||
|
|
||||||
|
#if ROUTING
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the <see cref="TemplateMatcher"/>.
|
/// Gets or sets the <see cref="TemplateMatcher"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -26,5 +47,19 @@ namespace Microsoft.AspNetCore.Routing.Tree
|
||||||
{
|
{
|
||||||
return TemplateMatcher?.Template?.TemplateText;
|
return TemplateMatcher?.Template?.TemplateText;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
#elif DISPATCHER
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the <see cref="RoutePatternMatcher"/>.
|
||||||
|
/// </summary>
|
||||||
|
public RoutePatternMatcher RoutePatternMatcher { get; set; }
|
||||||
|
|
||||||
|
private string DebuggerToString()
|
||||||
|
{
|
||||||
|
return RoutePatternMatcher?.RoutePattern?.RawText;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,31 +2,40 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.AspNetCore.Dispatcher.Patterns;
|
||||||
|
#if ROUTING
|
||||||
using Microsoft.AspNetCore.Routing.Template;
|
using Microsoft.AspNetCore.Routing.Template;
|
||||||
|
#elif DISPATCHER
|
||||||
|
using Microsoft.AspNetCore.Dispatcher;
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ROUTING
|
||||||
namespace Microsoft.AspNetCore.Routing.Tree
|
namespace Microsoft.AspNetCore.Routing.Tree
|
||||||
|
#elif DISPATCHER
|
||||||
|
namespace Microsoft.AspNetCore.Dispatcher
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#if ROUTING
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to build an <see cref="TreeRouter"/>. Represents a URL template tha will be used to match incoming
|
/// Used to build a <see cref="TreeRouter"/>. Represents a route template that will be used to match incoming
|
||||||
/// request URLs.
|
/// request URLs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class InboundRouteEntry
|
public
|
||||||
|
#elif DISPATCHER
|
||||||
|
/// <summary>
|
||||||
|
/// Used to build a <see cref="TreeMatcher"/>. Represents a route pattern that will be used to match incoming
|
||||||
|
/// request URLs.
|
||||||
|
/// </summary>
|
||||||
|
internal
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
class InboundRouteEntry
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the route constraints.
|
|
||||||
/// </summary>
|
|
||||||
public IDictionary<string, IRouteConstraint> Constraints { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the route defaults.
|
|
||||||
/// </summary>
|
|
||||||
public RouteValueDictionary Defaults { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the <see cref="IRouter"/> to invoke when this entry matches.
|
|
||||||
/// </summary>
|
|
||||||
public IRouter Handler { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the order of the entry.
|
/// Gets or sets the order of the entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -43,19 +52,54 @@ namespace Microsoft.AspNetCore.Routing.Tree
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public decimal Precedence { get; set; }
|
public decimal Precedence { get; set; }
|
||||||
|
|
||||||
|
#if ROUTING
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the name of the route.
|
/// Gets or sets the name of the route.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string RouteName { get; set; }
|
public string RouteName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the route constraints.
|
||||||
|
/// </summary>
|
||||||
|
public IDictionary<string, IRouteConstraint> Constraints { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the <see cref="RouteTemplate"/>.
|
/// Gets or sets the <see cref="RouteTemplate"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RouteTemplate RouteTemplate { get; set; }
|
public RouteTemplate RouteTemplate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets an arbitrary value associated with the entry.
|
/// Gets or sets the route defaults.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public object Tag { get; set; }
|
public RouteValueDictionary Defaults { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the <see cref="IRouter"/> to invoke when this entry matches.
|
||||||
|
/// </summary>
|
||||||
|
public IRouter Handler { get; set; }
|
||||||
|
|
||||||
|
#elif DISPATCHER
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the array of endpoints associated with the entry.
|
||||||
|
/// </summary>
|
||||||
|
public Endpoint[] Endpoints { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the dispatcher value constraints.
|
||||||
|
/// </summary>
|
||||||
|
public IDictionary<string, IDispatcherValueConstraint> Constraints { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the dispatcher value defaults.
|
||||||
|
/// </summary>
|
||||||
|
public DispatcherValueCollection Defaults { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the <see cref="RoutePattern"/>.
|
||||||
|
/// </summary>
|
||||||
|
public RoutePattern RoutePattern { get; set; }
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,12 +6,16 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
#if ROUTING
|
||||||
namespace Microsoft.AspNetCore.Routing.Tree
|
namespace Microsoft.AspNetCore.Routing.Tree
|
||||||
|
#elif DISPATCHER
|
||||||
|
namespace Microsoft.AspNetCore.Dispatcher
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A node in a <see cref="UrlMatchingTree"/>.
|
|
||||||
/// </summary>
|
|
||||||
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
||||||
|
#if ROUTING
|
||||||
public class UrlMatchingNode
|
public class UrlMatchingNode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -25,11 +29,37 @@ namespace Microsoft.AspNetCore.Routing.Tree
|
||||||
Matches = new List<InboundMatch>();
|
Matches = new List<InboundMatch>();
|
||||||
Literals = new Dictionary<string, UrlMatchingNode>(StringComparer.OrdinalIgnoreCase);
|
Literals = new Dictionary<string, UrlMatchingNode>(StringComparer.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string DebuggerToString()
|
||||||
|
{
|
||||||
|
return $"Length: {Depth}, Matches: {string.Join(" | ", Matches?.Select(m => $"({m.TemplateMatcher.Template.TemplateText})"))}";
|
||||||
|
}
|
||||||
|
#elif DISPATCHER
|
||||||
|
internal class UrlMatchingNode
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the length of the path to this node in the <see cref="UrlMatchingTree"/>.
|
/// Initializes a new instance of <see cref="UrlMatchingNode"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Depth { get; }
|
/// <param name="depth">The length of the path to this node in the <see cref="UrlMatchingTree"/>.</param>
|
||||||
|
public UrlMatchingNode(int depth)
|
||||||
|
{
|
||||||
|
Depth = depth;
|
||||||
|
|
||||||
|
Matches = new List<InboundMatch>();
|
||||||
|
Literals = new Dictionary<string, UrlMatchingNode>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string DebuggerToString()
|
||||||
|
{
|
||||||
|
return $"Length: {Depth}, Matches: {string.Join(" | ", Matches?.Select(m => $"({m.RoutePatternMatcher.RoutePattern.RawText})"))}";
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the length of the path to this node in the <see cref="UrlMatchingTree"/>.
|
||||||
|
/// </summary>
|
||||||
|
public int Depth { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether this node represents a catch all segment.
|
/// Gets or sets a value indicating whether this node represents a catch all segment.
|
||||||
|
|
@ -51,31 +81,26 @@ namespace Microsoft.AspNetCore.Routing.Tree
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the <see cref="UrlMatchingNode"/> representing
|
/// Gets or sets the <see cref="UrlMatchingNode"/> representing
|
||||||
/// parameter segments with constraints following this segment in the <see cref="TreeRouter"/>.
|
/// parameter segments with constraints following this segment.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UrlMatchingNode ConstrainedParameters { get; set; }
|
public UrlMatchingNode ConstrainedParameters { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the <see cref="UrlMatchingNode"/> representing
|
/// Gets or sets the <see cref="UrlMatchingNode"/> representing
|
||||||
/// parameter segments following this segment in the <see cref="TreeRouter"/>.
|
/// parameter segments following this segment.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UrlMatchingNode Parameters { get; set; }
|
public UrlMatchingNode Parameters { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the <see cref="UrlMatchingNode"/> representing
|
/// Gets or sets the <see cref="UrlMatchingNode"/> representing
|
||||||
/// catch all parameter segments with constraints following this segment in the <see cref="TreeRouter"/>.
|
/// catch all parameter segments with constraints following this segment.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UrlMatchingNode ConstrainedCatchAlls { get; set; }
|
public UrlMatchingNode ConstrainedCatchAlls { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the <see cref="UrlMatchingNode"/> representing
|
/// Gets or sets the <see cref="UrlMatchingNode"/> representing
|
||||||
/// catch all parameter segments following this segment in the <see cref="TreeRouter"/>.
|
/// catch all parameter segments following this segment.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UrlMatchingNode CatchAlls { get; set; }
|
public UrlMatchingNode CatchAlls { get; set; }
|
||||||
|
|
||||||
private string DebuggerToString()
|
|
||||||
{
|
|
||||||
return $"Length: {Depth}, Matches: {string.Join(" | ", Matches?.Select(m => $"({m.TemplateMatcher.Template.TemplateText})"))}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,12 +1,22 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
#if ROUTING
|
||||||
namespace Microsoft.AspNetCore.Routing.Tree
|
namespace Microsoft.AspNetCore.Routing.Tree
|
||||||
|
#elif DISPATCHER
|
||||||
|
namespace Microsoft.AspNetCore.Dispatcher
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
/// <summary>
|
#if ROUTING
|
||||||
/// A tree part of a <see cref="TreeRouter"/>.
|
public
|
||||||
/// </summary>
|
#elif DISPATCHER
|
||||||
public class UrlMatchingTree
|
internal
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
class UrlMatchingTree
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of <see cref="UrlMatchingTree"/>.
|
/// Initializes a new instance of <see cref="UrlMatchingTree"/>.
|
||||||
|
|
@ -25,6 +35,6 @@ namespace Microsoft.AspNetCore.Routing.Tree
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the root of the <see cref="UrlMatchingTree"/>.
|
/// Gets the root of the <see cref="UrlMatchingTree"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UrlMatchingNode Root { get; } = new UrlMatchingNode(length: 0);
|
public UrlMatchingNode Root { get; } = new UrlMatchingNode(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,11 +3,16 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Description>API for dispatching.</Description>
|
<Description>API for dispatching.</Description>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
<DefineConstants>$(DefineConstants);DISPATCHER</DefineConstants>
|
||||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<PackageTags>aspnetcore;routing</PackageTags>
|
<PackageTags>aspnetcore;routing</PackageTags>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\..\shared\Microsoft.AspNetCore.Routing.UrlMatchingTree.Sources\**\*.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Microsoft.AspNetCore.Dispatcher.Abstractions\Microsoft.AspNetCore.Dispatcher.Abstractions.csproj" />
|
<ProjectReference Include="..\Microsoft.AspNetCore.Dispatcher.Abstractions\Microsoft.AspNetCore.Dispatcher.Abstractions.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
// 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.Diagnostics;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Dispatcher
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A candidate endpoint to match incoming URLs in a <c>TreeMatcher</c>.
|
|
||||||
/// </summary>
|
|
||||||
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
|
||||||
public class InboundMatch
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the <see cref="InboundRouteEntry"/>.
|
|
||||||
/// </summary>
|
|
||||||
public InboundRouteEntry Entry { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the <see cref="RoutePatternMatcher"/>.
|
|
||||||
/// </summary>
|
|
||||||
public RoutePatternMatcher RoutePatternMatcher { get; set; }
|
|
||||||
|
|
||||||
private string DebuggerToString()
|
|
||||||
{
|
|
||||||
return RoutePatternMatcher?.RoutePattern?.RawText;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
// 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.Collections.Generic;
|
|
||||||
using Microsoft.AspNetCore.Dispatcher.Patterns;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Dispatcher
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Used to build a <see cref="TreeMatcher"/>. Represents a route pattern that will be used to match incoming
|
|
||||||
/// request URLs.
|
|
||||||
/// </summary>
|
|
||||||
public class InboundRouteEntry
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the dispatcher value constraints.
|
|
||||||
/// </summary>
|
|
||||||
public IDictionary<string, IDispatcherValueConstraint> Constraints { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the dispatcher value defaults.
|
|
||||||
/// </summary>
|
|
||||||
public DispatcherValueCollection Defaults { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the order of the entry.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Entries are ordered first by <see cref="Order"/> (ascending) then by <see cref="Precedence"/> (descending).
|
|
||||||
/// </remarks>
|
|
||||||
public int Order { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the precedence of the entry.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Entries are ordered first by <see cref="Order"/> (ascending) then by <see cref="Precedence"/> (descending).
|
|
||||||
/// </remarks>
|
|
||||||
public decimal Precedence { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the <see cref="RoutePattern"/>.
|
|
||||||
/// </summary>
|
|
||||||
public RoutePattern RoutePattern { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets an arbitrary value associated with the entry.
|
|
||||||
/// </summary>
|
|
||||||
public object Tag { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.Dispatcher
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
await SelectEndpointAsync(context, (Endpoint[])entry.Tag);
|
await SelectEndpointAsync(context, (entry.Endpoints));
|
||||||
if (context.ShortCircuit != null)
|
if (context.ShortCircuit != null)
|
||||||
{
|
{
|
||||||
Logger.RequestShortCircuited(context);
|
Logger.RequestShortCircuited(context);
|
||||||
|
|
@ -184,7 +184,7 @@ namespace Microsoft.AspNetCore.Dispatcher
|
||||||
|
|
||||||
private InboundRouteEntry MapInbound(
|
private InboundRouteEntry MapInbound(
|
||||||
RoutePattern routePattern,
|
RoutePattern routePattern,
|
||||||
object tag,
|
Endpoint[] endpoints,
|
||||||
int order)
|
int order)
|
||||||
{
|
{
|
||||||
if (routePattern == null)
|
if (routePattern == null)
|
||||||
|
|
@ -197,7 +197,7 @@ namespace Microsoft.AspNetCore.Dispatcher
|
||||||
Precedence = RoutePrecedence.ComputeInbound(routePattern),
|
Precedence = RoutePrecedence.ComputeInbound(routePattern),
|
||||||
RoutePattern = routePattern,
|
RoutePattern = routePattern,
|
||||||
Order = order,
|
Order = order,
|
||||||
Tag = tag
|
Endpoints = endpoints,
|
||||||
};
|
};
|
||||||
|
|
||||||
var constraintBuilder = new DispatcherValueConstraintBuilder(_constraintFactory, routePattern.RawText);
|
var constraintBuilder = new DispatcherValueConstraintBuilder(_constraintFactory, routePattern.RawText);
|
||||||
|
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
||||||
// 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.Diagnostics;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Dispatcher
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A node in a <see cref="UrlMatchingTree"/>.
|
|
||||||
/// </summary>
|
|
||||||
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
|
||||||
public class UrlMatchingNode
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of <see cref="UrlMatchingNode"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="depth">The length of the path to this node in the <see cref="UrlMatchingTree"/>.</param>
|
|
||||||
public UrlMatchingNode(int depth)
|
|
||||||
{
|
|
||||||
Depth = depth;
|
|
||||||
|
|
||||||
Matches = new List<InboundMatch>();
|
|
||||||
Literals = new Dictionary<string, UrlMatchingNode>(StringComparer.OrdinalIgnoreCase);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the length of the path to this node in the <see cref="UrlMatchingTree"/>.
|
|
||||||
/// </summary>
|
|
||||||
public int Depth { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether this node represents a catch all segment.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsCatchAll { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the list of matching route entries associated with this node.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// These entries are sorted by precedence then template.
|
|
||||||
/// </remarks>
|
|
||||||
public List<InboundMatch> Matches { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the literal segments following this segment.
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<string, UrlMatchingNode> Literals { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the <see cref="UrlMatchingNode"/> representing
|
|
||||||
/// parameter segments with constraints following this segment in the <see cref="TreeMatcher"/>.
|
|
||||||
/// </summary>
|
|
||||||
public UrlMatchingNode ConstrainedParameters { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the <see cref="UrlMatchingNode"/> representing
|
|
||||||
/// parameter segments following this segment in the <see cref="TreeMatcher"/>.
|
|
||||||
/// </summary>
|
|
||||||
public UrlMatchingNode Parameters { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the <see cref="UrlMatchingNode"/> representing
|
|
||||||
/// catch all parameter segments with constraints following this segment in the <see cref="TreeMatcher"/>.
|
|
||||||
/// </summary>
|
|
||||||
public UrlMatchingNode ConstrainedCatchAlls { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the <see cref="UrlMatchingNode"/> representing
|
|
||||||
/// catch all parameter segments following this segment in the <see cref="TreeMatcher"/>.
|
|
||||||
/// </summary>
|
|
||||||
public UrlMatchingNode CatchAlls { get; set; }
|
|
||||||
|
|
||||||
private string DebuggerToString()
|
|
||||||
{
|
|
||||||
return $"Length: {Depth}, Matches: {string.Join(" | ", Matches?.Select(m => $"({m.RoutePatternMatcher.RoutePattern.RawText})"))}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Dispatcher
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A tree part of a <see cref="TreeMatcher"/>.
|
|
||||||
/// </summary>
|
|
||||||
public class UrlMatchingTree
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of <see cref="UrlMatchingTree"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="order">The order associated with endpoints in this <see cref="UrlMatchingTree"/>.</param>
|
|
||||||
public UrlMatchingTree(int order)
|
|
||||||
{
|
|
||||||
Order = order;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the order of the endpoints associated with this <see cref="UrlMatchingTree"/>.
|
|
||||||
/// </summary>
|
|
||||||
public int Order { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the root of the <see cref="UrlMatchingTree"/>.
|
|
||||||
/// </summary>
|
|
||||||
public UrlMatchingNode Root { get; } = new UrlMatchingNode(depth: 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -6,6 +6,7 @@ Commonly used types:
|
||||||
Microsoft.AspNetCore.Routing.Route
|
Microsoft.AspNetCore.Routing.Route
|
||||||
Microsoft.AspNetCore.Routing.RouteCollection</Description>
|
Microsoft.AspNetCore.Routing.RouteCollection</Description>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
<DefineConstants>$(DefineConstants);ROUTING</DefineConstants>
|
||||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<PackageTags>aspnetcore;routing</PackageTags>
|
<PackageTags>aspnetcore;routing</PackageTags>
|
||||||
|
|
@ -13,6 +14,7 @@ Microsoft.AspNetCore.Routing.RouteCollection</Description>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\..\shared\Microsoft.AspNetCore.Routing.DecisionTree.Sources\**\*.cs" />
|
<Compile Include="..\..\shared\Microsoft.AspNetCore.Routing.DecisionTree.Sources\**\*.cs" />
|
||||||
|
<Compile Include="..\..\shared\Microsoft.AspNetCore.Routing.UrlMatchingTree.Sources\**\*.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue