public MangoObject(string Name, string Body)
 {
     this.Name = Name;
     this.Body = Body;
     children  = new MangoObject[0];
     parent    = null;
 }
예제 #2
0
        public void RemoveChild(MangoObject child)
        {
            //removes first instance of a child
            MangoObject[] children_ = new MangoObject[children.Length - 1];
            bool          removed   = false;

            for (int i = 0; i < children.Length; i++)
            {
                if (Children[i] != child && !removed)
                {
                    children_[i] = children[i];
                }
                else if (Children[i] == child && !removed)
                {
                    removed = true;
                    child.RemoveParent();
                }
                else
                {
                    children_[i - 1] = children[i];
                }
            }

            children = children_;
        }
 public MangoObject(string Name, string Body, int Start, int End)
 {
     //ideal for making from parsed string;
     this.Name   = Name;
     this.Body   = Body;
     children    = new MangoObject[0];
     parent      = null;
     ObjectStart = Start;
     ObjectEnd   = End;
 }
예제 #4
0
 public bool HasChild(MangoObject child)
 {
     for (int i = 0; i < Children.Length; i++)
     {
         if (Children[i] == child)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #5
0
 public void AddChild(MangoObject child)
 {
     try{
         if (!(child.Parent == this))
         {
             child.SetParent(this);
         }
     }
     catch (NullReferenceException) {
         //child.Parent is null, set parent to this
         child.SetParent(this);
     }
     MangoObject[] children_ = new MangoObject[children.Length + 1];
     children.CopyTo(children_, children.Length);
     children_[children.Length] = child;
     children = children_;
 }
예제 #6
0
        public void RemoveChild(int index)
        {
            MangoObject[] children_ = new MangoObject[children.Length - 1];
            bool          removed   = false;

            for (int i = 0; i < children.Length; i++)
            {
                if (i != index && !removed)
                {
                    children_[i] = children[i];
                }
                else if (i == index && !removed)
                {
                    removed = true;
                    children[i].RemoveParent();
                }
                else
                {
                    children_[i - 1] = children[i];
                }
            }

            children = children_;
        }
        }                                  //finds location in parsed string that object ends

        public MangoObject()
        {
            parent   = null;
            children = new MangoObject[0];
        }