本文整理汇总了C#中Processor.Handle方法的典型用法代码示例。如果您正苦于以下问题:C# Processor.Handle方法的具体用法?C# Processor.Handle怎么用?C# Processor.Handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Processor
的用法示例。
在下文中一共展示了Processor.Handle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanDisplayHelp
public void CanDisplayHelp()
{
const string text = "Supplies a value for tests.";
var proc = new Processor(defaultArgument: "--test");
proc.Handle("--test").Describe(text);
Assert.That(proc.Help(), Is.StringContaining(text));
}
示例2: CrashesOnUnassignedRequiredValues
public void CrashesOnUnassignedRequiredValues()
{
var proc = new Processor(defaultArgument: "--test");
proc.Handle("--test").Required();
Assert.Throws<ValueRequiredException>(
() => proc.Process(new string[0])
);
}
示例3: CanImplyFlagWhenPassingMultipleKeys
public void CanImplyFlagWhenPassingMultipleKeys()
{
var proc = new Processor(defaultArgument: "--test");
var test = proc.Handle("--test");
var set = new[] { "--bar", "--test", "foo" };
proc.Process(set);
Assert.That(test.Value, Is.EqualTo("foo"));
}
示例4: CanAddOptionsToDefaultArgument
public void CanAddOptionsToDefaultArgument()
{
var proc = new Processor(defaultArgument: "--test");
var test = proc.Handle("--test").TakesManyValues();
var set = new[] { "foo", "bar" };
proc.Process(set);
Assert.That(test.Value, Is.EquivalentTo(set));
}
示例5: Show
private static void Show(params string[] args)
{
var processor = new Processor(defaultArgument: "--method");
processor.Handle("--configuration", "-c").Required();
var method = processor.Handle("--method", "-m");
var full = processor.Handle("--full").Flag(false);
processor.Process(args);
var showFull = full.Enabled;
switch(method.Value.ToString())
{
case "name":
Console.WriteLine("Name: {0}", showFull ? "Adoption Option Parser" : "adoption");
break;
case "description":
Console.WriteLine("Description: {0}", showFull ? "Parses command line options!" : "option parser");
break;
}
}