次の方法で共有


StoreViewer - a hidden gem

Well, maybe not exactly hidden, but certainly not well-known.

Tucked away in the Microsoft.VisualStudio.Modeling.sdk assembly in the Microsoft.VisualStudio.Modeling.Diagnostics namespace you'll find a little class called StoreViewer that can visualize for you the full contents of your Store - both the model elements and the domain metadata.

Here it is showing the contents of an ExampleElement MEL from the MinimalLanguage template:

Note the pane on the bottom right where you can see all of the link instances that the element is playing a role in.  This is really useful where you've got links that aren't visualized anywhere in your designer.

To call this dialog up, you just need to use the overrloaded static Show() method:

         public static void Show(Store store);
  
         public static void Show(Partition partition);
  
         public static void Show(ModelElement element);

As you can see, you can focus on just a single model element or a whole store or partition.  Its usually most useful to look at a whole store as then you can browse around between elements.

Here's the browser examining the domain metadata in the store:

You can see the metadata for the domain class ExampleElement and see the set of rules that have been added to fire against it.

One way of using this is to hook it up to a menu entry in a debug build of your designer, but perhaps its most valuable use is in the Visual Studio immediate window.  When you hit a breakpoint in your designer, simply type the following into the immediate window:

 Microsoft.VisualStudio.Modeling.Diagnostics.StoreViewer.Show(<myModelElement>.Store);

Kudos to DmitriV for implementing this very slick piece of functionality.