private void Notify(BoardEvent boardEvent) { foreach (Action callback in this.listeners[boardEvent]) { callback.Invoke(); } }
public Board GetByBoardEventAndForeignId(BoardEvent boardEvent, long foreignId) { var item = DbUtil.Client.CreateDocumentQuery <BoardDO>(CollectionUri) .Where(b => b.BoardEvent.Type == boardEvent.Type && b.BoardEvent.ForeignId == foreignId) .AsEnumerable().FirstOrDefault(); return(item == null ? null : _mapper.Map <Board>(item)); }
public Trigger( BoardEvent triggerEvent, Ability ability, BoardEvent?expirationEvent = null, bool unlimited = false) { TriggerEvent = triggerEvent; Ability = ability; ExpirationEvent = expirationEvent; Unlimited = unlimited; }
public void AddListener(string name, Action <EventData> action) { if (events.ContainsKey(name)) { events[name].action += action; } else { events[name] = new BoardEvent(action); } }
/* * Event handling best practice from http://msdn.microsoft.com/en-us/library/w369ty8x.aspx */ protected virtual void OnRaiseBoardEvent(BoardEvent e) { // Make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. EventHandler<BoardEvent> handler = RaiseBoardEvent; // Event will be null if there are no subscribers if (handler != null) { // Use the () operator to raise the event. handler(this, e); } }
public void When(BoardEvent boardEvent, Action callback) { this.listeners[boardEvent].Add(callback); }
private void BoardMoveEvent(BoardEvent evt) { ((QuoridorService)_quoridorServiceConnector).SendGameEvent(Session.Instance.Opponent.Id.ToString(), evt); }