本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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));
}