Validation / Rejecting a change from a ChangeRule

I have a situation where I'd like to be able to reject a change from within a ChangeRule.

One of the classes / shapes on my diagram represents an external model. An attribute on that class is the filename of the referenced model. When that attribute is changed I need to change the current diagram to expose the interface(s) to the referenced model. If I cannot complete that change to the current diagram I'd like to reject the new value for the attribute.

I could probably implement this in the ValidateAttribute method instead of as a ChangeRule, but since I am doing a lot more than just validation it seems more appropriate to have the code as a ChangeRule.

That choice brings with it the problem that I can't easily reject the change.

Is there an option I am missing here

Thanks,
Brian.


Answer this question

Validation / Rejecting a change from a ChangeRule

  • Tinman

    That's right. Depends on whether you want to give the user an error message or not.

  • latesh

    ... the difference being throwing an exception will display a message box containing the error message, whereas Rollback doesn't give the user any feedback.

    See also the following post for a potential problem when calling Rollback from within a RemovingRule: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=249755&SiteID=1

    Duncan


  • panaconsultas

    doh!

    I can call ModelObject.Store.TransactionManager.CurrentTransaction.Rollback();

    Brian.


  • AndrewLittlejohn

    Also, if you throw an exception within a transaction (including in a rule), that will rollback the whole transaction.

  • Validation / Rejecting a change from a ChangeRule