static void Main(string[] args) { var options = new Options(); ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error)); if (!parser.ParseArguments(args, options)) { Environment.Exit(1); } var consoleOutput = new ConsoleOutput(); var queueTools = new QueueTools(); if (!string.IsNullOrEmpty(options.DumpFile)) { if (File.Exists(options.DumpFile)) { ImportFromDumpFile(options, queueTools, consoleOutput); consoleOutput.Info(options.DumpFile, "Imported."); } else { consoleOutput.Error(options.DumpFile, "Does not exist."); Environment.Exit(1); } } else if (!Invoke(options.Name, new QTouch(options), queueTools, consoleOutput, new ConsoleInput())) { Environment.Exit(1); } }
private static void ImportFromDumpFile(Options options, QueueTools queueTools, ConsoleOutput consoleOutput) { var s = new JavaScriptSerializer(); var deserialize = s.Deserialize <IEnumerable <QueueDescriptor> >(File.ReadAllText(options.DumpFile)); foreach (var queueDescriptor in deserialize) { options.Limit = (int)queueDescriptor.Limit; options.Transactional = queueDescriptor.Transactional; Invoke(queueDescriptor.Name, new QTouch(options), queueTools, consoleOutput, new ConsoleInput()); } }