Ejemplo n.º 1
0
    /// <inheritdoc />
    public bool Match(
        HttpContext?httpContext,
        IRouter?route,
        string routeKey,
        RouteValueDictionary values,
        RouteDirection routeDirection)
    {
        if (routeKey == null)
        {
            throw new ArgumentNullException(nameof(routeKey));
        }

        if (values == null)
        {
            throw new ArgumentNullException(nameof(values));
        }

        if (values.TryGetValue(routeKey, out var obj) && obj != null)
        {
            var value = Convert.ToString(obj, CultureInfo.InvariantCulture);
            return(!FileNameRouteConstraint.IsFileName(value));
        }

        // No value or null value.
        //
        // We want to return true here because the core use-case of the constraint is to *exclude*
        // things that look like file names. There's nothing here that looks like a file name, so
        // let it through.
        return(true);
    }
Ejemplo n.º 2
0
 bool IParameterLiteralNodeMatchingPolicy.MatchesLiteral(string parameterName, string literal)
 {
     return(!FileNameRouteConstraint.IsFileName(literal));
 }