/// <summary> /// Adds the specified listener to the list of listeners on the specified source. /// </summary> /// <param name="source">The object with the event.</param> /// <param name="listener">The object to add as a listener.</param> /// <param name="propertyName">The name of the property that exists on /// source upon which to listen for changes.</param> public static void AddListener( INotifyPropertyChanged source, IWeakEventListener listener, string propertyName) { Instance.PrivateAddListener(source, listener, propertyName); }
public static void RemoveListener(INotifyPropertyChanged source, IWeakEventListener listener) { if (source == null) { throw new ArgumentNullException("source"); } if (listener == null) { throw new ArgumentNullException("listener"); } PropertyChangedEventManager.CurrentManager.ProtectedRemoveListener(source, listener); }
/// <summary> /// Initializes a new instance of the <see cref="CollectionObserver"/> class. /// </summary> /// <param name="collection">The collection.</param> /// <param name="tag">The tag.</param> /// <param name="mementoService">The memento service.</param> /// <exception cref="ArgumentNullException">The <paramref name="collection"/> is <c>null</c>.</exception> public CollectionObserver(INotifyCollectionChanged collection, object tag = null, IMementoService mementoService = null) : base(tag, mementoService) { Argument.IsNotNull("collection", collection); _weakEventListener = this.SubscribeToWeakCollectionChangedEvent(collection, OnCollectionChanged); }
/// <summary> /// PropertyChangedEventManager から弱いイベントのリスナーを削除します。 /// (明示的に削除を行わなくてもメモリーリークは発生しません) /// </summary> /// <param name="notifyObject">WeakPropertyChanged を発火するオブジェクト</param> /// <param name="weakEventListener">弱いイベントの発火を待ち受けるオブジェクト</param> public void RemoveListener(INotifyPropertyChanged notifyObject, IWeakEventListener weakEventListener) { PropertyChangedEventManager.RemoveListener( notifyObject, weakEventListener, string.Empty); }
public static void RemoveListener(IHttpClientEvents source, IWeakEventListener listener) { // weak event pattern cannot be used if we're running from command line. Debug.Assert(!EnvironmentUtility.RunningFromCommandLine); SendingRequestEventManager.CurrentManager.ProtectedRemoveListener(source, listener); }
/// <summary>Adds the provided listener to the list of listeners on the provided source.</summary> public static void AddListener(DependencyObject source, IWeakEventListener listener) { if (source == null) throw new ArgumentNullException("source"); if (listener == null) throw new ArgumentNullException("listener"); DoubleClickEventManager.CurrentManager.ProtectedAddListener(source, listener); }
/// <summary>Removes the specified listener from the list of listeners on the provided source.</summary> public static void RemoveListener(DependencyObject source, IWeakEventListener listener) { if (source == null) throw new ArgumentNullException("source"); if (listener == null) throw new ArgumentNullException("listener"); PreviewMouseWheelEventManager.CurrentManager.ProtectedRemoveListener(source, listener); }
/// <summary>Adds an listener to the inner list of listeners.</summary> /// <param name="listener">The listener to add.</param> internal static void AddListener(IWeakEventListener listener) { // add the listener to the inner list of listeners CurrentManager.listeners.Add(listener); // start / stop the listening process CurrentManager.StartStopListening(); }
/// <summary>Removes an listener from the inner list of listeners.</summary> /// <param name="listener">The listener to remove.</param> internal static void RemoveListener(IWeakEventListener listener) { // removes the listener from the inner list of listeners CurrentManager.listeners.Remove(listener); // start / stop the listening process CurrentManager.StartStopListening(); }
/// <summary>Removes the specified listener from the list of listeners on the provided source.</summary> public static void RemoveListener(DependencyObject source, IWeakEventListener listener) { if (source == null) throw new ArgumentNullException("source"); if (listener == null) throw new ArgumentNullException("listener"); DataContextChangedEventManager.CurrentManager.ProtectedRemoveListener(source, listener); }
/// <summary> /// Remove a listener to the given source's event.</summary> public static void RemoveListener(object source, IWeakEventListener listener, PropertyDescriptor pd) { if (source == null) throw new ArgumentNullException("source"); if (listener == null) throw new ArgumentNullException("listener"); CurrentManager.PrivateRemoveListener(source, listener, pd); }
// // Public Methods // /// <summary> /// Add a listener to the given source's event. /// </summary> public static void AddListener(INotifyCollectionChanged source, IWeakEventListener listener) { if (source == null) throw new ArgumentNullException("source"); if (listener == null) throw new ArgumentNullException("listener"); CurrentManager.ProtectedAddListener(source, listener); }
/// <summary> /// Remove a handler for the given source's event. /// </summary> public static void RemoveHandler(EventCallBackHandler source, IWeakEventListener listener) { if (source == null) throw new ArgumentNullException("source"); if (listener == null) throw new ArgumentNullException("listener"); CurrentManager.ProtectedRemoveListener(source, listener); }
// // Public Methods // /// <summary> /// Add a listener to the given source's event. /// </summary> public static void AddListener(INotifyPropertyChanged source, IWeakEventListener listener, string propertyName) { if (source == null) throw new ArgumentNullException("source"); if (listener == null) throw new ArgumentNullException("listener"); CurrentManager.PrivateAddListener(source, listener, propertyName); }
public static void AddListener(Dispatcher source, IWeakEventListener listener) { if (source == null) throw new ArgumentNullException("source"); if (listener == null) throw new ArgumentNullException("listener"); CurrentManager.ProtectedAddListener(source, listener); }
public static void RemoveListener(IUpdatableSettings source, IWeakEventListener handler) { if ( source == null ) throw new ArgumentNullException("source"); if ( handler == null ) throw new ArgumentNullException("handler"); CurrentManager.ProtectedRemoveListener(source, handler); }
public static void AddListener( DataGridItemPropertyCollection source, IWeakEventListener listener ) { if( source == null ) throw new ArgumentNullException( "source" ); if( listener == null ) throw new ArgumentNullException( "listener" ); CurrentManager.ProtectedAddListener( source, listener ); }
public static void AddListener( DataGridVirtualizingCollectionViewBase source, IWeakEventListener listener ) { if( source == null ) throw new ArgumentNullException( "source" ); if( listener == null ) throw new ArgumentNullException( "listener" ); CurrentManager.ProtectedAddListener( source, listener ); }
public static void RemoveListener( DataGridCollectionView source, IWeakEventListener listener ) { if( source == null ) throw new ArgumentNullException( "source" ); if( listener == null ) throw new ArgumentNullException( "listener" ); CurrentManager.ProtectedRemoveListener( source, listener ); }
/// <summary> /// Remove a listener to the given source's event. /// </summary> public static void RemoveListener(ICollectionView source, IWeakEventListener listener) { /* for app-compat, allow RemoveListener(null, x) - it's a no-op (see Dev10 796788) if (source == null) throw new ArgumentNullException("source"); */ if (listener == null) throw new ArgumentNullException("listener"); CurrentManager.ProtectedRemoveListener(source, listener); }
/// <summary> /// Remove a listener to the given source's event. /// </summary> public static void RemoveListener(INotifyPropertyChanged source, IWeakEventListener listener, string propertyName) { /* for app-compat, allow RemoveListener(null, x) - it's a no-op (see Dev10 796788) if (source == null) throw new ArgumentNullException("source"); */ if (listener == null) throw new ArgumentNullException("listener"); CurrentManager.PrivateRemoveListener(source, listener, propertyName); }
public static void RemoveListener(TreeGridColumnCollection source, IWeakEventListener listener) { if (source == null) { throw new ArgumentNullException("source"); } if (listener == null) { throw new ArgumentNullException("listener"); } InternalCollectionChangedEventManager.CurrentManager.ProtectedRemoveListener(source, listener); }
/// <summary>Removes the specified listener from the list of listeners on the provided source.</summary> public static void RemoveListener(DependencyObject source, IWeakEventListener listener) { if (source == null) throw new ArgumentNullException("source"); if (listener == null) throw new ArgumentNullException("listener"); var ItemsControl = source as System.Windows.Controls.ItemsControl; if (ItemsControl == null) throw new ArgumentException("Type mismatch.", "source"); ItemContainerGeneratorStatusChangedEventManager.CurrentManager.ProtectedRemoveListener(ItemsControl.ItemContainerGenerator, listener); }
/// <summary> /// Initializes a new instance of the <see cref="ObjectObserver"/> class. /// </summary> /// <param name="propertyChanged">The property changed.</param> /// <param name="tag">The tag.</param> /// <param name="mementoService">The memento service. If <c>null</c>, the service will be retrieved from the <see cref="IServiceLocator"/>.</param> /// <exception cref="ArgumentNullException">The <paramref name="propertyChanged"/> is <c>null</c>.</exception> public ObjectObserver(INotifyPropertyChanged propertyChanged, object tag = null, IMementoService mementoService = null) : base(tag, mementoService) { Argument.IsNotNull("propertyChanged", propertyChanged); Log.Debug("Initializing ObjectObserver for type '{0}'", propertyChanged.GetType().Name); _weakEventListener = this.SubscribeToWeakPropertyChangedEvent(propertyChanged, OnPropertyChanged); InitializeDefaultValues(propertyChanged); Log.Debug("Initialized ObjectObserver for type '{0}'", propertyChanged.GetType().Name); }
// // Public Methods // /// <summary> /// Add a listener to the given source's event. /// </summary> public static void AddListener(DependencyObject source, IWeakEventListener listener) { if (source == null) throw new ArgumentNullException("source"); if (listener == null) throw new ArgumentNullException("listener"); // Freezable.Freeze() relies on the assumption that a frozen Freezable // has no listeners. This is because Freeze() fails if the Freezable // has any Expressions on it, and only Expressions ever listen // to the InheritanceContextChanged event. Debug.Assert(listener is Expression); CurrentManager.ProtectedAddListener(source, listener); }
/// <summary> /// Private method to add the specified listener to the list of listeners /// on the specified source. /// </summary> /// <param name="source">The object with the event.</param> /// <param name="listener">The object to add as a listener.</param> /// <param name="propertyName">The name of the property that exists /// on source upon which to listen for changes.</param> private void PrivateAddListener( INotifyPropertyChanged source, IWeakEventListener listener, string propertyName) { if (source == null) { return; } lock (SyncLock) { if (_list == null) { _list = new Dictionary<string, List<ListenerInfo>>(); } var sourceExists = _list.Any( list => list.Value.Any( entry => entry.InstanceReference != null && entry.InstanceReference.IsAlive && entry.InstanceReference.Target != null && entry.InstanceReference.Target.Equals(source))); if (_list.ContainsKey(propertyName)) { _list[propertyName].Add( new ListenerInfo( listener, source)); } else { var list = new List<ListenerInfo> { new ListenerInfo(listener, source) }; _list.Add(propertyName, list); } if (!sourceExists) { // Now, start listening to source StartListening(source); } } }
/// <summary> /// Remove a listener to the named property (empty means "any property")</summary> /// <param name="source">Source of the event</param> /// <param name="listener">The listener to remove</param> /// <param name="pd">Property descriptor for the value</param> private void PrivateRemoveListener(object source, IWeakEventListener listener, PropertyDescriptor pd) { Debug.Assert(listener != null && source != null && pd != null, "Listener, source, and pd of event cannot be null"); using (WriteLock) { HybridDictionary dict = (HybridDictionary)this[source]; if (dict != null) { ValueChangedRecord record = (ValueChangedRecord)dict[pd]; if (record != null) { // remove a listener from the list record.Remove(listener); // when the last listener goes away, remove the list if (record.IsEmpty) { dict.Remove(pd); } } if (dict.Count == 0) { Remove(source); } } } }
/// <summary> /// Adds the provided listener to the provided source for the event being managed. /// </summary> /// <param name = "source">The source.</param> /// <param name = "listener">The listener.</param> public static void AddListener(INotifyCollectionChanged source, IWeakEventListener listener) { CurrentManager.ProtectedAddListener(source, listener); }
/// <summary> /// Attach an WeakEventListener to the <see cref="LocalizeDictionary"/> /// </summary> /// <param name="listener">The listener to attach</param> public void AddEventListener(IWeakEventListener listener) { // calls AddListener from the inline WeakCultureChangedEventManager WeakCultureChangedEventManager.AddListener(listener); }
public void AddListener(IWeakEventListener <TSender, TArgs> listener) { listeners.Add(new NullWeakReference <IWeakEventListener <TSender, TArgs> >(listener)); }
public static void RemoveListener(object source, IWeakEventListener listener) { Instance.ProtectedRemoveListener(source, listener); }
public void UnSubscribeUpDateEvent(IWeakEventListener obj) => Events.SmartWeakEventManager <ActionPlanner> .RemoveListener(this, obj);
internal static void AddListener(ColumnCollection source, IWeakEventListener listener) { CurrentManager.ProtectedAddListener(source, listener); }
internal static void RemoveListener(ScrollViewer source, IWeakEventListener listener) { CurrentManager.ProtectedRemoveListener(source, listener); }
/// <summary> /// Remove a listener.</summary> /// <param name="listener">The listener to remove</param> public void Remove(IWeakEventListener listener) { // make sure list is ready for writing ListenerList.PrepareForWriting(ref m_listeners); m_listeners.Remove(listener); // when the last listener goes away, remove the callback if (m_listeners.IsEmpty) { StopListening(); } }
public static void RemoveListener(FrameworkElement source, IWeakEventListener listener) { RequestBringIntoViewWeakEventManager.CurrentManager.ProtectedRemoveListener(source, listener); }
public static void AddListener(ColumnBase source, IWeakEventListener listener) { CurrentManager.ProtectedAddListener(source, listener); }
/// <summary> /// Adds a weak listener to changes in the collection. This weak relation will not prevent the listener from being garbage collected. /// </summary> /// <param name="columnViewColumnCollection">The ObservableCollection<ColumnViewColumn> that is the source of the events.</param> /// <param name="iWeakEventListener">A weak listener to those events.</param> public static void AddListener(ObservableCollection <ColumnViewColumn> columnViewColumnCollection, IWeakEventListener iWeakEventListener) { // Validate the parameters. if (columnViewColumnCollection == null) { throw new ArgumentNullException("columnViewColumnCollection"); } if (iWeakEventListener == null) { throw new ArgumentNullException("iWeakEventListener"); } // Add a weak event listener for the ObservableCollection<ColumnViewColumn>s. CurrentManager.ProtectedAddListener(columnViewColumnCollection, iWeakEventListener); }
public static void RemoveListener(LocalizationManager source, IWeakEventListener listener) { CurrentManager.ProtectedRemoveListener(source, listener); }
internal static void RemoveListener(DataGridControl source, IWeakEventListener listener) { CurrentManager.ProtectedRemoveListener(source, listener); }
// Remove a listener to the given property private void PrivateRemoveListener(object source, IWeakEventListener listener, PropertyDescriptor pd) { Debug.Assert(listener != null && source != null && pd != null, "Listener, source, and pd of event cannot be null"); RemoveListener(source, pd, listener, null); }
public static void AddListener(DataGridControl source, IWeakEventListener listener) { CurrentManager.ProtectedAddListener(source, listener); }
public static void RemoveListener(ColumnCollection source, IWeakEventListener listener) { CurrentManager.ProtectedRemoveListener(source, listener); }
public static void RemoveListener(object source, IWeakEventListener listener) { CurrentManager.ProtectedRemoveListener(source, listener); }
public static void AddListener(IBindingList source, IWeakEventListener listener) { CurrentManager.ProtectedAddListener(source, listener); }
public static void RemoveListener(DataGridVirtualizingCollectionViewBase source, IWeakEventListener listener) { if (source == null) { throw new ArgumentNullException("source"); } if (listener == null) { throw new ArgumentNullException("listener"); } CurrentManager.ProtectedRemoveListener(source, listener); }
public static void RemoveListener(IWeakEventListener listener) { CurrentManager.ProtectedRemoveListener(typeof(NetworkChange), listener); }
internal static void AddListener(object source, IWeakEventListener listener) { CurrentManager.ProtectedAddListener(source, listener); }
/// <summary> /// Add the given listener to the list. /// </summary> public void Add(IWeakEventListener listener) { Invariant.Assert(_users == 0, "Cannot modify a ListenerList that is in use"); _list.Add(new Listener(listener)); }
internal static void AddListener(FrameworkElement source, IWeakEventListener listener) { RequestBringIntoViewWeakEventManager.CurrentManager.ProtectedAddListener(source, listener); }
/// <summary> /// Removes a previously added listener from the provided source. /// </summary> /// <param name = "source">The source.</param> /// <param name = "listener">The listener.</param> public static void RemoveListener(INotifyPropertyChanged source, IWeakEventListener listener) { CurrentManager.ProtectedRemoveListener(source, listener); }
/// <summary> Disconnects the listener from the event queue. </summary> /// <param name="mapView"> Map from which the viewport end changed events are delivered. </param> /// <param name="listener"> Event listener to be disconnected. </param> public static void RemoveListener(MapView mapView, IWeakEventListener listener) { CurrentManager.ProtectedRemoveListener(mapView, listener); }
/// <summary> /// Detach an WeakEventListener to the <see cref="LocalizeDictionary"/> /// </summary> /// <param name="listener">The listener to detach</param> public void RemoveEventListener(IWeakEventListener listener) { // calls RemoveListener from the inline WeakCultureChangedEventManager WeakCultureChangedEventManager.RemoveListener(listener); }
/// <summary> /// Removes the specified listener. /// </summary> /// <param name="listener">The listener.</param> public static void RemoveListener(IWeakEventListener listener) { CurrentManager.ProtectedRemoveListener(null, listener); }
/// <summary> /// Add a listener to the given property</summary> /// <param name="source">Source of the event</param> /// <param name="listener">The listener to add</param> /// <param name="pd">Property descriptor for the value</param> private void PrivateAddListener(object source, IWeakEventListener listener, PropertyDescriptor pd) { Debug.Assert(listener != null && source != null && pd != null, "Listener, source, and pd of event cannot be null"); using (WriteLock) { HybridDictionary dict = (HybridDictionary)this[source]; if (dict == null) { // no entry in the hashtable - add a new one dict = new HybridDictionary(); this[source] = dict; } ValueChangedRecord record = (ValueChangedRecord)dict[pd]; if (record == null) { // no entry in the dictionary - add a new one record = new ValueChangedRecord(this, source, pd); dict[pd] = record; } // add a listener to the list record.Add(listener); // schedule a cleanup pass ScheduleCleanup(); } }
/// <summary> /// Adds the listener. /// </summary> /// <param name="source">The source.</param> /// <param name="listener">The listener.</param> public static void AddListener(TranslationManager source, IWeakEventListener listener) { CurrentManager.ProtectedAddListener(source, listener); }
/// <summary> /// Add a listener.</summary> /// <param name="listener">The listener to add</param> public void Add(IWeakEventListener listener) { // make sure list is ready for writing ListenerList.PrepareForWriting(ref m_listeners); m_listeners.Add(listener); }
private void ProtectedRemoveListener(object source, IWeakEventListener listener) { throw new NotImplementedException(); }
private void RemoveListener(INotifyPropertyChanged source, string propertyName, IWeakEventListener listener, EventHandler <PropertyChangedEventArgs> handler) { using (WriteLock) { HybridDictionary dict = (HybridDictionary)this[source]; if (dict != null) { ListenerList list = (ListenerList)dict[propertyName]; if (list != null) { // make sure list is ready for writing if (ListenerList.PrepareForWriting(ref list)) { dict[propertyName] = list; } // remove a listener from the list if (handler != null) { ListenerList <PropertyChangedEventArgs> hlist = (ListenerList <PropertyChangedEventArgs>)list; hlist.RemoveHandler(handler); } else { list.Remove(listener); } // when the last listener goes away, remove the list if (list.IsEmpty) { dict.Remove(propertyName); } } if (dict.Count == 0) { StopListening(source); Remove(source); } dict.Remove(AllListenersKey); // invalidate list of all listeners _proposedAllListenersList = null; } } }
/// <summary> /// Removes a weak listener to changes in the collection. /// </summary> /// <param name="columnViewColumnCollection">The ObservableCollection<ColumnViewColumn> that is the source of the events.</param> /// <param name="iWeakEventListener">A weak listener to those events.</param> public static void RemoveListener(ObservableCollection <ColumnViewColumn> columnViewColumnCollection, IWeakEventListener iWeakEventListener) { // Validate the arguments. if (columnViewColumnCollection == null) { throw new ArgumentNullException("columnViewColumnCollection"); } if (iWeakEventListener == null) { throw new ArgumentNullException("iWeakEventListener"); } // Remove the weak listener. CurrentManager.ProtectedRemoveListener(columnViewColumnCollection, iWeakEventListener); }