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


C# ActionCall.InputType方法代码示例

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


在下文中一共展示了ActionCall.InputType方法的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: 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

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

示例4: ActionIsIncluded

        public static bool ActionIsIncluded(ActionCall call)
        {
            if (call.HasAttribute<JsonBindingAttribute>()) return true;

            if (call.InputType() != null && call.InputType().HasAttribute<JsonBindingAttribute>())
            {
                return true;
            }

            return false;
        }
开发者ID:DarthFubuMVC,项目名称:FubuMVC.Json,代码行数:11,代码来源:IgnoreJsonBindingAttribute.cs

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

示例6: IsPassThrough

        public static bool IsPassThrough(ActionCall call)
        {
            if (call.HasAttribute<PassThroughAuthenticationAttribute>()) return true;

            if (call.InputType() != null && call.InputType().HasAttribute<PassThroughAuthenticationAttribute>())
            {
                return true;
            }

            return false;
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:11,代码来源:ExcludePassThroughAuthentication.cs

示例7: ActionIsExempted

        public static bool ActionIsExempted(ActionCall call)
        {
            if (call.HasAttribute<NotAuthenticatedAttribute>()) return true;

            if (call.InputType() != null && call.InputType().HasAttribute<NotAuthenticatedAttribute>())
            {
                return true;
            }

            return false;
        }
开发者ID:,项目名称:,代码行数:11,代码来源:

示例8: Alter

        public static void Alter(IRouteDefinition route, ActionCall call, IConfigurationObserver observer)
        {
            var properties = call.HasInput
                                 ? new TypeDescriptorCache().GetPropertiesFor(call.InputType()).Keys
                                 : new string[0];

            Alter(route, call.Method.Name, properties, text => observer.RecordCallStatus(call, text));

            if (call.HasInput)
            {
                route.ApplyInputType(call.InputType());
            }
        }
开发者ID:jemacom,项目名称:fubumvc,代码行数:13,代码来源:MethodToUrlBuilder.cs

示例9: Alter

        public static void Alter(IRouteDefinition route, ActionCall call)
        {
            var properties = call.HasInput
                                 ? new TypeDescriptorCache().GetPropertiesFor(call.InputType()).Keys
                                 : new string[0];

            Alter(route, call.Method.Name, properties, text => call.Trace(text));

            if (call.HasInput)
            {
                route.ApplyInputType(call.InputType());
            }
        }
开发者ID:aluetjen,项目名称:fubumvc,代码行数:13,代码来源:MethodToUrlBuilder.cs

示例10: Matches

        public bool Matches(ActionCall call, IConfigurationObserver log)
        {
            var result = call.InputType() == _inputType;

            if (result && _foundCallAlready)
            {
                throw new FubuException(1003,
                                        "Cannot make input type '{0}' the default route as there is more than one action that uses that input type. Either choose a input type that is used by only one action, or use the other overload of '{1}' to specify the actual action method that will be called by the default route.",
                                        _inputType.Name,
                                        ReflectionHelper.GetMethod<RouteConventionExpression>(r => r.HomeIs<object>()).
                                            Name
                    );
            }

            if (result) _foundCallAlready = true;

            if (result && log.IsRecording)
            {
                log.RecordCallStatus(call,
                                     "Action '{0}' is the default route since its input type is {1} which was specified in the configuration as the input model for the default route"
                                         .ToFormat(call.Method.Name, _inputType.Name));
            }

            return result;
        }
开发者ID:roend83,项目名称:fubumvc,代码行数:25,代码来源:DefaultRouteInputTypeBasedUrlPolicy.cs

示例11: GetSwaggerOperations

        public IEnumerable<Operation> GetSwaggerOperations(ActionCall call)
        {
            var parameters = createParameters(call);
            var outputType = call.OutputType();
            var route = call.ParentChain().Route;

            var verbs = getRouteVerbs(route);

            return verbs.Select(verb =>
                                          {
                                              var summary = call.InputType().GetAttribute<DescriptionAttribute>(d => d.Description);

                                              return new Operation
                                                         {
                                                             parameters = parameters.ToArray(),
                                                             httpMethod = verb,
                                                             responseTypeInternal = outputType.FullName,
                                                             responseClass = outputType.Name,
                                                             nickname = call.InputType().Name,
                                                             summary = summary,

                                                             //TODO not sure how we'd support error responses
                                                             errorResponses = new ErrorResponses[0],

                                                             //TODO get notes, nickname, summary from metadata?
                                                         };
                                          });
        }
开发者ID:styson,项目名称:fubumvc-swagger,代码行数:28,代码来源:SwaggerMapper.cs

示例12: Build

        public IRouteDefinition Build(ActionCall call)
        {
            var pattern = call.Method.GetAttribute<UrlPatternAttribute>().Pattern;

            return call.HasInput
                       ? RouteBuilder.Build(call.InputType(), pattern)
                       : new RouteDefinition(pattern);
        }
开发者ID:joshuaflanagan,项目名称:fubumvc,代码行数:8,代码来源:UrlPatternAttributePolicy.cs

示例13: Alter

 public override void Alter(ActionCall call)
 {
     var inputType = call.InputType();
     Types.Each(attType =>
     {
         var ruleType = RuleTypeFor(inputType, attType);
         call.ParentChain().Authorization.AddPolicy(ruleType);
     });
 }
开发者ID:RobertTheGrey,项目名称:fubumvc,代码行数:9,代码来源:AuthorizedByAttribute.cs

示例14: Alter

        public static void Alter(IRouteDefinition route, ActionCall call)
        {
            var properties = call.HasInput
                ? new TypeDescriptorCache().GetPropertiesFor(call.InputType()).Keys
                : new string[0];

            Alter(route, call.Method.Name, properties);

            if (call.HasInput)
            {
                route.ApplyInputType(call.InputType());

                if (call.InputType().CanBeCastTo<ResourcePath>())
                {

                     ResourcePath.AddResourcePathInputs(route);
                }
            }
        }
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:19,代码来源:MethodToUrlBuilder.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.InputType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。