/// <summary> /// /// </summary> /// <returns></returns> private static bool ConsoleInteractiveMode() { XmlInfo xmlInfo = XmlInfo.GetInstance; xmlInfo.ClearData(); var xsdData = LoadXsdData(); if (!xsdData.Item1) { Console.WriteLine(xsdData.Item2); return(false); } var xmlData = LoadXmlData(); if (!xmlData.Item1) { Console.WriteLine(xmlData.Item2); return(false); } if (string.Equals(xmlInfo.GetXsdPath(), xmlInfo.GetXmlPath())) { Console.WriteLine("Error! XSD and XML path are the same"); return(false); } var validateXml = ValidateXml(); if (!validateXml.Item1) { Console.WriteLine("XML validation against XSD schema failed!"); Console.WriteLine(validateXml.Item2); return(false); } Console.WriteLine(SaveHeaderAndBiFile().Item2); return(true); }
private static bool ConsoleArgumentsMode(string[] args, bool interactiveMode) { string xsdPath = null; string xmlPath = null; string xmlns = null; string xmlPrefix = null; string xmlMainElementName = null; string savePath = null; for (int i = 0; i < args.Length; i++) { switch (args[i]) { case xsdPath_opt: xsdPath = args[i + 1]; continue; case xmlPath_opt: xmlPath = args[i + 1]; continue; case xmlns_opt: xmlns = args[i + 1]; continue; case xmlpx_opt: xmlPrefix = args[i + 1]; continue; case xmlMainElement_opt: xmlMainElementName = args[i + 1]; continue; case output_opt: savePath = args[i + 1]; continue; case interactive_opt: continue; } } if (!interactiveMode && (xsdPath == null || xmlPath == null || xmlns == null || xmlPrefix == null || xmlMainElementName == null)) { Console.WriteLine("Wrong Arguments! Application not in interactive mode. Mandatory arguments: [ -xsd | -xml | -xns | -xpx | -xen ]"); Console.WriteLine("Help mode: XmlBinaryConverter -help"); Console.WriteLine("Interactive mode: XmlBinaryConverter -it"); return(false); } XmlInfo xmlInfo = XmlInfo.GetInstance; xmlInfo.ClearData(); var xsdData = LoadXsdData(xsdPath); if (!xsdData.Item1) { Console.WriteLine(xsdData.Item2); return(false); } var xmlData = LoadXmlData(xmlPath, xmlns, xmlPrefix, xmlMainElementName); if (!xmlData.Item1) { Console.WriteLine(xmlData.Item2); return(false); } if (string.Equals(xmlInfo.GetXsdPath(), xmlInfo.GetXmlPath())) { Console.WriteLine("Error! XSD and XML path are the same"); return(false); } var validateXml = ValidateXml(); if (!validateXml.Item1) { Console.WriteLine("XML validation against XSD schema failed!"); Console.WriteLine(validateXml.Item2); return(false); } Console.WriteLine(SaveHeaderAndBiFile(savePath).Item2); return(true); }