Example #1
0
    public static UrlValueConstraint Parse(string template, string segment, string constraint)
    {
        if (string.IsNullOrEmpty(constraint))
        {
            throw new ArgumentException($"Malformed segment '{segment}' in route '{template}' contains an empty constraint.");
        }

        var targetType = GetTargetType(constraint);

        if (targetType is null || !UrlValueConstraint.TryGetByTargetType(targetType, out var result))
        {
            throw new ArgumentException($"Unsupported constraint '{constraint}' in route '{template}'.");
        }

        return(result);
    }
Example #2
0
 public QueryParameterDestination(string componentParameterName, UrlValueConstraint parser, bool isArray)
 {
     ComponentParameterName = componentParameterName;
     Parser  = parser;
     IsArray = isArray;
 }