public static bool IsTriggerForPhase(this IRule rule, RuleExecutionPhase phase){ //@"rule".contract_NotNull(rule); if (rule.IsTrigger()){ var phases_ = (string) rule.Params["sys.trigger.phases", ""]; var phases = phases_.Split(',', '_', ';', ' '); var phase_ = phase.ToString(); if (Array.IndexOf(phases, phase_) != -1) return true; } return false; }
public static IRule MakeTrigger(this IRule rule, RuleExecutionPhase phase, params RuleExecutionPhase[] phases){ //@"rule".contract_NotNull(rule); rule.Params[Constants.Meta.IsTrigger] = true; var phases_ = new List<string>(); phases_.Add(phase.ToString()); if (phases != null){ foreach (var p in phases) phases_.Add(p.ToString()); } rule.Params["sys.trigger.phases"] = string.Join(";", phases_.ToArray()); return rule; }
private void executeTriggers(IRuleContext context, RuleExecutionPhase phase){ foreach (var rule in Rules){ if (rule is ITriggerCollection){ ((ITriggerCollection) rule).ExecuteTriggers(context, phase); } } }