Example #1
0
        public virtual bool ReplaceChild(DbObject oldChild, DbObject newChild)
        {
            if (!CanBeChild(oldChild) || !CanBeChild(newChild))
            {
                return(false);
            }

            if (oldChild.Type != newChild.Type)
            {
                return(false);
            }

            int index = _childrenMap[oldChild.Type].FindIndex((o) => o.Equals(oldChild));

            if (index == -1)
            {
                return(false);
            }

            _childrenMap[oldChild.Type][index] = newChild;

            oldChild.Parent = null;
            SetParent(newChild);

            return(true);
        }
Example #2
0
 public FullName(DbObject obj)
 {
     _fullNameList = new List <Chunk>()
     {
         new Chunk(obj.Name, obj.Type)
     };
 }
Example #3
0
        private FullName LoadName()
        {
            FullName fullName = new FullName(this);
            DbObject parent   = Parent;

            while (parent != null && parent.Type != DbEntityEnum.Server)
            {
                fullName.AddPartent(parent);
                parent = parent.Parent;
            }

            return(fullName);
        }
Example #4
0
        public virtual bool AddChild(DbObject obj)
        {
            if (!CanBeChild(obj))
            {
                return(false);
            }

            List <DbObject> items = _childrenMap.ContainsKey(obj.Type) ? _childrenMap[obj.Type] : (_childrenMap[obj.Type] = new List <DbObject>());

            items.Add(obj);
            SetParent(obj);

            return(true);
        }
Example #5
0
        public virtual bool RemoveChild(DbObject obj)
        {
            if (!CanBeChild(obj))
            {
                return(false);
            }

            bool result = _childrenMap[obj.Type].Remove(obj);

            if (result)
            {
                obj.Parent = null;
            }
            return(result);
        }
Example #6
0
 private void SetParent(DbObject dbObject)
 {
     dbObject.Parent = this;
 }
Example #7
0
 protected virtual bool CanBeChild(DbObject obj)
 {
     return(false);
 }
Example #8
0
 public void AddPartent(DbObject obj)
 {
     _fullNameList.Insert(0, new Chunk(obj.Name, obj.Type));
 }