本文整理汇总了C#中CommandLineParser.Add方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineParser.Add方法的具体用法?C# CommandLineParser.Add怎么用?C# CommandLineParser.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandLineParser
的用法示例。
在下文中一共展示了CommandLineParser.Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanParseSwitches
public void CanParseSwitches()
{
CommandLineParser clp = new CommandLineParser(new string[] { "/" }, new string[] { ":" });
clp.Add<bool>("activate");
clp.Add<bool>("option");
string[] unParsed;
Dictionary<string, object> results = clp.ParseCommandLine(new string[] { "/activate:false", "/skipThisParam", "/option" }, out unParsed);
Assert.IsTrue(results.Count == 2, @"There should only be 2 options parsed");
Assert.IsTrue(results.Any(kvp => kvp.Key == "activate"), @"The ""activate"" key should exist in the result");
Assert.IsTrue(results.Any(kvp => kvp.Key == "option"), @"The ""option"" key should exist in the result");
Assert.IsFalse((bool)results.Single(kvp => kvp.Key == "activate").Value, @"The ""activate"" object should be false");
Assert.IsTrue((bool)results.Single(kvp => kvp.Key == "option").Value, @"The ""option"" object should be true");
Assert.IsTrue(unParsed.Single() == "/skipThisParam", @"There should be one unparsed option in the command line: /skipThisParam");
}