Example #1
0
        protected internal virtual bool isReachable(PvmActivity srcActivity, PvmActivity targetActivity, ISet <PvmActivity> visitedActivities)
        {
            if (srcActivity.Equals(targetActivity))
            {
                return(true);
            }

            if (visitedActivities.Contains(srcActivity))
            {
                return(false);
            }

            // To avoid infinite looping, we must capture every node we visit and
            // check before going further in the graph if we have already visited the node.
            visitedActivities.Add(srcActivity);

            IList <PvmTransition> outgoingTransitions = srcActivity.OutgoingTransitions;

            if (outgoingTransitions.Count == 0)
            {
                if (srcActivity.ActivityBehavior is EventBasedGatewayActivityBehavior)
                {
                    ActivityImpl        eventBasedGateway = (ActivityImpl)srcActivity;
                    ISet <ActivityImpl> eventActivities   = eventBasedGateway.EventActivities;

                    foreach (ActivityImpl eventActivity in eventActivities)
                    {
                        bool isReachable = isReachable(eventActivity, targetActivity, visitedActivities);

                        if (isReachable)
                        {
                            return(true);
                        }
                    }
                }
                else
                {
                    ScopeImpl flowScope = srcActivity.FlowScope;
                    if (flowScope != null && flowScope is PvmActivity)
                    {
                        return(isReachable((PvmActivity)flowScope, targetActivity, visitedActivities));
                    }
                }

                return(false);
            }
            else
            {
                foreach (PvmTransition pvmTransition in outgoingTransitions)
                {
                    PvmActivity destinationActivity = pvmTransition.Destination;
                    if (destinationActivity != null && !visitedActivities.Contains(destinationActivity))
                    {
                        bool reachable = isReachable(destinationActivity, targetActivity, visitedActivities);

                        // If false, we should investigate other paths, and not yet return the result
                        if (reachable)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Example #2
0
            protected internal virtual bool isReThrowingEscalationEventSubprocess(EscalationEventDefinition escalationEventDefinition)
            {
                PvmActivity escalationHandler = escalationEventDefinition.EscalationHandler;

                return(escalationHandler.SubProcessScope && escalationHandler.Equals(throwEscalationActivity.FlowScope));
            }