コード例 #1
0
        private static void FindUniqueStatesInclRunnableActivityCountDepthFirst(DcrGraph inputGraph)
        {
            Counter++;
            var activitiesToRun = inputGraph.GetRunnableActivities();

            var hashed = DcrGraph.HashDcrGraph(inputGraph);
             _seenStatesWithRunnableActivityCount.Add(hashed, activitiesToRun.Select(x => x.Id).ToList().Count);

            foreach (var activity in activitiesToRun)
            {
                // Spawn new work
                var inputGraphCopy = inputGraph.Copy();
                inputGraphCopy.Running = true;
                inputGraphCopy.Execute(inputGraphCopy.GetActivity(activity.Id));

                var stateSeen = _seenStatesWithRunnableActivityCount.ContainsKey(DcrGraph.HashDcrGraph(inputGraphCopy));

                if (!stateSeen)
                {
                    // Register wish to continue
                    FindUniqueStatesInclRunnableActivityCountDepthFirst(inputGraphCopy);
                }
            }
        }
コード例 #2
0
        private static void FindUniqueStatesInclRunnableActivityCount(DcrGraph inputGraph)
        {
            Counter++;
            var activitiesToRun = inputGraph.GetRunnableActivities();
            var iterations = new List<DcrGraph>();

            _seenStates.Add(inputGraph);

            var hashed = DcrGraph.HashDcrGraph(inputGraph);
            if (! _seenStatesWithRunnableActivityCount.ContainsKey(hashed))
            {
                _seenStatesWithRunnableActivityCount.Add(hashed, activitiesToRun.Select(x => x.Id).ToList().Count);
            }

            foreach (var activity in activitiesToRun)
            {
                // Spawn new work
                var inputGraphCopy = inputGraph.Copy();
                inputGraphCopy.Running = true;
                inputGraphCopy.Execute(inputGraphCopy.GetActivity(activity.Id));

                var stateSeen = _seenStates.Any(seenState => seenState.AreInEqualState(inputGraphCopy));

                if (!stateSeen)
                {
                    // Register wish to continue
                    iterations.Add(inputGraphCopy);
                }
            }

            // For each case where we want to go deeper, recurse
            foreach (var unseenState in iterations)
            {
                FindUniqueStatesInclRunnableActivityCount(unseenState);
            }
        }