Ejemplo n.º 1
0
        public bool SatisfiesCondition(CustomTuple tuple)
        {
            if (this is AndCondition andCondition)
            {
                return(andCondition.Left.SatisfiesCondition(tuple) && andCondition.Right.SatisfiesCondition(tuple));
            }
            else if (this is OrCondition orCondition)
            {
                return(orCondition.Left.SatisfiesCondition(tuple) || orCondition.Right.SatisfiesCondition(tuple));
            }
            else if (this is LeafCondition leafCondition)
            {
                if (leafCondition.AlwaysTrue)
                {
                    return(true);
                }

                CustomObject value = tuple.GetEntryFor(leafCondition.Column);

                switch (leafCondition.Operation)
                {
                case Compiler.Common.RelOp.Equals:
                    return(value.IsEqualTo(leafCondition.Value));

                case Compiler.Common.RelOp.GreaterThan:
                    return(value.IsGreaterThan(leafCondition.Value));

                case Compiler.Common.RelOp.GreaterOrEqualThan:
                    return(value.IsGreaterThan(leafCondition.Value) || value.IsEqualTo(leafCondition.Value));

                case Compiler.Common.RelOp.LessThan:
                    return(!value.IsGreaterThan(leafCondition.Value) && !value.IsEqualTo(leafCondition.Value));

                case Compiler.Common.RelOp.LessOrEqualThan:
                    return(!value.IsGreaterThan(leafCondition.Value));
                }
            }

            return(false);
        }