static int Main(string[] args) { var parameters = string.Join("; ", args); string from = null; string to = null; try { var builder = new DbConnectionStringBuilder() { ConnectionString = parameters }; foreach (DictionaryEntry it in (IDictionary)builder) { switch (it.Key.ToString()) { case "from": from = it.Value.ToString(); break; case "to": to = it.Value.ToString(); break; default: throw new ArgumentException("Unknown key: " + it.Key); } } if (from == null) { throw new ArgumentException("Missing key 'From'."); } if (to == null) { throw new ArgumentException("Missing key 'To'."); } } catch (Exception e) { Console.Error.WriteLine(string.Format(null, Usage, e.Message, parameters)); return(1); } try { var converter = new Converter(); using (var reader = new XmlTextReader(from)) { //! pandoc reader.XmlResolver = null; using (var writer = new StreamWriter(to, false, Encoding.UTF8)) { converter.Reader = reader; converter.Writer = writer; converter.Run(); } } return(0); } catch (Exception e) { Console.Error.WriteLine(e.Message); return(1); } }
static int Main(string[] args) { var parameters = string.Join("; ", args); string from = null; string to = null; bool verbose = false; try { var builder = new DbConnectionStringBuilder() { ConnectionString = parameters }; foreach (DictionaryEntry it in (IDictionary)builder) { switch (it.Key.ToString()) { case "from": from = it.Value.ToString(); break; case "to": to = it.Value.ToString(); break; case "verbose": verbose = bool.Parse(it.Value.ToString()); break; default: throw new Exception($"Unknown key: '{it.Key}'."); } } if (from == null) { throw new Exception("Missing required `from=<input-file>`"); } if (to == null) { throw new Exception("Missing required `to=<output-file>`"); } } catch (Exception exn) { Console.Error.WriteLine(string.Format(null, Usage, parameters, exn.Message)); return(1); } try { var settings = new XmlReaderSettings { ConformanceLevel = ConformanceLevel.Auto, // net40 DtdProcessing = DtdProcessing.Ignore, //! pandoc XmlResolver = null }; using (var reader = XmlReader.Create(from, settings)) using (var writer = new StreamWriter(to, false, Encoding.UTF8)) { var converter = new Converter(from, reader, writer, verbose); converter.Run(); } return(0); } catch (Exception exn) { Console.Error.WriteLine(exn.Message); return(1); } }
static int Main(string[] args) { var parameters = string.Join("; ", args); string from = null; string to = null; try { var builder = new DbConnectionStringBuilder() { ConnectionString = parameters }; foreach (DictionaryEntry it in (IDictionary)builder) { switch (it.Key.ToString()) { case "from": from = it.Value.ToString(); break; case "to": to = it.Value.ToString(); break; default: throw new ArgumentException("Unknown key: " + it.Key); } } if (from == null) throw new ArgumentException("Missing key 'From'."); if (to == null) throw new ArgumentException("Missing key 'To'."); } catch (Exception e) { Console.Error.WriteLine(string.Format(null, Usage, e.Message, parameters)); return 1; } try { var converter = new Converter(); using (var reader = new XmlTextReader(from)) { using (var writer = new StreamWriter(to, false, Encoding.UTF8)) { converter.Reader = reader; converter.Writer = writer; converter.Run(); } } return 0; } catch (Exception e) { Console.Error.WriteLine(e.Message); return 1; } }