private void OnLogUpdated(ConsoleLogEventHandler inEvent, string inMessage) { if (inEvent != null) { inEvent(inMessage); } }
Action IRunnerRepository.FindRunner(IParseResult inResult, ConsoleLogEventHandler inEvent) { Action <IParseResult, ConsoleLogEventHandler> act; if (mLookups.TryGetValue(inResult.GetType(), out act)) { return(() => { act(inResult, inEvent); }); } throw new NotSupportedException(inResult.GetType().ToString()); }
private void NotifyPurchaseLogs(int inPosition, ItemRackState inState, ConsoleLogEventHandler inEvent) { switch (inState) { case ItemRackState.CanPurchase: var item = this.PurchaseContext.Purchase(inPosition); this.OnLogUpdated(inEvent, string.Format("Purchased !! [{0}]", item.Name)); break; case ItemRackState.RackNotExist: this.OnLogUpdated(inEvent, "Item is not placed."); break; case ItemRackState.MissingChange: this.OnLogUpdated(inEvent, "Sorry, can not purchase this item because of lack of changes."); break; case ItemRackState.Soldout: this.OnLogUpdated(inEvent, "Sorry, this item has been sold out."); break; case ItemRackState.CanNotPurchase: var amount = this.PurchaseContext.ReceivedTotal; var price = this.PurchaseContext.Racks[inPosition].Item.Price; this.OnLogUpdated(inEvent, string.Format( "Money enough to purchase is not inserted. (left: {0})", price-amount )); break; } }
Action IRunnerRepository.FindRunner(IParseResult inResult, ConsoleLogEventHandler inEvent) { Action<IParseResult, ConsoleLogEventHandler> act; if (mLookups.TryGetValue(inResult.GetType(), out act)) { return () => { act(inResult, inEvent); }; } throw new NotSupportedException(inResult.GetType().ToString()); }