コード例 #1
0
        public void TestRemoveChainLeafView()
        {
            // Remove a non-leaf, expect no removals
            IList <View> removedViews = ViewServiceHelper.RemoveChainLeafView(top, child_2_2);

            Assert.AreEqual(0, removedViews.Count);
            Assert.AreEqual(2, child_2.Views.Length);

            // Remove the whole tree child-by-child
            removedViews = ViewServiceHelper.RemoveChainLeafView(top, child_2_2_2);
            Assert.AreEqual(1, removedViews.Count);
            Assert.AreEqual(child_2_2_2, removedViews[0]);
            Assert.AreEqual(2, child_2.Views.Length);

            removedViews = ViewServiceHelper.RemoveChainLeafView(top, child_2_2_1);
            Assert.AreEqual(2, removedViews.Count);
            Assert.AreEqual(child_2_2_1, removedViews[0]);
            Assert.AreEqual(child_2_2, removedViews[1]);
            Assert.AreEqual(1, child_2.Views.Length);

            removedViews = ViewServiceHelper.RemoveChainLeafView(top, child_1);
            Assert.AreEqual(1, removedViews.Count);
            Assert.AreEqual(child_1, removedViews[0]);

            removedViews = ViewServiceHelper.RemoveChainLeafView(top, child_2_1_1);
            Assert.AreEqual(3, removedViews.Count);
            Assert.AreEqual(child_2_1_1, removedViews[0]);
            Assert.AreEqual(child_2_1, removedViews[1]);
            Assert.AreEqual(child_2, removedViews[2]);

            Assert.AreEqual(0, child_2.Views.Length);
            Assert.AreEqual(0, top.Views.Length);
        }
コード例 #2
0
        public void Remove(EventStream eventStream, Viewable viewToRemove)
        {
            // If the viewToRemove to remove has child viewToRemove, don't disconnect - the child ViewToRemove(s) need this
            if (viewToRemove.HasViews)
            {
                return;
            }

            if (Log.IsDebugEnabled)
            {
                Log.Debug(".remove Views before the remove of view " + viewToRemove + ", for event stream " + eventStream);
                ViewSupport.DumpChildViews("EventStream ", eventStream);
            }

            // Remove views in chain leaving only non-empty parent views to the child view to be removed
            ViewServiceHelper.RemoveChainLeafView(eventStream, viewToRemove);

            if (Log.IsDebugEnabled)
            {
                Log.Debug(".remove Views after the remove, for event stream " + eventStream);
                ViewSupport.DumpChildViews("EventStream ", eventStream);
            }
        }