Apparently EcmaScriptComponent doesn’t support regular arrays. Is it possible to add the feature ?
Here is a little sample:
public class TestClass
{
public string Text { get; set; }
public string[] TextArray { get; set; }
public TestClass()
{
Text = "Test string";
TextArray = new string[2];
TextArray[0] = "String 1";
TextArray[1] = "String 2";
}
public void ShowMessage(string Text)
{
MessageBox.Show(Text);
}
}
private void button1_Click(object sender, EventArgs e)
{
TestClass t = new TestClass();
EcmaScriptComponent ScriptEngine = new EcmaScriptComponent();
ScriptEngine.RunInThread = true;
ScriptEngine.Debug = true;
ScriptEngine.Globals.SetVariable("TestClass", t);
ScriptEngine.Clear(false);
// First MessageBox is displayed, second isn't
ScriptEngine.Source = "TestClass.ShowMessage(TestClass.Text); TestClass.ShowMessage(TestClass.TextArray[0]);";
try
{
ScriptEngine.Run();
}
catch (Exception ex)
{
MessageBox.Show("Error while running: " + ex.Message);
}
}