コード例 #1
0
        public IEnumerable<IHttpRoute> Build(RouteBuilderInfo builderHelper)
        {
            var route = builderHelper.CreateRoute(GenerateRouteTemplate(builderHelper));

            builderHelper.ActionCall.SetParamsDefaults(route.Defaults);
            foreach (var arg in builderHelper.ActionCall.GetArgumentNames())
            {
                IHttpRouteConstraint constraint = GetConstraint(builderHelper, arg);
                if (constraint != null)
                {
                    route.Constraints[arg] = constraint;
                }
            }

            MethodInfo action = builderHelper.ActionCall.Method;
            if (action.Name.StartsWith("Get") || action.Name.StartsWith("Find") ||
                action.GetCustomAttribute<HttpGetAttribute>() != null)
            {
                route.ConstrainToGet();
            }

            if (action.Name.StartsWith("Post") || action.GetCustomAttribute<HttpPostAttribute>() != null)
            {
                route.ConstrainToPost();
            }
            return new[] { route };
        }
コード例 #2
0
        public IEnumerable <IHttpRoute> Build(RouteBuilderInfo builderHelper)
        {
            var route = builderHelper.CreateRoute(GenerateRouteTemplate(builderHelper));

            builderHelper.ActionCall.SetParamsDefaults(route.Defaults);
            foreach (var arg in builderHelper.ActionCall.GetArgumentNames())
            {
                IHttpRouteConstraint constraint = GetConstraint(builderHelper, arg);
                if (constraint != null)
                {
                    route.Constraints[arg] = constraint;
                }
            }

            MethodInfo action = builderHelper.ActionCall.Method;

            if (action.Name.StartsWith("Get") || action.Name.StartsWith("Find") ||
                action.GetCustomAttribute <HttpGetAttribute>() != null)
            {
                route.ConstrainToGet();
            }

            if (action.Name.StartsWith("Post") || action.GetCustomAttribute <HttpPostAttribute>() != null)
            {
                route.ConstrainToPost();
            }
            return(new[] { route });
        }
コード例 #3
0
        public virtual IEnumerable <Route> Build(RouteBuilderInfo info)
#endif
        {
            var modelInfo = new ModelInfo(info.ActionCall, CanBeRouteParameter);
            var route     = info.CreateRoute(BuildUrlTemplate(modelInfo));

            if (!IsCommand(info.ActionCall))
            {
                modelInfo.Members.ForEach(m =>
                {
                    SetDefaultValue(m, modelInfo.Instance, route.Defaults);
                    SetConstraint(m, info, route.Constraints);
                });
            }

            if (!IsCommand(info.ActionCall))
            {
                route.ConstrainToGet();
            }

            if (info.ActionCall.IsPost())
            {
                route.ConstrainToPost();
            }

            SetConstraints(info, route.Constraints);

            return(new[] { route });
        }
コード例 #4
0
 public IEnumerable<Route> Build(RouteBuilderInfo info)
 {
     var url = info.ActionCall.Controller.ToWebsiteRelativePath(info.ActionCall.Controller.Assembly).ToLower();
     url = url.TrimStart('~', '/');
     var route = info.CreateRoute(url);
     route.DataTokens["Namespaces"] = new[] { info.ActionCall.Controller.Namespace };
     return new[] { route };
 }
コード例 #5
0
        public IEnumerable <Route> Build(RouteBuilderInfo info)
        {
            var url = info.ActionCall.Controller.ToWebsiteRelativePath(info.ActionCall.Controller.Assembly).ToLower();

            url = url.TrimStart('~', '/');
            var route = info.CreateRoute(url);

            route.DataTokens["Namespaces"] = new[] { info.ActionCall.Controller.Namespace };
            return(new[] { route });
        }
コード例 #6
0
            Route MakeDefaultRoute()
            {
                var info  = new RouteBuilderInfo(_action, _parent);
                var route = info.CreateRoute(DefaultRouteUrl);

                if (_isModelInput)
                {
                    FillModelParamValues(route.Defaults);
                }
                else
                {
                    FillParamValues(route.Defaults);
                }
                route.ConstrainToGet();
                return(route);
            }
コード例 #7
0
		 public virtual IEnumerable<Route> Build(RouteBuilderInfo info)
#endif
        {
           var modelInfo=new ModelInfo(info.ActionCall,CanBeRouteParameter);
            var route = info.CreateRoute(BuildUrlTemplate(modelInfo));

            if (!IsCommand(info.ActionCall))
            {
                modelInfo.Members.ForEach(m =>
                {
                    SetDefaultValue(m, modelInfo.Instance, route.Defaults);
                    SetConstraint(m, info, route.Constraints);
                });
            }

            if (!IsCommand(info.ActionCall)) route.ConstrainToGet();
            
            if (info.ActionCall.IsPost()) route.ConstrainToPost();

            SetConstraints(info,route.Constraints);
                
            return new[] { route };
        }