public PhonebookCommand ReadCommand(string line)
        {
            string commandType = line.Substring(0, line.IndexOf('(')).Trim();

            string commandArgs = line.Split('(', ')')[1].Trim();

            string[] args = commandArgs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < args.Length; i++)
            {
                args[i] = args[i].Trim();
            }

            Commands type;

            PhonebookCommand command = null;

            switch (commandType)
            {
            case "find": type = Commands.Find; command = new FindCommand(args); break;

            case "serialize": type = Commands.Serialize; command = new SerializeCommand(args); break;

            case "add": type = Commands.add; command = new AddCommand(args); break;

            default: type = Commands.Find; command = new FindCommand(args); break;
            }

            return(command);
        }
        public List <PhonebookCommand> GetCommands()
        {
            List <PhonebookCommand> commands = new List <PhonebookCommand>();

            using (this.reader)
            {
                string   text  = this.reader.ReadToEnd();
                string[] lines = text.Split(new char[] { '\n', '\r', '\t' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var line in lines)
                {
                    PhonebookCommand command = ReadCommand(line);
                    commands.Add(command);
                }

                this.reader.Close();
                return(commands);
            }
        }