/// <summary> /// 移动到下一节点 /// </summary> /// <param name="next">下一节点</param> /// <param name="canReturnBack">是否可以回退</param> /// <returns></returns> public SimpleStatusMachine <T> Next(T next, bool canReturnBack) { var newNode = new Helper(next, canReturnBack); if (!newNode.Equals(this.link.Current)) { var pr = new DoubleTrackNode <Helper>(newNode); pr.PreNode = this.currentNode; this.currentNode.NextNode = pr; this.currentNode = pr; } return(this); }
/// <summary> /// Initializes a new instance of the <see cref="DoubleTrackNode{T}"/> class. /// </summary> /// <param name="item">节点对象</param> /// <param name="prev">前一节</param> /// <param name="next">下一节</param> public DoubleTrackNode(T item, DoubleTrackNode <T> prev, DoubleTrackNode <T> next) { this.Current = item; this.PreNode = prev; this.NextNode = next; }
/// <summary> /// Initializes a new instance of the <see cref="SimpleStatusMachine{T}"/> class. /// </summary> /// <param name="root">第一状态.</param> public SimpleStatusMachine(T root) { this.link = new DoubleTrackNode <Helper>(new Helper(root, true)); this.currentNode = this.link; }