/// <summary> /// Unregisters the specified subscriber from receiving routed event notifications for the specified routed event. /// </summary> /// <param name="dobj">The dependency object to monitor for changes.</param> /// <param name="routedEvent">The routed event </param> /// <param name="subscriber">The subscriber that wishes to stop receiving change notifications for the specified dependency property.</param> internal static void UnregisterRaisedNotification(DependencyObject dobj, RoutedEvent routedEvent, IRoutedEventRaisedNotificationSubscriber subscriber) { Contract.Require(dobj, "dobj"); Contract.Require(routedEvent, "routedEvent"); Contract.Require(subscriber, "subscriber"); routedEvent.raisedNotificationServer.Unsubscribe(dobj, subscriber); }
/// <summary> /// Adds a subscriber to the server's notification list. /// </summary> /// <param name="target">The target object for which the subscriber is requesting notifications.</param> /// <param name="subscriber">The subscriber that wishes to receive notifications for the specified target.</param> public void Subscribe(DependencyObject target, IRoutedEventRaisedNotificationSubscriber subscriber) { lock (subscriptions) { PooledLinkedList <IRoutedEventRaisedNotificationSubscriber> subscribers; if (!subscriptions.TryGetValue(target, out subscribers)) { lock (subscriberListPool) { subscribers = subscriberListPool.Retrieve(); } subscriptions[target] = subscribers; } subscribers.AddLast(subscriber); } }
/// <summary> /// Adds a subscriber to the server's notification list. /// </summary> /// <param name="target">The target object for which the subscriber is requesting notifications.</param> /// <param name="subscriber">The subscriber that wishes to receive notifications for the specified target.</param> public void Subscribe(DependencyObject target, IRoutedEventRaisedNotificationSubscriber subscriber) { lock (subscriptions) { PooledLinkedList<IRoutedEventRaisedNotificationSubscriber> subscribers; if (!subscriptions.TryGetValue(target, out subscribers)) { lock (subscriberListPool) { subscribers = subscriberListPool.Retrieve(); } subscriptions[target] = subscribers; } subscribers.AddLast(subscriber); } }
/// <summary> /// Removes a subscriber from the server's notification list. /// </summary> /// <param name="target">The target object for which the subscriber was requesting notifications.</param> /// <param name="subscriber">The subscriber that wishes to stop receiving notifications for the specified target.</param> public void Unsubscribe(DependencyObject target, IRoutedEventRaisedNotificationSubscriber subscriber) { lock (subscriptions) { PooledLinkedList<IRoutedEventRaisedNotificationSubscriber> subscribers; if (!subscriptions.TryGetValue(target, out subscribers)) return; subscribers.Remove(subscriber); if (subscribers.Count == 0) { subscriptions.Remove(target); lock (subscriberListPool) { subscriberListPool.Release(subscribers); } } } }
/// <summary> /// Removes a subscriber from the server's notification list. /// </summary> /// <param name="target">The target object for which the subscriber was requesting notifications.</param> /// <param name="subscriber">The subscriber that wishes to stop receiving notifications for the specified target.</param> public void Unsubscribe(DependencyObject target, IRoutedEventRaisedNotificationSubscriber subscriber) { lock (subscriptions) { PooledLinkedList <IRoutedEventRaisedNotificationSubscriber> subscribers; if (!subscriptions.TryGetValue(target, out subscribers)) { return; } subscribers.Remove(subscriber); if (subscribers.Count == 0) { subscriptions.Remove(target); lock (subscriberListPool) { subscriberListPool.Release(subscribers); } } } }
/// <summary> /// Unregisters the specified subscriber from receiving routed event notifications for the specified routed event. /// </summary> /// <param name="dobj">The dependency object to monitor for changes.</param> /// <param name="routedEvent">The routed event </param> /// <param name="subscriber">The subscriber that wishes to stop receiving change notifications for the specified dependency property.</param> internal static void UnregisterRaisedNotification(DependencyObject dobj, RoutedEvent routedEvent, IRoutedEventRaisedNotificationSubscriber subscriber) { Contract.Require(dobj, nameof(dobj)); Contract.Require(routedEvent, nameof(routedEvent)); Contract.Require(subscriber, nameof(subscriber)); routedEvent.raisedNotificationServer.Unsubscribe(dobj, subscriber); }
/// <summary> /// Registers the specified subscriber to receive routed event notifications for the specified routed event. /// </summary> /// <param name="dobj">The dependency object to monitor for changes.</param> /// <param name="routedEvent">The dependency property for which to receive change notifications.</param> /// <param name="subscriber">The subscriber that wishes to receive change notifications for the specified dependency property.</param> internal static void RegisterRaisedNotification(DependencyObject dobj, RoutedEvent routedEvent, IRoutedEventRaisedNotificationSubscriber subscriber) { Contract.Require(dobj, nameof(dobj)); Contract.Require(routedEvent, nameof(routedEvent)); Contract.Require(subscriber, nameof(subscriber)); routedEvent.raisedNotificationServer.Subscribe(dobj, subscriber); }