当前位置: 首页>>代码示例>>C#>>正文


C# Parser.RunTargets方法代码示例

本文整理汇总了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);
        }
开发者ID:serra,项目名称:CLAP,代码行数:13,代码来源:Tests.cs

示例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);
        }
开发者ID:serra,项目名称:CLAP,代码行数:29,代码来源:MultiParserTests.cs

示例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.");
        }
开发者ID:serra,项目名称:CLAP,代码行数:24,代码来源:MultiParserTests.cs

示例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);
        }
开发者ID:serra,项目名称:CLAP,代码行数:29,代码来源:MultiParserTests.cs


注:本文中的Parser.RunTargets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。