LoadTestContext.Add Method (String, Object)
Adds an element that has the provided key and value to the LoadTestContext.
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: 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.
Implements
IDictionary<TKey, TValue>.Add(TKey, TValue)
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 LoadTestContext. |
NotSupportedException | The LoadTestContext 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 LoadTestContext; for example, myLoadTestContext["myNonexistentKey"] = myValue. However, if the specified key already is located in the LoadTestContext, 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.