本文整理汇总了C#中Args.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Args.Get方法的具体用法?C# Args.Get怎么用?C# Args.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Args
的用法示例。
在下文中一共展示了Args.Get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestUsge
public void TestUsge()
{
var args = new Args(1, "abc", new DateTime(2013, 10, 15), this);
Assert.That(args.Get<int>(0), Is.EqualTo(1));
Assert.That(args.Get<string>(1), Is.EqualTo("abc"));
Assert.That(args.Get<DateTime>(2), Is.EqualTo(new DateTime(2013, 10, 15)));
Assert.That(args.Get<ArgsTest>(3), Is.SameAs(this));
}
示例2: ExtraArgumentsThatLookLikeFlags
public void ExtraArgumentsThatLookLikeFlags()
{
var args = new Args("x,y", "-x", "alpha", "-y", "beta");
args.Has('x').ShouldBeTrue();
args.Has('y').ShouldBeFalse();
args.Get<bool>('x').ShouldBeTrue();
args.Get<bool>('y').ShouldBeFalse();
args.NextArgument().ShouldBe(1);
}
示例3: ExtraArguments
public void ExtraArguments()
{
var args = new Args("x,y*", "-x", "-y", "alpha", "beta");
args.Has('x').ShouldBeTrue();
args.Has('y').ShouldBeTrue();
args.Get<bool>('x').ShouldBeTrue();
args.Get<string>('y').ShouldBe("alpha");
args.NextArgument().ShouldBe(3);
}
示例4: SimpleIntPresent
public void SimpleIntPresent()
{
var args = new Args("x#", "-x", "42");
args.Has('x').ShouldBeTrue();
args.Get<int>('x').ShouldBe(42);
args.NextArgument().ShouldBe(2);
}
示例5: Main
private static void Main(string[] _args)
{
Console.Out.WriteLine("Utility to remove all perforce pending change lists without files from current workspace.");
Console.Out.WriteLine("(C) 2011 Eugene Petrenko.");
Console.Out.WriteLine("Usage: ");
Console.Out.WriteLine(" p4ccc.exe [-client]");
Console.Out.WriteLine(" -client specifies workspace to perform the clean ");
Console.Out.WriteLine(" %P4CLIENT% in considered by default");
Console.Out.WriteLine("");
if (Environment.CommandLine.Contains("/?") || Environment.CommandLine.Contains("-?") ||
Environment.CommandLine.Contains("-help"))
return;
var args = new Args(_args);
string client = args.Get("client", Environment.GetEnvironmentVariable("P4CLIENT"));
Console.Out.WriteLine("p4 client = {0}", client);
var rx = new Regex("^Change\\s(\\d+)");
try
{
var lists = RunCommand("p4", "changelists -s pending -c MUNIT-009")
.Select(x =>
{
Match match = rx.Match(x);
if (!match.Success)
return (int?) null;
try
{
return
int.Parse(
match.Groups[1].Value);
}
catch
{
return null;
}
})
.Where(x => x != null)
.Select(x => x.Value)
.ToArray();
foreach (var list in lists)
{
try
{
RunCommand("p4", "changelist -d " + list);
}
catch
{
Console.Out.WriteLine("Failed to delete changelist {0}", list);
}
}
}
catch (Exception e)
{
Console.Out.WriteLine("Failed. " + e.Message);
}
}
示例6: SimpleStringPresent
public void SimpleStringPresent()
{
var args = new Args("x*", "-x", "param");
args.Has('x').ShouldBeTrue();
args.Get<string>('x').ShouldBe("param");
args.NextArgument().ShouldBe(2);
}
示例7: SimpleDoublePresent
public void SimpleDoublePresent()
{
var args = new Args("x##", "-x", "42.3");
args.Has('x').ShouldBeTrue();
args.Get<double>('x').ShouldBe(42.3);
}
示例8: SimpleBooleanPresent
public void SimpleBooleanPresent()
{
var args = new Args("x", "-x");
args.Get<bool>('x').ShouldBeTrue();
args.NextArgument().ShouldBe(1);
}
示例9: StringArray
public void StringArray()
{
var args = new Args("x[*]", "-x", "alpha");
args.Has('x').ShouldBeTrue();
var result = args.Get<List<string>>('x');
result.Count.ShouldBe(1);
result[0].ShouldBe("alpha");
}