LoadTestUserContext.Add Method (String, Object)
Adds an element that has the provided key and value to the LoadTestUserContext.
Namespace: Microsoft.VisualStudio.TestTools.LoadTesting
Assembly: Microsoft.VisualStudio.QualityTools.LoadTestFramework (in Microsoft.VisualStudio.QualityTools.LoadTestFramework.dll)
Syntax
'Declaration
Public Sub Add ( _
key As String, _
value As Object _
)
public void Add(
string key,
Object value
)
public:
virtual void Add(
String^ key,
Object^ value
) sealed
abstract Add :
key:string *
value:Object -> unit
override Add :
key:string *
value:Object -> unit
public final function Add(
key : String,
value : Object
)
Parameters
key
Type: StringThe unique identifier to use as the key of the element to add.
value
Type: ObjectThe object to use as the value of the element to add.
Implements
IDictionary.Add(UTP, UTP)
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | key is nulla null reference (Nothing in Visual Basic). |
ArgumentException | An element that has the same key already is located in the LoadTestUserContext. |
NotSupportedException | The LoadTestUserContext is read-only. |
Remarks
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 nulla null reference (Nothing in Visual Basic), but value can be nulla null reference (Nothing in Visual Basic) if value is a reference type.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.