Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: access indexer of a hosted object

0
0
Hi,

I have the following problem with a default property indexer (from DataRow dotnet Framework class).

In C# :
scriptEngine.AddHostObject("DotNet", new HostTypeCollection("mscorlib", "System.Core", "System.Data"));
In my Javascript :
var dt = new DotNet.System.Data.DataTable("testDataTable");
dt.Columns.Add("Col1",host.typeOf(DotNet.System.String));
var dr = dt.NewRow();
dr('Col1') = 'Test1'; // Works only with JScriptEngine, not with  V8ScriptEngine :-(
dr.set('Col1','Test1'); // Does not work :-(
dt.Rows.Add(dr);
1°/ Like you said in previous post, JScriptEngine & V8ScriptEngine are different, so dr('Col1') = 'Test1'; run only on JScriptEngine. For now, I was thinking using V8ScriptEngine, because error handling seems to be better.
2°/ The 2nd code you said in previous code dr.set('Col1','Test1'); does not run. Perharps because it's a default property indexer (this[]) ?

Do you have a solution or a workaround for this problem please ?

Thanks for advance.

Sybaris

Viewing all articles
Browse latest Browse all 2297