Example #1
0
        /// <summary>
        /// When the event is fired in this state, execute the chained activities
        /// </summary>
        /// <param name="fact"></param>
        /// <param name="conditionalExpression"></param>
        /// <returns></returns>
        protected void When <T>(Fact <T> fact, Expression <Func <T, bool> > conditionalExpression)
            where T : class
        {
            var ruleFact = _factCache[fact.Name] as IRuleFact <T>;

            if (ruleFact == null)
            {
                throw new ArgumentException($"The fact is unknown or has not been declared: {fact.Name}", nameof(fact));
            }

            var condition = _expressionConverter.GetRuleCondition(ruleFact, conditionalExpression);

            _conditions.Add(condition);
        }