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


C# Parser.RunStatic方法代码示例

本文整理汇总了C#中Parser.RunStatic方法的典型用法代码示例。如果您正苦于以下问题:C# Parser.RunStatic方法的具体用法?C# Parser.RunStatic怎么用?C# Parser.RunStatic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parser的用法示例。


在下文中一共展示了Parser.RunStatic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            var p = new Parser(typeof(Options));
            p.Register.HelpHandler("help,h,?", Console.WriteLine);
            p.Register.ParameterHandler("debug", () => System.Diagnostics.Debugger.Launch());
            p.Register.ErrorHandler(context => {
                if (context.Exception is CommandLineParserException)
                    Console.Write("{0}.\n{1}\n", context.Exception.Message, Options.HelpText);
                else
                    context.ReThrow = true; });

            p.RunStatic(args);
        }
开发者ID:ertseyhan,项目名称:Steg,代码行数:13,代码来源:Steg.cs

示例2: Execute_HandleError_Registered_Rethrow

        public void Execute_HandleError_Registered_Rethrow()
        {
            var p = new Parser<Sample_39>();
            var handled = false;

            p.Register.ErrorHandler(ex =>
            {
                handled = true;

                ex.ReThrow = true;
            });

            Expect(() => p.RunStatic(new string[] {}),
                   Throws.InstanceOf<Exception>());
            Expect(handled, Is.True);
        }
开发者ID:serra,项目名称:CLAP,代码行数:16,代码来源:Tests.cs

示例3: Execute_HandleError_Registered_NoRethrow

        public void Execute_HandleError_Registered_NoRethrow()
        {
            var p = new Parser<Sample_39>();
            var handled = false;

            p.Register.ErrorHandler(ex =>
            {
                handled = true;
            });

            p.RunStatic(new string[] { });

            Expect(handled, Is.True);
        }
开发者ID:serra,项目名称:CLAP,代码行数:14,代码来源:Tests.cs

示例4: Empty_Defined_NotStatic_TargetNull_Exception

        public void Empty_Defined_NotStatic_TargetNull_Exception()
        {
            var p = new Parser<Sample_15>();

            Expect(() => p.RunStatic(new string[] {}),
                   Throws.InstanceOf<ParserExecutionTargetException>());
        }
开发者ID:serra,项目名称:CLAP,代码行数:7,代码来源:Tests.cs

示例5: EmptyHandler_Static_CalledWhenNoArgs

        public void EmptyHandler_Static_CalledWhenNoArgs()
        {
            var mock = new Mock<IPrinter>();

            Sample_16.StaticPrinter = mock.Object;

            var p = new Parser<Sample_16>();

            p.RunStatic(new string[] { });

            mock.Verify(o => o.Print("a"));

            Sample_16.StaticPrinter = null;
        }
开发者ID:serra,项目名称:CLAP,代码行数:14,代码来源:Tests.cs

示例6: Run_Verb_NoMatchingMethod_Exception

        public void Run_Verb_NoMatchingMethod_Exception()
        {
            var p = new Parser<Sample_25>();

            Expect(() => p.RunStatic(new[] { "boo!" }), Throws.InstanceOf<VerbNotFoundException>());
        }
开发者ID:serra,项目名称:CLAP,代码行数:6,代码来源:Tests.cs

示例7: Run_NoVerb_NoDefaultVerb_Exception

        public void Run_NoVerb_NoDefaultVerb_Exception()
        {
            var p = new Parser<Sample_25>();

            Expect(() => p.RunStatic(new[] { "-x" }), Throws.InstanceOf<MissingDefaultVerbException>());
        }
开发者ID:serra,项目名称:CLAP,代码行数:6,代码来源:Tests.cs

示例8: RegisterEmptyHelpHandler_EmptyArguments_Called

        public void RegisterEmptyHelpHandler_EmptyArguments_Called()
        {
            var p = new Parser<Sample_25>();

            string help = null;

            p.Register.EmptyHelpHandler(h => help = h);

            Expect(help, Is.Null);

            p.RunStatic(new string[] { });

            Expect(help, Is.Not.Null);
        }
开发者ID:serra,项目名称:CLAP,代码行数:14,代码来源:Tests.cs

示例9: Help_Static

        public void Help_Static()
        {
            var mock = new Mock<IPrinter>();

            Sample_22.StaticPrinter = mock.Object;

            var p = new Parser<Sample_22>();

            p.RunStatic(new[] { "-?" });

            Sample_22.StaticPrinter = null;
        }
开发者ID:serra,项目名称:CLAP,代码行数:12,代码来源:Tests.cs

示例10: Help_NonStatic_CalledWithNull_Exception

        public void Help_NonStatic_CalledWithNull_Exception()
        {
            var p = new Parser<Sample_23>();

            p.RunStatic(new[] { "-?" });
        }
开发者ID:serra,项目名称:CLAP,代码行数:6,代码来源:Tests.cs

示例11: Execute_HandleError_Registered_Rethrow

        public void Execute_HandleError_Registered_Rethrow()
        {
            var p = new Parser<Sample_39>();
            var handled = false;

            p.Register.ErrorHandler(ex =>
            {
                handled = true;

                ex.ReThrow = true;
            });

            try
            {
                p.RunStatic(new string[] { });

                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.IsTrue(handled);
            }
        }
开发者ID:stemarie,项目名称:CLAP,代码行数:23,代码来源:Tests.cs

示例12: Execute_HandleError_Registered_DefaultNoRethrow

        public void Execute_HandleError_Registered_DefaultNoRethrow()
        {
            var p = new Parser<Sample_39>();
            var handled = false;

            p.Register.ErrorHandler(ex =>
            {
                handled = true;
            });

            p.RunStatic(new string[] { });

            Assert.IsTrue(handled);
        }
开发者ID:stemarie,项目名称:CLAP,代码行数:14,代码来源:Tests.cs

示例13: Empty_Defined_NotStatic_TargetNull_Exception

        public void Empty_Defined_NotStatic_TargetNull_Exception()
        {
            var p = new Parser<Sample_15>();

            p.RunStatic(new string[] { });
        }
开发者ID:stemarie,项目名称:CLAP,代码行数:6,代码来源:Tests.cs

示例14: Run_Verb_NoMatchingMethod_Exception

        public void Run_Verb_NoMatchingMethod_Exception()
        {
            var p = new Parser<Sample_25>();

            p.RunStatic(new[] { "boo!" });
        }
开发者ID:stemarie,项目名称:CLAP,代码行数:6,代码来源:Tests.cs

示例15: Run_NoVerb_NoDefaultVerb_Exception

        public void Run_NoVerb_NoDefaultVerb_Exception()
        {
            var p = new Parser<Sample_25>();

            p.RunStatic(new string[] { "-x" });
        }
开发者ID:stemarie,项目名称:CLAP,代码行数:6,代码来源:Tests.cs


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