コード例 #1
0
        /// <inheritdoc />
        public override bool Evaluate()
        {
            if (Operator == null || LeftPath == null || !LeftPath.IsValid)
            {
                return(false);
            }

            // If the operator does not support a right side, immediately evaluate with null
            if (Operator.RightSideType == null)
            {
                return(Operator.InternalEvaluate(LeftPath.GetValue(), null));
            }

            // Compare with a static value
            if (PredicateType == ProfileRightSideType.Static)
            {
                object?leftSideValue = LeftPath.GetValue();
                if (leftSideValue != null && leftSideValue.GetType().IsValueType&& RightStaticValue == null)
                {
                    return(false);
                }

                return(Operator.InternalEvaluate(leftSideValue, RightStaticValue));
            }

            if (RightPath == null || !RightPath.IsValid)
            {
                return(false);
            }

            // Compare with dynamic values
            return(Operator.InternalEvaluate(LeftPath.GetValue(), RightPath.GetValue()));
        }
コード例 #2
0
        /// <inheritdoc />
        public override bool Evaluate()
        {
            if (Operator == null || LeftPath == null || !LeftPath.IsValid)
            {
                return(false);
            }

            // Compare with a static value
            if (PredicateType == ProfileRightSideType.Static)
            {
                object?leftSideValue = LeftPath.GetValue();
                if (leftSideValue != null && leftSideValue.GetType().IsValueType&& RightStaticValue == null)
                {
                    return(false);
                }

                return(Operator.Evaluate(leftSideValue, RightStaticValue));
            }

            if (RightPath == null || !RightPath.IsValid)
            {
                return(false);
            }

            // Compare with dynamic values
            return(Operator.Evaluate(LeftPath.GetValue(), RightPath.GetValue()));
        }
コード例 #3
0
        internal override bool EvaluateObject(object target)
        {
            if (Operator == null || LeftPath == null || !LeftPath.IsValid)
            {
                return(false);
            }

            // Compare with a static value
            if (PredicateType == ProfileRightSideType.Static)
            {
                object?leftSideValue = GetListPathValue(LeftPath, target);
                if (leftSideValue != null && leftSideValue.GetType().IsValueType&& RightStaticValue == null)
                {
                    return(false);
                }

                return(Operator.Evaluate(leftSideValue, RightStaticValue));
            }

            if (RightPath == null || !RightPath.IsValid)
            {
                return(false);
            }

            // Compare with dynamic values
            if (PredicateType == ProfileRightSideType.Dynamic)
            {
                // If the path targets a property inside the list, evaluate on the list path value instead of the right path value
                if (RightPath.Target is ListPredicateWrapperDataModel)
                {
                    return(Operator.Evaluate(GetListPathValue(LeftPath, target), GetListPathValue(RightPath, target)));
                }
                return(Operator.Evaluate(GetListPathValue(LeftPath, target), RightPath.GetValue()));
            }

            return(false);
        }