示例#1
0
        // --------------------------------------------------
        // ACCESSORS
        // --------------------------------------------------

        #region Accessors

        /// <summary>
        /// Gets the value of this instance.
        /// </summary>
        /// <param name="scriptInterpreter">The script interpreter to consider.</param>
        /// <param name="scriptVariableSet">The script variable set to consider.</param>
        /// <returns>Returns the value of this instance.</returns>
        public bool GetValue(IBdoScriptInterpreter scriptInterpreter = null, IScriptVariableSet scriptVariableSet = null)
        {
            string valueString = ValueScript?.Trim();

            if (valueString?.Trim().Equals("true", StringComparison.OrdinalIgnoreCase) == true)
            {
                return(true);
            }

            if (scriptInterpreter != null)
            {
                return(scriptInterpreter.Evaluate(valueString, DataExpressionKind.Script, scriptVariableSet) as bool? == true);
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Evaluate this instance.
        /// </summary>
        /// <param name="condition">The condition to consider.</param>
        /// <param name="scriptInterpreter">Script interpreter.</param>
        /// <param name="scriptVariableSet">The script variable set used to evaluate.</param>
        /// <returns>True if the business script value is the true value.</returns>
        private static bool Evaluate(
            this ScriptCondition condition,
            IBdoScriptInterpreter scriptInterpreter,
            IScriptVariableSet scriptVariableSet)
        {
            if (condition == null)
            {
                return(false);
            }

            if (condition.Expression == null)
            {
                return(false);
            }

            var b = scriptInterpreter.Evaluate <bool?>(condition.Expression, scriptVariableSet);

            return(condition.TrueValue ? (b ?? false) : !(b ?? true));
        }