Ejemplo n.º 1
0
        public void ReplaceWith(object content)
        {
            if (Owner == null)
            {
                throw new InvalidOperationException();
            }

            XNode      here     = previous;
            XNode      orgNext  = next;
            XContainer orgOwner = Owner;

            Remove();
            foreach (object o in XUtil.ExpandArray(content))
            {
                if (o == null || orgOwner.OnAddingObject(o, true, here, false))
                {
                    continue;
                }
                XNode n = XUtil.ToNode(o);
                n = (XNode)XUtil.GetDetachedObject(n);
                n.SetOwner(orgOwner);
                n.previous = here;
                if (here != null)
                {
                    here.next = n;
                }
                else
                {
                    orgOwner.FirstNode = n;
                }
                n.next = orgNext;
                if (orgNext != null)
                {
                    orgNext.previous = n;
                }
                else
                {
                    orgOwner.LastNode = n;
                }
                here = n;
            }
        }