/// <summary>
        /// Creates a compiled script with an associated document name.
        /// </summary>
        /// <param name="documentName">A document name for the compiled script. Currently this name is used only as a label in presentation contexts such as debugger user interfaces.</param>
        /// <param name="code">The script code to compile.</param>
        /// <returns>A compiled script that can be executed multiple times without recompilation.</returns>
        public V8Script Compile(string documentName, string code)
        {
            VerifyNotDisposed();

            return(ScriptInvoke(() =>
            {
                var uniqueName = documentNameManager.GetUniqueName(documentName, "Script Document");
                return proxy.Compile(uniqueName, FormatCode ? MiscHelpers.FormatCode(code) : code);
            }));
        }
示例#2
0
        /// <summary>
        /// Creates a compiled script with the specified document information.
        /// </summary>
        /// <param name="documentInfo">A structure containing information about the script document.</param>
        /// <param name="code">The script code to compile.</param>
        /// <returns>A compiled script that can be executed multiple times without recompilation.</returns>
        public V8Script Compile(DocumentInfo documentInfo, string code)
        {
            VerifyNotDisposed();

            return(ScriptInvoke(() =>
            {
                documentInfo.UniqueName = documentNameManager.GetUniqueName(documentInfo.Name, DocumentInfo.DefaultName);
                return proxy.Compile(documentInfo, FormatCode ? MiscHelpers.FormatCode(code) : code);
            }));
        }