Example #1
0
        public static B DecodeBody <U, B>(this RequestPattern <U, B> pattern, ControllerContext req)
            where U : AbstractUrlPattern
        {
            var form = req.HttpContext.Request.Form;

            return(MvcEncoderDecoder <B> .Instance.FromDictionary(req, form));
        }
        public ControllerRouteMapper <C> MapRoute(RequestPattern <UrlPattern> pattern, Expression <Func <C, Func <ActionResult> > > handler)
        {
            var method     = GetMethodInfo(handler);
            var methodFunc = handler.Compile();

            this.AddRouteHandler(pattern, method, (c, context) => methodFunc.Invoke(c).Invoke());

            return(this);            // To allow for method chaining.
        }
Example #3
0
        // 2-argument URL patterns

        public ControllerRouteMapper <C> MapRoute <P1, P2>(RequestPattern <UrlPattern <P1, P2> > pattern, Expression <Func <C, Func <P1, P2, ActionResult> > > handler)
        {
            var methodFunc = handler.Compile();

            return(this.AddRouteHandler(pattern, handler, (c, context) =>
            {
                var p = pattern.Url.ExtractParameters(context);
                return methodFunc.Invoke(c).Invoke(p.Item1, p.Item2);
            }));
        }
Example #4
0
        public ControllerRouteMapper <C> MapRoute <BodyType>(RequestPattern <UrlPattern, BodyType> pattern, Expression <Func <C, Func <BodyType, ActionResult> > > handler)
        {
            var methodFunc = handler.Compile();

            return(this.AddRouteHandler(pattern, handler, (c, context) =>
            {
                var body = pattern.DecodeBody(context);
                return methodFunc.Invoke(c).Invoke(body);
            }));
        }
Example #5
0
        public ControllerRouteMapper <C> MapRoute <P1, P2, P3, P4, BodyType>(RequestPattern <UrlPattern <P1, P2, P3, P4>, BodyType> pattern, Expression <Func <C, Func <P1, P2, P3, P4, BodyType, ActionResult> > > handler)
        {
            var methodFunc = handler.Compile();

            return(this.AddRouteHandler(pattern, handler, (c, context) =>
            {
                var p = pattern.Url.ExtractParameters(context);
                var body = pattern.DecodeBody(context);
                return methodFunc.Invoke(c).Invoke(p.Item1, p.Item2, p.Item3, p.Item4, body);
            }));
        }
        public ControllerRouteMapper <C> MapRoute <P1, P2, P3, P4>(RequestPattern <UrlPattern <P1, P2, P3, P4> > pattern, Expression <Func <C, Func <P1, P2, P3, P4, ActionResult> > > handler)
        {
            var method     = GetMethodInfo(handler);
            var methodFunc = handler.Compile();
            var url        = pattern.Url;

            this.AddRouteHandler(pattern, method, (c, context) => {
                var p = pattern.Url.ExtractParameters(context);
                return(methodFunc.Invoke(c).Invoke(p.Item1, p.Item2, p.Item3, p.Item4));
            });

            return(this);            // To allow for method chaining.
        }
Example #7
0
        // 0-argument URL patterns

        public ControllerRouteMapper <C> MapRoute(RequestPattern <UrlPattern> pattern, Expression <Func <C, Func <ActionResult> > > handler)
        {
            var methodFunc = handler.Compile();

            return(this.AddRouteHandler(pattern, handler, (c, context) => methodFunc.Invoke(c).Invoke()));
        }
Example #8
0
 public static Route MapRoute <P1, P2, P3>(this RouteCollection routes, RequestPattern <UrlPattern <P1, P2, P3> > pattern, Func <HttpContextBase, P1, P2, P3, ActionResult> handler)
 {
     return(routes.AddRoute(pattern, FuncRouteHandler.Create(pattern, handler)));
 }