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


C# CommandLineParser.ShowUsage方法代码示例

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


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

示例1: Main

        static int Main(string[] args)
        {
#if WINDOWS
            // Set the correct directory for our dependency files.
            var is32Bit = IntPtr.Size == 4;
            var directory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                string.Format("Dependencies{0}{1}", Path.DirectorySeparatorChar, is32Bit ? "x32" : "x64"));
            SetDllDirectory(directory);
#endif

            var content = new BuildContent();

            // Parse the command line.
            var parser = new CommandLineParser(content)
            {
                Title = "MonoGame Content Builder\n" +
                        "Builds optimized game content for MonoGame projects."
            };
            if (!parser.ParseCommandLine(args))
                return -1;

            // Process all resoponse files.
            foreach (var r in content.ResponseFiles)
            {
                // Read in all the lines, trim whitespace, and remove empty or comment lines.
                var commands = File.ReadAllLines(r).
                                Select(x => x.Trim()).
                                Where(x => !string.IsNullOrEmpty(x) && !x.StartsWith("#")).
                                ToArray();

                // Parse the commands like they came from the command line.
                if (!parser.ParseCommandLine(commands))
                    return -1;
            }
            
            // Do we have anything to do?
            if (!content.HasWork)
            {
                parser.ShowUsage();
                return 0;
            }

            // Print a startup message.            
            var buildStarted = DateTime.Now;
            if (!content.Quiet)
                Console.WriteLine("Build started {0}\n", buildStarted);

            // Let the content build.
            int successCount, errorCount;
            content.Build(out successCount, out errorCount);

            // Print the finishing info.
            if (!content.Quiet)
            {
                Console.WriteLine("\nBuild {0} succeeded, {1} failed.\n", successCount, errorCount);
                Console.WriteLine("Time elapsed {0:hh\\:mm\\:ss\\.ff}.", DateTime.Now - buildStarted);
            }

            // Return the error count.
            return errorCount;
        }
开发者ID:Boerlam001,项目名称:MonoGame,代码行数:61,代码来源:Program.cs


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