本文整理汇总了C#中ArgumentList.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# ArgumentList.RemoveAt方法的具体用法?C# ArgumentList.RemoveAt怎么用?C# ArgumentList.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArgumentList
的用法示例。
在下文中一共展示了ArgumentList.RemoveAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ManagePlugins
/// <summary>
/// Enable/disable and get details about specific plugins.
/// </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 ManagePlugins(Server server, ISender sender, ArgumentList args)
{
/*
* Commands:
* list - shows all plugins
* info - shows a plugin's author & description etc
* disable - disables a plugin
* enable - enables a plugin
*/
if (args.Count > 0 && args[0] != null && args[0].Trim().Length > 0)
{
String command = args[0].Trim();
args.RemoveAt(0); //Allow the commands to use any additional arguments without also getting the command
switch (command)
{
case "list":
{
if (server.PluginManager.PluginList.Count > 0)
{
String plugins = "";
foreach (Plugin.Plugin plugin in server.PluginManager.PluginList.Values)
{
if (plugin.Name.Trim().Length > 0)
{
plugins += ", " + plugin.Name.Trim() + ((!plugin.Enabled) ? "[DISABLED] " : " ");
}
}
if (plugins.StartsWith(","))
{
plugins = plugins.Remove(0, 1).Trim(); //Remove the ', ' from the start and trim the ends
}
sender.sendMessage("Plugins: " + plugins + ".");
}
else
{
sender.sendMessage("There are no installed plugins.");
}
break;
}
case "info":
{
if (!(args.Count > 1 && args[1] != null && args[0].Trim().Length > 0))
{
sender.sendMessage("Please review your argument count.");
}
String pluginName = string.Join(" ", args);
if (server.PluginManager.PluginList.Count > 0)
{
Plugin.Plugin fplugin = server.PluginManager.GetPlugin(pluginName);
if (fplugin != null)
{
sender.sendMessage("Plugin Name: " + fplugin.Name);
sender.sendMessage("Plugin Author: " + fplugin.Author);
sender.sendMessage("Plugin Description: " + fplugin.Description);
sender.sendMessage("Plugin Enabled: " + fplugin.Enabled.ToString());
}
else
{
sender.sendMessage("The plugin \"" + args[1] + "\" was not found.");
}
}
else
{
sender.sendMessage("There are no plugins loaded.");
}
break;
}
case "disable":
{
if (!(args.Count > 1 && args[1] != null && args[1].Trim().Length > 0))
{
sender.sendMessage("Please review your argument count.");
}
String pluginName = string.Join(" ", args);
if (server.PluginManager.PluginList.Count > 0)
{
Plugin.Plugin fplugin = server.PluginManager.GetPlugin(pluginName);
if (fplugin != null)
{
if (fplugin.Enabled)
{
if (server.PluginManager.DisablePlugin(fplugin.Name))
{
sender.sendMessage(pluginName + " was disabled!");
}
else
{
sender.sendMessage("There was an issue disabling plugin \"" + pluginName + "\".");
}
//.........这里部分代码省略.........
示例2: PluginManage
public void PluginManage(ISender sender, ArgumentList args)
{
/*
* Commands:
* list - shows all plugins
* info - shows a plugin's author & description etc
* disable - disables a plugin
* enable - enables a plugin
* reload
* unload
* status
* load
*/
if (args.Count == 0)
throw new CommandError("Subcommand expected.");
string command = args[0];
args.RemoveAt(0); //Allow the commands to use any additional arguments without also getting the command
lock (PluginManager._plugins)
switch (command)
{
case "-l":
case "ls":
case "list":
{
if (PluginManager.PluginCount == 0)
{
sender.Message(255, "No plugins loaded.");
return;
}
var msg = new StringBuilder();
msg.Append("Plugins: ");
int i = 0;
foreach (var plugin in PluginManager.EnumeratePlugins)
{
if (i > 0)
msg.Append(", ");
msg.Append(plugin.Name);
if (!String.IsNullOrEmpty(plugin.Version))
{
msg.Append(" (");
msg.Append(plugin.Version);
msg.Append(")");
}
if (!plugin.IsEnabled)
msg.Append("[OFF]");
i++;
}
msg.Append(".");
sender.Message(255, Color.DodgerBlue, msg.ToString());
break;
}
case "-s":
case "stat":
case "status":
{
if (PluginManager.PluginCount == 0)
{
sender.Message(255, "No plugins loaded.");
return;
}
var msg = new StringBuilder();
foreach (var plugin in PluginManager.EnumeratePlugins)
{
msg.Clear();
msg.Append(plugin.IsDisposed ? "[DISPOSED] " : (plugin.IsEnabled ? "[ON] " : "[OFF] "));
msg.Append(plugin.Name);
msg.Append(" ");
msg.Append(plugin.Version);
if (plugin.Status != null && plugin.Status.Length > 0)
{
msg.Append(" : ");
msg.Append(plugin.Status);
}
sender.Message(255, Color.DodgerBlue, msg.ToString());
}
break;
}
case "-i":
case "info":
{
string name;
args.ParseOne(out name);
var fplugin = PluginManager.GetPlugin(name);
if (fplugin != null)
{
//.........这里部分代码省略.........