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


C# Options.PrintUsage方法代码示例

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


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

示例1: Main

        //this is the driver method that I am using to test the options class as it is being written, needs to be replaced with a good unit test suite
        public static void Main (string[] args)
        {
            var opt = new Option(new []{"h","talk"},()=>Console.WriteLine("hello world"),"Prints greeting");
            var opt2 = new Option(new []{"a","add3"},(int i)=>Console.WriteLine(i+3),"value","Adds 3 to value");
            var opt3 = new Option(new []{"x","so","dsdsdsajdlasdsjkdjask","ThisIsAnotherOne","YetAnotherOne","ItGoesOn", "d"},()=>Console.WriteLine("Goodbye World"),"This is a test of word wrapping if everything goes ok this shoudl wrap around on to several lines while maintaining an offset for other text. If this is not wrapped correctly something is wrong...very wrong.");

            Options opts = new Options("This is not the real options for this command so do not try them.")
            {
                opt,
                opt2,
                new Option((string x) => Console.WriteLine(x),"hostname","The hostname of the server"),
                opt3,
            };
            opts.PrintUsage();
            opt.Invoke("h",null);
            opt2.Invoke("a","10000");
            opts.Parse(new []{"--h","--add3","6"});
            opts.Parse(new []{"-ha","7"});
            opts.Parse(new []{"-a","this is fail"});
            Console.ReadLine();
        }
开发者ID:digitalhermit,项目名称:Jmaxxz.Console,代码行数:22,代码来源:Main.cs

示例2: PrintUsage

 static void PrintUsage(Options opts)
 {
     var v = typeof(Program).Assembly.GetName().Version;
     Console.WriteLine("Managed Extensibility Framework Explorer Version {0}", v);
     Console.WriteLine("Copyright (c) 2009 Microsoft Corporation. All rights reserved.");
     Console.WriteLine();
     Console.WriteLine("Built for: {0}", typeof(Export).Assembly);
     Console.WriteLine();
     Console.WriteLine("Usage:     mefx.exe [assembly files and directories] [action] {options}");
     Console.WriteLine();
     Console.WriteLine("Example:   mefx.exe /file:MyAssembly.dll /causes /verbose");
     Console.WriteLine();
     Console.WriteLine("Switches:");
     Console.WriteLine();
     opts.PrintUsage(Console.Out);
 }
开发者ID:ibratoev,项目名称:MEF.NET35,代码行数:16,代码来源:Program.cs


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