Example #1
0
        public static IResult Evaluate(this ITreeNode node, IResult rollingResult)
        {
            var nodeResult = node.Execute();

            //if I failed and have children don't bother aggregating the results
            if (nodeResult.Type != ResultType.Pass && node.Children.Any())
            {
                return(nodeResult);
            }

            switch (node.LogicType)
            {
            case LogicType.Or:
                return(rollingResult.Type == ResultType.Pass ? rollingResult : nodeResult);

            default:
                return(rollingResult.Type == ResultType.Pass ? nodeResult : rollingResult);
            }
        }