protected InheritanceNode(InheritanceNode parent, IInterface @interface, InheritanceNodeType nodeType, IEnumerable <InheritanceNode> childs) { this.Parent = parent; this.Interface = @interface; this.NodeType = nodeType; if (childs != null) { childList.AddRange(childs); } }
public void RebuildTree(bool rebuildPaths) { if (!treeRebuilded) { treeRebuilded = true; } var interfacesIterator = new GenericTreeIterator <IInterface>(@interface => @interface.GetCurrentLevelInheritedInterfaces()); interfacesIterator.IterateTree(true, this.Interface, delegate(GenericTreeIterationArgs <IInterface, InheritanceNode> iterationArgs) { if (iterationArgs.CurrentStage == GenericTreeIterationStage.Leave) { iterationArgs.Data = null; } else { var childs = iterationArgs.Current.GetCurrentLevelInheritedInterfaces(); InheritanceNodeType nodeType = childs.Count() == 0 ? InheritanceNodeType.SuperRoot : InheritanceNodeType.Node; InheritanceNode parentNode = iterationArgs.Data ?? this; InheritanceNode newNode = CreateNode(nodeType, parentNode, iterationArgs.Current, null); parentNode.AddChild(newNode); iterationArgs.Data = newNode; } }); pathsRebuilded = false; if (rebuildPaths) { RebuildPaths(); } }
internal static InheritanceNode CreateNode(InheritanceNodeType nodeType, InheritanceNode parent, IInterface @interface, IEnumerable <InheritanceNode> childs) { return(new InheritanceNode(parent, @interface, nodeType, childs)); }