public RuleTreeBranch (IRuleTreeNode[] children, AnalysisRuleAddinNode rule) { this.rule = rule; this.children = children; Debug.Assert (rule != null); Debug.Assert (children != null && children.Length > 0); Debug.Assert (children.All (c => (c is RuleTreeLeaf && ((RuleTreeLeaf)c).Rule.Input == rule.Output) || (c is RuleTreeBranch && ((RuleTreeBranch)c).Rule.Input == rule.Output) )); }
void PrintTreeStructure (StringBuilder builder, IRuleTreeNode[] children, string indent) { foreach (var c in children) { builder.Append (indent); var leaf = c as RuleTreeLeaf; if (leaf != null) { builder.AppendFormat ("[Leaf (Rule='{0}')]\n", leaf.Rule.FuncName); continue; } var branch = (RuleTreeBranch) c; builder.AppendFormat ("[Branch (Output='{0}',Rule='{1}')\n", branch.Rule.Output, branch.Rule.FuncName); PrintTreeStructure (builder, branch.Children, indent + " "); builder.Append (indent); builder.Append ("]\n"); } }
public RuleTreeRoot (IRuleTreeNode[] children, RuleTreeType treeType) { this.children = children; this.treeType = treeType; Debug.Assert (treeType != null); Debug.Assert (children != null && children.Length > 0); Debug.Assert (children.All (c => (c is RuleTreeLeaf && ((RuleTreeLeaf)c).Rule.Input == treeType.Input) || (c is RuleTreeBranch && ((RuleTreeBranch)c).Rule.Input == treeType.Input) )); }