@@ -120,6 +120,10 @@ namespace Jint
if (Options.IsClrAllowed())
{
Global.FastAddProperty("System", new NamespaceReference(this, "System"), false, false, false);
+ Global.FastAddProperty("importNamespace", new ClrFunctionInstance(this, (thisObj, arguments) =>
+ {
+ return new NamespaceReference(this, TypeConverter.ToString(arguments.At(0)));
+ }), false, false, false);
}
@@ -61,7 +61,8 @@ namespace Jint.Runtime.Interop
CultureInfo.InvariantCulture);
- var result = TypeConverter.ToObject(Engine, JsValue.FromObject(Engine, method.Invoke(Type, parameters.ToArray())));
+ var constructor = (ConstructorInfo)method;
+ var result = TypeConverter.ToObject(Engine, JsValue.FromObject(Engine, constructor.Invoke(parameters.ToArray())));
// todo: cache method info
@@ -77,9 +77,12 @@ And even create shortcuts to commong .NET methods
jint> log('Hello World !');
=> "Hello World !"
-Loading custom assemblies dynamically can be done by using standard reflection
+Loading custom assemblies dynamically can be done by using standard reflection `System.Reflection.Assembly.Load`. You will also need
+to assign local namespace the same way `System` does it for you, by using `importNamespace`:
- var import = System.Reflection.Assembly.Load;
+ var Foo = importNamespace('Foo');
+ var bar = new Foo.Bar();
+ log(bar.ToString());
## Implemented features: