Hello Sybaris,
If you expose an open generic type, script code can invoke the exposed object to yield a closed generic type:
Also, a single JavaScript
This syntax seems to be what you're looking for in your first question.
As for your second question, host type collections merge overloaded types when they differ only in their generic parameter count, so you can already do things like this:
Please let us know if you have more questions.
Thanks!
If you expose an open generic type, script code can invoke the exposed object to yield a closed generic type:
engine.AddHostObject("DotNet", new HostTypeCollection("mscorlib", "System.Core")); engine.AddHostType("SomeFunc", typeof(Func<,>)); engine.Execute(@" var System = DotNet.System; var IntToStringFunc = SomeFunc(System.Int32, System.String); var f = new IntToStringFunc(function(n) { return 'The value is ' + n + '.'; }); ");
new
expression can close a generic type and pass arguments to its constructor:engine.AddHostObject("DotNet", new HostTypeCollection("mscorlib", "System.Core")); engine.AddHostType("SomeFunc", typeof(Func<,>)); engine.Execute(@" var System = DotNet.System; var f = new SomeFunc(System.Int32, System.String, function(n) { return 'The value is ' + n + '.'; }); ");
As for your second question, host type collections merge overloaded types when they differ only in their generic parameter count, so you can already do things like this:
engine.AddHostObject("DotNet", new HostTypeCollection("mscorlib", "System.Core")); engine.Execute(@" var System = DotNet.System; var f1 = new System.Func(System.Int32, System.String, function(n) { return 'The value is ' + n + '.'; }); var f2 = new System.Func(System.Double, System.Double, System.Double, function(x, y) { return x * y; }); ");
Thanks!