コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
        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());
        }
コード例 #3
0
ファイル: IPluginCommand.cs プロジェクト: jiaping/JPCMS
        /// <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);
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
ファイル: PluginHelper.cs プロジェクト: jiaping/JPCMS
        /// <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);
        }
コード例 #6
0
ファイル: Bot.cs プロジェクト: mikaelssen/FruitBowlBot
        /// <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");
        }
コード例 #7
0
 public void Add(IPluginCommand pluginCommand)
 {
     _commands.Add(pluginCommand);
 }
コード例 #8
0
        private static void RegisterCommand(IPluginCommand command)
        {
            var commandFactory = ObjectFactory.GetInstance <PluginCommandMockRepository>();

            commandFactory.Add(command);
        }
		public void Add(IPluginCommand pluginCommand)
		{
			_commands.Add(pluginCommand);
		}
コード例 #10
0
		private static void RegisterCommand(IPluginCommand command)
		{
			var commandFactory = ObjectFactory.GetInstance<PluginCommandMockRepository>();
			commandFactory.Add(command);
		}
コード例 #11
0
 public void ExecuteCommand(IPluginCommand command)
 {
     command.Execute();
 }
コード例 #12
0
 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");
 }