如何从传递给主机 C# 方法的 JS 对象转换为名称和值对的字典?我的问题是如何解释在 exec 函数中收到的“对象”。如果它们是 int 的,我可以使用...
foreach (int i in args)...
...但他们是...什么?
例如,在一个 JS 文件中,我有
myApi.exec("doThang", { dog: "Rover", cat: "Purdy", mouse: "Mini", <non-specific list of more...> } );
在 C# 中我有
public void foo()
{
var engine = new V8ScriptEngine();
engine.AddHostObject("myApi", a); // see below
// load the above JS
string script = loadScript();
// execute that script
engine.Execute(script);
}
public class a
{
public void exec(string name, params object[] args){
// - how to iterate the args and create say a dictionary of key value pairs?
}
}
编辑:现在我了解'params'关键字不是ClearScript的特定部分,因此更改了问题的细节。