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); }
public FullName(DbObject obj) { _fullNameList = new List <Chunk>() { new Chunk(obj.Name, obj.Type) }; }
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); }
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); }
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); }
private void SetParent(DbObject dbObject) { dbObject.Parent = this; }
protected virtual bool CanBeChild(DbObject obj) { return(false); }
public void AddPartent(DbObject obj) { _fullNameList.Insert(0, new Chunk(obj.Name, obj.Type)); }