Exemplo n.º 1
0
        /// <summary>
        /// Parses the specified script code.
        /// </summary>
        /// <param name="code"> The code to parse. </param>
        /// <param name="flags"> The parsing flags. </param>
        /// <returns> The result of the expression, if ISEXPRESSION was passed. </returns>
        private object Parse(string code, SCRIPTITEM flags)
        {
            EXCEPINFO exceptionInfo;
            object    result    = null;
            int       errorCode = this.parser.ParseScriptText(code, null, IntPtr.Zero, null, 0, 0, flags, out result, out exceptionInfo);

            if (errorCode == unchecked ((int)0x80020009))    // DISP_E_EXCEPTION
            {
                throw new COMException(string.Format("{0} - {1}", exceptionInfo.bstrSource, exceptionInfo.bstrDescription));
            }
            if (errorCode == unchecked ((int)0x80020101))    // OLESCRIPT_E_SYNTAX
            {
                throw new System.Runtime.InteropServices.COMException("Syntax error");
            }
            if (errorCode != 0)
            {
                Marshal.ThrowExceptionForHR(errorCode);
            }
            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Parses the specified script code.
 /// </summary>
 /// <param name="code"> The code to parse. </param>
 /// <param name="flags"> The parsing flags. </param>
 /// <returns> The result of the expression, if ISEXPRESSION was passed. </returns>
 private object Parse(string code, SCRIPTITEM flags)
 {
     EXCEPINFO exceptionInfo;
     object result = null;
     int errorCode = this.parser.ParseScriptText(code, null, IntPtr.Zero, null, 0, 0, flags, out result, out exceptionInfo);
     if (errorCode == unchecked((int)0x80020009))    // DISP_E_EXCEPTION
         throw new COMException(string.Format("{0} - {1}", exceptionInfo.bstrSource, exceptionInfo.bstrDescription));
     if (errorCode == unchecked((int)0x80020101))    // OLESCRIPT_E_SYNTAX
         throw new System.Runtime.InteropServices.COMException("Syntax error");
     if (errorCode != 0)
         Marshal.ThrowExceptionForHR(errorCode);
     return result;
 }