/// <summary> /// Called before a property is changed on an object. Derived classes can control how the change is handled. /// Throw ArgumentException within this method, to display an error message in the UI. /// </summary> /// <param name="propertyName">Name of the changed property.</param> /// <param name="newValue">New value assigned to the property.</param> /// <param name="undoable">Return false if automatic undo of the property change is not needed.</param> /// <param name="cancel">Return true if the property change should not apply.</param> protected virtual void OnPropertyChanging(string propertyName, object newValue, ref bool undoable, ref bool cancel) { if (!Editable(propertyName)) { cancel = true; return; } PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(propertyName)); if (cancel) { return; } Handler.DoObjectChanging(this, propertyName, newValue, ref cancel); }
/// <summary> /// Called before a property is changed on an object. Derived classes can control how the change is handled. /// Throw ArgumentException within this method, to display an error message in the UI. /// </summary> /// <param name="propertyName">Name of the changed property.</param> /// <param name="newValue">New value assigned to the property.</param> /// <param name="undoable">Return false if automatic undo of the property change is not needed.</param> /// <param name="cancel">Return true if the property change should not apply.</param> void OnPropertyChanging(string propertyName, object newValue, ref bool undoable, ref bool cancel) { if (!Handler.PowerBIGovernance.AllowEditProperty(ObjectType, propertyName)) { cancel = true; return; } PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(propertyName)); if (cancel) { return; } Handler.DoObjectChanging(this, propertyName, newValue, ref cancel); }