本文整理汇总了C#中ArgumentList.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# ArgumentList.Contains方法的具体用法?C# ArgumentList.Contains怎么用?C# ArgumentList.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArgumentList
的用法示例。
在下文中一共展示了ArgumentList.Contains方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static int Main(string[] raw)
{
ArgumentList args = new ArgumentList(raw);
List<string> input = new List<string>(args.Unnamed);
if (args.Contains("nologo") == false)
{
Console.WriteLine("StampCopyright.exe");
Console.WriteLine("Copyright 2009-{0:yyyy} by Roger Knapp, Licensed under the Apache License, Version 2.0", DateTime.Now);
Console.WriteLine("");
}
if ((args.Count == 0 && args.Unnamed.Count == 0) || args.Contains("?") || args.Contains("help"))
return DoHelp();
try
{
args.TryGetValue("svn", out _subversion);
Log.ConsoleLevel = System.Diagnostics.TraceLevel.Warning;
_changes = 0;
_copyText = File.ReadAllText(input[0]).Trim();
_copyText = _copyText.Replace("YEAR", DateTime.Now.Year.ToString());
_copyText = _copyText.Replace("yyyy", DateTime.Now.Year.ToString());
input.RemoveAt(0);
ProjectVisitor visitor = new ProjectVisitor(false, input.ToArray());
visitor.VisitProjectItems(VisitProjectItem);
}
catch (ApplicationException ae)
{
Log.Error(ae);
Console.Error.WriteLine();
Console.Error.WriteLine(ae.Message);
Environment.ExitCode = -1;
}
catch (Exception e)
{
Log.Error(e);
Console.Error.WriteLine();
Console.Error.WriteLine(e.ToString());
Environment.ExitCode = -1;
}
if (args.Contains("wait"))
{
Console.WriteLine();
Console.WriteLine("Press [Enter] to continue...");
Console.ReadLine();
}
return Environment.ExitCode;
}
示例2: Run
public virtual void Run(ICommandInterpreter interpreter, string[] arguments)
{
ArgumentList args = new ArgumentList(arguments);
if (args.Count == 1 && args.Contains("?"))
{ Help(); return; }
//translate ordinal referenced names
Argument last = null;
for (int i = 0; i < _arguments.Length && args.Unnamed.Count > 0; i++)
{
if (_arguments[i].Type == typeof (ICommandInterpreter))
break;
last = _arguments[i];
args.Add(last.DisplayName, args.Unnamed[0]);
args.Unnamed.RemoveAt(0);
}
if (last != null && args.Unnamed.Count > 0 && last.Type.IsArray)
{
for (int i = 0; i < _arguments.Length && args.Unnamed.Count > 0; i++)
{
args.Add(last.DisplayName, args.Unnamed[0]);
args.Unnamed.RemoveAt(0);
}
}
List<object> invokeArgs = new List<object>();
foreach (Argument arg in _arguments)
{
object argValue = arg.GetArgumentValue(interpreter, args, arguments);
invokeArgs.Add(argValue);
}
//make sure we actually used all arguments.
List<string> names = new List<string>(args.Keys);
InterpreterException.Assert(names.Count == 0, "Unknown argument(s): {0}", String.Join(", ", names.ToArray()));
InterpreterException.Assert(args.Unnamed.Count == 0, "Too many arguments supplied.");
Invoke(Method, Target, invokeArgs.ToArray());
}
示例3: Slots
/// <summary>
/// Checks the state of a slot.
/// </summary>
/// <param name="server">Current Server instance</param>
/// <param name="sender">Sending player</param>
/// <param name="args">Arguments sent with command</param>
public static void Slots(Server server, ISender sender, ArgumentList args)
{
bool dinfo = args.Contains("-d") || args.Contains("-dp") || args.Contains("-pd");
bool pinfo = args.Contains("-p") || args.Contains("-dp") || args.Contains("-pd");
int k = 0;
for (int i = 0; i < 255; i++)
{
var slot = Netplay.slots[i];
var player = Main.players[i];
if (slot.state != SlotState.VACANT)
{
k += 1;
var name = "";
if (player != null)
{
name = string.Concat(", ", player.Op ? "Op. " : "", "\"", (player.Name ?? "<null>"), "\"");
if (player.AuthenticatedAs != null)
{
if (player.Name == player.AuthenticatedAs)
name = name + " (auth'd)";
else
name = name + " (auth'd as " + player.AuthenticatedAs + ")";
}
}
var addr = "<secret>";
if (!(sender is Player && player.Op))
addr = slot.remoteAddress;
var msg = string.Format("slot {0}: {1}, {2}{3}", i, slot.state, addr, name);
if (pinfo && player != null)
{
msg += string.Format(", {0}/{1}hp", player.statLife, player.statLifeMax);
}
if (dinfo)
{
msg += string.Format(", {0}{1}{2}, tx:{3:0.0}K, rx:{4:0.0}K, q:{5}",
slot.conn.kicking ? "+" : "-", slot.conn.sending ? "+" : "-", slot.conn.receiving ? "+" : "-",
slot.conn.BytesSent / 1024.0, slot.conn.BytesReceived / 1024.0,
slot.conn.QueueLength);
}
sender.sendMessage(msg);
}
}
sender.sendMessage(string.Format("{0}/{1} slots occupied.", k, Main.maxNetplayers));
}
示例4: Main
static int Main(string[] raw)
{
ArgumentList args = new ArgumentList(raw);
using (DisposingList dispose = new DisposingList())
using (Log.AppStart(Environment.CommandLine))
{
if (args.Contains("nologo") == false)
{
Console.WriteLine("XhtmlValidate.exe");
Console.WriteLine("Copyright 2010 by Roger Knapp, Licensed under the Apache License, Version 2.0");
Console.WriteLine("");
}
if ((args.Unnamed.Count == 0) || args.Contains("?") || args.Contains("help"))
return DoHelp();
try
{
FileList files = new FileList();
files.RecurseFolders = true;
foreach (string spec in args.Unnamed)
{
Uri uri;
if (Uri.TryCreate(spec, UriKind.Absolute, out uri) && !(uri.IsFile || uri.IsUnc))
{
using(WebClient wc = new WebClient())
{
TempFile tfile = new TempFile();
dispose.Add(tfile);
wc.DownloadFile(uri, tfile.TempPath);
files.Add(tfile.Info);
}
}
else
files.Add(spec);
}
if( files.Count == 0 )
return 1 + DoHelp();
XhtmlValidation validator = new XhtmlValidation(XhtmlDTDSpecification.Any);
foreach (FileInfo f in files)
validator.Validate(f.FullName);
}
catch (ApplicationException ae)
{
Log.Error(ae);
Console.Error.WriteLine();
Console.Error.WriteLine(ae.Message);
Environment.ExitCode = -1;
}
catch (Exception e)
{
Log.Error(e);
Console.Error.WriteLine();
Console.Error.WriteLine(e.ToString());
Environment.ExitCode = -1;
}
}
if (args.Contains("wait"))
{
Console.WriteLine();
Console.WriteLine("Press [Enter] to continue...");
Console.ReadLine();
}
return Environment.ExitCode;
}
示例5: TestUnnamed
public void TestUnnamed()
{
ArgumentList args = new ArgumentList("some", "/thing", "else");
Assert.AreEqual(2, args.Unnamed.Count);
Assert.AreEqual(1, args.Count);
Assert.IsTrue(args.Contains("thing"));
Assert.AreEqual("some", args.Unnamed[0]);
Assert.AreEqual("else", args.Unnamed[1]);
args.Unnamed.RemoveAt(0);
Assert.AreEqual(1, args.Unnamed.Count);
Assert.AreEqual("else", args.Unnamed[0]);
args.Clear();
Assert.AreEqual(0, args.Count);
Assert.AreEqual(1, args.Unnamed.Count);
args.Unnamed.Clear();
Assert.AreEqual(0, args.Unnamed.Count);
}
示例6: Main
static int Main(string[] raw)
{
ArgumentList args = new ArgumentList(raw);
using (Log.AppStart(Environment.CommandLine))
{
if (args.Count == 0 || args.Unnamed.Count == 0 || args.Contains("?"))
return DoHelp();
if (args.Contains("nologo") == false)
{
Console.WriteLine("CSharpTest.Net.CoverageReport.exe");
Console.WriteLine("Copyright 2009 by Roger Knapp, Licensed under the Apache License, Version 2.0");
Console.WriteLine("");
}
try
{
List<string> filesFound = new List<string>();
FileList files = new FileList();
files.RecurseFolders = args.Contains("s");
files.Add(new List<string>(args.Unnamed).ToArray());
XmlParser parser = new XmlParser( args.SafeGet("exclude").Values );
foreach (System.IO.FileInfo file in files)
{
filesFound.Add(file.FullName);
using(Log.Start("parsing file: {0}", file.FullName))
parser.Parse(file.FullName);
}
parser.Complete();
if (args.Contains("module"))
{
using (Log.Start("Creating module report."))
using (XmlReport rpt = new XmlReport(OpenText(args["module"]), parser, "Module Summary", filesFound.ToArray()))
new MetricReport(parser.ByModule).Write(rpt);
}
if (args.Contains("namespace"))
{
using (Log.Start("Creating namespace report."))
using (XmlReport rpt = new XmlReport(OpenText(args["namespace"]), parser, "Namespace Summary", filesFound.ToArray()))
new MetricReport(parser.ByNamespace).Write(rpt);
}
if (args.Contains("class"))
{
using (Log.Start("Creating class report."))
using (XmlReport rpt = new XmlReport(OpenText(args["class"]), parser, "Module Class Summary", filesFound.ToArray()))
new MetricReport(parser.ByModule, parser.ByNamespace, parser.ByClass).Write(rpt);
}
if (args.Contains("unused"))
{
using (Log.Start("Creating unused statement report."))
using (UnusedReport rpt = new UnusedReport(OpenText(args["unused"]), parser))
new MetricReport(parser.ByModule, parser.ByMethod).Write(rpt);
}
if (args.Contains("combine"))
{
using (Log.Start("Creating combined coverage file."))
using (XmlCoverageWriter wtr = new XmlCoverageWriter(OpenText(args["combine"]), parser))
new MetricReport(parser.ByModule, parser.ByMethod).Write(wtr);
}
//foreach (ModuleInfo mi in parser)
// Console.WriteLine("{0} hit {1} of {2} for {3}", mi.Name, mi.VisitedPoints, mi.SequencePoints, mi.CoveragePercent);
}
catch (Exception e)
{
Log.Error(e);
Console.Error.WriteLine();
Console.Error.WriteLine("Exception: {0}", e.Message);
Console.Error.WriteLine();
Environment.ExitCode = -1;
}
}
if (args.Contains("wait"))
{
Console.WriteLine("Press [Enter] to continue...");
Console.ReadLine();
}
return Environment.ExitCode;
}
示例7: MapCommand
void MapCommand( ISender sender, ArgumentList argz)
{
bool autosave = false;
if (argz.Contains("automap"))
{
autosave = true;
argz.Remove("automap");
}
try {
if (isMapping)
{
throw new CommandError("Still currently mapping.");
}
p = mapoutputpath;
filename = "world-now.png";
var timestamp = false;
var reload = false;
var highlight = false;
string nameOrID = "";
var savefromcommand = false;
string cs = colorscheme;
var autosaveedit = false;
var options = new OptionSet ()
{
{ "t|timestamp", v => timestamp = true },
{ "n|name=", v => filename = v },
{ "L|reload", v => reload = true },
{ "s|save", v => savefromcommand = true },
{ "p|path=", v => p = v },
{ "h|highlight=", v => { nameOrID = v; highlight = true; } },
{ "c|colorscheme=", v => cs = v },
{ "a|autosave", v => autosaveedit = true },
};
var args = options.Parse (argz);
if (autosaveedit)
{
if (autosaveenabled)
{
properties.setValue("autosave-enabled", "False");
sender.sendMessage("autosave disabled.");
}
else
{
properties.setValue("autosave-enabled", "True");
sender.sendMessage("autosave enabled.");
}
if (highlight)
{
if (highlightsearch(sender as Player, nameOrID))
{
properties.setValue("autosave-highlight", "True");
properties.setValue("autosave-highlightID", nameOrID);
sender.sendMessage("autosave highlight settings updated.");
}
}
if (timestamp)
{
if (autosavetimestamp)
{
properties.setValue("autosave-timestamp", "False");
sender.sendMessage("autosave now using regular name.");
}
else
{
properties.setValue("autosave-timestamp", "True");
sender.sendMessage("autosave now using timestamp.");
}
}
if (filename != "world-now.png")
{
properties.setValue("autosave-filename", filename);
}
properties.Save();
return;
}
if (reload || autosave) {
sender.sendMessage ("map: Reloaded settings database, entries: " + properties.Count);
properties.Load ();
var msg = string.Concat (
"Settings: mapoutputpath=", p, ", ",
"colorscheme=", cs);
if ( !(Directory.Exists(p)) ){
msg = string.Concat ( msg , " (DOESNT EXIST)" );
ProgramLog.Error.Log ("<map> ERROR: Loaded Directory does not exist.");
}
if (!autosave)
{
ProgramLog.Admin.Log("<map> " + msg);
}
//sender.sendMessage ("map: " + msg);
if ( !(cs=="MoreTerra" || cs=="Terrafirma") ){
ProgramLog.Error.Log ("<map> ERROR: please change colorscheme");
}
}
//.........这里部分代码省略.........
示例8: OpPlayer
/// <summary>
/// Sets OP status to a given Player.
/// </summary>
/// <param name="sender">Sending player</param>
/// <param name="args">Arguments sent with command</param>
public void OpPlayer(ISender sender, ArgumentList args)
{
var playerName = args.GetString(0);
if (Storage.IsAvailable)
{
var existing = Authentication.GetPlayer(playerName);
if (existing == null && (args.Contains("-c") || args.Contains("-create")))
{
var password = args.GetString(1);
existing = Authentication.CreatePlayer(playerName, password, true);
Utils.NotifyAllOps("Opping " + playerName + " [" + sender.SenderName + "]", true);
var player = Tools.GetPlayerByName(playerName);
if (player != null)
{
player.SendMessage("You are now a server operator.", Color.Green);
player.SetOp(true);
player.SetAuthentication(player.name, "tdsm");
}
sender.Message("Op success", Color.DarkGreen);
}
else if (existing != null)
{
if (existing.Operator)
throw new CommandError("Player is already an operator");
if (Authentication.UpdatePlayer(playerName, null, op: true))
{
Utils.NotifyAllOps("Opping " + playerName + " [" + sender.SenderName + "]", true);
var player = Tools.GetPlayerByName(playerName);
if (player != null)
{
player.SendMessage("You are now a server operator.", Color.Green);
player.SetOp(true);
player.SetAuthentication(player.name, "tdsm");
}
sender.Message("Op success", Color.DarkGreen);
}
else
{
sender.Message("Failed to op player", Color.DarkRed);
}
}
else
{
sender.Message("No user found by " + playerName, Color.DarkRed);
sender.Message("Please use the `user` command or add the -create switch", Color.DarkRed);
}
}
else
{
var password = args.GetString(1);
Utils.NotifyAllOps("Opping " + playerName + " [" + sender.SenderName + "]", true);
Core.Ops.Add(playerName, password);
var player = Tools.GetPlayerByName(playerName);
if (player != null)
{
player.SendMessage("You are now a server operator.", Color.Green);
player.SetOp(true);
player.SetAuthentication(player.name, "tdsm");
}
if (!Core.Ops.Save())
{
Utils.NotifyAllOps("Failed to save op list [" + sender.SenderName + "]", true);
return;
}
}
}
示例9: autoSave
public void autoSave()
{
bool firstrun = true;
DateTime lastsave = new DateTime();
ISender console = new ConsoleSender();
List<string> empty = new List<string>();
ArgumentList arguments = new ArgumentList();
while (isEnabled)
{
if (autosaveenabled)
{
if (!firstrun && (DateTime.UtcNow > lastsave.AddMinutes(autosaveinterval)))
{
if (!arguments.Contains("automap"))
{
arguments.Add("automap");
}
MapCommand(console, arguments);
lastsave = DateTime.UtcNow;
}
if (firstrun)
{
firstrun = false;
lastsave = DateTime.UtcNow;
}
}
Thread.Sleep(1000);
}
}