Пример #1
0
        public static List <Task> ParseTasks(string[] args)
        {
            List <Task> tasks = new List <Task>();

            try
            {
                // for invalid args.  return empty list
                if (args.Length % 2 == 0)
                {
                    Task t;

                    for (int i = 0; i < args.Length; i += 2)
                    {
                        switch (args[i].ToLower())
                        {
                        case "/ec":
                            t = new ExitCodeTask(args[i + 1]);
                            tasks.Add(t);
                            break;

                        case "/s":
                            t = new SleepTask(args[i + 1]);
                            tasks.Add(t);
                            break;

                        case "/sr":
                            t = new SleepRandomTask(args[i + 1]);
                            tasks.Add(t);
                            break;

                        case "/log":
                            t = new LogTask(args[i + 1], args);
                            tasks.Add(t);
                            break;

                        case "/pinfo":
                            t = new ProcessInfoTask(args[i + 1]);
                            tasks.Add(t);
                            break;

                        case "/fe":
                            t = new FileExistsTask(args[i + 1]);
                            tasks.Add(t);
                            break;

                        case "/regw":
                            t = new RegistryWriterTask(args[i + 1]);
                            tasks.Add(t);
                            break;

                        case "/regd":
                            t = new RegistryDeleterTask(args[i + 1]);
                            tasks.Add(t);
                            break;

                        default:
                            Console.WriteLine("Error: Invalid switch specified.");
                            return(new List <Task>());
                        }
                    }
                }
            }
            catch
            {
                Console.WriteLine("Error: Invalid switch data specified.  Couldn't parse the data.");
                return(new List <Task>());
            }

            return(tasks);
        }
Пример #2
0
Файл: Task.cs Проект: zooba/wix3
        public static List<Task> ParseTasks(string[] args)
        {
            List<Task> tasks = new List<Task>();

            try
            {
                // for invalid args.  return empty list
                if (args.Length % 2 == 0)
                {
                    Task t;

                    for (int i = 0; i < args.Length; i += 2)
                    {
                        switch (args[i].ToLower())
                        {
                            case "/ec":
                                t = new ExitCodeTask(args[i + 1]);
                                tasks.Add(t);
                                break;
                            case "/s":
                                t = new SleepTask(args[i + 1]);
                                tasks.Add(t);
                                break;
                            case "/sr":
                                t = new SleepRandomTask(args[i + 1]);
                                tasks.Add(t);
                                break;
                            case "/log":
                                t = new LogTask(args[i + 1], args);
                                tasks.Add(t);
                                break;
                            case "/pinfo":
                                t = new ProcessInfoTask(args[i + 1]);
                                tasks.Add(t);
                                break;
                            case "/fe":
                                t = new FileExistsTask(args[i + 1]);
                                tasks.Add(t);
                                break;
                            case "/regw":
                                t = new RegistryWriterTask(args[i + 1]);
                                tasks.Add(t);
                                break;
                            case "/regd":
                                t = new RegistryDeleterTask(args[i + 1]);
                                tasks.Add(t);
                                break;

                            default:
                                Console.WriteLine("Error: Invalid switch specified.");
                                return new List<Task>();
                        }
                    }
                }
            }
            catch
            {
                Console.WriteLine("Error: Invalid switch data specified.  Couldn't parse the data.");
                return new List<Task>();
            }

            return tasks;
        }