public Properties(String[] args) { MessageHandler tmpMh = new MessageHandler(false); foreach (String arg in args) if (arg.StartsWith("-h", StringComparison.InvariantCultureIgnoreCase) || arg.StartsWith("/h", StringComparison.InvariantCultureIgnoreCase) || arg.StartsWith("-?") || arg.StartsWith("/?")) { tmpMh.printUsage(); tmpMh.exitSuccess(""); } //get full path to execution directory where config file lives String pathToExe = getExePath(); String configFile = pathToExe + Path.DirectorySeparatorChar + "GenVSTGTs.config"; if (!File.Exists(configFile)) tmpMh.exitError("\nGenVSTGTs exited with errors: 'GenVSTGTs.config' Congifuration File not found in path: '" + pathToExe + "'"); else getProperties(configFile); //gets properties and puts them into global properties Dictionary variable processCmdArgs(args); }
private void processCmdArgs(String[] args) { if (args == null || args.Length < 1) return; Console.WriteLine("\nCommand Line override argument(s) detected..\n"); String[] tmpArgs = new String[2]; cmdArgs = new Dictionary<string, string>(); foreach (String arg in args) { if (!Regex.IsMatch(arg, @"^.*\w=\w.*$")) { MessageHandler tmpMh = new MessageHandler(false); tmpMh.error("Invalid Argument! Arguments must be of the form 'KEY=VALUE'"); tmpMh.printUsage(); tmpMh.exitError(""); } tmpArgs = arg.Split('='); cmdArgs.Add(tmpArgs[0].Trim(), tmpArgs[1].Trim()); Console.WriteLine(" " + arg); } }