protected string Stringify <T>(UrlArgument <T> p, T value) { var stringifier = p as PathComponent <T>; return(stringifier != null ? stringifier.ToString(value) : null); }
protected RouteValueDictionary Querify <T>(UrlArgument <T> p, T value) { var querifier = p as QueryStringEncoding <T>; if (querifier == null) { return(null); } return(querifier.ToDictionary(value)); }
protected string Stringify <T>(UrlArgument <T> p, T value, int position) { try { var stringifier = p as SimpleUrlComponent <T>; return(stringifier != null ? stringifier.ToString(value) : null); } catch (InvalidUrlComponentValueException problem) { throw new InvalidUrlArgumentException(string.Format("Invalid argument {{{0}}} to construct URL “{1}”", position, this.Description), problem); } }
private static T DecodeLastParameter <T>(UrlArgument <T> descriptor, string[] parameterStrings, int index, RequestContext req) { var query = req.HttpContext.Request.QueryString; var simple = (descriptor as PathComponent <T>); var queryParam = (descriptor as QueryStringEncoding <T>); if (simple == null && queryParam == null) { throw new ArgumentException("Do not recognise UrlParameter subclass " + descriptor.GetType().Name); } if (simple != null) { return(simple.FromString(parameterStrings[index])); } else { return(queryParam.FromDictionary(req.HttpContext.Request.QueryString)); } }
protected static UrlPattern <P1, P2, P3, P4> Path <P1, P2, P3, P4>(string pattern, SimpleUrlComponent <P1> p1, SimpleUrlComponent <P2> p2, SimpleUrlComponent <P3> p3, UrlArgument <P4> p4) { return(new UrlPattern <P1, P2, P3, P4>(pattern, p1, p2, p3, p4)); }
protected static UrlPattern <P1, P2> Path <P1, P2>(string pattern, SimpleUrlComponent <P1> p1, UrlArgument <P2> p2) { return(new UrlPattern <P1, P2>(pattern, p1, p2)); }
protected static UrlPattern <P1> Path <P1>(string pattern, UrlArgument <P1> p1) { return(new UrlPattern <P1>(pattern, p1)); }
protected static UrlPattern <P1, P2, P3> Path <P1, P2, P3>(string pattern, PathComponent <P1> p1, PathComponent <P2> p2, UrlArgument <P3> p3) { return(new UrlPattern <P1, P2, P3>(pattern, p1, p2, p3)); }