private void Attach() { var obj = _object.Target; if (obj == null) { return; } foreach (var propertyObservationStrategy in PropertyObservationStrategies) { _propertyObservation = propertyObservationStrategy.AttemptAttach(obj, PropertyName); if (_propertyObservation != null) { //found a strategy that works with object and property combination break; } } if (_propertyObservation != null) { _propertyObservation.ValueChanged += PropertyObservation_ValueChanged; } }
private void Detach() { var obj = _object.Target; if (obj == null) { return; } if (_propertyObservation != null) { _propertyObservation.Detach(obj, PropertyName); _propertyObservation.ValueChanged -= PropertyObservation_ValueChanged; _propertyObservation = null; } }