public void AddCondition <T>(FactDeclaration <T> factDeclaration, IRuleCondition <T> condition)
            where T : class
        {
            var declaration = GetDeclaration(factDeclaration.Name);

            declaration.AddCondition(condition);
        }
        public static bool CheckCondition(this HtmlNode node, IRuleCondition condition)
        {
            var nodesForCondition = GetNodesThatMatchTheCondition(node, condition.NodeRelationship, condition.MarkerAttribute);
            var forCondition      = nodesForCondition as HtmlNode[] ?? nodesForCondition.ToArray();

            if (!forCondition.Any())
            {
                return(false);
            }
            return(forCondition.Any(probeNode => NodeMatchesTheCondition(probeNode, condition.MarkerAttribute, condition.MarkerValues)));
        }
Example #3
0
        private static string GetVBExpression(IRuleCondition condition, Dictionary<string, Type> inputs)
        {
            string vbExpression = "";

            if (condition.GetType().Name == "LogicCondition")
            {
                LogicCondition logicCondition = condition as LogicCondition;

                var subconditionExpressions = new List<string>();
                foreach (var subcondition in logicCondition.Conditions)
                {
                    subconditionExpressions.Add(GetVBExpression(subcondition, inputs));
                }

                if (logicCondition.Operator == "all")
                {
                    vbExpression = "(" + String.Join(" AndAlso ", subconditionExpressions) + ")";
                }
                else
                {
                    vbExpression = "(" + String.Join(" OrElse ", subconditionExpressions) + ")";
                }
            }
            else
            {
                ExpressionCondition expressionCondition = condition as ExpressionCondition;

                var type = expressionCondition.GetExpressionType(inputs).Name;

                switch (type)
                {
                    case "String":
                        vbExpression = String.Format(_stringOperators[expressionCondition.Operator], new object[] { expressionCondition.LeftHandSide, expressionCondition.RightHandSide[0] });
                        break;
                    case "Int32":
                    case "Double":
                    case "Decimal":
                        break;
                    case "Boolean":
                        vbExpression = String.Format(_booleanOperators[expressionCondition.Operator], new object[] { expressionCondition.LeftHandSide });
                        break;
                    case "DateTime":
                        break;
                    default:
                        break;
                }
            }
            return vbExpression;
        }
Example #4
0
 public void Add(IRuleCondition <T2> condition)
 {
     _conditions.Add(condition);
 }
Example #5
0
 /// <summary>
 /// Creates an instance of the Rule Template Class
 /// </summary>
 /// <param name="ruleCondition">Rule Condition</param>
 /// <param name="ruleConsequence">Rule Consequence</param>
 public RuleTemplate(IRuleCondition <TFact> ruleCondition, IRuleConsequence <TFact, TOutput> ruleConsequence)
 {
     RuleCondition   = ruleCondition;
     RuleConsequence = ruleConsequence;
 }
 public void AddCondition(IRuleCondition condition)
 {
     Conditions.Add(condition);
 }