Ejemplo n.º 1
0
        /// <summary>
        /// 用LINQ解析条件表达式
        /// </summary>
        /// <param name="transition"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        private bool ParseCondition(WfTransition transition, Dictionary <string, string> condition)
        {
            var              expression = ReplaceParameterToValue(transition.condition, condition);
            Expression       expr       = System.Linq.Dynamic.DynamicExpression.Parse(typeof(Boolean), expression);
            LambdaExpression lamb       = Expression.Lambda(expr);
            var              result     = (Func <bool>)lamb.Compile();

            return(result());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 是否满足Transition的条件
        /// </summary>
        /// <param name="transition"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        private bool IsValidTransition(WfTransition transition, Dictionary <string, string> condition)
        {
            var isValid = false;

            if (string.IsNullOrEmpty(transition.condition))
            {
                isValid = true;
                return(isValid);
            }
            if (condition == null || condition.Count == 0)
            {
                return(isValid);
            }
            isValid = ParseCondition(transition, condition);

            return(isValid);
        }