/// <summary>Gets or sets script variable values.</summary>
        /// <param name="index">The name of the variable.</param>
        /// <returns>The variable value.</returns>
        public void setJsVariable(string global, object value)
        {
            JavaScriptEngine nse = JavascriptEngine;

            if (nse != null)
            {
                nse[global] = value;
            }
        }
        /// <summary>Gets or sets script variable values.</summary>
        /// <param name="index">The name of the variable.</param>
        /// <returns>The variable value.</returns>
        public object getJsVariable(string global)
        {
            JavaScriptEngine nse = JavascriptEngine;

            if (nse != null)
            {
                return(nse[global]);
            }

            return(null);
        }
        /// <summary>Runs a nitro function by name with a set of arguments only if the method exists.</summary>
        /// <param name="name">The name of the function in lowercase.</param>
        /// <param name="context">The context to use for the 'this' value.</param>
        /// <param name="args">The set of arguments to use when calling the function.</param>
        /// <param name="optional">True if the method call is optional. No exception is thrown if not found.</param>
        /// <returns>The value that the called function returned, if any.</returns>
        public object RunLiteral(string name, object context, object[] args, bool optional)
        {
            JavaScriptEngine jse = JavascriptEngine;

            if (jse != null)
            {
                var obj = jse[name] as Jint.Native.JsValue;
                if (obj == null)
                {
                    if (optional)
                    {
                        return(null);
                    }
                    throw new Exception("The method '" + name + "' does not exist in your Javascript global scope.");
                }
                return(jse.Run(obj, context, args));
            }

            return(null);
        }
        /// <summary>Attempts to execute the given code segment.</summary>
        public object Execute(string code, object scope)
        {
            JavaScriptEngine nse = JavascriptEngine;

            return(nse.Compile(code));
        }