Using the params keyword throws the following exception:
V8ExecutionErrorException: Uncaught Error: Failed to invoke constructor: => Message: Types.ChangeType(): Cannot convert value "Hello" (type: 'System.String') to type 'System.String[]'. If you are developing the source type yourself, implement the 'IConvertible' interface.
Sample:
/// <summary>
/// The MFString field contains zero or more strings.
/// </summary>
[ScriptObject("MFString", ScriptMemberSecurity.NoAcccess)]
public class MFString
{
private List<string> values = new List<string>();
public MFString(params string[] values)
{
this.values.AddRange(values);
}
[ScriptMember("push", ScriptMemberSecurity.Locked)]
private void Push(params string[] values)
{
this.values.AddRange(values);
}
[ScriptMember("toString", ScriptMemberSecurity.Locked)]
public override string ToString()
{
return string.Join(", ", values);
}
}
Engine.RegisterType<MFString>(null, null, ScriptMemberSecurity.Locked);
Engine.GlobalObject.SetProperty(typeof(MFString));
Engine.Execute
(@"
function test() {
var s = new MFString('Hello', 'World');
Browser.println(s);
s.push('!', 'Test', 'Test2');
Browser.println(s);
}
test();
", "V8.NET", true, 0);
Using the params keyword throws the following exception:
V8ExecutionErrorException: Uncaught Error: Failed to invoke constructor: => Message: Types.ChangeType(): Cannot convert value "Hello" (type: 'System.String') to type 'System.String[]'. If you are developing the source type yourself, implement the 'IConvertible' interface.
Sample: