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


C# CommandLineParser.InternalValue方法代码示例

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


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

示例1: WriteParserInfo

            private string WriteParserInfo(CommandLineParser parser)
            {
                StringBuilder builder = new StringBuilder();

                // ----------------------- DEBUG OUTPUT -------------------------------
                builder.AppendFormat("Program Name      : {0}\r\n", parser.ApplicationName);
                builder.AppendFormat("Non-switch Params : {0}\r\n", parser.Parameters.Length);
                for (int j = 0; j < parser.Parameters.Length; j++)
                {
                    builder.AppendFormat("                {0} : {1}\r\n", j, parser.Parameters[j]);
                }

                builder.AppendLine("----");
                builder.AppendFormat("Value of ShowSomeHelp    : {0}\r\n", this.ShowSomeHelp);
                builder.AppendFormat("Value of m_SomethingElse : {0}\r\n", this.wibble);
                builder.AppendFormat("Value of UserName        : {0}\r\n", this.UserName);
                builder.AppendLine("----");

                // Walk through all of the registered switches getting the available
                // information back out.
                CommandLineParser.SwitchInfo[] si = parser.Switches;
                if (si != null)
                {
                    builder.AppendFormat("There are {0} registered switches:\r\n", si.Length);
                    foreach (CommandLineParser.SwitchInfo s in si)
                    {
                        builder.AppendFormat("Command : {0} - [{1}]\r\n", s.Name, s.Description);
                        builder.AppendFormat("Type    : {0}\r\n", s.Type);

                        if (s.IsEnum)
                        {
                            builder.Append("- Enums allowed (");
                            foreach (string e in s.Enumerations)
                            {
                                builder.AppendFormat("{0} ", e);
                            }

                            builder.Append(")");
                        }

                        builder.AppendLine();

                        if (s.Aliases != null)
                        {
                            Console.Write("Aliases : [{0}] - ", s.Aliases.Length);
                            foreach (string alias in s.Aliases)
                            {
                                Console.Write(" {0}", alias);
                            }

                            builder.AppendLine();
                        }

                        builder.AppendFormat(
                                "------> Value is : {0} (Without any callbacks {1})\n",
                                s.Value ?? "(Unknown)",
                                s.InternalValue ?? "(Unknown)");
                    }
                }
                else
                {
                    builder.AppendFormat("There are no registered switches.");
                }

                // Test looking for a specificly named values.
                builder.AppendFormat("----");
                if (parser["help"] != null)
                {
                    builder.AppendFormat("Request for help = {0}\r\n", parser["help"]);
                }
                else
                {
                    builder.AppendFormat("Request for help has no associated value.\r\n");
                }

                builder.AppendFormat("User Name is {0}\r\n", parser["name"]);

                // Note the difference between the parser and a callback value.
                builder.AppendFormat(
                        "The property of test (/test) is internally is read-only, "
                        + "e.g. no update can be made by the parser:\n" + "   -- The indexer gives a value of : {0}\n"
                        + "   -- Internally the parser has    : {1}\r\n",
                        parser["test"],
                        parser.InternalValue("test"));

                // Test if the enumeration value has changed to Friday!
                if (this.DoW == DaysOfWeek.Fri)
                {
                    builder.AppendLine("\nYeah Friday.... PUB LUNCH TODAY...");
                }

                // For error handling, were any switches handled?
                string[] unhandled = parser.UnhandledSwitches;
                if (unhandled != null)
                {
                    builder.AppendLine("\nThe following switches were not handled.");
                    foreach (string s in unhandled)
                    {
                        builder.AppendFormat("  - {0}\r\n", s);
                    }
//.........这里部分代码省略.........
开发者ID:RustyF,项目名称:EnergyTrading-Core,代码行数:101,代码来源:CommandLineParserFixture.cs


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