Currently, Silk Performer supports all kernel, web, and browser BDL functions for C# binding. In Visual Studio you can access these functions by calling their equivalent static C# class methods, such as Kernel.MeasureStart(), Web.PageUrl(), or Browser.Click().
In other words: For each built-in Silk Performer .bdh file, you will find a corresponding C# class in the PerfRunDotNet assembly. And for each API function defined in that .bdh file, there is an equivalent static method in the corresponding C# class.
A C# class that is intended to be used for load testing in Silk Performer contains a VirtualUser attribute and a CodePage attribute. VirtualUser specifies a UserName and a ScriptName property. CodePage specifies the codepage of the recording system. Methods with the Transaction attribute will be mapped to transactions when exported to Silk Performer.
namespace SilkPerformerRecorder { [VirtualUser(UserName = "VUser", ScriptName = "MyScript")] [CodePage(1252)] public class MyScript { [Transaction(ETransactionType.TRANSTYPE_INIT)] public void TInit() { } [Transaction(ETransactionType.TRANSTYPE_MAIN)] public void TMain()
To pass parameters from .Net/C# to BDL and vice versa, some built-in data types have to be converted.
While Silk Performer and its BDL are based on the multi-byte character set (MBCS) encoding, the C# language works with Unicode. Thus, every string has to be converted when passed between the two worlds. The PerfRunDotNet assembly works with the BdlString class, which handles all these conversions. Moreover, it also takes care about binary buffers. For convenience, the BdlString class is assignment compatible with the C# string.
Sizespec and lenspec variables have been removed in the C# mapping, since C# strings typically know their length.
Some static integer values, like severity parameters, have been replaced by specific enums.
BDL forms are mapped to a BdlForm class in C#:
private static readonly BdlForm ZIP_SEARCH001 = new BdlForm() { Entries = new BdlFormEntries() { { "zip-search", "", Kernel.USE_HTML_VAL }, // hidden, unchanged, value: "zip-search" { "zip-search:zipcode", "", Kernel.USE_HTML_VAL }, // unchanged, value: "" { "javax.faces.ViewState", "", Kernel.USE_HTML_VAL }, // hidden, unchanged, value: "j_id3:j_id4" { "zip-search:search-zipcode.x", "62" }, // added { "zip-search:search-zipcode.y", "4" } // added } };
Due to Silk Performer being a MBCS-based application, the recorder automatically generates a codepage attribute in the C# script, which gets carried over to the .bdf script stub. It also takes care about converting all Unicode strings that cannot be represented in the system codepage into hex-byte arrays.
If the CodePage attribute is defined in a C# script, the following applies:
If the CodePage attribute is not defined in a C# script, the system codepage is used during replay.