public void Subscribe(IRefreshBusSubscriber subscriber) { if (subscribers.Contains(subscriber)) { throw new SubscriptionException("You cannot subscribe to the RefreshBus more than once. Subscriber '" + subscriber + "' just attempted to register a second time it's type was(" + subscriber.GetType().Name + ")"); } RefreshObject += subscriber.RefreshBus_RefreshObject; subscribers.Add(subscriber); }
public void Unsubscribe(IRefreshBusSubscriber unsubscriber) { if (!subscribers.Contains(unsubscriber)) { throw new SubscriptionException("You cannot unsubscribe from the RefreshBus if never subscribed in the first place. '" + unsubscriber + "' just attempted to unsubscribe when it wasn't subscribed in the first place it's type was (" + unsubscriber.GetType().Name + ")"); } RefreshObject -= unsubscriber.RefreshBus_RefreshObject; subscribers.Remove(unsubscriber); }