Due to specific requirements, I need to execute a JavaScript function, which is defined in a separate JS file, from a .NET desktop application and retrieve the output.
To achieve this task, I am utilizing Jurassic. However, I am unsure how to invoke functions that require complex data types. Let me illustrate this with an example.
Consider the following function defined in the JS file:
function plus(a, b) {
return a + b;
}
In order to call this function in .NET, I am using the following code snippet:
Dim auxfile As New Jurassic.FileScriptSource(pathToPreviosJSFile)
Dim aux As New Jurassic.ScriptEngine
aux.Evaluate(auxfile)
Dim suma As Integer = aux.Evaluate("plus(2,3)")
With this implementation, the value of 'suma' would be 5. However, if the definition of the plus function were as follows:
function plus(a, b) {
return a.value + b.value;
}
How should I modify my call to the plus function to obtain the same result?