I tried above 2 suggestions, but it didn't work. I am running latest version of ClearScript.Manager i.e. 1.2.0.17920
Thanks
Thanks
public void myUpdate(string collectionName, DynamicObject entity)
{
//somehow serialize the object to json
}
engine.Execute("myObjdate({name:"hello"});
And i didnt found any way to serialize the object to json/bson any idea on how to do it?JSON
object:publicvoid myUpdate(string collectionName, DynamicObject entity) { var json = Convert.ToString(engine.Script.JSON.stringify(entity)); // ... }
Can you elaborate any on "perfomance improvements for repeated execution"?
Console
type and are running a script that repeatedly calls Console.WriteLine()
. Because methods in JavaScript are just function-valued properties, each call consists of two steps - fetching the "WriteLine" property and invoking the result.const
/readonly
fields (most significantly enum
tokens).I've been taking the approach of having a pool of runtimes and creating engines when needed via CreateScriptEngine from the runtime. I also compile and cache the scripts per runtime for reuse. Would that still be a recommended approach for a server-side implementation?
public class NodeList : IList<Node>
{
....
public Node this[int index]
{
get
{
return item(index);
}
set
{
}
}
...
}
Script: document.getElementsByTagName('head')[0]
document.getElementsByTagName('head') returns a NodeList as expected but attempting to get [0] returns undefined (although .Item.get(0) works)window
to be the same as the global object, and that's very easy to set up:
engine.Execute("window = this");
GlobalMembers
host object under a different (dummy) name:engine.AddHostObject("_window", HostItemFlags.GlobalMembers, new MyWindow());
window
and the global object (because they're one and the same). In fact, this way your host object might not need dynamic support at all.