private void CleanUpObservation() { if (ObservingEvent == null) { return; } ObservingEvent.RemoveEventHandler(PropertyResolutionObject, ChangeHandlerDelegate); }
} // A formality of reflective event binding... private void ConfigureObservation() { if (string.IsNullOrEmpty(ControllableAttribute.ObservableEventName)) { return; } ObservingEvent = PropertyResolutionObject.GetType().GetEvent(ControllableAttribute.ObservableEventName); if (ObservingEvent == null) { throw new MissingMemberException("Could not find change-observing event named " + ControllableAttribute.ObservableEventName); } ChangeHandlerDelegate = Delegate.CreateDelegate(ObservingEvent.EventHandlerType, this, ((Action)HandleObservedPropertyChanged).Method); ObservingEvent.AddEventHandler(PropertyResolutionObject, ChangeHandlerDelegate); }