public virtual void Dispose() { if (ObservedInstance != null) { ObservedInstance.PropertyChanged -= HandleNextPropertyChanged; } if (NextEntry != null) { NextEntry.Dispose(); } }
private void HandleNextPropertyChanged(object sender, PropertyChangedEventArgs args) { if (args.PropertyName != ObservedProperty.Name) { return; } var newValue = ObservedProperty.GetValue(ObservedInstance); if (newValue != null && !(newValue is INotifyPropertyChanged)) { throw new InvalidOperationException(); } NextEntry.Reattach(newValue as INotifyPropertyChanged); }
protected virtual void Reattach(INotifyPropertyChanged observedInstance) { ObservedInstance = observedInstance; if (observedInstance == null || NextEntry == null) { return; } var nextInstance = ObservedProperty.GetValue(ObservedInstance); if (nextInstance != null && !(nextInstance is INotifyPropertyChanged)) { throw new InvalidOperationException(); } NextEntry.Reattach(nextInstance as INotifyPropertyChanged); }