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


C# ActionCall类代码示例

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


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

示例1: Apply

        public IEnumerable<IViewToken> Apply(ActionCall call, ViewBag views)
        {
            if(call.OutputType() == typeof(FubuContinuation) || !_policyResolver.HasMatchFor(call))
            {
                return new IViewToken[0];
            }

            string viewName = _policyResolver.ResolveViewName(call);
            string viewLocatorName = _policyResolver.ResolveViewLocator(call);
            IEnumerable<SparkViewToken> allViewTokens =
                views.Views.Where(view =>
                    view.GetType().CanBeCastTo<SparkViewToken>()).Cast<SparkViewToken>();

            SparkViewDescriptor matchedDescriptor = null;
            allViewTokens.FirstOrDefault(
                token =>
                {
                    matchedDescriptor = token.Descriptors
                        .Where(e => e.Templates
                                        .Any(template => template.Contains(viewLocatorName) && template.Contains(viewName)))
                        .SingleOrDefault();

                    return matchedDescriptor != null;
                });

            IEnumerable<IViewToken> viewsBoundToActions =
                matchedDescriptor != null
                    ? new IViewToken[] { new SparkViewToken(call, matchedDescriptor, viewLocatorName, viewName) }
                    : new IViewToken[0];

            return viewsBoundToActions;
        }
开发者ID:nhsevidence,项目名称:fubumvc,代码行数:32,代码来源:ActionAndViewMatchedBySparkViewDescriptors.cs

示例2: should_log_when_default_route_found

        public void should_log_when_default_route_found()
        {
            var call = new ActionCall(typeof(TestController), _method);
            _policy.Matches(call, _log);

            _log.GetLog(call).ShouldNotBeEmpty();
        }
开发者ID:roynmoore,项目名称:fubumvc,代码行数:7,代码来源:DefaultRouteInputTypeBasedUrlPolicyTester.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)
        {
            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

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

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

示例7: Apply

        public IEnumerable<IViewToken> Apply(ActionCall call, ViewBag views)
        {
            string viewName = call.Method.Name;
            string actionName = _actionNameFromActionCallConvention(call.HandlerType.Name);
            IEnumerable<SparkViewToken> allViewTokens =
                views.Views.Cast<SparkViewToken>();

            SparkViewDescriptor matchedDescriptor = null;
            allViewTokens.FirstOrDefault(
                token =>
                {
                    matchedDescriptor = token.Descriptors
                        .Where(e => e.Templates
                                        .Exists(template => template.Contains(actionName) && template.Contains(viewName)))
                        .SingleOrDefault();
                    return matchedDescriptor != null;
                });

            IEnumerable<IViewToken> viewsBoundToActions =
                matchedDescriptor != null
                    ? new IViewToken[] { new SparkViewToken(call, matchedDescriptor, actionName) }
                    : new IViewToken[0];

            return viewsBoundToActions;
        }
开发者ID:JamieDraperUK,项目名称:fubumvc,代码行数:25,代码来源:ActionAndViewMatchedBySparkViewDescriptors.cs

示例8: TransferToCall

        public Task TransferToCall(ActionCall call, string categoryOrHttpMethod = null)
        {
            var chain = _resolver.Find(call.HandlerType, call.Method, categoryOrHttpMethod);

            var partial = _factory.BuildBehavior(chain);
            return partial.InvokePartial();
        }
开发者ID:DarthFubuMVC,项目名称:fubumvc,代码行数:7,代码来源:ContinuationHandler.cs

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

示例10: BuildViewLocator

        public string BuildViewLocator(ActionCall call)
        {
            var strippedName = call.HandlerType.FullName.RemoveSuffix(DiagnosticsEndpointUrlPolicy.ENDPOINT);
            _markerTypes.Each(type => strippedName = strippedName.Replace(type.Namespace + ".", string.Empty));

            if (!strippedName.Contains("."))
            {
                return string.Empty;
            }

            var viewLocator = new StringBuilder();
            while (strippedName.Contains("."))
            {
                viewLocator.Append(strippedName.Substring(0, strippedName.IndexOf(".")));
                strippedName = strippedName.Substring(strippedName.IndexOf(".") + 1);

                var hasNext = strippedName.Contains(".");
                if (hasNext)
                {
                    viewLocator.Append(Path.DirectorySeparatorChar);
                }
            }

            return viewLocator.ToString();
        }
开发者ID:GunioRobot,项目名称:fubumvc,代码行数:25,代码来源:DiagnosticsEndpointSparkPolicy.cs

示例11: should_log_when_default_route_found

        public void should_log_when_default_route_found()
        {
            var call = new ActionCall(typeof (TestController), _method);
            _policy.Matches(call);

            call.As<ITracedModel>().StagedEvents.OfType<Traced>().Any().ShouldBeTrue();
        }
开发者ID:NeilSorensen,项目名称:fubumvc,代码行数:7,代码来源:DefaultRouteInputTypeBasedUrlPolicyTester.cs

示例12: SparkViewToken

 public SparkViewToken(ActionCall actionCall, SparkViewDescriptor matchedDescriptor, string actionName, string viewName)
 {
     _actionCall = actionCall;
     _matchedDescriptor = matchedDescriptor;
     _actionName = actionName;
     _viewName = viewName;
 }
开发者ID:joedivec,项目名称:fubumvc,代码行数:7,代码来源:SparkViewToken.cs

示例13: Alter

        public override void Alter(ActionCall call)
        {
            var chain = call.ParentChain();

            if (_formatters == FormatterOptions.All)
            {
                chain.Input.AllowHttpFormPosts = true;
                chain.UseFormatter<JsonFormatter>();
                chain.UseFormatter<XmlFormatter>();

                return;
            }

            if ((_formatters & FormatterOptions.Json) != 0)
            {
                chain.UseFormatter<JsonFormatter>();
            }

            if ((_formatters & FormatterOptions.Xml) != 0)
            {
                chain.UseFormatter<XmlFormatter>();
            }

            if ((_formatters & FormatterOptions.Html) != 0)
            {
                chain.Input.AllowHttpFormPosts = true;
            }
            else
            {
                chain.Input.AllowHttpFormPosts = false;
            }
        }
开发者ID:mtscout6,项目名称:fubumvc,代码行数:32,代码来源:ConnegAttribute.cs

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

示例15: Attach

        public virtual void Attach(IViewProfile viewProfile, ViewBag bag, ActionCall action)
        {
            // No duplicate views!
            var outputNode = action.ParentChain().Output;
            if (outputNode.HasView(viewProfile.ConditionType)) return;

            var log = new ViewAttachmentLog(viewProfile);
            action.Trace(log);

            foreach (var filter in _filters)
            {
                var viewTokens = filter.Apply(action, bag);
                var count = viewTokens.Count();

                if (count > 0)
                {
                    log.FoundViews(filter, viewTokens.Select(x => x.Resolve()));
                }

                if (count != 1) continue;

                var token = viewTokens.Single().Resolve();
                outputNode.AddView(token, viewProfile.ConditionType);

                break;
            }
        }
开发者ID:jorferreira,项目名称:fubumvc,代码行数:27,代码来源:ViewAttacher.cs


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