LoadTestUserContext::Add Method (String^, Object^)
Adds an element that has the provided key and value to the LoadTestUserContext.
Assembly: Microsoft.VisualStudio.QualityTools.LoadTestFramework (in Microsoft.VisualStudio.QualityTools.LoadTestFramework.dll)
Parameters
- key
-
Type:
System::String^
The unique identifier to use as the key of the element to add.
- value
-
Type:
System::Object^
The object to use as the value of the element to add.
| Exception | Condition |
|---|---|
| ArgumentNullException | key is null. |
| ArgumentException | An element that has the same key already is located in the LoadTestUserContext. |
| NotSupportedException | The LoadTestUserContext is read-only. |
You can also use the Item property to add new elements by setting the value of a key that is not located in the LoadTestUserContext; for example, myLoadTestUserContext["myNonexistentKey"] = myValue. However, if the specified key already is located in the LoadTestUserContext, setting the Item property overwrites the old value. In contrast, the Add method does not modify existing elements.
key cannot be null, but value can be null if value is a reference type.