当前位置: 首页>>代码示例>>C#>>正文


C# RouteDefinition.AddHttpMethodConstraint方法代码示例

本文整理汇总了C#中FubuMVC.Core.Registration.Routes.RouteDefinition.AddHttpMethodConstraint方法的典型用法代码示例。如果您正苦于以下问题:C# RouteDefinition.AddHttpMethodConstraint方法的具体用法?C# RouteDefinition.AddHttpMethodConstraint怎么用?C# RouteDefinition.AddHttpMethodConstraint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FubuMVC.Core.Registration.Routes.RouteDefinition的用法示例。


在下文中一共展示了RouteDefinition.AddHttpMethodConstraint方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: add_multiple_http_constraints

        public void add_multiple_http_constraints()
        {
            var route = new RouteDefinition("something");
            route.AddHttpMethodConstraint("get");
            route.AddHttpMethodConstraint("POST");

            route.GetHttpMethodConstraints().ShouldHaveTheSameElementsAs("GET", "POST");
        }
开发者ID:jemacom,项目名称:fubumvc,代码行数:8,代码来源:RouteDefinitionTester.cs

示例2: Build

        public IRouteDefinition Build(ActionCall call)
        {
            var className = call.HandlerType.Name.ToLower()
                .Replace("endpoints", "")
                .Replace("endpoint", "")
                
                .Replace("controller", "");

            RouteDefinition route = null;
            if (RouteDefinition.VERBS.Any(x => x.EqualsIgnoreCase(call.Method.Name)))
            {
                route = new RouteDefinition(className);
                route.AddHttpMethodConstraint(call.Method.Name.ToUpper());
            }
            else
            {
                route = new RouteDefinition("{0}/{1}".ToFormat(className, call.Method.Name.ToLowerInvariant()));
            }

            if (call.InputType() != null)
            {
                if (call.InputType().CanBeCastTo<ResourcePath>())
                {
                    ResourcePath.AddResourcePathInputs(route);
                }
                else
                {
                    AddBasicRouteInputs(call, route);
                }
            }

            return route;
        }
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:33,代码来源:DefaultUrlPolicy.cs

示例3: Configure

 public void Configure(BehaviorGraph graph)
 {
     var route = new RouteDefinition("");
     route.AddHttpMethodConstraint("GET");
     var chain = new BehaviorChain { Route = route };
     chain.AddToEnd(new RedirectNode());
     graph.AddChain(chain);
     graph.Services.AddService(this);
 }
开发者ID:mikeobrien,项目名称:FubuMVC.RegexUrlPolicy,代码行数:9,代码来源:DefaultDocument.cs

示例4: Build

        public IRouteDefinition Build(ActionCall call)
        {
            Type viewModelType = call.HandlerType.GetGenericArguments()[0];

            var route = new RouteDefinition(viewModelType.Name.Replace("ViewModel","").ToLower());
            route.ApplyInputType(viewModelType);
            route.AddHttpMethodConstraint("POST");

            return route;
        }
开发者ID:davidroberts63,项目名称:Fubu-NerdDinner,代码行数:10,代码来源:SaveHandlerUrlPolicy.cs

示例5: Build

        public IRouteDefinition Build(ActionCall call)
        {
            // Later on we need to put in real plural naming.
            string pattern = call.HandlerType.GetGenericArguments()[0].Name.Replace("ViewModel", "") + "es";

            var route = new RouteDefinition(pattern.ToLower());
            route.ApplyInputType(call.InputType());
            route.AddHttpMethodConstraint("GET");

            return route;
        }
开发者ID:davidroberts63,项目名称:Fubu-NerdDinner,代码行数:11,代码来源:ListingHandlerUrlPolicy.cs

示例6: Configure

        public void Configure(BehaviorGraph graph)
        {
            if (!graph.Behaviors.Any(x => x.Route != null && x.GetRoutePattern().IsEmpty()))
            {
                var action = ActionCall.For<DefaultHome>(x => x.GoToDiagnostics());
                var continuer = new ContinuationNode();

                var route = new RouteDefinition("");
                route.AddHttpMethodConstraint("GET");
                var chain = new BehaviorChain {Route = route};
                chain.AddToEnd(action);
                chain.AddToEnd(continuer);

                graph.AddChain(chain);
            }
        }
开发者ID:DarthFubuMVC,项目名称:FubuMVC.Diagnostics,代码行数:16,代码来源:DiagnosticsRegistration.cs

示例7: Build

        public IRouteDefinition Build(ActionCall call)
        {
            string pattern = call.HandlerType.GetGenericArguments()[0].Name.Replace("ViewModel", "");

            var route = new RouteDefinition(pattern.ToLower());
            route.Append("{Id}");

            if (call.InputType().Name.StartsWith("Edit`"))
            {
                route.Append("edit");
            }
            else if (call.InputType().Name.StartsWith("Get`"))
            {
                route.Append("view");
            }

            route.ApplyInputType(call.InputType());
            route.AddHttpMethodConstraint("GET");

            return route;
        }
开发者ID:davidroberts63,项目名称:Fubu-NerdDinner,代码行数:21,代码来源:GetHandlerUrlPolicy.cs

示例8: create_route_with_http_constraints

        public void create_route_with_http_constraints()
        {
            var route = new RouteDefinition("something");
            route.AddHttpMethodConstraint("Get");
            route.AddHttpMethodConstraint("POST");

            route.ToRoute().Constraints.Single().Value.ShouldBeOfType<HttpMethodConstraint>()
                .AllowedMethods.ShouldHaveTheSameElementsAs("GET", "POST");
        }
开发者ID:jemacom,项目名称:fubumvc,代码行数:9,代码来源:RouteDefinitionTester.cs

示例9: responds_to_get_if_GET_is_explicitly_allowed

 public void responds_to_get_if_GET_is_explicitly_allowed()
 {
     var route = new RouteDefinition("something");
     route.AddHttpMethodConstraint("Get");
     route.AddHttpMethodConstraint("POST");
     route.RespondsToGet().ShouldBeTrue();
 }
开发者ID:jemacom,项目名称:fubumvc,代码行数:7,代码来源:RouteDefinitionTester.cs

示例10: does_not_respond_to_get_if_http_methods_are_explicitly_defined_and_get_is_not_allowed

 public void does_not_respond_to_get_if_http_methods_are_explicitly_defined_and_get_is_not_allowed()
 {
     var route = new RouteDefinition("something");
     route.AddHttpMethodConstraint("POST");
     route.RespondsToGet().ShouldBeFalse();
 }
开发者ID:jemacom,项目名称:fubumvc,代码行数:6,代码来源:RouteDefinitionTester.cs


注:本文中的FubuMVC.Core.Registration.Routes.RouteDefinition.AddHttpMethodConstraint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。