JsParse() 개인적인 메소드

private JsParse ( JsValue script, JsSourceContext sourceContext, JsValue sourceUrl, JsParseScriptAttributes parseAttributes, JsValue &result ) : JsErrorCode
script JsValue
sourceContext JsSourceContext
sourceUrl JsValue
parseAttributes JsParseScriptAttributes
result JsValue
리턴 JsErrorCode
예제 #1
0
        /// <summary>
        /// Parses a script and returns a function representing the script
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="script">The script to parse</param>
        /// <param name="sourceContext">A cookie identifying the script that can be used
        /// by debuggable script contexts</param>
        /// <param name="sourceUrl">The location the script came from</param>
        /// <param name="parseAttributes">Attribute mask for parsing the script</param>
        /// <returns>A function representing the script code</returns>
        public static JsValue ParseScript(string script, JsSourceContext sourceContext, string sourceUrl,
                                          ref JsParseScriptAttributes parseAttributes)
        {
            JsValue scriptValue = JsValue.FromString(script);

            scriptValue.AddRef();

            JsValue sourceUrlValue = JsValue.FromString(sourceUrl);

            sourceUrlValue.AddRef();

            JsValue result;

            try
            {
                JsErrorCode errorCode = NativeMethods.JsParse(scriptValue, sourceContext, sourceUrlValue,
                                                              parseAttributes, out result);
                JsErrorHelpers.ThrowIfError(errorCode);
            }
            finally
            {
                scriptValue.Release();
                sourceUrlValue.Release();
            }

            return(result);
        }
        /// <summary>
        /// Parses a script and returns a <c>Function</c> representing the script
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="script">The script to parse</param>
        /// <param name="sourceContext">The cookie identifying the script that can be used
        /// by script contexts that have debugging enabled</param>
        /// <param name="sourceName">The location the script came from</param>
        /// <returns>The <c>Function</c> representing the script code</returns>
        public static JsValue ParseScript(string script, JsSourceContext sourceContext, string sourceName)
        {
            JsValue     result;
            JsErrorCode errorCode;

            if (Utils.IsWindows())
            {
                errorCode = NativeMethods.JsParseScript(script, sourceContext, sourceName, out result);
                JsErrorHelpers.ThrowIfError(errorCode);
            }
            else
            {
                JsValue scriptValue = JsValue.FromString(script);
                scriptValue.AddRef();

                JsValue sourceUrlValue = JsValue.FromString(sourceName);
                sourceUrlValue.AddRef();

                try
                {
                    errorCode = NativeMethods.JsParse(scriptValue, sourceContext, sourceUrlValue,
                                                      JsParseScriptAttributes.None, out result);
                    JsErrorHelpers.ThrowIfError(errorCode);
                }
                finally
                {
                    scriptValue.Release();
                    sourceUrlValue.Release();
                }
            }

            return(result);
        }