當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。