public void Add(ICmd newCmd) { mCmds.Add(newCmd); //Add to the mCmds list c = newCmd.GetCell(); //Update c t = c.Text; //Update t bgc = c.BGColor; //Update bgc }
public static void Initialise() { if (initialised) { return; } // Load ICmds var type = typeof(ICmd); Commands = new Dictionary <string, ICmd>(); foreach (var ctype in AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s => s.GetTypes()) .Where(p => type.IsAssignableFrom(p) && !p.IsAbstract)) { ICmd cmd = (ICmd)Activator.CreateInstance(ctype); Commands[cmd.Name] = cmd; } // Load Internals Internals = new Dictionary <string, Internal>(); foreach (string name in Tools.GetEnumNames <Internal>()) { Internals[name] = (Internal)Enum.Parse(typeof(Internal), name); } // Load Constants ImportConstants <Direction>(); ImportConstants <Job>(); ImportConstants <Event>(); ImportConstants <ListenerExpiry>(); ImportConstants <Action>(); initialised = true; }
private bool Next() { ICmd CmdHandle = CurrentCmd; if (CmdHandle == null) { return(false); } lock (CmdHandle) { if (CmdHandle.IsReapteCmd) { return(true); } else if (CmdQueue.Count > 1 && CmdHandle.IsSuccess) { CmdQueue.Dequeue(); return(true); } else { return(false); } } }
public void executeUndo() //execute the command on the top of the undo stack { redoMessage = getUndoMessage(); //get the redo message ICmd cmd = undo.Pop(); //pop the command to undo from the undo stack redo.Push(cmd.Exec()); //execute the undo command and add it to the redo stack }
public override void ProcessCmd(ICmd cmd) { if (CurrentState.ProcessCmd(cmd)) { NextState = null; } else { if (cmd is CmdMove) { NextState = GetState(E_StateType.Move); } else if (cmd is CmdAttack) { NextState = GetState(E_StateType.Attack); } else if (cmd is CmdDeath) { NextState = GetState(E_StateType.Death); } else if (cmd is CmdWeaponShow) { NextState = GetState(E_StateType.Idle); } } if (NextState == null) { return; } ChangeState(cmd); }
// 添加cmd 并执行一次 public void AddCmd(ICmd cmd) { if (cmdCur != cmdCounter.Cur - cmdOffset) { syncCmd(); } #if UNITY_4_1 Undo.IncrementCurrentEventIndex(); #endif // 清除当前位置之后的cmd if (cmdList.Count > cmdCur) { cmdList.RemoveRange(cmdCur, cmdList.Count - cmdCur); } cmdList.Add(cmd); cmd.execute(); cmdCur++; #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 Undo.RegisterCompleteObjectUndo(cmdCounter, cmd.CmdName); #elif (UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9) Undo.RegisterUndo(cmdCounter, cmd.CmdName); #else Undo.RecordObject(cmdCounter, cmd.CmdName); #endif cmdCounter.Cur++; }
private void CmdTask() { while (true) { ICmd cmdHandle = CurrentCmd; if (cmdHandle == null) { return; } cmdHandle.SyncExcute(PacketHandle); IsPrivateCmd = false; double ResponsedTime = 0; if (cmdHandle.IsSuccess) { ResponsedTime = (cmdHandle.ResponsedTime - cmdHandle.RequestedTime).TotalMilliseconds; } CmdCostTime += ResponsedTime; if (!IsPrivateCmd) { Log.info("本次命令执行耗时" + ResponsedTime.ToString() + "ms!"); } if (Next()) { if (!IsPrivateCmd) { Log.info("将执行下一条命令!"); } CmdEvent.Set(); } else { return; } } }
private void redoCellTextChangeToolStripMenuItem_Click(object sender, EventArgs e) { ICmd temp = mySpreadsheet.popRedo(); mySpreadsheet.AddUndo(temp.Exec()); undoCellTextChangeToolStripMenuItem.Enabled = true; }
public override bool ProcessCmd(ICmd cmd) { if (cmd is CmdMove) { if (Cmd != null) { Cmd.SetSuccess(); } SetFinished(false); Initialize(cmd); return(true); } if (cmd is CmdWeaponShow) { cmd.SetSuccess(); PlayAnim(GetMotionType()); return(true); } if (cmd is CmdIdle) { cmd.SetSuccess(); SetFinished(true); } return(false); }
public void ProcessCmd(ICmd cmd) { if (cmd != null && cmd.IsFailed) { return; } FSM.ProcessCmd(cmd); }
public bool Add(ICmd cmd) { lock (CmdLock) { CmdQueue.Enqueue(cmd); return(true); } }
/// <summary> /// /// </summary> /// <param name="cmdStr"></param> /// <returns></returns> internal static ICmd ParseSqlCmdString(string cmdStr, CoreEA.ICoreEAHander dbe) { ICmd curCmd = null; if (string.IsNullOrEmpty(cmdStr)) { ProcessException.DisplayErrors(new Exception("Empty Command")); return(null); } try { cmdStr = cmdStr.TrimStart(); cmdStr = cmdStr.TrimEnd(); //Can't to lower , otherwise the insert data will never 大写 //cmdText = cmdText.ToLower(); string tempCmdText = cmdStr.ToLower(); if (tempCmdText.StartsWith("select")) { curCmd = new SelectCmd(dbe); } else if (tempCmdText.StartsWith("insert")) { curCmd = new InsertCmd(dbe); } else if (tempCmdText.StartsWith("update")) { curCmd = new UpdateCmd(dbe); } else if (tempCmdText.StartsWith("delete")) { curCmd = new DeleteCmd(dbe); } else if (tempCmdText.StartsWith("alter") || (tempCmdText.StartsWith("drop"))) { curCmd = new SpecialCmd(dbe); } else if (tempCmdText.StartsWith("create")) { curCmd = new CreateCmd(dbe); } else if (tempCmdText.StartsWith("sp_rename")) { curCmd = new SpecialCmd(dbe); } else { curCmd = null; //throw new Exception("ErrorMsg_CannotParseSqlCmd".GetFromResourece()); } } catch (Exception ee) { ProcessException.DisplayErrors(ee); } return(curCmd); }
/// <summary> /// 添加命令进行派发 /// </summary> /// <param name="cmd"></param> public void AddCmd(ICmd cmd) { IdleTimer = 0f; ActiveCmds.Add(cmd); for (int i = 0; i < CmdHandlers.Count; i++) { CmdHandlers[i].ProcessCmd(cmd); } }
//接收命令 public void ReceiveCmd(EnumCmdType cmd, ICmd data) { if (!dicCmds.ContainsKey(cmd)) { Debug.LogError("Error: " + _name + " 对象不存在此命令:" + cmd + " 触发命令失败"); return; } dicCmds[cmd].Invoke(data); }
public LatestVersionService( ICmd cmd, IStartInstanceService startInstanceService, WorkingFolder workingFolder) { this.cmd = cmd; this.startInstanceService = startInstanceService; this.workingFolder = workingFolder; }
static void Run(ICmd <int> cmd, After after) { try { cmd.Execute(); after.ProcessOk(); } catch (Exception e) { after.ProcessFailed(e); } }
public static bool AllowedCmd(ICmd cmd, SocketUser user) { bool isOwner = false; if (user is IGuildUser guildUser) { isOwner = guildUser.RoleIds.Any((role) => role == Bot.Config.OwnerRoleId); } return(isOwner || !cmd.OwnerOnly); }
public static Disposable <(ICmd, CommandResultValidation)> ChangeResultValidation( this ICmd cmd, CommandResultValidation newResultValidation) { var oldValue = cmd.ResultValidation; cmd.ResultValidation = newResultValidation; return(Disposable.New( (Cmd: cmd, OldValue: oldValue), state => state.Cmd.ResultValidation = state.OldValue)); }
/// <summary> /// 撤销 /// </summary> public virtual void Undo() { if (!this.CanUndo) { return; } ICmd cmd = cmdHistories[CurrentPosition--]; cmd.Revoke(); }
/// <summary> /// 重做 /// </summary> public virtual void Redo() { if (!this.CanRedo) { return; } ICmd cmd = cmdHistories[++CurrentPosition]; cmd.Excute(); }
protected override void Initialize(ICmd cmd) { base.Initialize(cmd); Cmd = cmd as CmdMove; FinalRotation.SetLookRotation(Owner.BlackBoard.DesiredDirection); StartRotation = Owner.Transform.rotation; Owner.BlackBoard.MotionType = GetMotionType(); RotationProgress = 0; }
public override void Execute() { if (WeaponCmd != null && TimeToFinishCmd < Time.timeSinceLevelLoad) { WeaponCmd.SetSuccess(); WeaponCmd = null; //todo: play id anim. PlayIdleAnim(); } }
static async Task Run(ICmd <Task> cmd, After after) { try { await cmd.Execute(); after.ProcessOk(); } catch (Exception e) { after.ProcessFailed(e); } }
static R Run <R>(ICmd <R> cmd, R fail, After after) { try { var result = cmd.Execute(); after.ProcessOk(); return(result); } catch (Exception e) { after.ProcessFailed(e); return(fail); } }
public Installer( ICommandLine commandLine, ICmd cmd, IGitEnvironmentService gitEnvironmentService, IProgressService progressService) { this.commandLine = commandLine; this.cmd = cmd; this.gitEnvironmentService = gitEnvironmentService; this.progressService = progressService; }
/// <summary> /// 放回缓存 /// </summary> /// <param name="cmd"></param> public static void Return(ICmd cmd) { if (cmd == null) { return; } cmd.SetUnused(); UnusedCmds[cmd.Type].Enqueue(cmd); #if DEBUG UsedCmds.Remove(cmd); #endif }
public void Clear() { lock (CmdLock) { ICmd cmdhandle = CurrentCmd; CmdQueue.Clear(); if (cmdhandle != null) { cmdhandle.IsCmdStop = true; } } }
static async Task <R> Run <R>(ICmd <Task <R> > cmd, R fail, After after) { try { var result = await cmd.Execute(); after.ProcessOk(); return(result); } catch (Exception e) { after.ProcessFailed(e); return(fail); } }
public DiffService( WorkingFolder workingFolder, IGitDiffService gitDiffService, IGitStatusService gitStatusService, IGitDiffParser diffParser, ICmd cmd) { this.workingFolder = workingFolder; this.gitDiffService = gitDiffService; this.gitStatusService = gitStatusService; this.diffParser = diffParser; this.cmd = cmd; }
protected override void Initialize(ICmd cmd) { base.Initialize(cmd); Owner.BlackBoard.MotionType = E_MotionType.None; Owner.BlackBoard.MoveDir = Vector3.zero; Owner.BlackBoard.Speed = 0; if (WeaponCmd == null) { PlayIdleAnim(); } }
/// <summary> /// The residence of the listening-socket thread, one for each of the <see cref="ICmd"/> /// </summary> /// <param name="cmd"></param> /// <param name="cmdPort"></param> protected internal void HostCmd(ICmd cmd, int cmdPort) { using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { //this should NOT be reachable from any other machine var endPt = new IPEndPoint(IPAddress.Loopback, cmdPort); socket.Bind(endPt); socket.Listen(Constants.SOCKET_LISTEN_NUM); for (; ; )//ever { try { var buffer = new List<byte>(); var client = socket.Accept(); PrintToConsole($"Connect from port {cmdPort}"); var data = new byte[Constants.DEFAULT_BLOCK_SIZE]; //park for first data received client.Receive(data, 0, data.Length, SocketFlags.None); buffer.AddRange(data.Where(b => b != (byte)'\0')); while (client.Available > 0) { if (client.Available < Constants.DEFAULT_BLOCK_SIZE) { data = new byte[client.Available]; client.Receive(data, 0, client.Available, SocketFlags.None); } else { data = new byte[Constants.DEFAULT_BLOCK_SIZE]; client.Receive(data, 0, (int)Constants.DEFAULT_BLOCK_SIZE, SocketFlags.None); } buffer.AddRange(data.Where(b => b != (byte)'\0')); } var output = cmd.Execute(buffer.ToArray()); client.Send(output); client.Close(); } catch (Exception ex) { PrintToConsole(ex); } } } }