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


C# ActionCall.ToRouteDefinition方法代码示例

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


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

示例1: Build

        public IRouteDefinition Build(ActionCall call)
        {
            var entityType = GetGenericParameter(call.HandlerType);
            var pluralName = GetPluralName(entityType);
            if (call.Method.Name == "New")
            {
                var routeDefinition = call.ToRouteDefinition();
                routeDefinition.Append("api");
                routeDefinition.Append(pluralName);
                routeDefinition.Append("new");
                routeDefinition.AddHttpMethodConstraint("GET");
                return routeDefinition;
            }
            else if (call.Method.Name == "List")
            {
                var routeDefinition = call.ToRouteDefinition();
                routeDefinition.Append("api");
                routeDefinition.Append(pluralName);
                routeDefinition.AddHttpMethodConstraint("GET");
                return routeDefinition;
            }
            else if (call.Method.Name == "Add")
            {
                var routeDefinition = call.ToRouteDefinition();
                routeDefinition.Append("api");
                routeDefinition.Append(pluralName);
                routeDefinition.AddHttpMethodConstraint("POST");
                return routeDefinition;
            }

            else if (call.Method.Name == "Get")
            {
                var routeDefinition = call.ToRouteDefinition();
                routeDefinition.Append("api");
                routeDefinition.Append(pluralName);

                routeDefinition.Input.AddRouteInput(new RouteParameter(new SingleProperty(call.InputType().GetProperty("Id"))), true);
                routeDefinition.AddHttpMethodConstraint("GET");
                return routeDefinition;
            }

            else if (call.Method.Name == "Update")
            {
                var routeDefinition = call.ToRouteDefinition();
                routeDefinition.Append("api");
                routeDefinition.Append(pluralName);

                routeDefinition.Input.AddRouteInput(new RouteParameter(new SingleProperty(call.InputType().GetProperty("Id"))), true);
                routeDefinition.AddHttpMethodConstraint("POST");
                return routeDefinition;
            }

            throw new InvalidOperationException("Unknown method: " + call.Method.Name);
        }
开发者ID:adbrowne,项目名称:FubuMovies,代码行数:54,代码来源:MyUrlPolicy.cs

示例2: Build

        public IRouteDefinition Build(ActionCall call)
        {
            var routeDefinition = call.ToRouteDefinition();

            var strippedNamespace = call
                                        .HandlerType
                                        .Namespace
                                        .Replace(typeof (EndpointMarker).Namespace + ".", string.Empty);

            if (strippedNamespace != call.HandlerType.Namespace)
            {
                if (!strippedNamespace.Contains("."))
                {
                    routeDefinition.Append(BreakUpCamelCaseWithHypen(strippedNamespace));
                }
                else
                {
                    var patternParts = strippedNamespace.Split(new[] { "." }, StringSplitOptions.None);
                    foreach (var patternPart in patternParts)
                    {
                        routeDefinition.Append(BreakUpCamelCaseWithHypen(patternPart.Trim()));
                    }
                }
            }

            routeDefinition.Append(BreakUpCamelCaseWithHypen(call.HandlerType.Name.Replace(ENDPOINT, string.Empty)));
            routeDefinition.ApplyRouteInputAttributes(call);
            routeDefinition.ApplyQueryStringAttributes(call);
            return routeDefinition;
        }
开发者ID:wbinford,项目名称:kittystats,代码行数:30,代码来源:EndpointUrlPolicy.cs

示例3: Build

 public IRouteDefinition Build(ActionCall call)
 {
     var routeDefinition = call.ToRouteDefinition();
     routeDefinition.Append(call.HandlerType.Namespace.Replace(GetType().Namespace + ".", string.Empty).ToLower());
     routeDefinition.Append(call.HandlerType.Name.Replace("Handler", string.Empty).ToLower());
     return routeDefinition;
 }
开发者ID:chester89,项目名称:FubuSamples,代码行数:7,代码来源:HandlerUrlPolicy.cs

示例4: Build

 public IRouteDefinition Build(ActionCall call)
 {
     var routeDefinition = call.ToRouteDefinition();
     routeDefinition.Append(call.HandlerType.Namespace.Substring(call.HandlerType.Namespace.LastIndexOf('.') + 1));
     routeDefinition.Append(call.HandlerType.Name.Substring(0, call.HandlerType.Name.LastIndexOf("Projection")));
     return routeDefinition;
 }
开发者ID:emilcardell,项目名称:WebFrontEndCQRS,代码行数:7,代码来源:ProjectionUrlPolicy.cs

示例5: Build

        public IRouteDefinition Build(ActionCall call)
        {
            IRouteDefinition route = call.ToRouteDefinition();

            if (!IgnoreControllerNamespaceEntirely)
            {
                addNamespace(route, call);
            }

            if (!IgnoreControllerNamesEntirely)
                addClassName(route, call);

            addMethodName(route, call);

            if (call.HasInput)
            {
                _routeInputPolicy.AlterRoute(route, call);
            }

            _modifications.Each(m =>
                                    {
                                        if (m.Filter(call))
                                            m.Modify(route);
                                    });

            return route;
        }
开发者ID:RobertTheGrey,项目名称:fubumvc,代码行数:27,代码来源:UrlPolicy.cs

示例6: Build

 public IRouteDefinition Build(ActionCall call)
 {
     var routeDefinition = call.ToRouteDefinition();
     var urlAttribute = call.Method.GetAttribute<FubuDiagnosticsUrlAttribute>();
     routeDefinition.Append(DiagnosticsUrls.ToRelativeUrl(urlAttribute.Url));
     return routeDefinition;
 }
开发者ID:ketiko,项目名称:fubumvc,代码行数:7,代码来源:DiagnosticsAttributeUrlPolicy.cs

示例7: Build

        // TODO -- sucks, but need to break the IUrlPolicy signature to add diagnostics
        public IRouteDefinition Build(ActionCall call)
        {
            var route = call.ToRouteDefinition();

            // TODO -- far better diagnostics here
            if (MethodToUrlBuilder.Matches(call.Method.Name))
            {
                MethodToUrlBuilder.Alter(route, call);
                return route;
            }

            if (!IgnoreControllerNamespaceEntirely)
            {
                addNamespace(route, call);
            }

            if (!IgnoreControllerNamesEntirely)
            {
                addClassName(route, call);
            }

            AddMethodName(route, call);

            if (call.HasInput)
            {
                _routeInputPolicy.AlterRoute(route, call);
            }

            _modifications.Where(m => m.Filter(call)).Each(m => m.Modify(route));

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

示例8: Build

 public IRouteDefinition Build(ActionCall call)
 {
     var route = call.ToRouteDefinition();
     route.Append(call.HandlerType.Name.RemoveSuffix("Controller"));
     route.Append(call.Method.Name);
     return route;
 }
开发者ID:RobertTheGrey,项目名称:fubumvc,代码行数:7,代码来源:HelloSparkUrlPolicy.cs

示例9: Build

        public IRouteDefinition Build(ActionCall call)
        {
            var route = call.ToRouteDefinition();
            Alter(route, call);

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

示例10: Build

        public IRouteDefinition Build(ActionCall call)
        {
            var method = call.Method;
            var definition = call.ToRouteDefinition();
            definition.Append(DIAGNOSTICS_URL_ROOT + "/" + UrlFor(method));

            return definition;
        }
开发者ID:JordanZaerr,项目名称:FubuMVC.Diagnostics,代码行数:8,代码来源:DiagnosticUrlPolicy.cs

示例11: Build

 public IRouteDefinition Build(ActionCall call)
 {
     var def = call.ToRouteDefinition();
     var entityType = call.HandlerType.GetGenericArguments()[0];
     def.Append(entityType.Name.ToLowerInvariant());
     def.AddHttpMethodConstraint("GET");
     return def;
 }
开发者ID:rauhryan,项目名称:awesomesauce,代码行数:8,代码来源:RestfulIndexRoutingConvention.cs

示例12: Build

 public IRouteDefinition Build(ActionCall call)
 {
     var def = call.ToRouteDefinition();
     var entityType = call.HandlerType.GetGenericArguments()[0];
     def.Append(entityType.Name.ToLowerInvariant());
     def.Input.AddRouteInput(new RouteParameter(accessor),true);
     def.AddHttpMethodConstraint("DELETE");
     return def;
 }
开发者ID:KevM,项目名称:awesomesauce,代码行数:9,代码来源:RestfulDeleteRoutingConvention.cs

示例13: Build

        public IRouteDefinition Build(ActionCall call)
        {
            var routeDefinition = call.ToRouteDefinition();
            string strippedNamespace = "";

            _markerTypes
                .Each(marker =>
                          {
                              strippedNamespace = call
                                  .HandlerType
                                  .Namespace
                                  .Replace(marker.Namespace + ".", string.Empty);
                          });

            if (strippedNamespace != call.HandlerType.Namespace)
            {
                if (!strippedNamespace.Contains("."))
                {
                    routeDefinition.Append(BreakUpCamelCaseWithHypen(strippedNamespace));
                }
                else
                {
                    var patternParts = strippedNamespace.Split(new[] { "." }, StringSplitOptions.None);
                    foreach (var patternPart in patternParts)
                    {
                        routeDefinition.Append(BreakUpCamelCaseWithHypen(patternPart.Trim()));
                    }
                }
            }

            var handlerName = call.HandlerType.Name;
            var match = HandlerExpression.Match(handlerName);
            if (match.Success && MethodToUrlBuilder.Matches(handlerName))
            {
                // We're forcing handlers to end with "_handler" in this case
                handlerName = handlerName.Substring(0, match.Index);
                var properties = call.HasInput
                                 ? new TypeDescriptorCache().GetPropertiesFor(call.InputType()).Keys
                                 : new string[0];

                MethodToUrlBuilder.Alter(routeDefinition, handlerName, properties, text => { });

                if (call.HasInput)
                {
                    routeDefinition.ApplyInputType(call.InputType());
                }
            }
            else
            {
                // Otherwise we're expecting something like "GetHandler"
                var httpMethod = call.HandlerType.Name.Replace(HANDLER, string.Empty);
                routeDefinition.ConstrainToHttpMethods(httpMethod.ToUpper());
            }

            return routeDefinition;
        }
开发者ID:davidalpert,项目名称:FubuMVC.Conventions,代码行数:56,代码来源:HandlersUrlPolicy.cs

示例14: Build

        public IRouteDefinition Build(ActionCall call)
        {
            var ns = call.HandlerType.Namespace.Split('.').Last();
            var route = call.ToRouteDefinition();

            route.Append(ns);
            route.Append(call.HandlerType.Name);

            return route;
        }
开发者ID:robashton,项目名称:WorksOnMono,代码行数:10,代码来源:WomViewUrlPolicy.cs

示例15: Build

 public IRouteDefinition Build(ActionCall call)
 {
     var route = call.ToRouteDefinition();
     var properties = (call.HasInput ? new TypeDescriptorCache().GetPropertiesFor(call.InputType()).Values : Enumerable.Empty<PropertyInfo>()).ToList();
     AppendNamespace(route, call, properties, _configuration.SegmentPatterns.Where(x => x.Type == Configuration.Segment.Namespace).Select(x => x.Regex));
     AppendClass(route, call, properties, _configuration.SegmentPatterns.Where(x => x.Type == Configuration.Segment.Class).Select(x => x.Regex));
     AppendMethod(route, call, properties, _configuration.SegmentPatterns.Where(x => x.Type == Configuration.Segment.Method).Select(x => x.Regex));
     ConstrainToHttpMethod(route, call, _configuration.HttpConstraintPatterns);
     return route;
 }
开发者ID:mikeobrien,项目名称:FubuMVC.RegexUrlPolicy,代码行数:10,代码来源:RegexUrlPolicy.cs


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