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)

System::Object
  Microsoft.VisualStudio.Modeling.Integration::ReferenceContext

public ref class ReferenceContext 

NameDescription
System_CAPS_pubmethodAdd(Object^, Object^)

Associate a value with a particular key in the reference context.

System_CAPS_pubmethodContains(Object^)

Query whether the specified key has been associated with a value in this context

System_CAPS_pubmethodEquals(Object^)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodRemove(Object^)

Remove the association between the specified key and its value from the context, if any.

System_CAPS_pubmethodToString()

(Inherited from Object.)

System_CAPS_pubmethodTryGetValue<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.

Return to top
Show: