Kishore Gopalan


I have a domain class which is a compartment shape. There is a compartment called "Operations" which contains items of type CustomAttribute. The CustomAttribute has two domain properties. When the model is run, I'm able to add new Operations and set the properties of the CustomAttribute.

Now, I want a Change rule to be fired when any of these properties changes. I tried a code like this

Code Snippet

[RuleOn(typeof(global::EntityLanguage.CustomAttribute), FireTime = TimeToFire.TopLevelCommit)]

public class MyChangeRule : ChangeRule


public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)


// Do my stuff




But it doesnt work. Change rules are working fine when applied at the domain class level. But when tried at the level of a compartment within the domain class they dont seem to be working. Any ways to accomplish this



Re: Visual Studio Extensibility Change Rule for domain property of a compartment item

DuncanP - MSFT


That code should work fine. I've justed tried an equivalent rule for ClassOperation in a language based on the Class Diagrams language template, and the rule fires when a new ClassOperation is dragged onto the Operations compartment, or when the properties are edited via the properties grid. Fyi the signature of my rule was as follows:

[RuleOn(typeof(ClassOperation), FireTime=TimeToFire.TopLevelCommit)]
public class OperationAttChangeRule : ChangeRule

The only thing you haven't shown in your code snippet is registering the new rule in the "MyLanguageDomainModel.GetCustomDomainTypes()" method.