Skip to content

Instantly share code, notes, and snippets.

@kiichi
Created February 2, 2015 16:57
Show Gist options
  • Select an option

  • Save kiichi/cbc2c2fd82c78acaac4d to your computer and use it in GitHub Desktop.

Select an option

Save kiichi/cbc2c2fd82c78acaac4d to your computer and use it in GitHub Desktop.
Jint - Manipulating Object using JavaScript via .NET
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Jint;
//https://github.com/sebastienros/jint
namespace JintTest {
public class Person {
public string Name;
public int Age;
}
public class Program {
static void Main(string[] args) {
var p = new Person {
Name="Kiichi Takeuchi",
Age = 10
};
var engine = new Engine().Execute("function test(p) {p.Name = 'Kiichi Awsome';return p;}");
Jint.Native.JsValue val = engine.Invoke("test", p);
Console.WriteLine(((Person)val.ToObject()).Name);
Console.Read();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment