public override void Execute(RuleExecution context) { if (context == null) { throw new ArgumentNullException("context"); } context.Halted = true; }
public override void Execute(RuleExecution context) { if (codeDomStatement == null) { throw new InvalidOperationException(Messages.NullStatement); } CodeDomStatementWalker.Execute(context, codeDomStatement); }
public override bool Evaluate(RuleExecution execution) { if (_expression == null) { return(true); } return(Executor.EvaluateBool(_expression, execution)); }
internal override void Execute(RuleExecution execution) { Type leftType = execution.Validation.ExpressionInfo(assignStatement.Left).ExpressionType; Type rightType = execution.Validation.ExpressionInfo(assignStatement.Right).ExpressionType; RuleExpressionResult leftResult = RuleExpressionWalker.Evaluate(execution, assignStatement.Left); RuleExpressionResult rightResult = RuleExpressionWalker.Evaluate(execution, assignStatement.Right); leftResult.Value = Executor.AdjustType(rightType, rightResult.Value, leftType); }
public static RuleExpressionResult Evaluate(RuleExecution execution, CodeExpression expression) { if (execution == null) { throw new ArgumentNullException("execution"); } RuleExpressionInternal ruleExpr = GetExpression(expression); return(ruleExpr.Evaluate(expression, execution)); }
internal void Execute(RuleExecution ruleExecution) { Tracer tracer = null; if (WorkflowActivityTrace.Rules.Switch.ShouldTrace(TraceEventType.Information)) { tracer = new Tracer(name); tracer.StartRuleSet(); } Executor.ExecuteRuleSet(analyzedRules, ruleExecution, tracer, RuleSet.RuleSetTrackingKey + name); }
public void Execute(RuleExecution ruleExecution) { // we have no way of knowing if the ruleset has been changed, so no caching done if (ruleExecution == null) { throw new ArgumentNullException("ruleExecution"); } if (ruleExecution.Validation == null) { throw new ArgumentException(SR.GetString(SR.Error_MissingValidationProperty), "ruleExecution"); } RuleEngine engine = new RuleEngine(this, ruleExecution.Validation); engine.Execute(ruleExecution); }
internal static bool EvaluateBool(CodeExpression expression, RuleExecution context) { object result = RuleExpressionWalker.Evaluate(context, expression).Value; if (result is bool) { return((bool)result); } Type expectedType = context.Validation.ExpressionInfo(expression).ExpressionType; if (expectedType == null) { // oops ... not a boolean, so error InvalidOperationException exception = new InvalidOperationException(Messages.ConditionMustBeBoolean); exception.Data[RuleUserDataKeys.ErrorObject] = expression; throw exception; } return((bool)AdjustType(expectedType, result, typeof(bool))); }
public override void Execute(RuleExecution context) { // This action has no execution behaviour. }
public abstract void Execute(RuleExecution context);
internal override void Execute(RuleExecution execution) { RuleExpressionWalker.Evaluate(execution, exprStatement.Expression); }
internal abstract void Execute(RuleExecution execution);
internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution) { return(ruleExpr.Evaluate(execution)); }
internal static void Execute(RuleExecution execution, CodeStatement statement) { RuleCodeDomStatement ruleStmt = GetStatement(statement); ruleStmt.Execute(execution); }
public abstract bool Evaluate(RuleExecution execution);
internal static void ExecuteRuleSet(IList <RuleState> orderedRules, RuleExecution ruleExecution, Tracer tracer, string trackingKey) { // keep track of rule execution long[] executionCount = new long[orderedRules.Count]; bool[] satisfied = new bool[orderedRules.Count]; // clear the halted flag ruleExecution.Halted = false; //ActivityExecutionContext activityExecutionContext = ruleExecution.ActivityExecutionContext; // loop until we hit the end of the list int current = 0; while (current < orderedRules.Count) { RuleState currentRuleState = orderedRules[current]; // does this rule need to be evaluated? if (!satisfied[current]) { // yes, so evaluate it and determine the list of actions needed if (tracer != null) { tracer.StartRule(currentRuleState.Rule.Name); } satisfied[current] = true; bool result = currentRuleState.Rule.Condition.Evaluate(ruleExecution); if (tracer != null) { tracer.RuleResult(currentRuleState.Rule.Name, result); } ICollection <RuleAction> actions = (result) ? currentRuleState.Rule.thenActions : currentRuleState.Rule.elseActions; ICollection <int> activeRules = result ? currentRuleState.ThenActionsActiveRules : currentRuleState.ElseActionsActiveRules; // are there any actions to be performed? if ((actions != null) && (actions.Count > 0)) { ++executionCount[current]; string ruleName = currentRuleState.Rule.Name; if (tracer != null) { tracer.StartActions(ruleName, result); } // evaluate the actions foreach (RuleAction action in actions) { action.Execute(ruleExecution); // was Halt executed? if (ruleExecution.Halted) { break; } } // was Halt executed? if (ruleExecution.Halted) { break; } // any fields updated? if (activeRules != null) { foreach (int updatedRuleIndex in activeRules) { RuleState rs = orderedRules[updatedRuleIndex]; if (satisfied[updatedRuleIndex]) { // evaluate at least once, or repeatedly if appropriate if ((executionCount[updatedRuleIndex] == 0) || (rs.Rule.ReevaluationBehavior == RuleReevaluationBehavior.Always)) { if (tracer != null) { tracer.TraceUpdate(ruleName, rs.Rule.Name); } satisfied[updatedRuleIndex] = false; if (updatedRuleIndex < current) { current = updatedRuleIndex; } } } } } continue; } } ++current; } // no more rules to execute, so we are done }