My ninth How do I is up.
Scenario
Let’s say that we have some “Add rules” in our model to perform some custom operation every time a model element is added. One common problem is that we want to perform this operation only when the user creates a model element on demand, this can be translated to the user drags a shape from the toolbox, uses the model explorer, etc. But the add rule is also fired when the store is being deserialized and somehow we need to distinguish both cases. The focus of this How do I tackles this scenario.
Interfaces and classes needed
Code snippet
var transaction = e.ModelElement.Store.TransactionManager.CurrentTransaction;
if(transaction != null && !transaction.IsSerializing)
{
//TODO: perform operation
}
Assemblies needed
- Microsoft.VisualStudio.Modeling.Sdk
Stay tuned,
Pablo

