// 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; #if ROUTING namespace Microsoft.AspNetCore.Routing.Tree #elif DISPATCHER namespace Microsoft.AspNetCore.Dispatcher #else #error #endif { [DebuggerDisplay("{DebuggerToString(),nq}")] #if ROUTING public class UrlMatchingNode { /// /// Initializes a new instance of . /// /// The length of the path to this node in the . public UrlMatchingNode(int length) { Depth = length; Matches = new List(); Literals = new Dictionary(StringComparer.OrdinalIgnoreCase); } private string DebuggerToString() { return $"Length: {Depth}, Matches: {string.Join(" | ", Matches?.Select(m => $"({m.TemplateMatcher.Template.TemplateText})"))}"; } #elif DISPATCHER internal class UrlMatchingNode { /// /// Initializes a new instance of . /// /// The length of the path to this node in the . public UrlMatchingNode(int depth) { Depth = depth; Matches = new List(); Literals = new Dictionary(StringComparer.OrdinalIgnoreCase); } private string DebuggerToString() { return $"Length: {Depth}, Matches: {string.Join(" | ", Matches?.Select(m => $"({m.RoutePatternMatcher.RoutePattern.RawText})"))}"; } #else #error #endif /// /// Gets the length of the path to this node in the . /// public int Depth { get; } /// /// Gets or sets a value indicating whether this node represents a catch all segment. /// public bool IsCatchAll { get; set; } /// /// Gets the list of matching route entries associated with this node. /// /// /// These entries are sorted by precedence then template. /// public List Matches { get; } /// /// Gets the literal segments following this segment. /// public Dictionary Literals { get; } /// /// Gets or sets the representing /// parameter segments with constraints following this segment. /// public UrlMatchingNode ConstrainedParameters { get; set; } /// /// Gets or sets the representing /// parameter segments following this segment. /// public UrlMatchingNode Parameters { get; set; } /// /// Gets or sets the representing /// catch all parameter segments with constraints following this segment. /// public UrlMatchingNode ConstrainedCatchAlls { get; set; } /// /// Gets or sets the representing /// catch all parameter segments following this segment. /// public UrlMatchingNode CatchAlls { get; set; } } }