/// <summary> /// Load arguments from array /// </summary> /// <param name="pArgs">Argument array from Main()</param> /// <param name="pShowHelp">Show help indicator</param> /// <returns>Arguments</returns> public XmlCastReport Load(string[] pArgs, out bool pShowHelp) { if (pArgs.Length > 0 && pArgs[1].ToString().ToLower() == "-reporttype") { if (pArgs.Length >= 13) { // Do not show help by default pShowHelp = false; string type; string value; XmlCastReport castReport = new XmlCastReport() { Snapshot = new XmlSnapshot() }; for (int i = 2; i < pArgs.Length; i += 2) { type = LoadType(pArgs[i - 1]); value = pArgs[i]; if (string.IsNullOrEmpty(type)) { // unrecognized type -> show help pShowHelp = true; // return nothing return(null); } // Set Current Argument SetArgument(type, value, castReport); } return(castReport); } else { pShowHelp = true; return(null); } } else { // Do not show help by default pShowHelp = false; if (pArgs == null || pArgs.Length == 0) { // No Arguments // unrecognized type -> show help pShowHelp = true; // return nothing return(null); } if (pArgs.Length == 1) { try { // Load from XML file return(XmlCastReport.LoadXML(pArgs[0])); } catch { // not enough arguments -> show help pShowHelp = true; // return nothing return(null); } } else if (pArgs.Length % 2 == 0) { string type; string value; XmlCastReport castReport = new XmlCastReport() { Snapshot = new XmlSnapshot() }; for (int i = 1; i < pArgs.Length; i += 2) { type = LoadType(pArgs[i - 1]); value = pArgs[i]; if (string.IsNullOrEmpty(type)) { // unrecognized type -> show help pShowHelp = true; // return nothing return(null); } // Set Current Argument SetArgument(type, value, castReport); } // all right if (!castReport.Check()) { // XSD do not check -> show help pShowHelp = true; // return nothing return(null); } return(castReport); } else { // not enough arguments -> show help pShowHelp = true; // return nothing return(null); } } }
/// <summary> /// Load arguments from array /// </summary> /// <param name="pArgs">Argument array from Main()</param> /// <param name="pShowHelp">Show help indicator</param> /// <returns>Arguments</returns> public XmlCastReport Load(string[] pArgs, out bool pShowHelp) { // Do not show help by default pShowHelp = false; // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (pArgs == null || pArgs.Length == 0) { // No Arguments // unrecognized type -> show help pShowHelp = true; // return nothing return(null); } if (pArgs.Length == 1) { try { // Load from XML file XmlCastReport cstRep = XmlCastReport.LoadXML(pArgs[0]); if (!cstRep.Check()) { // XSD do not check -> show help pShowHelp = true; // return nothing return(null); } return(cstRep); } catch { // not enough arguments -> show help pShowHelp = true; // return nothing return(null); } } if (pArgs.Length % 2 == 0) { XmlCastReport castReport = new XmlCastReport() { Snapshot = new XmlSnapshot() }; for (int i = 1; i < pArgs.Length; i += 2) { var type = LoadType(pArgs[i - 1]); var value = pArgs[i]; if (string.IsNullOrEmpty(type)) { // unrecognized type -> show help pShowHelp = true; // return nothing return(null); } // Set Current Argument SetArgument(type, value, castReport); } // all right if (!castReport.Check()) { // XSD do not check -> show help pShowHelp = true; // return nothing return(null); } return(castReport); } // not enough arguments -> show help pShowHelp = true; // return nothing return(null); }