0

だから私は次のコードを持っています:

    public override void Extract(object sender, ExtractionEventArgs e)
    {
            if (e.Response.HtmlDocument != null)
            {

                var myParam = e.Request.QueryStringParameters.Where(parameter => parameter.Name == QueryName).Select(parameter => parameter.Value).Distinct();

                myParam.

                // add the extracted value to the web performance test context
                e.WebTest.Context.Add(this.ContextParameterName, myParam.ToString());
                e.Success = true;
                return;

            }


        // If the extraction fails, set the error text that the user sees
        e.Success = false;
        e.Message = String.Format(CultureInfo.CurrentCulture, "Not Found: {0}", QueryName);
    }

戻ってきました:

System.Linq.Enumerable+<DistinctItem>d_81`1[system.string]

私は次の行に沿って何かを期待しています:

0152-1231-1231-123d

私の質問は、クエリ文字列の実際の値を から抽出する方法ですextractioneventargs。彼らはそれが可能だと言っていますが、私にはわかりません。

4

1 に答える 1

1

使用できますstring.Join

string resultAsString = string.Join("-", myParam);
e.WebTest.Context.Add(this.ContextParameterName, resultAsString);

ここでは、クエリ文字列パラメーターの値が01521231などであり、それらをダッシュ​​で結合すると想定しています。

オブジェクトを受け入れることができるのでWebTest.Context.Add、目的に合う場合は、結果を配列として追加することもできます。

e.WebTest.Context.Add(this.ContextParameterName, myParam.ToArray());

(この文字列System.Linq.Enumerable+<DistinctItem>d_81``1[system.string]は型名であり、ToString()(オーバーライドされていない限り) デフォルトで任意のオブジェクトに対して返されるものであることに注意してください)。

于 2012-11-04T22:51:06.797 に答える