public void ExciteState(T nowValue) { if ((IsTop || nextState == null) && TmpExciteStateEvent != null) { TmpExciteStateEvent.Invoke(nowValue); } if (nextState == null) { nextState = new RecursiveState <T>(nowValue); nextState.IsTop = false; } else { nextState.ExciteState(nowValue); } }
public void ExciteState(T nowValue, Action <T> changeStateEvent, Action <T> reductionStateEvent) { if ((IsTop || nextState == null) && TmpExciteStateEvent != null) { TmpExciteStateEvent.Invoke(nowValue); } if (nextState == null) { nextState = new RecursiveState <T>(nowValue, changeStateEvent, reductionStateEvent); nextState.IsTop = false; } else { nextState.ExciteState(nowValue); } }
/// <summary> /// 激发状态,并针对该次激发提供独特的激发事件和还原事件 /// </summary> /// <param name="nowValue">激发后状态的值</param> /// <param name="tmpExciteStateEvent">临时激发事件</param> /// <param name="tmpRestoreStateEvent">临时还原事件</param> public void ExciteState(T nowValue, Action <T> tmpExciteStateEvent, Action <T> tmpRestoreStateEvent) { this.TmpExciteStateEvent += tmpExciteStateEvent; this.TmpRestoreStateEvent += tmpRestoreStateEvent; if (ExciteStateEvent != null) { ExciteStateEvent.Invoke(nowValue); } if (TmpExciteStateEvent != null) { TmpExciteStateEvent.Invoke(nowValue); TmpExciteStateEvent = null; } NowValue = nowValue; IsExcited = true; }