private void OnExportButtonClick(object sender, RoutedEventArgs e) { textBlock.Text = string.Empty; ProcessorInfo processorInfo = CreateProcessorInfo(); if (DoCreateSettingsFile.IsChecked == true) { XmlSerializer serializer = new XmlSerializer(processorInfo.GetType()); string savePath; if (!string.IsNullOrEmpty(processorInfo.outputFilesPrefix.Trim())) { savePath = Path.Combine(processorInfo.outputDir, string.Format("{0}-settings.xml", processorInfo.outputFilesPrefix)); } else { savePath = Path.Combine(processorInfo.outputDir, "settings.xml"); } using (XmlWriter writer = XmlWriter.Create(savePath)) serializer.Serialize(writer, processorInfo); } Processor.Processor.Run(processorInfo); }
public static void Main(string[] args) { Log.onLog = OnLog; Parser parser = new Parser(with => { with.EnableDashDash = true; with.CaseInsensitiveEnumValues = true; with.CaseSensitive = false; with.EnableDashDash = true; with.HelpWriter = Console.Out; }); try { parser.ParseArguments <ProcessorInfoArguments, SettingsFileArgument>(args) .WithParsed <ProcessorInfoArguments>(x => { ProcessorInfo info = (ProcessorInfo)x; if (!x.noSettingsFile) { XmlSerializer serializer = new XmlSerializer(info.GetType()); string savePath; if (!string.IsNullOrEmpty(info.outputFilesPrefix.Trim())) { savePath = Path.Combine(info.outputDir, string.Format("{0}-settings.xml", info.outputFilesPrefix)); } else { savePath = Path.Combine(info.outputDir, "settings.xml"); } using (XmlWriter writer = XmlWriter.Create(savePath)) serializer.Serialize(writer, info); } Processor.Processor.Run(info); }) .WithParsed <SettingsFileArgument>(x => { if (!File.Exists(x.file)) { Log.Line(LogType.Error, "Could not find settings file '{0}'", x.file); return; } XmlSerializer serializer = new XmlSerializer(typeof(ProcessorInfo)); using (XmlReader reader = XmlReader.Create(x.file)) { ProcessorInfo info = (ProcessorInfo)serializer.Deserialize(reader); Processor.Processor.Run(info); } }) .WithNotParsed(HandleParseErrors); } catch (Exception e) { Log.Exception(e); } finally { parser.Dispose(); } // TODO: Set the return value based on the result of the processor }