Created
February 2, 2015 16:57
-
-
Save kiichi/cbc2c2fd82c78acaac4d to your computer and use it in GitHub Desktop.
Jint - Manipulating Object using JavaScript via .NET
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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