Exemple #1
0
        /// <summary>
        /// Evaluates using the specified evaluator.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The base row.</param>
        /// <param name="baseColumn">The base column.</param>
        /// <param name="actualObj">The actual value object.</param>
        /// <returns><c>true</c> if the result is successful; otherwise, <c>false</c>.</returns>
        public override bool Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actualObj)
        {
            if (this.customValueType == CustomValueType.Formula)
            {
                object val = base.GetExpected(evaluator, baseRow, baseColumn);
                if (this.IgnoreBlank && (val == null))
                {
                    return(true);
                }
                bool?nullable = ConditionValueConverter.TryBool(val);
                if (!nullable.HasValue)
                {
                    return(false);
                }
                return(nullable.Value);
            }
            object objA = actualObj.GetValue();

            switch (this.customValueType)
            {
            case CustomValueType.Empty:
                return((objA == null) || object.Equals(objA, string.Empty));

            case CustomValueType.NonEmpty:
                if (objA == null)
                {
                    return(false);
                }
                return(!object.Equals(objA, string.Empty));

            case CustomValueType.Error:
                return(evaluator.IsCalcError(objA));

            case CustomValueType.NonError:
                return(!evaluator.IsCalcError(objA));
            }
            return(false);
        }
Exemple #2
0
 /// <summary>
 /// Gets the expected bool value.
 /// </summary>
 /// <param name="evaluator">The evaluator.</param>
 /// <param name="baseRow">The base row index.</param>
 /// <param name="baseColumn">The base column index.</param>
 /// <returns>Returns the expected bool value.</returns>
 protected bool?GetExpectedBoolean(ICalcEvaluator evaluator, int baseRow, int baseColumn)
 {
     return(ConditionValueConverter.TryBool(this.GetExpected(evaluator, baseRow, baseColumn)));
 }