jint

Export global function using webpack

无人久伴 提交于 2019-12-23 15:15:28
问题 I'm trying to write an isomorphic module. The server javascript is going to run inside of JINT. I have created a webpack bundle specifically to build the server version of the module. I want to expose a single function that I can get JINT to call. I am using the scriptEngine.Invoke function from JINT however this is looking for a function on the global object. I don't know how to get a function onto the global object. I have tried using the expose-loader but this seems to export the entire

How to create timer on JINT Javascript side

别来无恙 提交于 2019-12-22 08:59:22
问题 I´m developing a C# project using JINT (https://github.com/sebastienros/jint), and I need to create a timer on my JS so it can execute a function on my javascript every time the timer tim set is elapsed. How can I accomplish that?. I have used setInterval or setTimeout functions but it seems that they are not part of JINT since it is based on ECMASCRIPT and this functions are not native. Can someone tell me how I can do this?. Thanks!! 回答1: Neither setInterval and setTimeout are supported by

C# - Return a value asychronously

一曲冷凌霜 提交于 2019-12-20 07:16:37
问题 private TaskCompletionSource<bool> response; private string _text = ""; public void SetResult(bool result) { this.response.SetResult(result); } public async Task<bool> SendYesNo() { response = new TaskCompletionSource<bool>(); MessageBox.Show(this._text, "", MessageBoxButtons.YesNo); this._text = ""; return response.Task.Result; } I'm using this code which is executed in a JavaScript script file so I can't call the await keyword. I want to return a boolean after I set it using SetResult . If

Jint with monotouch

大城市里の小女人 提交于 2019-12-12 22:35:09
问题 I just wanted to know if Jint (Javascript Interpreter for .NET) works on MonoTouch. I have a project on MonoDevelop where I use the Jint library and I just wanted to figure out if I can use it with MonoTouch. Is there any tutorial that I can look into on how to use it? 回答1: It looks like it is possible, but with some modifications to Jint. This describes what other people have had to do to make it work. 回答2: You will have to replace all the calls to reflection.emit with pure reflection in the

Jint Array functions ECMA 5.1

丶灬走出姿态 提交于 2019-12-10 10:53:36
问题 I'm attempting to use Jint (v2.10.4.0) to translate one arbitrary JSON structure to another. However, I am having issues with using map . According to the ECMA 5.1 language spec, map should exist on Array.prototye. However, when I attempt to use it, I get an error: Jint.Runtime.JavaScriptException: 'Object has no method 'map'' I'm testing this like Engine engine = new Engine(); var doubles = engine.SetValue("x", "[ 1, 2, 3, 4, 5 ]") .Execute("x.map(function(a){ return a + a; })")

Jint + XNA (C#)

好久不见. 提交于 2019-12-07 03:32:08
问题 Is it possible to use jint to manipulate a 3D environment created with XNA (C#), and to add functionality to this environment (again using jint)? 回答1: As a contributor to Jint, I would recommend you Jint. Jint makes it more simple than what Lua does. Moreover, I don't know if this is possible with Lua, but you can give it .NET objects and play with them in javascript (Jint stands for Javascript INTpreter). You can also secure your application with Permissions Set. Here is the same code

Jint Array functions ECMA 5.1

对着背影说爱祢 提交于 2019-12-06 12:05:38
I'm attempting to use Jint (v2.10.4.0) to translate one arbitrary JSON structure to another. However, I am having issues with using map . According to the ECMA 5.1 language spec, map should exist on Array.prototye. However, when I attempt to use it, I get an error: Jint.Runtime.JavaScriptException: 'Object has no method 'map'' I'm testing this like Engine engine = new Engine(); var doubles = engine.SetValue("x", "[ 1, 2, 3, 4, 5 ]") .Execute("x.map(function(a){ return a + a; })") .GetCompletionValue() .ToObject(); Console.WriteLine(doubles); Console.ReadKey(); Ideally, I'd also like to use

How to create timer on JINT Javascript side

那年仲夏 提交于 2019-12-05 13:44:31
I´m developing a C# project using JINT ( https://github.com/sebastienros/jint ), and I need to create a timer on my JS so it can execute a function on my javascript every time the timer tim set is elapsed. How can I accomplish that?. I have used setInterval or setTimeout functions but it seems that they are not part of JINT since it is based on ECMASCRIPT and this functions are not native. Can someone tell me how I can do this?. Thanks!! Neither setInterval and setTimeout are supported by Jint because they are part of the Window API in browsers. with Jint, instead of browser, we have access to

Jint + XNA (C#)

前提是你 提交于 2019-12-05 07:47:41
Is it possible to use jint to manipulate a 3D environment created with XNA (C#), and to add functionality to this environment (again using jint)? As a contributor to Jint, I would recommend you Jint . Jint makes it more simple than what Lua does. Moreover, I don't know if this is possible with Lua, but you can give it .NET objects and play with them in javascript (Jint stands for Javascript INTpreter). You can also secure your application with Permissions Set. Here is the same code provided before with Jint : class Program { static void Main(string[] args) { Program p = new Program(); p.Run();

How do I load a JavaScript file with Jint in C#?

天大地大妈咪最大 提交于 2019-11-27 23:13:55
I want to load a JavaScript file using Jint, but I can't seem to figure it out. The documentation said I could do something like engine.run(file1) , but it doesn't appear to be loading any files. Do I need to do something special with the file name? Here's my JavaScript file: // test.js status = "test"; Here's my C# JintEngine js = new JintEngine(); js.Run("test.js"); object result = js.Run("return status;"); Console.WriteLine(result); Console.ReadKey(); If I put in code manually in Run it works. object result = js.Run("return 2 * 21;"); // prints 42 I found a workaround by manually loading