private protected virtual bool IsNodeTreeListValid(Node node, string propertyName) { NodeTreeHelperList.GetChildNodeList(node, propertyName, out IReadOnlyList <Node> ChildNodeList); Debug.Assert(ChildNodeList != null); bool IsValid = true; if (ChildNodeList.Count == 0) { IsValid &= InvariantFailed(IsEmptyListValid(node, propertyName)); } for (int Index = 0; Index < ChildNodeList.Count; Index++) { Node ChildNode = ChildNodeList[Index]; Debug.Assert(ChildNode != null); IsValid &= InvariantFailed(IsNodeTreeValid(ChildNode)); } return(IsValid); }
private protected virtual void BrowseChildrenOfNode(IReadOnlyBrowseContext browseNodeContext, INode node) { IList <string> PropertyNames = NodeTreeHelper.EnumChildNodeProperties(node); foreach (string PropertyName in PropertyNames) { INode ChildNode; Type ChildInterfaceType, ChildNodeType; IReadOnlyList <INode> ChildNodeList; IReadOnlyList <INodeTreeBlock> ChildBlockList; bool IsHandled = false; if (NodeTreeHelperChild.IsChildNodeProperty(node, PropertyName, out ChildNodeType)) { NodeTreeHelperChild.GetChildNode(node, PropertyName, out ChildNode); Debug.Assert(ChildNode != null); IReadOnlyBrowsingPlaceholderNodeIndex ChildNodeIndex = CreateChildNodeIndex(browseNodeContext, node, PropertyName, ChildNode); // Create a collection containing one index for this child node. IReadOnlyIndexCollection IndexCollection = CreatePlaceholderIndexCollection(browseNodeContext, PropertyName, ChildNodeIndex); browseNodeContext.AddIndexCollection(IndexCollection); IsHandled = true; } else if (NodeTreeHelperOptional.IsOptionalChildNodeProperty(node, PropertyName, out ChildNodeType)) { IReadOnlyBrowsingOptionalNodeIndex OptionalNodeIndex = CreateOptionalNodeIndex(browseNodeContext, node, PropertyName); // Create a collection containing one index for this optional node. IReadOnlyIndexCollection IndexCollection = CreateOptionalIndexCollection(browseNodeContext, PropertyName, OptionalNodeIndex); browseNodeContext.AddIndexCollection(IndexCollection); IsHandled = true; } else if (NodeTreeHelperList.IsNodeListProperty(node, PropertyName, out ChildNodeType)) { NodeTreeHelperList.GetChildNodeList(node, PropertyName, out ChildNodeList); Debug.Assert(ChildNodeList != null); // Create a collection containing indexes for each children. IReadOnlyIndexCollection IndexCollection = BrowseNodeList(browseNodeContext, node, PropertyName, ChildNodeList); browseNodeContext.AddIndexCollection(IndexCollection); IsHandled = true; } else if (NodeTreeHelperBlockList.IsBlockListProperty(node, PropertyName, out ChildInterfaceType, out ChildNodeType)) { NodeTreeHelperBlockList.GetChildBlockList(node, PropertyName, out ChildBlockList); Debug.Assert(ChildBlockList != null); // Create a collection containing indexes for each child blocks and their children. IReadOnlyIndexCollection IndexCollection = BrowseNodeBlockList(browseNodeContext, node, PropertyName, ChildBlockList); browseNodeContext.AddIndexCollection(IndexCollection); IsHandled = true; } else if (NodeTreeHelper.IsBooleanProperty(node, PropertyName)) { browseNodeContext.AddValueProperty(PropertyName, ValuePropertyType.Boolean); IsHandled = true; } else if (NodeTreeHelper.IsEnumProperty(node, PropertyName)) { browseNodeContext.AddValueProperty(PropertyName, ValuePropertyType.Enum); IsHandled = true; } else if (NodeTreeHelper.IsStringProperty(node, PropertyName)) { browseNodeContext.AddValueProperty(PropertyName, ValuePropertyType.String); IsHandled = true; } else if (NodeTreeHelper.IsGuidProperty(node, PropertyName)) { browseNodeContext.AddValueProperty(PropertyName, ValuePropertyType.Guid); IsHandled = true; } else if (NodeTreeHelper.IsDocumentProperty(node, PropertyName)) { IsHandled = true; // Ignore the doc node. } Debug.Assert(IsHandled); } }