public void AddNotificationListener(ObjectName name, NotificationCallback callback, NotificationFilterCallback filterCallback, object handback)
 {
     var key = new NotificationSubscriptionKey(name, callback, filterCallback, handback);
     if (_subscriptions.ContainsKey(key))
     {
         throw new InvalidOperationException("Subscription already exists.");
     }
     var pullDeliverySubscription = _eventingClient.SubscribeUsingPullDelivery<TargetedNotificationType>(new Filter(Schema.NotificationDialect, null), new Mandatory(name.CreateSelectorSetHeader()));
     var listener = new PullSubscriptionListener(pullDeliverySubscription, callback, filterCallback, handback);
     _subscriptions.Add(key, listener);
 }
        public void AddNotificationListener(ObjectName name, NotificationCallback callback, NotificationFilterCallback filterCallback, object handback)
        {
            var key = new NotificationSubscriptionKey(name, callback, filterCallback, handback);

            if (_subscriptions.ContainsKey(key))
            {
                throw new InvalidOperationException("Subscription already exists.");
            }
            var pullDeliverySubscription = _eventingClient.SubscribeUsingPullDelivery <TargetedNotificationType>(new Filter(Schema.NotificationDialect, null), new Mandatory(name.CreateSelectorSetHeader()));
            var listener = new PullSubscriptionListener(pullDeliverySubscription, callback, filterCallback, handback);

            _subscriptions.Add(key, listener);
        }
        public override bool Equals(object obj)
        {
            if (!(obj is NotificationSubscriptionKey))
            {
                return(false);
            }
            NotificationSubscriptionKey other = (NotificationSubscriptionKey)obj;

            return(Callback.Equals(other.Callback) &&
                   AreBothNullOrEqual(_filterCallback, other._filterCallback) &&
                   AreBothNullOrEqual(_handback, other._handback) &&
                   ObjectName.Equals(other.ObjectName));
        }
        public void RemoveNotificationListener(ObjectName name, NotificationCallback callback, NotificationFilterCallback filterCallback, object handback)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            var key = new NotificationSubscriptionKey(name, callback, filterCallback, handback);

            PullSubscriptionListener listener;

            if (_subscriptions.TryGetValue(key, out listener))
            {
                _subscriptions.Remove(key);
                listener.Dispose();
            }
        }
        public void RemoveNotificationListener(ObjectName name, NotificationCallback callback, NotificationFilterCallback filterCallback, object handback)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            var key = new NotificationSubscriptionKey(name, callback, filterCallback, handback);

            PullSubscriptionListener listener;
            if (_subscriptions.TryGetValue(key, out listener))
            {
                _subscriptions.Remove(key);
                listener.Dispose();
            }
        }