Esempio n. 1
0
        /// <summary>
        /// performs the action loop according to trigger values available fromt the state engine
        /// </summary>
        /// <param name="stateEngine">state engine containinig workflow definitions</param>
        public void ActionLoop(StateEngine stateEngine)
        {
            IEnumerable<WorkflowTrigger> activeTriggers;

            while( (activeTriggers = stateEngine.Actions).Count() > 0)
            {
                var optionSet = new MenuOptions<WorkflowTrigger>(activeTriggers);

                foreach(var option in optionSet.Options)
                    Console.WriteLine("  {0}", option.Value.Text);

                var input = Console.ReadLine().ToUpper();
                MenuItemInfo<WorkflowTrigger> menuItem;
                if(! optionSet.Options.TryGetValue(input, out menuItem))
                {
                    Console.WriteLine(" ** Option {0} was not understood, try again", input);
                    continue;
                }

                stateEngine.Fire(menuItem.Value);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// performs the action loop according to trigger values available fromt the state engine
        /// </summary>
        /// <param name="stateEngine">state engine containinig workflow definitions</param>
        public void ActionLoop(StateEngine stateEngine)
        {
            IEnumerable <WorkflowTrigger> activeTriggers;

            while ((activeTriggers = stateEngine.Actions).Count() > 0)
            {
                var optionSet = new MenuOptions <WorkflowTrigger>(activeTriggers);

                foreach (var option in optionSet.Options)
                {
                    Console.WriteLine("  {0}", option.Value.Text);
                }

                var input = Console.ReadLine().ToUpper();
                MenuItemInfo <WorkflowTrigger> menuItem;
                if (!optionSet.Options.TryGetValue(input, out menuItem))
                {
                    Console.WriteLine(" ** Option {0} was not understood, try again", input);
                    continue;
                }

                stateEngine.Fire(menuItem.Value);
            }
        }