// removes the individual change handler // from a passed object. public void RemoveOnPropertyChangedHandler ( ObjectType obj, OnPropertyChangedDelegate <ObjectType, PropertyType> propChangedHandler ) { APropertyValueWrapper <ObjectType, PropertyType> valueWrapper = GetValueWrapper(obj, true); valueWrapper.OnPropertyChangedEvent -= propChangedHandler; }
// Constructor - takes default value, // and two callbacks as arguments. // the first callback fires before a property is changed on an object // the second - after // Provides default values for all its arguments public AProp ( PropertyType defaultValue = default(PropertyType), BeforePropertyChangedDelegate <ObjectType, PropertyType> beforePropertyChangedFn = null, OnPropertyChangedDelegate <ObjectType, PropertyType> onPropertyChangedFn = null ) { _defaultValue = defaultValue; BeforePropertyChangedFn = beforePropertyChangedFn; OnPropertyChangedFn = onPropertyChangedFn; }
// adds an individual property change handler // on the passed object. (other object won't get affected) public void AddOnPropertyChangedHandler ( ObjectType obj, OnPropertyChangedDelegate <ObjectType, PropertyType> propChangedHandler ) { if (propChangedHandler == null) { return; } APropertyValueWrapper <ObjectType, PropertyType> valueWrapper = GetValueWrapper(obj, true); valueWrapper.OnPropertyChangedEvent += propChangedHandler; }