public void Start(OrderPlaced @event) { var id = new Guid(@event.Order.Id); IMidget midget = @event.Order.IsDodgy ? (IMidget) new DodgyOrderMidget(id, dispatcher) : new OrderMidget(id, dispatcher); midget.OnCompleted += MidgetCompleted; midgets.Add(id, midget); }
public void KillMidget(IMidget midget) { if (midget == null || !_midgets.ContainsKey(midget.CorrelationId)) { return; } _pubsub.Unsubscribe <OrderCooked>(midget.CorrelationId, midget); _pubsub.Unsubscribe <OrderPriced>(midget.CorrelationId, midget); _pubsub.Unsubscribe <OrderPaid>(midget.CorrelationId, midget); _pubsub.Unsubscribe <RetryCooking>(midget.CorrelationId, midget); _midgets.Remove(midget.CorrelationId); }