/// <summary> /// Handles plugin commands by checking if an actor of the specified name exists and then /// forwarding the message on if it does so /// </summary> /// <param name="msg"></param> private void HandlePluginCommand(IPluginCommand msg) { var child = Context.Child(msg.PluginName); if (child.IsNobody()) { child.Forward(msg); } }
public void CreateCommand() { IPluginFactory factory = new PluginFactory(); Type applyScriptCommandType = typeof(ApplyScriptCommand); factory.RegisterCommand(applyScriptCommandType); IPluginCommand plugin = factory.CreateCommand("ApplyScript", null, null); Assert.AreEqual(typeof(ApplyScriptCommand), plugin.GetType()); }
/// <summary> /// 取得命令对象 /// </summary> /// <param name="commandName">命令关键字</param> /// <returns>命令对象</returns> public static IPluginCommand CreateCommand(string commandName) { IPluginCommand command = null; switch (commandName.ToLower()) { case "checkfile": command = new PluignCheckFileCommand(); break; case "checkversion": command = new PluignCheckVersionCommand(); break; case "download": command = new PluginDownLoadCommand(); break; case "installskin": command = new PluginInstallSkinCommand(); break; case "installmodels": command = new PluginInstallModelsCommand(); break; case "installdbfile": command = new PluginInstallDBFileCommand(); break; case "installcontrol": command = new PluginInstallWidgetAndControlCommand(); break; case "installdll": command = new PluginInstallDllCommand(); break; case "installdb": command = new PluginInstallDBCommand(); break; case "delete": command = new PluginDeleteCommand(); break; case "updateconfig": command = new PluginUpdatePluginFileCommand(); break; } return(command); }
/// <summary> /// Build list of commands for executing /// </summary> /// <param name="config"></param> /// <returns></returns> protected virtual IEnumerable <IPluginCommand> BuildChain(EnvironmentModel config) { IList <IPluginCommand> result = new List <IPluginCommand>(); IDataStore data = new DataStore(); foreach (CommandModel cmd in config.Commands) { ISettingStore settings = new SettingStore(cmd, config); IPluginCommand plugin = PluginFactory.CreateCommand(cmd.PluginType, settings, data); result.Add(plugin); } return(result); }
/// <summary> /// 运行客户端传来的命令 /// </summary> /// <param name="pluginName">插件名称</param> /// <param name="cmd">执行的命令</param> /// <param name="action">当前动作</param> /// <returns>执行命令的结果信息</returns> public string RunCommand(string pluginName, string cmd, PluginAction action) { string result = ""; IPluginCommand command = PluginCommandFactory.CreateCommand(cmd); PluginInfo info = GetPluginInfo(pluginName, cmd); if (info != null) { result = command.Run(info, action); } else if (IsTemplate(pluginName)) { info = new PluginInfo(PluginType.RESOURCE); info.Directory = pluginName; result = command.Run(info, action); } else { result = new PluginJsonResult(false, "当前插件不存在").ToString(); } return(result); }
/// <summary>w /// turns off or on a plugin based on its name /// </summary> /// <param name="message"></param> /// <returns>result string</returns> private string PluginManager(Message message) { var plugin = ""; var toggle = true; if (message.Arguments.Count > 0 && message.Arguments.Count < 3) { if (message.Arguments.ElementAtOrDefault(0) != null) { plugin = message.Arguments[0]; } if (message.Arguments.ElementAtOrDefault(1) != null) { toggle = Convert.ToBoolean(message.Arguments[1]); } IPluginCommand[] plugs = _plugins.Where(plug => plug.Command == plugin).ToArray(); IPluginCommand[] plugsalas = _plugins.Where(plug => plug.Aliases.Contains(plugin)).ToArray(); IPluginCommand[] combined = new IPluginCommand[plugs.Length + plugsalas.Length]; Array.Copy(plugs, combined, plugs.Length); Array.Copy(plugsalas, 0, combined, plugs.Length, plugsalas.Length); if (combined.Count() > 0) { combined[0].Loaded = toggle; string status = toggle ? "Enabled" : "Disabled"; return($"{combined[0].PluginName} is now { status }"); } else { return($"Could not find a plugin with the command { plugin }"); } } return("You must define a plugin command, and a bool"); }
public void Add(IPluginCommand pluginCommand) { _commands.Add(pluginCommand); }
private static void RegisterCommand(IPluginCommand command) { var commandFactory = ObjectFactory.GetInstance <PluginCommandMockRepository>(); commandFactory.Add(command); }
private static void RegisterCommand(IPluginCommand command) { var commandFactory = ObjectFactory.GetInstance<PluginCommandMockRepository>(); commandFactory.Add(command); }
public void ExecuteCommand(IPluginCommand command) { command.Execute(); }
private void ExecuteCommand(IPluginCommand pluginCommand) { _PlayerPluginContext.Log(LogLevel.Information, "Command " + pluginCommand.Key + "=" + pluginCommand.Value + " intercepted"); pluginCommand.ReportProgress(0.5f, "Plugin command executing"); pluginCommand.ReturnResult("OK"); }