| | | 1 | | /******************************************************************************** |
| | | 2 | | * RouterConfig.cs * |
| | | 3 | | * * |
| | | 4 | | * Author: Denes Solti * |
| | | 5 | | ********************************************************************************/ |
| | | 6 | | using System; |
| | | 7 | | |
| | | 8 | | namespace NanoRoute |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Defines how the router prioritizes literal and parameterized child segments during matching. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <example> |
| | | 14 | | /// <code> |
| | | 15 | | /// builder.ConfigureRouting(config => config with { MatchingPrecedence = MatchingPrecedence.ParameterizedFirst } |
| | | 16 | | /// </code> |
| | | 17 | | /// </example> |
| | | 18 | | public enum MatchingPrecedence |
| | | 19 | | { |
| | | 20 | | /// <summary> |
| | | 21 | | /// Instructs the router to select literal child segments before parameterized child segments. |
| | | 22 | | /// </summary> |
| | | 23 | | /// <example> |
| | | 24 | | /// <code> |
| | | 25 | | /// builder.ConfigureRouting(config => config with { MatchingPrecedence = MatchingPrecedence.LiteralFirst }); |
| | | 26 | | /// </code> |
| | | 27 | | /// </example> |
| | | 28 | | LiteralFirst, |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Instructs the router to select parameterized child segments before literal child segments. |
| | | 32 | | /// </summary> |
| | | 33 | | /// <example> |
| | | 34 | | /// <code> |
| | | 35 | | /// builder.ConfigureRouting(config => config with { MatchingPrecedence = MatchingPrecedence.ParameterizedFir |
| | | 36 | | /// </code> |
| | | 37 | | /// </example> |
| | | 38 | | ParameterizedFirst |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Configures runtime behavior of <see cref="Router"/> instances. |
| | | 43 | | /// </summary> |
| | | 44 | | /// <example> |
| | | 45 | | /// <code> |
| | | 46 | | /// builder.ConfigureRouting(config => config with |
| | | 47 | | /// { |
| | | 48 | | /// MatchingPrecedence = MatchingPrecedence.ParameterizedFirst |
| | | 49 | | /// }); |
| | | 50 | | /// </code> |
| | | 51 | | /// </example> |
| | | 52 | | public record RouterConfig |
| | | 53 | | { |
| | | 54 | | /// <summary> |
| | | 55 | | /// Gets or sets how NanoRoute prioritizes literal and parameterized child segments at the same depth. |
| | | 56 | | /// </summary> |
| | | 57 | | /// <exception cref="ArgumentOutOfRangeException">Thrown when the assigned value is not a defined <see cref="Mat |
| | | 58 | | /// <example> |
| | | 59 | | /// <code> |
| | | 60 | | /// builder.ConfigureRouting(config => config with { MatchingPrecedence = MatchingPrecedence.ParameterizedFir |
| | | 61 | | /// </code> |
| | | 62 | | /// </example> |
| | | 63 | | public MatchingPrecedence MatchingPrecedence |
| | | 64 | | { |
| | | 65 | | get; |
| | | 66 | | init |
| | 1 | 67 | | { |
| | 1 | 68 | | if (!Enum.IsDefined(typeof(MatchingPrecedence), value)) |
| | 1 | 69 | | throw new ArgumentOutOfRangeException(nameof(value)); |
| | | 70 | | |
| | 1 | 71 | | field = value; |
| | 1 | 72 | | } |
| | | 73 | | } |
| | | 74 | | } |
| | | 75 | | } |