Programming with the UML API
The UML API of Visual Studio Ultimate lets you write code to create, read, and update UML models and diagrams.
In addition to the API reference pages, the following topics describe the API.
Topic |
Example types and methods described |
Features described |
---|---|---|
UML elements and their properties and associations. For example, IElement and its descendants, including: IClass, IActivity, IUseCase, IComponent, IInteraction, IModel, IPackage |
In Visual Studio Ultimate, UML models conform to the UML specification version 2.1.2, which can be obtained at the UML Resource Page. Each type is an interface that has the same name as the UML type, prefixed with "I". |
|
IPackage.CreateClass() IClass.CreateOperation() |
Each element type has methods for creating its children. |
|
IShape, IDiagram IShape.Move() |
Each element in a model can be represented as a shape on a diagram. In some cases, you can create new shapes for each object. You can move, resize, color, and collapse or expand these shapes. |
|
IModelStore IDiagramContext |
The Model Store stores the model. The Diagram Context gives you access to the current diagram and store. |
|
ILinkedUndoContext |
You can link a series of changes into one transaction. |
|
IMenuCommand IGestureExtension ICommandExtension |
You can extend a diagram's functionality by defining commands invoked by double-clicking and by dragging onto the diagram. |
|
ValidationContext |
You can define validation rules that help you make sure that a model conforms to specified constraints. |
|
IElement, IShape |
When an element is dragged from UML Model Explorer or a UML diagram to another diagram or application, it is serialized as an IDataObject. |
|
IInteraction, ILifeline, IMessage |
Creating and updating an interaction diagram is slightly different from working with the other diagram types. |
|
ILayer, ILayerDiagram |
You can write code to create and edit layer diagrams, and also validate program code against them. |
About the Implementation
The UML modeling tools are built on Domain-Specific Language Tools. Each package and each diagram is represented by a Domain-Specific Language Tools model, and a collection of rules and other methods maintains consistency between them.
Types from that platform are visible in some of the assemblies that you reference in order to write UML extensions. Although you can make extensions to the UML tools by accessing the Domain-Specific Language Tools API, you should bear the following considerations in mind:
You might find that some apparently simple changes introduce inconsistencies and unexpected effects.
The implementation may change in the future, so that adaptations you make using the Domain-Specific Language Tools API might no longer work.
The API assemblies
This table summarizes the assemblies that provide extensibility for the UML tools, and the namespaces that you are recommended to use.
Assembly |
Namespaces |
Provides access to: |
---|---|---|
Microsoft.VisualStudio.Uml.Interfaces |
(All) |
The UML types. |
Microsoft.VisualStudio.ArchitectureTools.Extensibility |
||
Microsoft.VisualStudio.ArchitectureTools.Extensibility.Presentation |
||
Microsoft.VisualStudio.Modeling.Sdk.11.0 |
||
(other namespaces) |
Recommended only for advanced use. |
|
Microsoft.VisualStudio.Modeling.Sdk.Diagrams.11.0 |
Microsoft.VisualStudio.Modeling.Diagrams.ExtensionEnablement |
|
(other namespaces) |
Recommended only for advanced use. |
|
Microsoft.VisualStudio.TeamFoundation.WorkItemTracking |
||
Microsoft.TeamFoundation.WorkItemTracking.Client |
||
Microsoft.TeamFoundation.Client |
||
System.ComponentModel.Composition |
||
System.Linq |
Easy manipulation of collections, especially when dealing with relationships. |
See Also
Concepts
Extending UML Models and Diagrams