/// <summary> /// Unsubscribes to a channel based on a tag /// </summary> /// <param name="tag"></param> public static void Unsubscribe(string tag) { foreach (var channel in _channels.Values) { foreach (var subscription in channel.Keys) { if (subscription.Tag == tag) { channel.TryRemove(subscription, out var _); OnSubscriptionRemoved?.Invoke(null, subscription); } } } }
/// <summary> /// Unsubscribes to a channel based on an object owner /// </summary> /// <param name="owner">The owner object</param> public static void Unsubscribe(object owner) { if (owner == null) { return; } foreach (var channel in _channels.Values) { foreach (var subscription in channel.Keys) { if (subscription.Owner == owner) { channel.TryRemove(subscription, out var _); OnSubscriptionRemoved?.Invoke(owner, subscription); } } } }
private void RaiseOnSubRemoved(ISubscription subscription) => OnSubscriptionRemoved?.Invoke(this, subscription);
/// <param name="eventName"></param> private void RaiseOnEventRemoved(string eventName) { OnSubscriptionRemoved?.Invoke(this, eventName); }