Class RouteMatch
Represents a route resolved by a RouteResolverBase<TData>.
This class may be used both as a dictionary of route parameter names and values, and a list of the values.
Because of its double nature, this class cannot be enumerated directly. However, you may use the Pairs property to iterate over name / value pairs, and the Values property to iterate over values.
When enumerated in a non-generic fashion via the
Namespace: EmbedIO.Routing
Syntax
public sealed class RouteMatch : IReadOnlyList<string>, IReadOnlyDictionary<string, string>
Fields
None
A RouteMatch instance that represents no match.
Declaration
public static readonly RouteMatch None
Field Value
| Type | Description |
|---|---|
| RouteMatch |
Remarks
The RouteMatch instance returned by this property has the following specifications:
- its IsMatch property is the false;
- its Path property is the empty string;
- it has no parameters;
- its SubPath property is the empty string.
This instance can be used to initialize a non-nullable field or property of type RouteMatch
Properties
Count
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
IsMatch
Gets a value indicating whether this instance actually represents a match.
Declaration
public bool IsMatch { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Item[Int32]
Declaration
public string this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index |
Property Value
| Type | Description |
|---|---|
| String |
Item[String]
Declaration
public string this[string key] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| String | key |
Property Value
| Type | Description |
|---|---|
| String |
Keys
Declaration
public IEnumerable<string> Keys { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<String> |
Names
Gets a list of the names of the route's parameters.
Declaration
public IReadOnlyList<string> Names { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<String> |
Pairs
Gets an
Declaration
public IEnumerable<KeyValuePair<string, string>> Pairs { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<KeyValuePair<String, String>> |
Path
Gets the URL path that was successfully matched against the route.
Declaration
public string Path { get; }
Property Value
| Type | Description |
|---|---|
| String |
SubPath
Gets the part of Path that follows the matched route,
prefixed by /.
For a non-base route, this property is always /.
Declaration
public string SubPath { get; }
Property Value
| Type | Description |
|---|---|
| String |
Values
Declaration
public IEnumerable<string> Values { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<String> |
Methods
ContainsKey(String)
Declaration
public bool ContainsKey(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| String | key |
Returns
| Type | Description |
|---|---|
| Boolean |
IndexOf(String)
Returns the index of the parameter with the specified name.
Declaration
public int IndexOf(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| String | name | The parameter name. |
Returns
| Type | Description |
|---|---|
| Int32 | The index of the parameter, or -1 if none of the route parameters have the specified name. |
TryGetValue(String, out String)
Declaration
public bool TryGetValue(string key, out string value)
Parameters
| Type | Name | Description |
|---|---|---|
| String | key | |
| String | value |
Returns
| Type | Description |
|---|---|
| Boolean |
UnsafeFromBasePath(String, String)
Returns a RouteMatch object equal to the one that would result by matching the specified URL path against the specified parameterless base route.
Declaration
public static RouteMatch UnsafeFromBasePath(string basePath, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| String | basePath | The base route to match |
| String | path | The URL path to match. |
Returns
| Type | Description |
|---|---|
| RouteMatch | A newly-constructed RouteMatch. |
Remarks
This method assumes that basePath is a
valid base URL path, and path
is a valid, non-base URL path or route. Otherwise, the behavior of this method
is unspecified.
Ensure that you validate both parameters before
calling this method, using either
UnsafeFromRoot(String)
Returns a RouteMatch object equal to the one
that would result by matching the specified URL path against a
base route of "/".
Declaration
public static RouteMatch UnsafeFromRoot(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | The URL path to match. |
Returns
| Type | Description |
|---|---|
| RouteMatch | A newly-constructed RouteMatch. |
Remarks
This method assumes that path
is a valid, non-base URL path or route. Otherwise, the behavior of this method
is unspecified.
Ensure that you validate path before
calling this method, using either