本文整理汇总了C#中ArgumentList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ArgumentList.Add方法的具体用法?C# ArgumentList.Add怎么用?C# ArgumentList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArgumentList
的用法示例。
在下文中一共展示了ArgumentList.Add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Mux
public void Mux(object sender, DoWorkEventArgs e)
{
var inputM2TsFlags = _keepM2TsAudio ? null : "--no-audio";
var inputMkvFlags = _keepM2TsAudio ? "--no-audio" : null;
var args = new ArgumentList();
// Chapter file
args.AddIfAllNonEmpty("--chapters", _inputChaptersPath);
// Output file
args.AddAll("-o", _outputMkvPath);
// Input M2TS file
args.AddNonEmpty("--no-video", inputM2TsFlags, _inputM2TsPath);
// If an input chapter file is specified, exclude chapters from the input MKV file
if (!string.IsNullOrEmpty(_inputChaptersPath))
args.Add("--no-chapters");
// Input MKV file
args.AddNonEmpty(inputMkvFlags, _inputMkvPath);
Execute(args, sender, e);
}
示例2: ban
// bans if ban = true, unbans if ban = false
public static void ban(String name, String bannedby, bool ban)
{
Player player = FindPlayer(name);
Sender sender = new ConsoleSender();
ArgumentList command = new ArgumentList();
command.Add(name);
if (player != null)
{
if (player.Name != null)
{
if (ban)
{
Commands.Ban(sender, command);
server.sendToOneClient(Packet.PLAYER_BANNED(name), bannedby);
}
}
}
else
{
if (ban)
server.sendToOneClient(Packet.PLAYER_NOT_FOUND_ERROR(), bannedby);
else
{
Commands.UnBan(sender, command);
server.sendToOneClient(Packet.PLAYER_UNBANNED(name), bannedby);
}
}
}
示例3: ProcessArgumentList
/////////////////////////////////////////////////////////////////////////////
// converts a list of text arguments into individual ArgumentExpresion's and
// return them as an ArgumentList which later need to be interpreted by ArgumentsEvaluator
public ArgumentList ProcessArgumentList( Expression parent, NmpStringList strArgs )
{
// ******
ArgumentList objArgs = new ArgumentList();
// ******
for( int iArg = 0; iArg < strArgs.Count; iArg++ ) {
string strArg = strArgs[ iArg ];
// ******
if( string.IsNullOrEmpty(strArg) ) {
//
// empty string arg
//
objArgs.Add( new ArgumentExpression(parent, string.Empty) );
}
else {
char firstChar = strArg[ 0 ];
//
// if we don't understand the cast maybe we should just let
// it go ...
//
if( SC.OPEN_PAREN == firstChar && ! IgnoreCastLikeThis(strArg) ) {
//
// (cast) something
//
ArgumentExpression ae = EvaluateCastExpression( parent, strArg );
if( null != ae ) {
objArgs.Add( ae );
}
else {
objArgs.Add( new ArgumentExpression( parent, strArg ) );
}
}
else if( SC.ATCHAR == firstChar && strArg.Length > 1 && '@' != strArg[1] ) {
//
// @macro ...
//
// string must be more than just "@", "@@" escapes it
//
objArgs.Add( EvaluateAtExpression( parent, strArg.Substring(1) ) );
}
else {
//
// a string
//
objArgs.Add( new ArgumentExpression(parent, strArg) );
}
}
}
// ******
return objArgs;
}
示例4: GivePlayerStartingEquipment
public void GivePlayerStartingEquipment(Player InPlayer)
{
string[] equipment = new string[100];
string[] data = new string[2];
ArgumentList giveArgs = new ArgumentList(Server);
giveArgs.Add(InPlayer.Name);
giveArgs.Add("0");
giveArgs.Add("0");
equipment = startingEquipment.Split(':');
for (int i = 0; i < equipment.Length; i++)
{
data = equipment[i].ToString().Split('-');
giveArgs[1] = data[1];
giveArgs[2] = data[0];
Terraria_Server.Commands.Commands.Give(Server, InPlayer, giveArgs);
}
}
示例5: Test
public void Test()
{
ArgumentList args = new ArgumentList("-test=value", "/Test", "\"/other:value\"");
Assert.AreEqual(2, args.Count);
Assert.AreEqual(1, args[0].Count);
Assert.AreEqual("test", args[0].Name);
Assert.AreEqual("value", args[1].Value);
Assert.AreEqual(1, args[1].Count);
Assert.AreEqual("other", args[1].Name);
Assert.AreEqual("value", args[1].Value);
string[] keys = args.Keys;
Assert.AreEqual(2, keys.Length);
Assert.AreEqual("other", keys[0]);//alpha-sorted
Assert.AreEqual("test", keys[1]);
Assert.AreEqual(0, new ArgumentList("unnamed").Keys.Length);
Assert.AreEqual(0, new ArgumentList(/*empty*/).Keys.Length);
ArgumentList.DefaultComparison = StringComparer.Ordinal;
Assert.AreEqual(StringComparer.Ordinal, ArgumentList.DefaultComparison);
ArgumentList.NameDelimeters = new char[] { '=' };
Assert.AreEqual('=', ArgumentList.NameDelimeters[0]);
ArgumentList.PrefixChars = new char[] { '/' };
Assert.AreEqual('/' , ArgumentList.PrefixChars[0]);
args = new ArgumentList("-test=value", "/Test", "\"/other:value\"");
Assert.AreEqual(2, args.Count);
Assert.AreEqual(0, args[0].Count);
Assert.AreEqual("Test", args[0].Name);
Assert.AreEqual(null, args[1].Value);
Assert.AreEqual(1, args.Unnamed.Count);
foreach(string sval in args.Unnamed)
Assert.AreEqual("-test=value", sval);
Assert.AreEqual(0, args[1].Count);
Assert.AreEqual("other:value", args[1].Name);
Assert.AreEqual(null, args[1].Value);
args.Unnamed = new string[0];
Assert.AreEqual(0, args.Unnamed.Count);
args.Add("other", "value");
Assert.AreEqual(null, (string)args["Test"]);
Assert.AreEqual("value", (string)args["other"]);
Assert.AreEqual("value", (string)args.SafeGet("other"));
Assert.IsNotNull(args.SafeGet("other-not-existing"));
Assert.AreEqual(null, (string)args.SafeGet("other-not-existing"));
string test;
ArgumentList.Item item;
args = new ArgumentList();
Assert.AreEqual(0, args.Count);
Assert.IsFalse(args.TryGetValue(String.Empty, out item));
args.Add(String.Empty, null);
Assert.IsTrue(args.TryGetValue(String.Empty, out item));
args = new ArgumentList();
Assert.AreEqual(0, args.Count);
Assert.IsFalse(args.TryGetValue(String.Empty, out test));
args.Add(String.Empty, null);
Assert.IsTrue(args.TryGetValue(String.Empty, out test));
test = item;
Assert.IsNull(test);
string[] testarry = item;
Assert.IsNotNull(testarry);
Assert.AreEqual(0, testarry.Length);
item.Value = "roger";
Assert.AreEqual("roger", item.Value);
Assert.AreEqual(1, item.Values.Length);
Assert.AreEqual("roger", item.Values[0]);
Assert.Contains("roger", item.ToArray());
Assert.AreEqual(1, item.ToArray().Length);
item.AddRange(new string[] { "wuz", "here" });
Assert.AreEqual(3, item.Values.Length);
Assert.AreEqual("roger wuz here", String.Join(" ", item));
item.Values = new string[] { "roger", "was", "here" };
Assert.AreEqual("roger was here", String.Join(" ", item));
KeyValuePair<string, string[]> testkv = item;
Assert.AreEqual(String.Empty, testkv.Key);
Assert.AreEqual(3, testkv.Value.Length);
Assert.AreEqual("roger was here", String.Join(" ", testkv.Value));
}
示例6: time
public static void time(String time, String changedby)
{
Sender sender = new ConsoleSender();
ArgumentList command = new ArgumentList();
command.Add(time);
Commands.Time(sender, command);
server.sendToOneClient(Packet.TIME_CHANGED(time), changedby);
}
示例7: spawn
public static void spawn(String from, String target, String npc, String amount)
{
Sender sender = new ConsoleSender();
ArgumentList command = new ArgumentList();
command.Add(amount);
command.Add(npc);
command.Add(target);
Commands.SpawnNPC(sender, command);
server.sendToOneClient(Packet.SPAWNED_NPC(npc, amount), from);
}
示例8: purge
public static void purge(String from, String topurge)
{
Sender sender = new ConsoleSender();
ArgumentList command = new ArgumentList();
command.Add(topurge);
Commands.Purge(sender, command);
server.sendToOneClient(Packet.PURGED(topurge), from);
}
示例9: op
public static void op(String name, String oppedby, String password)
{
Player player = FindPlayer(name);
if (player != null)
{
if (player.Name != null)
{
Sender sender = new ConsoleSender();
ArgumentList command = new ArgumentList();
command.Add(name);
if (!player.Op)
{
command.Add(password);
Commands.OpPlayer(sender, command);
server.sendToOneClient(Packet.OPPED(name), oppedby);
}
else
{
Commands.DeopPlayer(sender, command);
server.sendToOneClient(Packet.DEOPPED(name), oppedby);
}
}
}
else
{
server.sendToOneClient(Packet.PLAYER_NOT_FOUND_ERROR(), oppedby);
}
}
示例10: kick
public static void kick(String name, String kickedby)
{
Player player = FindPlayer(name);
if (player != null)
{
if (player.Name != null)
{
Sender sender = new ConsoleSender();
ArgumentList command = new ArgumentList();
command.Add(name);
Commands.Kick(sender, command);
server.sendToOneClient(Packet.PLAYER_KICKED(name), kickedby);
}
}
else
{
server.sendToOneClient(Packet.PLAYER_NOT_FOUND_ERROR(), kickedby);
}
}
示例11: give
public static void give(String from, String target, String item, String amount)
{
Sender sender = new ConsoleSender();
ArgumentList command = new ArgumentList();
command.Add(target);
command.Add(amount);
command.Add(item);
Commands.Give(sender, command);
server.sendToOneClient(Packet.GAVE_ITEM(item, amount), from);
}
示例12: CreateCurrentCommandLine
private static CommandLine CreateCurrentCommandLine()
{
var currentArgs = Environment.GetCommandLineArgs();
System.Diagnostics.Debug.Assert(currentArgs != null);
System.Diagnostics.Debug.Assert(currentArgs.Length > 0);
// first Argument is path to executable
if(currentArgs.Length == 0)
throw new Exception();
if(currentArgs.Length == 1)
return new CommandLine(currentArgs[0]);
var filePath = currentArgs[0];
var args = new ArgumentList();
for(int i = 1; i < currentArgs.Length; ++i)
args.Add(currentArgs[i]);
return new CommandLine(filePath, args);
}
示例13: 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());
}
示例14: 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);
}
}