Esempio n. 1
0
        private static IEnumerable GetContainedActivities(CompositeActivity activity)
        {
            if (!activity.Enabled)
            {
                yield break;
            }

            foreach (Activity containedActivity in activity.Activities)
            {
                if (containedActivity is CompositeActivity && !Helpers.IsCustomActivity((CompositeActivity)containedActivity))
                {
                    foreach (Activity nestedActivity in WebServiceActivityHelpers.GetContainedActivities((CompositeActivity)containedActivity))
                    {
                        if (nestedActivity.Enabled)
                        {
                            yield return(nestedActivity);
                        }
                    }
                }
                else
                {
                    if (containedActivity.Enabled)
                    {
                        yield return(containedActivity);
                    }
                }
            }
            yield break;
        }
Esempio n. 2
0
        internal static IEnumerable GetSucceedingActivities(Activity startActivity)
        {
            Activity         currentActivity = null;
            Stack <Activity> activityStack   = new Stack <Activity>();

            activityStack.Push(startActivity);

            while ((currentActivity = activityStack.Pop()) != null)
            {
                if (currentActivity is CompositeActivity && Helpers.IsCustomActivity((CompositeActivity)currentActivity))
                {
                    break;
                }

                if (currentActivity.Parent != null)
                {
                    bool pastCurrentActivity = false;

                    foreach (Activity siblingActivity in currentActivity.Parent.Activities)
                    {
                        if (siblingActivity == currentActivity)
                        {
                            pastCurrentActivity = true;
                            continue;
                        }

                        if (!pastCurrentActivity)
                        {
                            continue;
                        }

                        if (siblingActivity.Enabled)
                        {
                            if (siblingActivity is CompositeActivity && !Helpers.IsCustomActivity((CompositeActivity)siblingActivity))
                            {
                                foreach (Activity containedActivity in WebServiceActivityHelpers.GetContainedActivities((CompositeActivity)siblingActivity))
                                {
                                    yield return(containedActivity);
                                }
                            }
                            else
                            {
                                yield return(siblingActivity);
                            }
                        }
                    }
                }
                activityStack.Push(currentActivity.Parent);
            }
            yield break;
        }
Esempio n. 3
0
        internal static IEnumerable GetPreceedingActivities(Activity startActivity, bool crossOverLoop)
        {
            Activity         currentActivity = null;
            Stack <Activity> activityStack   = new Stack <Activity>();

            activityStack.Push(startActivity);

            while ((currentActivity = activityStack.Pop()) != null)
            {
                if (currentActivity is CompositeActivity && Helpers.IsCustomActivity((CompositeActivity)currentActivity))
                {
                    break;
                }

                if (currentActivity.Parent != null)
                {
                    foreach (Activity siblingActivity in currentActivity.Parent.Activities)
                    {
                        //
                        if (siblingActivity == currentActivity && ((currentActivity.Parent is ParallelActivity && !Helpers.IsFrameworkActivity(currentActivity)) || (currentActivity.Parent is StateActivity && !Helpers.IsFrameworkActivity(currentActivity))))
                        {
                            continue;
                        }

                        //
                        if (currentActivity.Parent is IfElseActivity && !Helpers.IsFrameworkActivity(currentActivity))
                        {
                            continue;
                        }

                        //For Listen Case.
                        if (currentActivity.Parent is ListenActivity && !Helpers.IsFrameworkActivity(currentActivity))
                        {
                            continue;
                        }

                        // State Machine logic:
                        // If startActivity was in the InitialState, then
                        // there are no preceeding activities.
                        // Otherwise, we just return the parent state as
                        // the preceeding activity.
                        StateActivity currentState = currentActivity.Parent as StateActivity;
                        if (currentState != null)
                        {
                            StateActivity enclosingState = StateMachineHelpers.FindEnclosingState(startActivity);
                            //If we are at Initial State there is no preceeding above us.
                            if (StateMachineHelpers.IsInitialState(enclosingState))
                            {
                                yield break;
                            }
                            else
                            {
                                yield return(currentState);
                            }
                        }

                        if (siblingActivity == currentActivity)
                        {
                            break;
                        }

                        if (siblingActivity.Enabled)
                        {
                            if (siblingActivity is CompositeActivity && !Helpers.IsCustomActivity((CompositeActivity)siblingActivity) && (crossOverLoop || !IsLoopActivity(siblingActivity)))
                            {
                                foreach (Activity containedActivity in WebServiceActivityHelpers.GetContainedActivities((CompositeActivity)siblingActivity))
                                {
                                    yield return(containedActivity);
                                }
                            }
                            else
                            {
                                yield return(siblingActivity);
                            }
                        }
                    }
                }

                if (!crossOverLoop && IsLoopActivity(currentActivity.Parent))
                {
                    break;
                }
                else
                {
                    activityStack.Push(currentActivity.Parent);
                }
            }
            yield break;
        }