void OnChangeEvent(EventItem item) { switch (item.Type) { case EventType.QuoteChanged: OnQuoteChanged(item.Quote); break; case EventType.NewOrder: if (item.Order.Owner.Username.Equals(UserLogged.Username)) { OnNewOrder(item.Order); } break; case EventType.CompleteOrder: if (item.Order.Owner.Username.Equals(UserLogged.Username)) { OnCompleteOrder(item.Order); WriteMessage("Complete", item.Order); } break; case EventType.IncompleteOrder: if (item.Order.Owner.Username.Equals(UserLogged.Username)) { OnIncompleteOrder(item.Order, item.OldOrder); WriteMessage("Partial", item.Order); } break; case EventType.DeleteOrder: if (item.Order.Owner.Username.Equals(UserLogged.Username)) { DeleteOrder(item.Order); } break; default: break; } }
public void AddEventHandler(string eventName, Action <dynamic> eventHandler) { var isFirst = false; if (!this._eventsList.TryGetValue(eventName, out var eventItem)) { var eventKey = Guid.NewGuid(); var @event = new EventEmitter(); eventItem = new EventItem(eventKey, @event); _eventsList.Add(eventName, eventItem); _eventEmittersList.Add(eventKey, @event); _connector.EventDictionary.Add(eventKey, this); isFirst = true; } eventItem.Event.Subject += eventHandler; if (isFirst) { _target.AddEventHandler(eventItem.EventKey, eventName); } }