【发布时间】:2017-09-29 13:06:37
【问题描述】:
我有两个类,但我想将 LastFridayDate 类中的值字符串“版本”转换为 Buildversion 类。
大家好,我有两个类,但我想将 LastFridayDate 类中的值字符串“版本”转换为 Buildversion 类。
我无法访问字符串版本,任何人的帮助。
我的代码:
using System;
using Microsoft.VisualStudio.TestTools.WebTesting;
using Microsoft.VisualStudio.TestTools.LoadTesting;
using System.ComponentModel;
namespace PTUtil
{
[System.ComponentModel.DisplayName("GetVersion")]
[System.ComponentModel.Description("Get the Build No Version")]
public class LastFridayDate : WebTestPlugin
{
String version;
//Setting the version in the usercontext
public override void PostWebTest(object sender, PostWebTestEventArgs e)
{
version = e.WebTest.Context["Param_ClientSoftwareVersion"].ToString();
}
}
/// Specify a name for use in the user interface.
/// The user sees this name in the Add Validation dialog box.
[DisplayName("Build Version Processing")]
/// Specify a description for use in the user interface
/// The user sees this description in the Add Validation dialog box.
[Description("Add the build version for a load test")]
public class BuildVersion : ILoadTestPlugin
{
[DisplayName("Comment")]
[Description("What the plugin is for")]
public string theComment { get; set; }
[DisplayName("Test Type")]
[Description("M for Manual or A for Automatic")]
[DefaultValue("A")]
public string connectionStr { get; set; }
[DisplayName("Version Context Parameter")]
[Description("The Context Parameter for the build version")]
[DefaultValue("{{Param_ClientSoftwareVersion}}")]
public string Version_param { get; set; }
LoadTest m_loadTest;
public void Initialize(LoadTest loadTest)
{
m_loadTest = loadTest;
m_loadTest.LoadTestFinished += new EventHandler(m_loadTest_LoadTestFinished);
}
// Do it *after* the Load Test.
//---------------------------------------------------------------------
void m_loadTest_LoadTestFinished(object sender, System.EventArgs e)
{
}
}
}
【问题讨论】:
-
您的字段
version没有修饰符,默认情况下将其设为私有。使用 public 修饰符使其可见:public String version;在此处阅读更多信息docs.microsoft.com/en-us/dotnet/csharp/programming-guide/…
标签: c# class interface web-performance