ReferenceContext Class
When a ModelBusReference is serialized, the serialized string can be made relative to some context information such as a file path. When the string is deserialized, you can provide the same context or a different context. ReferenceContext is a dictionary that stores the context information. The set of keys and types stored in a context depend on the class of ModelBusAdapter that you use.
Assembly: Microsoft.VisualStudio.Modeling.Sdk.Integration.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.Integration.12.0.dll)
| Name | Description | |
|---|---|---|
![]() | ReferenceContext() |
| Name | Description | |
|---|---|---|
![]() | Add(Object^, Object^) | Associate a value with a particular key in the reference context. |
![]() | Contains(Object^) | Query whether the specified key has been associated with a value in this context |
![]() | Equals(Object^) | (Inherited from Object.) |
![]() | Finalize() | (Inherited from Object.) |
![]() | GetHashCode() | (Inherited from Object.) |
![]() | GetType() | (Inherited from Object.) |
![]() | MemberwiseClone() | (Inherited from Object.) |
![]() | Remove(Object^) | Remove the association between the specified key and its value from the context, if any. |
![]() | ToString() | (Inherited from Object.) |
![]() | TryGetValue<T>(Object^, T) | Lookup the value associated with a specified key in the context. |
For Modelbus Adapters that use file paths, use the keys ModelBusReferencePropertySerializer.FilePathSaveContextKey and ModelBusReferencePropertySerializer.FilePathLoadContextKey to index folder names in the ReferenceContext.
For more information, see Integrating Models by using Visual Studio Modelbus.
To serialize relative to a path:
elementReference.ReferenceContext.Add( ModelBusReferencePropertySerializer.FilePathSaveContextKey, currentProjectFilePath); string serialized = modelBus.SerializeReference(elementReference);
To retrieve the reference from the string:
ReferenceContext context = new ReferenceContext();
context.Add(ModelBusReferencePropertySerializer.FilePathLoadContextKey,
currentProjectFilePath);
ModelBusReference elementReferenceRestored =
modelBus.DeserializeReference(serialized, context);
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

