public void LoadScript(String script, String name)
        {
            if (!loadedPolyfill)
            {
                loadedPolyfill = true;
                String polyfill;
                using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Manticore.polyfill.clearscript.pack.js"))
                {
                    using (StreamReader reader = new StreamReader(s))
                    {
                        polyfill = reader.ReadToEnd();
                    }
                }
                if (this.WillLoadPolyfill != null)
                {
                    this.WillLoadPolyfill(this, EventArgs.Empty);
                }
                v8.Execute("polyfill.js", polyfill);
                if (this.DidLoadPolyfill != null)
                {
                    this.DidLoadPolyfill(this, EventArgs.Empty);
                }
            }
            ScriptEventArgs args = new ScriptEventArgs(name, script);

            if (this.WillLoadScript != null)
            {
                this.WillLoadScript(this, args);
            }
            v8.Execute(name, script);
            if (this.DidLoadScript != null)
            {
                this.DidLoadScript(this, args);
            }
        }
Ejemplo n.º 2
0
        public void LoadScript(String script, String name)
        {
            String poly = null;

            if (!_loadedPolyfill)
            {
                _loadedPolyfill = true;
                poly            = GetPolyfill();
            }
            RunOnJsThread(() =>
            {
                if (poly != null)
                {
                    if (this.WillLoadPolyfill != null)
                    {
                        this.WillLoadPolyfill(this, EventArgs.Empty);
                    }
                    jsEngine.Execute(poly, new Jint.Parser.ParserOptions
                    {
                        Source = "polyfill.pack.js"
                    });
                    if (this.DidLoadPolyfill != null)
                    {
                        this.DidLoadPolyfill(this, EventArgs.Empty);
                    }
                }
                ScriptEventArgs args = new ScriptEventArgs(name, script);
                if (this.WillLoadScript != null)
                {
                    this.WillLoadScript(this, args);
                }
                jsEngine.Execute(script, new Jint.Parser.ParserOptions
                {
                    Source = name
                });
                if (this.DidLoadScript != null)
                {
                    this.DidLoadScript(this, args);
                }
            });
        }