WebTestContext.Item 属性

获取或设置与来自 WebTestContext 对象的指定键关联的值。

命名空间:  Microsoft.VisualStudio.TestTools.WebTesting
程序集:  Microsoft.VisualStudio.QualityTools.WebTestFramework(在 Microsoft.VisualStudio.QualityTools.WebTestFramework.dll 中)

语法

声明
Public Default Property Item ( _
    key As String _
) As Object
    Get
    Set
public Object this[
    string key
] { get; set; }
public:
virtual property Object^ default[String^ key] {
    Object^ get (String^ key) sealed;
    void set (String^ key, Object^ value) sealed;
}
abstract Item : Object with get, set
override Item : Object with get, set
JScript 不支持索引属性。

参数

  • key
    类型:System.String
    与集合中的键相对应的字符串。

属性值

类型:System.Object
Object ,它包含与 key 关联的值。

实现

IDictionary<TKey, TValue>.Item[TKey]

异常

异常 条件
KeyNotFoundException

未找到 key。

备注

由环境变量或负载测试定义的上下文将重写此属性返回的项。 因此,如果 Web 性能测试正在包含名为“myContext”的上下文的负载测试中运行,则对 MyWebTestContext.Item("myContext") 的调用将返回 LoadTestContext.Item("myContext") 的值。

.NET Framework 安全性

请参见

参考

WebTestContext 类

Microsoft.VisualStudio.TestTools.WebTesting 命名空间