• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Routes.RouteDefinition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



RouteDefinition类属于FubuMVC.Core.Registration.Routes命名空间,在下文中一共展示了RouteDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: 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


示例2: add_http_method_constraint

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

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


示例3: create_url_for_a_route_with_two_parameters

        public void create_url_for_a_route_with_two_parameters()
        {
            var url = new RouteDefinition<SampleViewModel>("my/sample/{InPath}/{AlsoInPath}");
            url.AddRouteInput(x => x.InPath);
            url.AddRouteInput(x => x.AlsoInPath);

            url.ToRoute().Url.ShouldEqual("my/sample/{InPath}/{AlsoInPath}");
        }
开发者ID:shashankshetty,项目名称:fubumvc,代码行数:8,代码来源:RouteDefinitionTester.cs


示例4: 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


示例5: add_constraint_to_route_with_model

        public void add_constraint_to_route_with_model()
        {
            var url = new RouteDefinition<SampleViewModel>("my/sample");
            var constraintToAdd = new HttpMethodConstraint("POST");
            url.AddRouteConstraint("httpMethod", constraintToAdd);
            Route route = url.ToRoute();

            route.Constraints["httpMethod"].ShouldEqual(constraintToAdd);
        }
开发者ID:shashankshetty,项目名称:fubumvc,代码行数:9,代码来源:RouteDefinitionTester.cs


示例6: AddBasicRouteInputs

        public static void AddBasicRouteInputs(ActionCall call, RouteDefinition route)
        {
            call.InputType()
                .GetProperties()
                .Where(x => x.HasAttribute<RouteInputAttribute>())
                .Each(prop => route.Append("{" + prop.Name + "}"));

            route.ApplyInputType(call.InputType());
        }
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:9,代码来源:DefaultUrlPolicy.cs


示例7: create_default_value_for_a_route

        public void create_default_value_for_a_route()
        {
            var url = new RouteDefinition<SampleViewModel>("my/sample");
            url.AddRouteInput(x => x.InPath);
            url.RouteInputFor("InPath").DefaultValue = "something";
            Route route = url.ToRoute();

            route.Defaults["InPath"].ShouldEqual("something");
        }
开发者ID:shashankshetty,项目名称:fubumvc,代码行数:9,代码来源:RouteDefinitionTester.cs


示例8: create_url_with_input_model

        public void create_url_with_input_model()
        {
            var url = new RouteDefinition<SampleViewModel>("test/edit/{InPath}");
            url.AddRouteInput(x => x.InPath);

            url.CreateUrl(new SampleViewModel
            {
                InPath = "5"
            }).ShouldEqual("/test/edit/5");
        }
开发者ID:bbehrens,项目名称:fubumvc,代码行数:10,代码来源:RouteDefinitionTester.cs


示例9: add_constraint_to_route_with_model

        public void add_constraint_to_route_with_model()
        {
            var parent = new RouteDefinition("my/sample");
            parent.Input = new RouteInput<SampleViewModel>(parent);
            var constraintToAdd = new HttpMethodConstraint("POST");
            parent.AddRouteConstraint("httpMethod", constraintToAdd);
            Route route = parent.ToRoute();

            route.Constraints["httpMethod"].ShouldEqual(constraintToAdd);
        }
开发者ID:Memmo,项目名称:fubumvc,代码行数:10,代码来源:RouteDefinitionTester.cs


示例10: 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


示例11: create_url_will_escape_the_url

        public void create_url_will_escape_the_url()
        {
            var url = new RouteDefinition<SampleViewModel>("test/edit/{InPath}");
            url.AddRouteInput(x => x.InPath);

            url.CreateUrl(new SampleViewModel
            {
                InPath = "some text"
            }).ShouldEqual("/test/edit/some%20text");
        }
开发者ID:shashankshetty,项目名称:fubumvc,代码行数:10,代码来源:RouteDefinitionTester.cs


示例12: create_two_default_values_for_a_route

        public void create_two_default_values_for_a_route()
        {
            var url = new RouteDefinition<SampleViewModel>("my/sample");
            url.AddRouteInput(x => x.InPath);
            url.AddRouteInput(x => x.AlsoInPath);
            url.RouteInputFor("InPath").DefaultValue = "something";
            url.RouteInputFor("AlsoInPath").DefaultValue = "something else";
            Route route = url.ToRoute();

            route.Defaults.Count().ShouldEqual(2);
        }
开发者ID:shashankshetty,项目名称:fubumvc,代码行数:11,代码来源:RouteDefinitionTester.cs


示例13: 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


示例14: adds_the_route_aliases

        public void adds_the_route_aliases()
        {
            var route1 = new RouteDefinition("something/else");
            var route2 = new RouteDefinition("again/something/else");

            var chain = theGraph.BehaviorFor<RouteAliasController>(x => x.get_something());
            var routes = chain.AdditionalRoutes;

            routes.ShouldHaveCount(2);
            routes.ShouldContain(route1);
            routes.ShouldContain(route2);
        }
开发者ID:mtscout6,项目名称:fubumvc,代码行数:12,代码来源:UrlAliasAttributeTester.cs


示例15: create_url_with_input_model_and_default_value_for_optional_input

        public void create_url_with_input_model_and_default_value_for_optional_input()
        {
            var url = new RouteDefinition<SampleViewModelWithInputs>("test/edit/{OptionalInput}");
            url.AddRouteInput(x => x.OptionalInput);

            url
                .CreateUrl(new SampleViewModelWithInputs
                {
                    OptionalInput = "a"
                })
                .ShouldEndWith("/test/edit/a");
        }
开发者ID:bbehrens,项目名称:fubumvc,代码行数:12,代码来源:RouteDefinitionTester.cs


示例16: sets_the_full_url

        public void sets_the_full_url()
        {
            var fullUrl = "this/is/a/test";

            var route = new RouteDefinition("blah");
            route.ApplyInputType(typeof(object));
            
            theChain.Route = route;
            
            theUrlResolver.Stub(x => x.UrlFor(theInput, theChain)).Return(fullUrl);
            theResolver.Stub(x => x.Find(theSearch)).Return(theChain);

            theRequest.Attach(theServices);

            theRequest.Url.ShouldEqual(fullUrl);
        }
开发者ID:joemcbride,项目名称:FubuMVC.Core.UI,代码行数:16,代码来源:FormRequestTester.cs


示例17: setupActions

        private BehaviorGraph setupActions()
        {
            var registry = new FubuRegistry();
            registry.Actions.IncludeType<RouteAliasAction1>();

            registry.Configure(x =>
            {
                theRouteDefinitionAlias = new RouteDefinition("{Client}/");
                theRouteDefinitionAlias.Input = MockRepository.GenerateMock<IRouteInput>();
                theRouteDefinitionAlias.Input.Stub(_ => _.Rank).Return(5);

                x.BehaviorFor<RouteAliasAction1>(_ => _.M1()).As<RoutedChain>().AddRouteAlias(theRouteDefinitionAlias);
            });

            return BehaviorGraph.BuildFrom(registry);
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:16,代码来源:ChainResoluationCacheRootAt.cs


示例18: 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


示例19: 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


示例20: should_not_have_constraints_by_default

        public void should_not_have_constraints_by_default()
        {
            var url = new RouteDefinition("my/sample");
            Route route = url.ToRoute();

            route.Constraints.ShouldBeNull();
        }
开发者ID:shashankshetty,项目名称:fubumvc,代码行数:7,代码来源:RouteDefinitionTester.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Routes.RouteInput类代码示例发布时间:2022-05-26
下一篇:
C# Querying.ChainSearch类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap