コード例 #1
0
        private protected virtual ReadOnlyNodeStateDictionary BuildChildrenStateTable(ReadOnlyBrowseContext browseContext)
        {
            IReadOnlyNodeState State = browseContext.State;
            ReadOnlyInnerReadOnlyDictionary <string> InnerTable          = State.InnerTable;
            ReadOnlyIndexCollectionReadOnlyList      IndexCollectionList = browseContext.IndexCollectionList;

            ReadOnlyNodeStateDictionary ChildStateTable = CreateChildStateTable();

            foreach (IReadOnlyIndexCollection <IReadOnlyBrowsingChildIndex> NodeIndexCollection in IndexCollectionList)
            {
                // List of indexes for this property (one for placeholder and optional node, several for lists and block lists)
                IReadOnlyList <IReadOnlyBrowsingChildIndex> NodeIndexList = NodeIndexCollection.NodeIndexList;
                string PropertyName = NodeIndexCollection.PropertyName;

                Debug.Assert(InnerTable.ContainsKey(PropertyName));
                IReadOnlyInner <IReadOnlyBrowsingChildIndex> Inner = (IReadOnlyInner <IReadOnlyBrowsingChildIndex>)InnerTable[PropertyName];

                for (int i = 0; i < NodeIndexList.Count; i++)
                {
                    IReadOnlyBrowsingChildIndex ChildIndex = NodeIndexList[i];

                    // If the inner is that of a block list, and the index is for the first node in the block, add block-specific states
                    if (Inner is IReadOnlyBlockListInner <IReadOnlyBrowsingBlockNodeIndex> AsBlockListInner && ChildIndex is IReadOnlyBrowsingNewBlockNodeIndex AsNewBlockIndex)
                    {
                        IReadOnlyBlockState BlockState = AsBlockListInner.InitNewBlock(AsNewBlockIndex);
                        ((IReadOnlyBlockState <IReadOnlyInner <IReadOnlyBrowsingChildIndex> >)BlockState).InitBlockState();
                        Stats.BlockCount++;

                        IReadOnlyBrowsingPatternIndex PatternIndex = BlockState.PatternIndex;
                        IReadOnlyPatternState         PatternState = BlockState.PatternState;
                        AddState(PatternIndex, PatternState);
                        Stats.PlaceholderNodeCount++;

                        IReadOnlyBrowsingSourceIndex SourceIndex = BlockState.SourceIndex;
                        IReadOnlySourceState         SourceState = BlockState.SourceState;
                        AddState(SourceIndex, SourceState);
                        Stats.PlaceholderNodeCount++;

                        ChildIndex = AsNewBlockIndex.ToExistingBlockIndex();
                    }

                    IReadOnlyNodeState ChildState = BuildChildState(Inner, ChildIndex);
                    ChildStateTable.Add(NodeIndexList[i], ChildState);
                }
            }

            return(ChildStateTable);
        }
コード例 #2
0
        private protected virtual void BuildChildrenStates(ReadOnlyBrowseContext browseContext, ReadOnlyNodeStateDictionary childrenStateTable)
        {
            IReadOnlyNodeState State = browseContext.State;
            ReadOnlyInnerReadOnlyDictionary <string> InnerTable          = State.InnerTable;
            ReadOnlyIndexCollectionReadOnlyList      IndexCollectionList = browseContext.IndexCollectionList;

            // Build states for children in the order they have been reported when browsing the parent state
            foreach (IReadOnlyIndexCollection <IReadOnlyBrowsingChildIndex> NodeIndexCollection in IndexCollectionList)
            {
                IReadOnlyList <IReadOnlyBrowsingChildIndex> NodeIndexList = NodeIndexCollection.NodeIndexList;
                string PropertyName = NodeIndexCollection.PropertyName;
                IReadOnlyInner <IReadOnlyBrowsingChildIndex> Inner = (IReadOnlyInner <IReadOnlyBrowsingChildIndex>)InnerTable[PropertyName];

                for (int i = 0; i < NodeIndexList.Count; i++)
                {
                    IReadOnlyBrowsingChildIndex ChildNodeIndex = NodeIndexList[i];
                    IReadOnlyNodeState          ChildState     = childrenStateTable[ChildNodeIndex];

                    BuildStateTable(Inner, browseContext, ChildState.ParentIndex, ChildState);
                }
            }
        }
コード例 #3
0
 /// <inheritdoc/>
 public override IReadOnlyNodeState InitChildState(IReadOnlyBrowsingChildIndex nodeIndex)
 {
     Debug.Assert(nodeIndex is IReadOnlyBrowsingPlaceholderNodeIndex);
     return(InitChildState((IReadOnlyBrowsingPlaceholderNodeIndex)nodeIndex));
 }
コード例 #4
0
 /// <inheritdoc/>
 public override IReadOnlyNodeState InitChildState(IReadOnlyBrowsingChildIndex nodeIndex)
 {
     return(InitChildState(nodeIndex));
 }
コード例 #5
0
 /// <summary>
 /// Initializes a newly created state for a node in the inner.
 /// </summary>
 /// <param name="nodeIndex">Index of the node.</param>
 /// <returns>The created node state.</returns>
 public abstract IReadOnlyNodeState InitChildState(IReadOnlyBrowsingChildIndex nodeIndex);
コード例 #6
0
 /// <inheritdoc/>
 public override IReadOnlyNodeState InitChildState(IReadOnlyBrowsingChildIndex nodeIndex)
 {
     Debug.Assert(nodeIndex is IReadOnlyBrowsingExistingBlockNodeIndex);
     return(InitChildState((IReadOnlyBrowsingExistingBlockNodeIndex)nodeIndex));
 }
コード例 #7
0
        private protected virtual IReadOnlyNodeState BuildChildState(IReadOnlyInner <IReadOnlyBrowsingChildIndex> inner, IReadOnlyBrowsingChildIndex nodeIndex)
        {
            IReadOnlyNodeState ChildState = inner.InitChildState(nodeIndex);

            AddState(nodeIndex, ChildState);

            // For debugging: count nodes according to their type
            if (inner is IReadOnlyOptionalInner <IReadOnlyBrowsingOptionalNodeIndex> AsOptionalInner)
            {
                Stats.OptionalNodeCount++;
                if (AsOptionalInner.IsAssigned)
                {
                    Stats.AssignedOptionalNodeCount++;
                }
            }
            else
            {
                Stats.PlaceholderNodeCount++;
            }

            return(ChildState);
        }