コード例 #1
0
        public override void Execute()
        {
            if (String.IsNullOrWhiteSpace(Supplement))
            {
                throw new CommandException(
                          $"Please enter a valid supplement for the command \"{Body}\""
                          );
            }

            String[] validSupplements = new String[] {
                //"AFN",
                "AFD"
            };

            if (Program.CurrentAutomata != null)
            {
                try {
                    var conversionType = Supplement.ToUpper();
                    if (validSupplements.Contains(conversionType))
                    {
                        if (conversionType == "AFN")
                        {
                            //Program.CurrentAutomata = AutomataConverter.ToNDFA(Program.CurrentAutomata);
                        }
                        else if (conversionType == "AFD")
                        {
                            Program.CurrentAutomata = AutomataConverter.ToDFA(Program.CurrentAutomata);
                        }
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Automata succesfully converted! Type 'show_automata' to see its inner members.");
                        Console.ResetColor();
                    }
                    else
                    {
                        Program.LogError($"{Supplement} is not a valid conversion type.");
                    }
                } catch (Exception e) {
                    Program.LogError(e.Message);
                }
            }
            else
            {
                Program.LogError("Can't convert. Automata not set.");
            }
        }