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


C# Build.Help方法代码示例

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


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

示例1: Main

        private static void Main(string[] args)
        {
            using (var build = new Build()
                .Recognize(typeof(DotGraphController))
                .Recognize(typeof(GraphController))
                .Recognize(typeof(SerializeController)))
            {
                try
                {
                    var parsedMethod = build.Parse(args);
                    if (parsedMethod.UnRecognizedArguments.Any())//Warning:
                    {
                        var unRecognizedArgumentsMessage = string.Format(
                                                               @"Unrecognized arguments:
            {0}
            Did you mean any of these arguments?
            {1}", String.Join(",", parsedMethod.UnRecognizedArguments.Select(unrec => unrec.Value).ToArray()),
                                                               String.Join(",", parsedMethod.ArgumentWithOptions.Select(rec => rec.Name).ToArray()));
                        Console.WriteLine(unRecognizedArgumentsMessage);
                        Environment.Exit(1);
                    }
                    else
                    {
                        parsedMethod.Invoke(Console.Out);
                    }
                }
                catch (TypeConversionFailedException ex)
                {

                    Console.WriteLine(String.Format("Could not convert argument {0} with value {1} to type {2}",
                            ex.Argument, ex.Value, ex.TargetType));
                    if (null != ex.InnerException)
                    {
                        Console.WriteLine("Inner exception: ");
                        Console.WriteLine(ex.InnerException.Message);
                    }
                    Environment.Exit(1);
                }
                catch (MissingArgumentException ex)
                {
                    Console.WriteLine(String.Format("Missing argument(s): {0}", String.Join(", ", ex.Arguments.ToArray())));
                    if (build.RecognizesHelp)
                        Console.WriteLine(build.Help());
                    Environment.Exit(1);
                }
                #if DEBUG
                catch (Exception ex1)
                {
                    Console.WriteLine(string.Join(Environment.NewLine, new object[]
                            {
                                "The invokation failed with exception:",
                                ex1.Message, ex1.StackTrace
                            }));
                    Environment.Exit(1);
                }
                #endif
            }
        }
开发者ID:wallymathieu,项目名称:mejram,代码行数:58,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            var path =  Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location)
                .FullName;
            using(var parserBuilder = new Build().ConfigurationFrom(
                path))
            {

                try
                {
                    var parsedMethod = parserBuilder.Parse(args);
                    if (parsedMethod.UnRecognizedArguments.Any())//Warning:
                    {
                        var unRecognizedArgumentsMessage = string.Format(
            @"Unrecognized arguments:
            {0}
            Did you mean any of these arguments?
            {1}", String.Join(",", parsedMethod.UnRecognizedArguments.Select(unrec => unrec.Value).ToArray()),
              String.Join(",", parsedMethod.ArgumentWithOptions.Select(rec => rec.Argument.ToString()).ToArray()));
                        Console.WriteLine(unRecognizedArgumentsMessage);
                    }else
                    {
                        parsedMethod.Invoke(Console.Out);
                    }
                }
                catch (TypeConversionFailedException ex)
                {

                     Console.WriteLine(String.Format("Could not convert argument {0} with value {1} to type {2}",
                        ex.Argument, ex.Value, ex.TargetType));
                     if (null!=ex.InnerException)
                    {
                        Console.WriteLine("Inner exception: ");
                        Console.WriteLine(ex.InnerException.Message);
                    }
                }
                catch (MissingArgumentException ex)
                {
                    Console.WriteLine(String.Format("Missing argument(s): {0}",String.Join(", ",ex.Arguments.Select(a=>String.Format("{0}: {1}",a.Key,a.Value)).ToArray())));
                    if (parserBuilder.RecognizesHelp)
                        Console.WriteLine(parserBuilder.Help());
                }
            #if DEBUG
                catch (Exception ex1)
                {
                    Console.WriteLine( string.Join(Environment.NewLine, new object[]{
                        "The invokation failed with exception:",
                        ex1.Message, ex1.StackTrace}));
                    return;
                }
            #endif
            }
        }
开发者ID:Lundalogik,项目名称:isop,代码行数:53,代码来源:Program.cs


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