• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ActionCall类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: AttemptToAttachViewToAction

        public void AttemptToAttachViewToAction(ViewBag bag, ActionCall call, IConfigurationObserver observer)
        {
            foreach (var filter in _filters)
            {
                var viewTokens = filter.Apply(call, bag);
                var count = viewTokens.Count();

                observer.RecordCallStatus(call, "View filter '{0}' found {1} view token{2}".ToFormat(
                    filter.GetType().Name, count, (count != 1) ? "s" : "" ));

                if( count > 0 )
                {
                    viewTokens.Each(t =>
                        observer.RecordCallStatus(call, "Found view token: {0}".ToFormat(t)));
                }

                // if the filter returned more than one, consider it "failed", ignore it, and move on to the next
                if (count == 1)
                {
                    var token = viewTokens.First();
                    observer.RecordCallStatus(call, "Selected view token: {0}".ToFormat(token));
                    call.AddToEnd(token.ToBehavioralNode());
                    break;
                }
            }
        }
开发者ID:JamieDraperUK,项目名称:fubumvc,代码行数:26,代码来源:ViewAttacher.cs


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


示例18: Matches_should_return_true_for_GetEntityList_action_call_handlers

        public void Matches_should_return_true_for_GetEntityList_action_call_handlers()
        {
            var policy = new ListingHandlerUrlPolicy();
            var action = new ActionCall(typeof(ListingHandler<StubViewModel, StubEntity>), null);

            Assert.IsTrue(policy.Matches(action, null));
        }
开发者ID:davidroberts63,项目名称:Fubu-NerdDinner,代码行数:7,代码来源:ListingHandlerUrlPolicyTests.cs


示例19: GetJavaScriptViewToken

 private SparkViewToken GetJavaScriptViewToken(ActionCall call)
 {
     var response = JavaScriptResponse.GetResponse(call);
     string viewName = response.ViewName;
     string controllerName = call.HandlerType.Name.RemoveSuffix("Controller");
     return _viewFactory.GetViewToken(call, controllerName, viewName, Spark.LanguageType.Javascript);
 }
开发者ID:Eilon,项目名称:spark,代码行数:7,代码来源:MigrationSampleRegistry.cs


示例20: FindActions

        public IEnumerable<ActionCall> FindActions(TypePool types)
        {
            //var tpes = types.TypesMatching(t => t.Closes(typeof (StateMachine<>)));
            foreach(var sm in new List<Type>{typeof(TicketStateMachine)})
            {
                //TODO: Where can I load things into the container - using ObjDef?
                var machine = (StateMachine)Activator.CreateInstance(sm);

                var t = typeof (StateMachineOptionsAction<>).MakeGenericType(sm);
                var ta =  new ActionCall(t, t.GetMethod("Execute", BindingFlags.Public | BindingFlags.Instance));
                //can I build the route here?

                yield return ta;

                var tt = typeof(StateMachineInstanceOptionsAction<>).MakeGenericType(sm);
                yield return new ActionCall(tt, tt.GetMethod("Execute", BindingFlags.Public | BindingFlags.Instance));

                var ttt = typeof(StateMachineCurrentStateAction<>).MakeGenericType(sm);
                yield return new ActionCall(ttt, ttt.GetMethod("Execute", BindingFlags.Public | BindingFlags.Instance));

                foreach (var @event in machine.Events)
                {
                    //need to track the event name
                    //between here and the event url generation
                    //so I used a custom ActionCall extension
                    var eventName = @event.Name;
                    var et = typeof (StateMachineRaiseEventAction<,>).MakeGenericType(sm, @event.GetType());
                    var call = new EventActionCall(eventName, et, et.GetMethod("Execute", BindingFlags.Public | BindingFlags.Instance));
                    yield return call;
                }
            }
        }
开发者ID:ahjohannessen,项目名称:Hiphopanonymous,代码行数:32,代码来源:EventInvocationSource.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ActionContext类代码示例发布时间:2022-05-24
下一篇:
C# ActionBlock类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap