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


C# ParameterList.WithValue方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            var inputFile = new Parameter<FileInfo>
            {
                ShortName = "i",
                LongName = "input",
                ValueName = "filename",
                Description = "The path of the input file.",
            };

            var outputFile = new Parameter<FileInfo>()
            {
                ShortName = "o",
                LongName = "output",
                ValueName = "filename",
                Description = "The path of the output file.",
            };

            var playingOption = new Parameter<PlayingOption>()
            {
                ShortName = "p",
                LongName = "playing-option",
                Description = "The options for playing.",
            };

            var randomNumbers = new ParameterList<double>
            {
                ShortName = "r",
                LongName = "random",
                Description = "Random numbers.",
            };

            var fast = new Parameter<bool>
            {
                ShortName = "f",
                LongName = "fast",
                Description = "Make it fast.",
            };

            var culture = new Parameter<CultureInfo>
            {
                ShortName = "cu",
                LongName = "culture",
                Description = "The culture.",
                IsOptional = true,
                DefaultValue = CultureInfo.InvariantCulture
            };

            var count = new Parameter<int>()
            {
                ShortName = "c",
                LongName = "count",
                Description = "Count of something.",
                IsOptional = true,
                DefaultValue = 1,
                PossibleValues = { 1, 2, 3, 4, 5 },
                StaticContextParameters =
                {
                    randomNumbers
                }
            };

            var commandLine = new CommandLine
            {
                ProgramName = "sarcasmizer",

                Description = "This is a good program.",

                Parameters =
                {
                    inputFile,
                    outputFile,
                    playingOption,
                    count,
                    fast,
                    culture
                },

                Examples =
                {
                    new Example
                    {
                        Parameters =
                        {
                            inputFile.WithValue(new FileInfo("foo.txt")),
                            outputFile.WithValue(new FileInfo("bar.txt"))
                        },
                        Description = "Simple example."
                    },
                    new Example
                    {
                        Parameters =
                        {
                            inputFile.WithValue(new FileInfo("foo.txt")),
                            outputFile.WithValue(new FileInfo("bar.txt")),
                            count.WithValue(8)
                        },
                        Description = "Example."
                    },
                    new Example
//.........这里部分代码省略.........
开发者ID:davidnemeti,项目名称:Sarcasm,代码行数:101,代码来源:Program.cs


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