public static ProcessStatusOptionType GetOptionType(string option) { ProcessStatusOptionType optionType = ProcessStatusOptionType.None; foreach (var pair in Options) { foreach (var item in pair.Value) { if (item == option) { optionType = pair.Key; break; } } } return(optionType); }
private static ProcessStatusCommandLineOptions ParseOptions(CommandLineOptions commandLineOptions) { if (commandLineOptions == null) { throw new CommandLineException(string.Format(CultureInfo.CurrentCulture, "Option used in invalid context -- {0}", "must specify a option.")); } ProcessStatusCommandLineOptions targetOptions = new ProcessStatusCommandLineOptions(); if (commandLineOptions.Arguments.Count >= 0) { foreach (var arg in commandLineOptions.Arguments.Keys) { ProcessStatusOptionType optionType = ProcessStatusOptions.GetOptionType(arg); if (optionType == ProcessStatusOptionType.None) { throw new CommandLineException( string.Format(CultureInfo.CurrentCulture, "Option used in invalid context -- {0}", string.Format(CultureInfo.CurrentCulture, "cannot parse the command line argument : [{0}].", arg))); } switch (optionType) { case ProcessStatusOptionType.Help: targetOptions.IsSetHelp = true; break; case ProcessStatusOptionType.Version: targetOptions.IsSetVersion = true; break; } } } return(targetOptions); }