Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScriptEngine"/> class.
        /// </summary>
        public ScriptEngine()
        {
            try
            {
                _engine = Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("{16d51579-a30b-4c8b-a276-0ff4dc41e755}"), true)) as IActiveScript;
            }
            catch
            {
                _engine = Activator.CreateInstance(Type.GetTypeFromProgID("javascript", true)) as IActiveScript;
            }

            Site = new ScriptSite();
            _engine.SetScriptSite(Site);

            // support 32-bit & 64-bit process
            if (IntPtr.Size == 4)
            {
                _parse32 = (IActiveScriptParse32)_engine;
                _parse32.InitNew();
            }
            else
            {
                _parse64 = (IActiveScriptParse64)_engine;
                _parse64.InitNew();
            }
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Initializes a new instance of the <see cref="ScriptEngine"/> class.
    /// </summary>
    /// <param name="language">The scripting language. Standard Windows Script engines names are 'jscript' or 'vbscript'.</param>
    public ScriptEngine(string language)
    {
        if (language == null)
        {
            throw new ArgumentNullException("language");
        }

        Type engine = Type.GetTypeFromProgID(language, true);

        _engine = Activator.CreateInstance(engine) as IActiveScript;
        if (_engine == null)
        {
            throw new ArgumentException(language + " is not an Windows Script Engine", "language");
        }

        _site = new ScriptSite();
        _engine.SetScriptSite(_site);

        // support 32-bit & 64-bit process
        if (IntPtr.Size == 4)
        {
            _parse32 = _engine as IActiveScriptParse32;
            _parse32.InitNew();
        }
        else
        {
            _parse64 = _engine as IActiveScriptParse64;
            _parse64.InitNew();
        }
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScriptEngine"/> class.
        /// </summary>
        /// <param name="language">The scripting language. Standard Windows Script engines names are 'jscript' or 'vbscript'.</param>
        public ScriptEngine(string language)
        {
            if (language == null)
            {
                throw new ArgumentNullException(nameof(language));
            }

            Type engine;
            Guid clsid;

            if (Guid.TryParse(language, out clsid))
            {
                engine = Type.GetTypeFromCLSID(clsid, true);
            }
            else
            {
                engine = Type.GetTypeFromProgID(language, true);
            }

            _engine = Activator.CreateInstance(engine) as IActiveScript;
            if (_engine == null)
            {
                throw new ArgumentException(language + " is not an Windows Script Engine", nameof(language));
            }

            Site = new ScriptSite();
            _engine.SetScriptSite(Site);

            // support 32-bit & 64-bit process
            if (IntPtr.Size == 4)
            {
                _parse32 = (IActiveScriptParse32)_engine;
                _parse32.InitNew();
            }
            else
            {
                _parse64 = (IActiveScriptParse64)_engine;
                _parse64.InitNew();
            }
        }
    /// <summary>
    /// Initializes a new instance of the <see cref="ScriptEngine"/> class.
    /// </summary>
    /// <param name="language">The scripting language. Standard Windows Script engines names are 'jscript' or 'vbscript'.</param>
    public ScriptEngine(string language)
    {
        if (language == null)
        {
            throw new ArgumentNullException("language");
        }

        // support CLSID format (for chakra support that doesn't have a name on its own)
        Type engine;
        Guid clsid;

        if (Guid.TryParse(language, out clsid))
        {
            engine = Type.GetTypeFromCLSID(clsid, true);
        }
        else
        {
            engine = Type.GetTypeFromProgID(language, true);
        }
        _engine = Activator.CreateInstance(engine) as IActiveScript;
        if (_engine == null)
        {
            throw new ArgumentException(language + " is not an Windows Script Engine", "language");
        }

        _site = new ScriptSite();
        _engine.SetScriptSite(_site);

        // support 32-bit & 64-bit process
        if (IntPtr.Size == 4)
        {
            _parse32 = _engine as IActiveScriptParse32;
            _parse32.InitNew();
        }
        else
        {
            _parse64 = _engine as IActiveScriptParse64;
            _parse64.InitNew();
        }
    }
        /// <summary>
        /// Initializes a new instance of the <see cref="ScriptEngine"/> class.
        /// </summary>
        /// <param name="language">The scripting language. Standard Windows Script engines names are 'jscript' or 'vbscript'.</param>
        public ScriptEngine(string language)
        {
            if (language == null)
                throw new ArgumentNullException("language");

            Type engine = Type.GetTypeFromProgID(language, true);
            this.engine = Activator.CreateInstance(engine) as IActiveScript;
            if (this.engine == null)
                throw new ArgumentException(language + " is not an Windows Script Engine", "language");

            Site = new ScriptSite();
            this.engine.SetScriptSite(Site);

            // support 32-bit & 64-bit process
            if (IntPtr.Size == 4)
            {
                parse32 = this.engine as IActiveScriptParse32;
                parse32.InitNew();
            }
            else
            {
                parse64 = this.engine as IActiveScriptParse64;
                parse64.InitNew();
            }
        }
Ejemplo n.º 6
0
        /// <summary> 
        /// Initializes a new instance of the <see cref="ScriptEngine"/> class. 
        /// </summary>
        public ScriptEngine()
        {
            try
            {
                _engine = Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("{16d51579-a30b-4c8b-a276-0ff4dc41e755}"), true)) as IActiveScript;
            }
            catch
            {
            	_engine = Activator.CreateInstance(Type.GetTypeFromProgID("javascript", true)) as IActiveScript;
            }

            Site = new ScriptSite();
            _engine.SetScriptSite(Site);

            // support 32-bit & 64-bit process 
            if (IntPtr.Size == 4)
            {
                _parse32 = (IActiveScriptParse32)_engine;
                _parse32.InitNew();
            }
            else
            {
                _parse64 = (IActiveScriptParse64)_engine;
                _parse64.InitNew();
            }
        }