SequenceFlow FindFlowToExecute(IExecutionContext context)
        {
            if (!HasOutgoing)
            {
                return(null);
            }
            if (Outgoing.Count() == 1)
            {
                // join flows
                return(Parent.FindElement <SequenceFlow>(Outgoing.ElementAt(0).Text));
            }

            foreach (var og in Outgoing)
            {
                var flow = Parent.FindElement <SequenceFlow>(og.Text);
                if (flow != null)
                {
                    if (flow.Evaluate(context))
                    {
                        return(flow);
                    }
                }
            }
            if (!String.IsNullOrEmpty(Default))
            {
                return(Parent.FindElement <SequenceFlow>(Default));
            }
            return(null);
        }
Beispiel #2
0
        protected virtual ValueTask CompleteBody(IExecutionContext context)
        {
            if (Outgoing == null)
            {
                if (_onComplete != null)
                {
                    return(_onComplete(context, this));
                }
                return(ValueTask.CompletedTask);
            }

            if (Outgoing.Count() == 1)
            {
                // simple outgouning - same token
                var targetFlow = Parent.FindElement <SequenceFlow>(Outgoing.First().Text);
                context.Schedule(targetFlow, _onComplete, _token);
                _token = null;
            }
            else
            {
                // same as task + parallelGateway
                Parent.KillToken(_token);
                _token = null;
                foreach (var flowId in Outgoing)
                {
                    var targetFlow = Parent.FindElement <SequenceFlow>(flowId.Text);
                    context.Schedule(targetFlow, _onComplete, Parent.NewToken());
                }
            }
            if (_onComplete != null)
            {
                return(_onComplete(context, this));
            }
            return(ValueTask.CompletedTask);
        }
Beispiel #3
0
 protected void ScheduleOutgoing(IExecutionContext context)
 {
     if (Outgoing == null)
     {
         return;
     }
     if (Outgoing.Count() == 1)
     {
         var targetFlow = Parent.FindElement <SequenceFlow>(Outgoing.First().Text);
         context.Schedule(targetFlow, _onComplete, _token);
     }
     else
     {
         Parent.KillToken(_token);
         foreach (var o in Outgoing)
         {
             var targetFlow = Parent.FindElement <SequenceFlow>(o.Text);
             context.Schedule(targetFlow, _onComplete, Parent.NewToken());
         }
     }
 }