public static string AsString(this CoinAction action) { switch (action) { case CoinAction.CoinCreated: return("coin_created"); case CoinAction.CoinSpent: return("coin_spent"); default: return(default(CoinAction).AsString()); } }
/// <summary> /// Communicate with payment keypad simulator. /// </summary> private void ReadPaymentInstructions() { try { do { string template = _vendingMessageRepository.GetMessage(MessageCode.MakeYourPayment); if (!string.IsNullOrWhiteSpace(template)) { string msg = string.Format(template, msgAccepted); _displayPanel.DisplayMessage(msg); } // get the key code char code = _readKeypadInput.ReadInput(_cancellationToken); if (code == '#') { // cancel simulation key DisplayMessageByCode(MessageCode.Ok); CoinAction?.Invoke(PaymentCmdEvent.Cancel, null); } else if (MapToCoins.ContainsKey(code)) { // valid coin code var coin = MapToCoins[code]; DisplayMessageByCode(MessageCode.Ok); // signal about payment CoinAction?.Invoke(PaymentCmdEvent.Payment, coin); } else { // invalid keypad simulation key DisplayMessageByCode(MessageCode.InvalidInput); } }while (IsStateOn); } catch (Exception e) { FailtException?.Invoke(e); } }
public void InvokeCoinAction(PaymentCmdEvent cmd, INotionValue obj) { CoinAction?.Invoke(cmd, obj); }
public CoinChange(CoinIdentifier coinIdentifier, CoinAction coinAction) { CoinIdentifier = coinIdentifier; CoinAction = coinAction; }