Exemplo n.º 1
0
        public static bool RuleIsTrue(ProxyRule rule, IEnumerable <Assertion> worldState)
        {
            var factGroup = new FactGroup()
            {
                Junction = rule.Junction,
                Facts    = rule.IfTrue
            };

            return(FactGroupIsTrue(factGroup, worldState));
            //return rule.FactGroups.All(fg => FactGroupIsTrue(fg, worldState));
        }
Exemplo n.º 2
0
        private static bool FactGroupIsTrue(FactGroup factGroup, IEnumerable <Assertion> worldState)
        {
            switch (factGroup.Junction)
            {
            case JunctionEnum.And:
                return(factGroup.Facts.All(fact => FactIsTrue(fact, worldState)));

            case JunctionEnum.Or:
                return(factGroup.Facts.Any(fact => FactIsTrue(fact, worldState)));
            }
            throw new Exception("Unknown junction type: " + factGroup.Junction);
        }