Esempio n. 1
0
 public void AddChild(FmlNode l)
 {
     if (l == null)
     {
         return;
     }
     if (ChildList.Count > ChildCount)
     {
         for (int i = 0, imax = ChildList.Count; i < imax; ++i)
         {
             if (ChildList[i] == null)
             {
                 ChildList[i] = l;
                 break;
             }
         }
     }
     else
     {
         ChildList.Add(l);
     }
     l.AddBranch(this);
     ++ChildCount;
     SetDirty();
 }
Esempio n. 2
0
        public int ReplaceAllChild(FmlNode from, FmlNode to)
        {
            if (from == to)
            {
                return(0);
            }
            int count = 0;

            for (int i = 0, imax = ChildList.Count; i < imax; ++i)
            {
                if (ChildList[i] == from)
                {
                    ChildList[i] = to;
                    ++count;
                }
            }

            if (count > 0)
            {
                if (from == null)
                {
                    to.AddBranch(this, count);
                    ChildCount += count;
                }
                else if (to == null)
                {
                    from.RemoveBranch(this, count);
                    ChildCount -= count;
                    RemoveNullTail();
                }
                else
                {
                    to.AddBranch(this, count);
                    from.RemoveBranch(this, count);
                }
                SetDirty();
            }

            return(count);
        }
Esempio n. 3
0
        public bool ReplaceChild(FmlNode from, FmlNode to)
        {
            if (from == to)
            {
                return(false);
            }

            for (int i = 0, imax = ChildList.Count; i < imax; ++i)
            {
                if (ChildList[i] == from)
                {
                    ChildList[i] = to;

                    if (from == null)
                    {
                        to.AddBranch(this);
                        ++ChildCount;
                    }
                    else if (to == null)
                    {
                        from.RemoveBranch(this);
                        --ChildCount;
                        RemoveNullTail();
                    }
                    else
                    {
                        to.AddBranch(this);
                        from.RemoveBranch(this);
                    }

                    SetDirty();
                    return(true);
                }
            }
            return(false);
        }