public static RandomRule BuildRuleTree(int CurrentDepth, int MaxDepth , SimpleLogger logger, string Name) { RandomRule rr = new RandomRule(logger, Name); CurrentDepth += 1; if (CurrentDepth <= MaxDepth) rr.RegisterRules( BuildRuleTree(CurrentDepth, MaxDepth, logger, Name + ".Passed") , BuildRuleTree(CurrentDepth, MaxDepth, logger, Name + ".Failed")); return rr; }
static void Main(string[] args) { SimpleLogger log = new SimpleLogger("RandomRuleBuilder"); log.StartTimer("Building Rules"); RandomRule baseRule = RandomRule.BuildRuleTree(0, 10, log, "BaseRule"); log.StopTimer("Rules Built"); Console.WriteLine(log.ToString()); log.StartTimer("Begin Processing Rules"); baseRule.Invoke(); log.StopTimer("All Rules Processed"); Console.WriteLine(log.ToString()); Console.Read(); }
public RandomRule(SimpleLogger logger, string Name) : base(Name) { _logger = logger; }