Example #1
0
        private static string GetRouteUrl(AbstractUrlPattern url)
        {
            var range          = Enumerable.Range(0, url.SimpleParameterCount);
            var parameterNames = range.Select(i => "{" + url.ParameterName(i) + "}").ToArray();

            return(string.Format(NoInitialSlash(url.PathPattern), (object[])parameterNames));
        }
Example #2
0
        private static string[] UrlStringParameters(AbstractUrlPattern url, RequestContext req)
        {
            var parameters = url.ParameterCount == 0 ? null : new string[url.ParameterCount];
            var values     = req.RouteData.Values;

            for (int i = 0; i < url.PathParameterCount; i++)
            {
                parameters[i] = (values[url.ParameterName(i)] as string) ?? "";
            }

            var query = req.HttpContext.Request.QueryString;

            for (int i = url.PathParameterCount; i < url.ParameterCount; i++)
            {
                parameters[i] = (query[url.ParameterName(i)] as string) ?? "";
            }

            return(parameters);
        }
Example #3
0
 public static string GetRouteName(this AbstractUrlPattern pattern)
 {
     return(pattern.PathPattern);
 }