Пример #1
0
        protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context)
        {
            // Find first scope that supports breaking.
            var supportedScopeTypes = new[] { nameof(For), nameof(While), nameof(ForEach) }.ToHashSet();

            var query =
                from scope in context.WorkflowInstance.Scopes
                let scopeActivity = context.WorkflowExecutionContext.GetActivityBlueprintById(scope.ActivityId) !
                                    let scopeType = scopeActivity.Type
                                                    let supportsBreak = supportedScopeTypes.Contains(scopeType)
                                                                        where supportsBreak
                                                                        select scope;

            var supportedScope = query.FirstOrDefault();

            if (supportedScope != null)
            {
                context.GetActivityData(supportedScope.ActivityId).SetState("Break", true);
            }

            return(Done());
        }