Unosquare
    Show / Hide Table of Contents

    Class Route

    Provides utility methods to work with routes.

    Inheritance
    Object
    Route
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: EmbedIO.Routing
    Syntax
    public static class Route

    Methods

    IsValid(String, Boolean)

    Determines whether a string is a valid route.

    To be considered a valid route, the specified string:

    • must not be null;
    • must not be the empty string;
    • must start with a slash ('/') character;
    • if a base route, must end with a slash ('/') character;
    • if not a base route, must not end with a slash ('/') character, unless it is the only character in the string;
    • must not contain consecutive runs of two or more slash ('/') characters;
    • may contain one or more parameter specifications.

    Each parameter specification must be enclosed in curly brackets ('{' and '}'. No whitespace is allowed inside a parameter specification.

    Two parameter specifications must be separated by literal text.

    A parameter specification consists of a valid parameter name, optionally followed by a '?' character to signify that it will also match an empty string.

    If '?' is not present, a parameter by default will NOT match an empty string.

    See IsValidParameterName(String) for the definition of a valid parameter name.

    To include a literal open curly bracket in the route, it must be doubled ("{{").

    A literal closed curly bracket ('}') may be included in the route as-is.

    A segment of a base route cannot consist only of an optional parameter.

    Declaration
    public static bool IsValid(string route, bool isBaseRoute)
    Parameters
    Type Name Description
    String route

    The route to check.

    Boolean isBaseRoute

    true if checking for a base route; otherwise, false.

    Returns
    Type Description
    Boolean

    true if route is a valid route; otherwise, false.

    IsValidParameterName(String)

    Determines whether a string is a valid route parameter name.

    To be considered a valid route parameter name, the specified string:

    • must not be null;
    • must not be the empty string;
    • must consist entirely of decimal digits, upper- or lower-case letters of the English alphabet, or underscore ('_') characters;
    • must not start with a decimal digit.

    Declaration
    public static bool IsValidParameterName(string value)
    Parameters
    Type Name Description
    String value

    The value.

    Returns
    Type Description
    Boolean

    true if value is a valid route parameter; otherwise, false.

    See Also

    RouteAttribute

    Comments

    Back to top Copyright © 2017-2019 Unosquare