コード例 #1
0
        /// <summary>
        /// 解析用户输入的条件表达式
        /// </summary>
        /// <param name="parseCondition">条件表达式</param>
        /// <returns>解析结果</returns>
        public bool CacluateCondition(string parseCondition)
        {
            if (string.IsNullOrEmpty(parseCondition))
            {
                return(true);
            }
            ParseExpression pe = new ParseExpression();

            pe.UserFunctions = (IExpParsing)this;

            pe.ChangeExpression(parseCondition);
            object condValue = pe.Value();

            return((bool)condValue);
        }
コード例 #2
0
        /// <summary>
        /// 解析用户输入的条件表达式
        /// </summary>
        /// <param name="parseCondition">条件表达式</param>
        /// <returns>解析结果</returns>
        public decimal CacluateExpression(string Expression)
        {
            if (string.IsNullOrEmpty(Expression))
            {
                throw new Exception("Expression is null");
            }
            ParseExpression pe = new ParseExpression();

            pe.UserFunctions = (IExpParsing)this;

            pe.ChangeExpression(Expression);
            object  condValue = pe.Value();
            decimal result    = decimal.MinValue;

            decimal.TryParse(condValue.ToString(), out result);

            return(result);
        }