本文整理汇总了C#中Parser.RunTargets方法的典型用法代码示例。如果您正苦于以下问题:C# Parser.RunTargets方法的具体用法?C# Parser.RunTargets怎么用?C# Parser.RunTargets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser.RunTargets方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandlePreMatureError_RegisteredHandler
public void HandlePreMatureError_RegisteredHandler()
{
var s = new Sample_65();
var p = new Parser<Sample_65>();
var handled = false;
p.Register.ErrorHandler(c => handled = true);
p.RunTargets(new[] { "." }, s);
Assert.IsTrue(handled);
}
示例2: MultiParser_Run_With_Target_Alias
public void MultiParser_Run_With_Target_Alias()
{
var mock = new MethodInvokerMock();
var called = false;
mock.Action = (method, obj, parameters) =>
{
called = true;
Assert.IsTrue(method.Name == "Print");
Assert.IsTrue(method.DeclaringType == typeof(Sample_03));
Assert.IsTrue(parameters.Contains(10));
Assert.IsTrue(parameters.Contains("aaa"));
};
MethodInvoker.Invoker = mock;
var p = new Parser(typeof(Sample_02), typeof(Sample_03));
p.RunTargets(new[]
{
"s03.print", //the Sample_03 class has an alias attribute of 's03'
"-c=10",
"-prefix=aaa",
}, new Sample_02(), new Sample_03());
Assert.IsTrue(called);
}
示例3: MultiParser_Run_With_Target_Alias_That_Is_Defined_More_Than_Once
public void MultiParser_Run_With_Target_Alias_That_Is_Defined_More_Than_Once()
{
var mock = new MethodInvokerMock();
var called = false;
mock.Action = (method, obj, parameters) =>
{
called = true;
};
MethodInvoker.Invoker = mock;
var p = new Parser(typeof(Sample_02), typeof(Sample_02_Default));
p.RunTargets(new[]
{
"s02.print", //both of the provided types below have the same alias attribute value.
"-c=10",
"-prefix=aaa",
}, new Sample_02(), new Sample_02_Default());
Assert.IsFalse(called, "The method should not have been called due to the conflicting aliases.");
}
示例4: MultiParser_Run_HappyFlow_2
public void MultiParser_Run_HappyFlow_2()
{
var mock = new MethodInvokerMock();
var called = false;
mock.Action = (method, obj, parameters) =>
{
called = true;
Assert.IsTrue(method.Name == "Print");
Assert.IsTrue(method.DeclaringType == typeof(Sample_02));
Assert.IsTrue(parameters.Contains(10));
Assert.IsTrue(parameters.Contains("aaa"));
};
MethodInvoker.Invoker = mock;
var p = new Parser(typeof(Sample_02), typeof(Sample_03));
p.RunTargets(new[]
{
"sample_02.print",
"-c=10",
"-prefix=aaa",
}, new Sample_02(), new Sample_03());
Assert.IsTrue(called);
}