private static FunctionObject LoadUglify(CSharp.Context context, ResourceHelper resourceHelper) { string uglifyCode = resourceHelper.Get("uglify-js.js"); context.Execute(String.Concat(uglifyCode)); return context.GetGlobalAs<FunctionObject>("uglify"); }
private static FunctionObject LoadUglify(CSharp.Context context, ResourceHelper resourceHelper) { const string defineModule = "var module = {};"; string uglifyCode = resourceHelper.Get("uglify-js.js"); context.Execute(String.Concat(defineModule, uglifyCode)); return context.GetGlobalAs<FunctionObject>("uglify"); }
public static void AttachToContext(CSharp.Context context) { CommonObject prototype = context.Environment.NewObject(); FunctionObject constructor = Utils.CreateConstructor<Func<FunctionObject, CommonObject, CommonObject>> (context.Environment, 0, Construct); FunctionObject log = Utils.CreateFunction<Action<FunctionObject, CommonObject, object>> (context.Environment, 1, ConsoleObject.Log); FunctionObject dir = Utils.CreateFunction<Action<FunctionObject, CommonObject, object>> (context.Environment, 1, ConsoleObject.Dir); prototype.Prototype = context.Environment.Prototypes.Object; prototype.Put("log", log, DescriptorAttrs.Immutable); prototype.Put("dir", dir, DescriptorAttrs.Immutable); constructor.Put("prototype", prototype, DescriptorAttrs.Immutable); context.SetGlobal("Console", constructor); context.Execute("console = new Console();"); }