public void RemoveNotificationRequest(Interactor source, NotificationRequest notificationRequest) { Notification notification; if (_cache.TryGetValue(notificationRequest.TopicPattern, out notification) && notification.Notifiables.Contains(source)) { notification.Notifiables.Remove(source); if (notification.Notifiables.Count == 0) _cache.Remove(notificationRequest.TopicPattern); } }
void AddNotificationRequest(Interactor source, NotificationRequest notificationRequest) { Notification notification; if (!_cache.TryGetValue(notificationRequest.TopicPattern, out notification)) _cache.Add(notificationRequest.TopicPattern, notification = new Notification(new Regex(notificationRequest.TopicPattern))); if (!notification.Notifiables.Contains(source)) { notification.Notifiables.Add(source); _messageBus.NewNotificationRequests.OnNext(SourceMessage.Create(source, notification.TopicPattern)); } }