.NET to Javascript compiler

.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\\";

    // path/Pages contains test *.html pages
    // path/Pages/js contains generated *.js files
    LocalPageFactory pageFactory = new LocalPageFactory(path + "{0}.html", 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

    pageFactory.AddPage(host, "Equal").Add(EqualApp.Start, "StartScript");
    pageFactory.AddPage(host, "Timer").Add(TimerApp.Start, "StartScript")
        .Navigate(); // Navigate to this page
  }
}
Alert.cs in TestJScriptLib class library
public class AlertApp : Mshtml
{
  public static void Start()
  {
    window.alert("Hallo");
  }
}
© 2009 JScriptSuite. All rights reserved.