Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Store Class

The store contains an in-memory representation of the elements and links in one or more models.

Namespace: Microsoft.VisualStudio.Modeling
Assembly: Microsoft.VisualStudio.Modeling.Sdk (in microsoft.visualstudio.modeling.dll)

public class Store : IServiceProvider, IDisposable
public class Store implements IServiceProvider, IDisposable
public class Store implements IServiceProvider, IDisposable

The store contains information about one or more models. A store can contain a collection of models, although often there is only one model in the store.

The store also contains metadata about a model and information about the instances of the elements and links between elements that make up that model.

NoteTip

 Metadata is data about the types allowed in the model and their relationships.

The store has several data structures that are filled when a model is loaded into the store. This occurs when your domain-specific language is launched, either as an experimental build or when you have deployed your domain-specific language and an end user launches it, or when you load a model programmatically into the store.

The DomainDataDirectory contains the metadata about the types allowed to be in the model.

The ElementDirectory contains information about each element instance and their links. (The instances in the ElementDirectory must be of types defined in the DomainDataDirectory.)

From the store, you can navigate to the individual items in the store. You can get information about elements or types. You can also do the following tasks:

  • add items

  • delete items

  • modify existing elements and links and their properties

Whenever you modify a store, you must enclose any code that writes to the store in a Transaction. You can cancel all the changes to the store made in a transaction by doing a Rollback of the transaction or by simply not doing a Commit of the transaction.

The store has a RuleManager that contains functionality to subscribe to rules. The store also can subscribe to events.

The store also has an UndoManager which has members that allow you to undo and redo changes to the store.

You generally do not need to create a new instance of a store, although you can and can read a model into it by deserializing a model into the new instance.

Often, you get access to the store from the Store property of an element or link in the model. The event arguments of rules and events provide the element or link instance that the rule or event pertains to, and you can use its Store property to access the store and its TransactionManager.

The following examples show different ways to instantiate a store.

When there are dependencies between domain models, as in the third example below, the domain models should be specified in order of dependency.

// Create a store with your domain models (classes in the generated 
// code derived from Microsoft.VisualStudio.Modeling.DomainModel).
Store store = new Store(typeof(ActivityDomainModel));

// Domain models can be loaded into the store after construction.
// Be sure to call store.Dispose() when you are done with it. 
Store store2 = new Store();
Store2.LoadDomainModels(typeof(ActivityDomainModel));

// Multiple domain models can be loaded into the store at once
Store store3 = new Store(typeof(BaseActivityDomainModel), typeof(ExtendedActivityDomainModel));

System.Object
  Microsoft.VisualStudio.Modeling.Store

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft