private void ResetWeakHandler(object source) { // Unsubscribes the previous subscription and create a new one. this.weakHandler?.Unsubscribe(); this.weakHandler = null; // Gets the new value. var newValue = this.GetNotiyfPropertyChangedProperty(source); if (newValue != null) { this.weakHandler = new INotifyPropertyChangedWeakEventHandler(newValue, this.OnPropertyChanged); } }
private void UnobserveInternal() { this.whenChanged = null; this.weakHandler?.Unsubscribe(); this.weakHandler = null; this.propertyInfo = null; foreach (var node in this.Nodes.Where(x => x.IsObservable)) { node.UnobserveInternal(); } this.nodes.Clear(); }
private void ObserveInternal(INotifyPropertyChanged source, Action whenChanged) { this.whenChanged = whenChanged; if (source != null) { // Observes this one. this.weakHandler = source.AddWeakEventHandler(this.OnPropertyChanged); // Observes the children. foreach (var node in this.Nodes.Where(x => x.IsObservable)) { node.ObserveInternal(node.GetNotiyfPropertyChangedProperty(source), whenChanged); } } }