Note
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
You can write code to attach arbitrary strings to model elements. A string could be, for example, a URI, the cached result of a computation, or a ModelBus reference to an element in another model. Each string is contained in an IReference object. Any number of IReference objects can be attached to each model element.
Every IReference object has a Name. You could use this Name to indicate how the reference value should be interpreted. For example, you could set Name to "URI" to indicate that the Value should be interpreted as a URI. There are some predefined reference name values used by the modeling tools.
Attaching a Reference to an IElement
To use the following methods, you must add a reference to:
Microsoft.VisualStudio.ArchitectureTools.Extensibility.dll
You should insert this directive in your code:
using Microsoft.VisualStudio.ArchitectureTools.Extensibility.Uml;
| Method call | Description | 
|---|---|
| element.AddReference (nameString, valueString, duplicatesAllowed) | Creates an IReferencewith the given name and value strings, and links it toelement. Returns theIReference.Throws an exception if duplicatesAllowedis false and there is already anIReferencewith the same name attached toelement. | 
| element.GetReferences(name) | Returns all the IReferenceobjects linked toelementthat have the givenname. | 
| element.DeleteAllReferences(name) | Deletes all the IReferenceobjects linked to element that have the given name. | 
| reference.Delete() | Deletes this IReference. | 
| ReferenceConstants.WorkItem | The value used to name work item references. | 
See Also
Define a work item link handler Define and install a modeling extension Programming with the UML API