/// <summary> /// Initializes the passed command with the parameters /// </summary> /// <param name="command">The command</param> /// <param name="arg">The parameters to be transferred</param> /// <returns>Returns the result of the initialize</returns> public virtual TOut InitializeCommand(ICommand <TParameter, TOut> command, TParameter arg) { command.FinishEvent += Command_FinishEvent; command.WaitEvent += Command_WaitEvent; return(command.Initialize(arg)); }
// goes to the next command in the priority queue. public void ChangeCommand() { if (commandQueue.Count != 0 && commandQueue.Peek() != null) // if priority queue isn't empty, gets next command { currentCommand = commandQueue.Dequeue(); currentCommand.Initialize(); } else currentCommand = new GetNextCommandSet(this, int.MaxValue); // priority queue is empty, and needs to be re-populated. }
private void InitCommand(ICommand command, bool interruptible, HashSet <ISubsystem> requirements) { command.Initialize(); var scheduledCommand = new CommandState(interruptible); m_scheduledCommands.Add(command, scheduledCommand); OnCommandInitialize?.Invoke(command); foreach (var requirement in requirements) { m_requirements.Add(requirement, command); } }
private static void LoadCommand(Type classType, Assembly DLLAssembly) { Type typeInterface = classType.GetInterface("ICommand", true); if (typeInterface != null) { ICommand instance = (ICommand)Activator.CreateInstance(DLLAssembly.GetType(classType.ToString())); if (!Command.Command.OnCommandLoad.Call(instance, new CommandLoadEventArgs(true)).Canceled) { instance.Initialize(); Logger.Log("[Command]: " + instance.Name + " Initialized!", LogType.Debug); } } }
public void RegisterCommand(int id, string name, string caption, string toolTip, string icon, ICommand command) { if (GetCommand(name) != null) { return; } EnvDTE.Command vsCommand = _commandRegistrar.RegisterCommand(Application, id, name, caption, toolTip, icon, command); if (vsCommand != null) { command.Initialize(name, caption, toolTip, vsCommand); _commandRegistry.Register(command); } }
/////////////////////////////////////////////////////////////////////// public ReturnCode Initialize( Interpreter interpreter, IClientData clientData, ref Result result ) { if (command != null) { return(command.Initialize(interpreter, clientData, ref result)); } else { return(ReturnCode.Error); } }
public void ExecuteCommand(ICommand command, bool isUndoable = true) { if (command == null) { throw new ArgumentNullException("Command is null"); } if (isUndoable) { _commands.Push(command); } command.Initialize(Game); command.Execute(); CreateAnimation($"Command added: {command.GetHintText()}"); if (isUndoable) { CommandStackChanged?.Invoke(); } }
/// <summary> /// Load a DLL /// </summary> /// <param name="s">The filepath of the DLL</param> /// <param name="args">The args to passed to the plugin OnLoad method.</param> public static void LoadDLL(string s, string[] args) { Assembly DLLAssembly = LoadFile(s); //Prevents the dll from being in use inside windows try { foreach (Type ClassType in DLLAssembly.GetTypes()) { if (ClassType.IsPublic) { if (!ClassType.IsAbstract) { Type typeInterface = ClassType.GetInterface("ICommand", true); if (typeInterface != null) { ICommand instance = (ICommand)Activator.CreateInstance(DLLAssembly.GetType(ClassType.ToString())); if (!Command.Command.OnCommandLoad.Call(instance, new CommandLoadEventArgs(true)).Canceled) { instance.Initialize(); Logger.Log("[Command]: " + instance.Name + " Initialized!", LogType.Debug); } } typeInterface = ClassType.GetInterface("IPlugin", true); if (typeInterface != null) { IPlugin instance = (IPlugin)Activator.CreateInstance(DLLAssembly.GetType(ClassType.ToString())); if (!Plugin.Plugin.OnPluginLoad.Call(instance, new PluginLoadEventArgs(true)).Canceled) { instance.OnLoad(args); Plugin.Plugin.AddReference(instance); Logger.Log("[Plugin]: " + instance.Name + " Initialized!", LogType.Debug); } } } } } } catch { } //Stops loading bad DLL files }
public bool Update(GameObject unit) { if (!initialized) { initialized = Initialize(); } if (status != TaskStatus.READY) { return(false); } if (currentCommand == null) { currentStep = stepList.Find(step => !step.done); if (currentStep == null) { done = true; return(true); } currentCommand = (ICommand)unit.AddComponent(currentStep.commandType); currentCommand.Initialize(currentStep.args); } if (currentCommand != null && currentCommand.isFinished()) { if (!currentCommand.isSuccessful()) { Abort(); return(false); } FinishStep(); } return(true); }
/// <summary> /// Adds command to category commands. /// </summary> /// <param name="cnd">Commad to adding.</param> /// <param name="categoryCommands">Parent category.</param> private void _AddCommandToCategory(ICommand cmd, List <ICommand> categoryCommands) { ICommand cmdToAdding = null; if (_commands.Contains(cmd.Name)) { cmdToAdding = (ICommand)_commands[cmd.Name]; // get command from command cache } else { cmdToAdding = cmd; // add commands to commands array _commands.Add(cmdToAdding.Name, cmdToAdding); cmdToAdding.Initialize(App.Current); } // add comannd to category array if (!categoryCommands.Contains(cmdToAdding)) { categoryCommands.Add(cmdToAdding); } }
/// <summary> /// 初始化 /// </summary> /// <param name="parameters"></param> /// <param name="jobEntity"></param> public virtual void Initialize(Hashtable internalParameters, JobEntity jobEntity) { // 获取外部参数 Hashtable parameters = new Hashtable(); this.JobEntity = jobEntity; XmlNodeList parameterList = jobEntity.JobNode.SelectNodes("Parameters/Parameter"); for (int i = 0; i < parameterList.Count; i++) { XmlNode parameterNode = parameterList[i]; string paramName = XmlUtil.GetAttrValue(parameterNode, "Name"); if (internalParameters.ContainsKey(paramName) == true) { continue; } string paramValue = XmlUtil.GetAttrValue(parameterNode, "Value"); // 先替换掉内部的参数 paramValue = BaseCommand.ReplaceParameters(internalParameters, paramValue); // 再替换一下外部前面定义的参数 paramValue = BaseCommand.ReplaceParameters(parameters, paramValue); parameters[paramName] = paramValue; } // 传入命令的参数,要包括内部参数和外部参数 foreach (DictionaryEntry parameter in internalParameters) { parameters[parameter.Key.ToString()] = parameter.Value.ToString(); } CommandList.Clear(); string appDir = (string)parameters[DDPConst.Param_AppDir]; parameters[DDPConst.C_JobCode] = this.JobEntity.Code; parameters[DDPConst.C_ThreadName] = this.ThreadName; XmlNode commandsNode = jobEntity.JobNode.SelectSingleNode("Commands"); if (commandsNode != null) { for (int i = 0; i < commandsNode.ChildNodes.Count; i++) { XmlNode node = commandsNode.ChildNodes[i]; if (!(node is XmlElement)) { continue; } ICommand command = CommandFactory.CreateCommand(appDir, node); if (command != null) { // 初始化 command.Initialize(parameters, node); // 加入命令列表 this.CommandList.Add(command); } } } LogManager.Current.WriteCommonLog(this.JobCode, "初始化完成", this.ThreadName); }
public ICommand GetSlotBCommand() { slotB.Initialize(player); return(slotB); }
/// <summary> /// Adds command to category commands. /// </summary> /// <param name="cnd">Commad to adding.</param> /// <param name="categoryCommands">Parent category.</param> private void _AddCommandToCategory(ICommand cmd, List<ICommand> categoryCommands) { ICommand cmdToAdding = null; if (_commands.Contains(cmd.Name)) cmdToAdding = (ICommand)_commands[cmd.Name]; // get command from command cache else { cmdToAdding = cmd; // add commands to commands array _commands.Add(cmdToAdding.Name, cmdToAdding); cmdToAdding.Initialize(App.Current); } // add comannd to category array if (!categoryCommands.Contains(cmdToAdding)) categoryCommands.Add(cmdToAdding); }