This project is read-only.

Quick Start

Download Javascript .NET

Download the latest release files here. It contains a single assembly named Noesis.Javascript.dll. Copy it inside a folder of your own.

Create a sample Console application

Open Visual Studio and create a new Console application

Change the platform target of the application

Go in the project's properties --> Build -->Change platform target to x86

Reference the assembly from your project

Add a reference to the assembly by right clicking on the project in Visual Studio, then Add Reference, open in the tab Browse and select the Noesis.Javascript.dll file you previously copied.

Add using

In the using section of you program, add this statement:
using Noesis.Javascript;

Initialize an Javascript's Object

JavascriptContext context = new JavascriptContext();

Setting a parameter to the javascript's context: SetParameter(string iString, Object iObject);

 context.SetParameter("test", "Hello World !\n");

Get a parameter to the javascript's context: GetParameter(string iString);

 context.GetParameter("test");

Run the javascript's script in the context: Run(string iScript);

context.Run("console.Print(test); number += 10;");

Sample "Hello World" of the program

    class Program
    {
        public class SystemConsole
        {
            public SystemConsole() { }

            public void Print(string iString)
            {
                Console.WriteLine(iString);
            }
        }

        static void Main(string[] args)
        {
            // Initialize the context
            JavascriptContext context = new JavascriptContext();

            // Setting the externals parameters of the context
            context.SetParameter("console", new SystemConsole());
            context.SetParameter("message", "Hello World !");
            context.SetParameter("number", 1);

            // Running the script
            context.Run("var i; for (i = 0; i < 5; i++) console.Print(message + ' (' + i + ')'); number += i;");

            // Getting a parameter (outputs 7)
            Console.WriteLine(context.GetParameter("number"));
        }
    }

Last edited Jul 5, 2010 at 7:04 PM by webadminnoesis, version 16

Comments

No comments yet.