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"); }
private static CSharp.Context SetupContext(ResourceHelper resourceHelper) { var context = new CSharp.Context(); context.CreatePrintFunction(); var require = new RequireDefinition(context, resourceHelper); require.Define(); return context; }
/// <summary> /// Initializes a new instance of the <see cref="RequireDefinition"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="resourceHelper">The resource helper.</param> public RequireDefinition(CSharp.Context context, ResourceHelper resourceHelper) { if (context == null) throw new ArgumentNullException("context"); if (resourceHelper == null) throw new ArgumentNullException("resourceHelper"); this.context = context; this.resourceHelper = resourceHelper; this.requireCache = new Dictionary<string, CommonObject>(); this.cacheLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); this.require = Utils.CreateFunction<Func<string, CommonObject>>(this.context.Environment, 1, Require); }
private static CSharp.Context SetupContext(ResourceHelper resourceHelper) { var context = new CSharp.Context(); //context.CreatePrintFunction(); // Debug.registerConsolePrinter(); // IronJS.Support.Debug.registerAstPrinter(AstPrinter); // IronJS.Support.Debug.registerExprPrinter(ExprPrinter); ConsoleConstructor.AttachToContext(context); var require = new RequireDefinition(context, resourceHelper); require.Define(); return context; }
/// <summary> /// Initializes a new instance of the <see cref="Uglifier"/> class. /// </summary> public Uglifier() { this.resourceHelper = new ResourceHelper(); this.context = SetupContext(this.resourceHelper); this.uglify = LoadUglify(this.context, this.resourceHelper); }