.NET application
TestBrowserApp: Windows.Forms Application. The application initializes
the Host object from JScriptSuite.BrowserHost assembly.
To debug .NET code which will later be translated to javascript,
the application registers pages and a folder to save the generated javascript files.
static class Program
{
[STAThread]
static void Main()
{
string path = Path.GetDirectoryName(typeof(Program).Assembly.Location);
path = Path.GetDirectoryName(Path.GetDirectoryName(path)) + "\\Pages\\";
LocalPageFactory pageFactory = new LocalPageFactory()
{
// path contains test *.html pages
PageUrlFormat = path + "{0}.html",
// path/js contains generated *.js files
ScriptPathFormat = path + "js\\{0}.js"
};
IBrowserHost host = Host.CreateBrowserHost();
pageFactory.AddPage(host, "Alert") // Register test page and .NET code which control this page after load
// Path/Pages/Alert.html and Path/Pages/js/Alert.js
.Add(AlertApp.Start, "StartScript"); // .NET - delegate will be started after load Alert.html
// AlertApp.Start will be translated StartScript - javascript function
.Navigate(); // Navigate to this page
}
}
Alert.cs in TestJScriptLib class library
public class AlertApp : HtmlGlobal
{
public static void Start()
{
window.alert("Hallo");
}
}