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


C# CommandLineParser.IsSet方法代码示例

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


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

示例1: ItShouldBePossibleToCreateACommandLneParserAndShowHelp

 public void ItShouldBePossibleToCreateACommandLneParserAndShowHelp()
 {
     const string helpString = "help";
     var args = new[] { "-test","-help" };
     var eb = new ExitBehaviour();
     var commandLineParser = new CommandLineParser(args, helpString,eb);
     Assert.AreEqual(helpString,commandLineParser.Help);
     Assert.IsTrue(commandLineParser.IsSet("help"));
     Assert.AreEqual(1,eb.ShowHelpCalled);
 }
开发者ID:kendarorg,项目名称:ZakFramework,代码行数:10,代码来源:CommandLineParserTest.cs

示例2: ItShouldBePossibleToCreateACommandLneParser

        public void ItShouldBePossibleToCreateACommandLneParser()
        {
            const string helpString = "help";
            var args = new [] {"-test","-parameter","parameterValue"};
            var commandLineParser = new CommandLineParser(args, helpString);
            var resultValue = commandLineParser["test"];
            Assert.IsTrue(commandLineParser.IsSet("test"));
            Assert.IsTrue(resultValue.Length==0);
            resultValue = commandLineParser["notPresent"];
            Assert.IsNull(resultValue);
            Assert.IsFalse(commandLineParser.IsSet("notPresent"));
            resultValue = commandLineParser["parameter"];
            Assert.IsTrue(commandLineParser.IsSet("parameter"));
            Assert.AreEqual("parameterValue",resultValue);

            commandLineParser["parameter"] = "newValue";
            Assert.IsTrue(commandLineParser.IsSet("parameter"));
            resultValue = commandLineParser["parameter"];
            Assert.AreEqual("newValue", resultValue);
        }
开发者ID:kendarorg,项目名称:ZakFramework,代码行数:20,代码来源:CommandLineParserTest.cs

示例3: InitializeRoot

        public static void InitializeRoot(CommandLineParser commandLineParser = null)
        {
            //Nothing set
            if (CommandLineParser.GetEnv("ROOT") != null)
            {
                BaseRoot = CommandLineParser.GetEnv("ROOT");
            }
            else if (commandLineParser == null || !commandLineParser.IsSet("root"))
            {
                BaseRoot = Environment.CurrentDirectory;
            }
            else
            {
                BaseRoot = commandLineParser["root"] == null ? CommandLineParser.GetEnv("ROOT") : commandLineParser["root"];
            }

            BaseRoot = BaseRoot.Replace('\\', Path.DirectorySeparatorChar);
            BaseRoot = BaseRoot.Replace('/', Path.DirectorySeparatorChar);
        }
开发者ID:kendarorg,项目名称:ZakFramework,代码行数:19,代码来源:FileUtils.cs

示例4: ItShouldBePossibleToGetEnvironmentVariables

        public void ItShouldBePossibleToGetEnvironmentVariables()
        {
            var args = new[] { "-test"};
            var commandLineParser = new CommandLineParser(args, "help");
            var temp = CommandLineParser.GetEnv("TEMP");
            commandLineParser["TEMP"] = temp;
            Assert.IsTrue(Directory.Exists(temp));
            var os = CommandLineParser.GetEnv("OS");
            commandLineParser["os"] = os;

            var notExistingVariable = CommandLineParser.GetEnv("thisDoesNotExists"+Guid.NewGuid().ToString());
            Assert.IsNull(notExistingVariable);

            Assert.IsTrue(commandLineParser.IsSet("os"));
            Assert.IsTrue(commandLineParser.IsSet("oS"));
            Assert.AreEqual(commandLineParser["os"], commandLineParser["oS"]);

            Assert.IsTrue(commandLineParser.IsSet("Temp"));
            Assert.IsTrue(commandLineParser.IsSet("temP"));
            Assert.AreEqual(commandLineParser["TEMP"], commandLineParser["temp"]);

            Assert.IsFalse(string.IsNullOrWhiteSpace(os));
        }
开发者ID:kendarorg,项目名称:ZakFramework,代码行数:23,代码来源:CommandLineParserTest.cs


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