コード例 #1
0
        private protected virtual bool IsNodeTreeBlockListValid(Node node, string propertyName)
        {
            NodeTreeHelperBlockList.GetChildBlockList(node, propertyName, out IList <NodeTreeBlock> ChildBlockList);
            Debug.Assert(ChildBlockList != null);

            bool IsValid = true;

            if (ChildBlockList.Count == 0)
            {
                IsValid &= InvariantFailed(IsEmptyBlockListValid(node, propertyName));
            }

            for (int BlockIndex = 0; BlockIndex < ChildBlockList.Count; BlockIndex++)
            {
                NodeTreeBlock Block = ChildBlockList[BlockIndex];
                Debug.Assert(Block.NodeList.Count > 0);

                for (int Index = 0; Index < Block.NodeList.Count; Index++)
                {
                    Node ChildNode = Block.NodeList[Index];
                    Debug.Assert(ChildNode != null);

                    IsValid &= InvariantFailed(IsNodeTreeValid(ChildNode));
                }
            }

            return(IsValid);
        }
コード例 #2
0
        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);
            }
        }