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.
Namespace: Microsoft.VisualStudio.Modeling.Integration
Assembly: Microsoft.VisualStudio.Modeling.Sdk.Integration.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.Integration.12.0.dll)
Inheritance Hierarchy
System.Object
Microsoft.VisualStudio.Modeling.Integration.ReferenceContext
Syntax
public class ReferenceContext
public ref class ReferenceContext
type ReferenceContext = class end
Public Class ReferenceContext
Constructors
Name | Description | |
---|---|---|
ReferenceContext() |
Methods
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. |
Remarks
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.
Examples
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);
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also
Microsoft.VisualStudio.Modeling.Integration Namespace
Return to top