/// <summary> /// 檢查previousFeature→currentFeature的順序是否符合規範,否則拋出例外 /// </summary> /// <typeparam name="T">定義要回傳的TResult</typeparam> /// <param name="currentCast">當前的功能</param> /// <param name="func">若順序正確,則要執行的func</param> /// <returns>TResult</returns> private T ThrowOrderException <T>(Feature currentCast, Func <T> func) { if (FeatureRule.IsTheOrderingLegit(PreviousFeature, currentCast)) { return(func.Invoke()); } else { throw new OrderException(FeatureRule.ORDER_EXCEPTION_MSG); } }
/// <summary> /// 檢查previousCast→currentCast的順序是否符合規範,否則拋出例外 /// </summary> /// <typeparam name="T">定義要回傳的TResult</typeparam> /// <param name="currentCast">當前的功能</param> /// <param name="func">若順序正確,則要執行的func</param> /// <returns>TResult</returns> private T CheckOrder <T>(Feature currentCast, Func <T> func) { if (FeatureRule.IsTheOrderingLegit(PreviousCast, currentCast)) { return(func.Invoke()); } else { throw new OrderException(FeatureRule.INCORRECT_ORDER_MSG); } }
/// <summary> /// Clear事件 /// </summary> public void Clear() { Feature CurrentFeature = Feature.CLEAR; if (FeatureRule.IsTheOrderingLegit(PreviousFeature, CurrentFeature)) { NumberMachine.Clear(); //執行成功時記錄下這次的Cast PreviousFeature = Feature.Null; } else { throw new OrderException(FeatureRule.ORDER_EXCEPTION_MSG); } }
/// <summary> /// Clear事件 /// </summary> public void Clear() { Feature CurrentCast = Feature.CLEAR; if (FeatureRule.IsTheOrderingLegit(PreviousCast, CurrentCast)) { NumberMachine.Clear(); //執行成功時記錄下這次的Cast //PreviousCast = Cast.CLEAR; PreviousCast = Feature.Null; } else { throw new OrderException(FeatureRule.INCORRECT_ORDER_MSG); } }