Share via


New Beta1 sample available: ImsLocks.

Today we made a new Beta1 sample available on the Code Gallery (https://code.msdn.microsoft.com/DslTools). This sample, named ImsLocks, explains how a DSL author can prevent the DSL user from editing partially or completely his designer. This can be used for instance to provide a read-only reader for a model, or an annotation/review tool. This also browses you through the new Microsoft.VisualStudio.Modeling.Immutability namespace:

image

It’s important to note that:

  • In previous versions of the DSL Tools we used to use mainly the Default partition for both the model elements and the presentation elements. This is no longer the case! We now have one partition for the Model elements, and one partition for the presentation elements, thus enabling the finer grain control of the independent locking of presentation as a whole, and model as a whole. This is underlying the IMS Locks DSL Tools feature in Visual Studio 2010
  • now, before any modification to a Model Element or a Presentation Element, the IMS (In Memory Store) Gets and verifies the Locks permissions of the ModelElement / PresentationElement, of the partition it is located in, and of the Store itself. The DSL Author can implement the ILockingPolicy interface to provide a service to refine these locks.

 

Check out the documentation and the code to know more about this sample that shows how to make some parts of a model read-only by:

  • Creating a CustomLockingPolicy class implementing ILockingPolicy and add it to the services of the DocData
  • Creating a means of updating the Locks
  • Making use of the locks (to provide useful feedback to the user of the DSL

 

Enjoy!