コード例 #1
0
        public override ICondition Compile(MyEntity container, bool inverted)
        {
            inverted ^= Invert;
            if (Children == null || Children.Length == 0)
            {
                return(ConstantCondition.For(inverted));
            }
            if (Children.Length == 1)
            {
                return(Children[0].Compile(container, inverted));
            }
            var compiled = new ICondition[Children.Length];

            for (var i = 0; i < compiled.Length; i++)
            {
                compiled[i] = Children[i].Compile(container, false);
            }
            if (compiled.Any(x => x == ConstantCondition.True))
            {
                return(ConstantCondition.For(!inverted));
            }
            if (compiled.All(x => x == ConstantCondition.False))
            {
                return(ConstantCondition.For(inverted));
            }
            return(new AnyCondition(container, compiled, inverted));
        }