Example #1
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 #2
0
        public ControllerRouteMapper <C> MapRoute <P1, P2, BodyType>(RequestPattern <UrlPattern <P1, P2>, BodyType> pattern, Expression <Func <C, Func <P1, P2, 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, body);
            }));
        }