public ReactiveNode(IndexedListOnSequence <T> indexedListOnSequence, IReactiveSequence <T> reactiveSequence, int currStartIndex)
            {
                _indexedListOnSequence = indexedListOnSequence;
                _reactiveSequence      = reactiveSequence;

                UpdateFromSequence(indexedListOnSequence, reactiveSequence.Value, currStartIndex);
                reactiveSequence.Changed += OnSequenceChanged;
            }
 internal static Node CreateNode(IndexedListOnSequence <T> indexedListOnSequence,
                                 ISequence <T> sequence, int currStartIndex)
 {
     if (sequence is INonreactiveSequence <T> nonreactiveSequence)
     {
         return(new NonreactiveNode(indexedListOnSequence, nonreactiveSequence, currStartIndex));
     }
     else if (sequence is IReactiveSequence <T> reactiveSequence)
     {
         return(new ReactiveNode(indexedListOnSequence, reactiveSequence, currStartIndex));
     }
     else
     {
         throw new InvalidOperationException($"Unknown Sequence type: {sequence.GetType().FullName}");
     }
 }
            protected void UpdateFromSequence(IndexedListOnSequence <T> indexedListOnSequence, INonreactiveSequence <T> sequence, int currStartIndex)
            {
                IIndexedList <T> indexedList = indexedListOnSequence.IndexedList;

                if (sequence is ParentSequence <T> parentSequence)
                {
                    SequenceImmutableArray <ISequence <T> > childSequences = parentSequence.Children;

                    // Remove the old items, if there are any
                    if (_currDescendentItemCount > 0)
                    {
                        indexedList.Update(currStartIndex, _currDescendentItemCount, null);
                        _currDescendentItemCount = 0;
                    }

                    int childSequencesLength = childSequences.Count;
                    _childNodes = new Node[childSequencesLength];
                    for (int i = 0; i < childSequencesLength; i++)
                    {
                        Node childNode = CreateNode(indexedListOnSequence, childSequences[i], currStartIndex);
                        int  childNodeDescendentItemCount = childNode.CurrDescendentItemCount;

                        _childNodes[i]            = childNode;
                        _currDescendentItemCount += childNodeDescendentItemCount;
                        currStartIndex           += childNodeDescendentItemCount;
                    }
                }
                else if (sequence is IItemsSequence <T> itemsSequence)
                {
                    indexedList.Update(currStartIndex, _currDescendentItemCount, itemsSequence.Items.GetArray());

                    _childNodes = null;
                    _currDescendentItemCount = itemsSequence.ItemCount;
                }
                else
                {
                    throw new InvalidOperationException($"Unknown Sequence type: {sequence.GetType().FullName}");
                }
            }
 public NonreactiveNode(IndexedListOnSequence <T> indexedListOnSequence, INonreactiveSequence <T> sequence, int currStartIndex)
 {
     UpdateFromSequence(indexedListOnSequence, sequence, currStartIndex);
 }