예제 #1
0
        /// <summary>
        /// Evaluates a logical expression containing symbols and values.
        /// </summary>
        /// <param name="condition">conditional expression</param>
        /// <returns>The result of the condition evaluation</returns>
        /// <exception cref="InvalidHandleException">the Session handle is invalid</exception>
        /// <exception cref="ArgumentNullException">the condition is null or empty</exception>
        /// <exception cref="InvalidOperationException">the conditional expression is invalid</exception>
        /// <remarks><p>
        /// Win32 MSI API:
        /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msievaluatecondition.asp">MsiEvaluateCondition</a>
        /// </p></remarks>
        public bool EvaluateCondition(string condition)
        {
            if (string.IsNullOrWhiteSpace(condition))
            {
                throw new ArgumentNullException("condition");
            }

            uint value = RemotableNativeMethods.MsiEvaluateCondition((int)this.Handle, condition);

            if (value == 0)
            {
                return(false);
            }
            else if (value == 1)
            {
                return(true);
            }
            else
            {
                throw new InvalidOperationException();
            }
        }