コード例 #1
0
        internal void RemoveNode(bool notifyParent)
        {
            OnRemoving(new ConfigurationNodeChangedEventArgs(ConfigurationNodeChangedAction.Remove, this, parent));

            for (int i = 0; i < childCount; i++)
            {
                childNodes[i].RemoveNode(false);
            }
            Debug.Assert(Site != null, "The site should be set by now.");
            // since the name is based on site have to store to really remove it
            string nameToRemove = this.Name;

            RemoveNodeFromChildLookup(notifyParent, nameToRemove);
            hierarchy.RemoveNode(this);
            if (notifyParent && (parent != null))
            {
                parent.childNodes[index] = null;
                for (int i = index; i < parent.childCount - 1; ++i)
                {
                    parent.childNodes[i]       = parent.childNodes[i + 1];
                    parent.childNodes[i].index = i;
                }
                parent.childCount--;
                parent.OnChildRemoved(new ConfigurationNodeChangedEventArgs(ConfigurationNodeChangedAction.Remove, this, null));
            }
            parent = null;
            OnRemoved(new ConfigurationNodeChangedEventArgs(ConfigurationNodeChangedAction.Remove, this, parent));
        }