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


C# Routes.RouteDefinition类代码示例

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


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


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