public FuncReturnBehavior Select(string varName, SelectOption[] options)
        {
            Console.WriteLine("Select:");
            int counter = 1;
            foreach (SelectOption option in options)
            {
                Console.WriteLine("\t{0}: {1}", counter, option.Text);
                counter++;
            }

            bool success = false;
            int result = 0;

            do
            {
                Console.Write("请输入选项前的数字并按回车:");
                string input = Console.ReadLine();
                if (!int.TryParse(input, out result))
                {
                    Console.WriteLine("请输入一个数字!");
                    continue;
                }
                else if (result <= 0 || result > options.Length)
                {
                    Console.WriteLine("没有这个选项!");
                    continue;
                }
                else
                {
                    success = true;
                }
            } while (!success);

            if (UserSelected != null)
            {
                UserSelected(this, new SelectEventArgs(varName, options[result - 1].Value));
            }

            return FuncReturnBehavior.Next;
        }
Пример #2
0
 public virtual void Visit(SelectOption selectOption, object[] args)
 {
 }
 public virtual void Visit(SelectOption selectOption, object[] args)
 {
 }