Example #1
0
        public override BaseActivity GetNextActivity()
        {
            if (If == null)
            {
                return(null);
            }

            BaseActivity resultActivity = null;

            var ifResult = If();

            if (ifResult)
            {
                if (True != null)
                {
                    resultActivity = True();
                }
            }
            else
            {
                if (False != null)
                {
                    resultActivity = False();
                }
            }

            return(resultActivity);
        }
        public override BaseActivity GetNextActivity()
        {
            var activityWithConditionQueue = ActivityWithConditionQueue;
            var defaultActivity            = DefaultActivity ?? FuncHelper <BaseActivity> .DoNothingReturnDefault;

            if (activityWithConditionQueue == null)
            {
                // Have no activities queue.

                return(defaultActivity());
            }

            BaseActivity resultActivity = null;
            // Using of the hasVariant flag because the resultActivity allowed to be null.
            var hasVariant = false;

            foreach (var conditionAndActivity in activityWithConditionQueue)
            {
                if (conditionAndActivity == null)
                {
                    continue;
                }
                if (conditionAndActivity.Condition == null)
                {
                    continue;
                }

                if (conditionAndActivity.Condition())
                {
                    // It is the first satisfactory conditionAndActivityPair pair.

                    hasVariant = true;

                    if (conditionAndActivity.Activity != null)
                    {
                        resultActivity = conditionAndActivity.Activity();
                    }

                    break;
                }
            }

            if (hasVariant == false)
            {
                // Has no a satisfactory activity.

                resultActivity = defaultActivity();
            }

            return(resultActivity);
        }