Hi,
No. You won't be able to pass complex C# objects into JavaScript in the current version. Only two types of objects can be passed into JavaScript:
1. Simple values that has a direct JavaScript corresponding type, such as string, DateTime, etc;
2. A JSObject that were returned to you from the JavaScript world. For example, a DOM element object, etc;
What you can do is to create a Jason string based on your .NET object, then call EvalScript to turn that Jason string into a JavaScript object. After that you will be able to pass that back to the JavaScript. For example, suppose you have a .NET Person class with FirstName and LastName property, you can do something like this:
Code: C#
//This will return a string like {"FirstName": "Joe", "Last Name": "Smith"}
//The following code use the popular Jason.NET library. You can also use the .NET
//built-in JavaScriptSerializer class, which is available since .NET 3.5
string jasonString = Newtonsoft.Jason.JasonConvert.SerializeObject(person);
//Turn the string object into a JavaScript object
JSObject jsPerson = m_WebView.Eval(jasonString);
//Now you can pass jsPerson to func.Invoke
Supporting passing any .NET object directly into the JavaScript world is not hard to implement but have serious performance implications comparing with the above method. With the above method, all properties values are captured and passed to the .NET side with one call and after the call the .NET object can be discarded. The other method is to hold the .NET object on the .NET side, and create a proxy object on the JavaScript side that points to this .NET object, then whenever you access any property/method of that proxy object from your script, that proxy object calls back to the .NET side to access the corresponding .NET property/calling the .NET method. This can easily drag down the performance because not only the JavaScript <-> .NET crossing is relatively expensive, but also all calls has to be synchronized on the .NET side. This can potentially causing more problems for you in the long run even though it can get you started very quickly. So we are a bit hesitate to implement that.
Thanks