public void ReadJsFile(string in_filename) { IronJS.Hosting.Context ctx = IronJS.Hosting.Context.Create(); // set up 'puts' function // Action<object> emit = ( obj ) => { Console.WriteLine( JsTypeConverter.ToString( obj ) ); }; var emit = IronJS.Api.HostFunction.create <Action <IronJS.Box> >(ctx.Environment, (obj) => { Console.WriteLine(IronJS.Api.TypeConverter.toString(obj)); }); ctx.PutGlobal("puts", emit); // Forms the `net" namespace net netObj = new net(ctx.Environment); ctx.PutGlobal("net", netObj); // Forms the `http" namespace /* * http httpObj = new http( ctx.Environment ); * ctx.PutGlobal( "http", httpObj ); */ ctx.ExecuteFile(in_filename); }
void ResetEnv_Click(object sender, RoutedEventArgs e) { ijsCtx = IronJS.Hosting.Context.Create(); var inspect = IronJS.Native.Utils.createHostFunction<Action<IronJS.BoxedValue>>( ijsCtx.Environment, Inspect); var print = IronJS.Native.Utils.createHostFunction<Action<IronJS.BoxedValue>>( ijsCtx.Environment, Print); ijsCtx.PutGlobal("inspect", inspect); ijsCtx.PutGlobal("print", print); if (sender != null) RenderEnvironment(); }