public void DropWithChildren() { EntityChildrenCollection children = this.Children; while (this.Children.Count > 0) { Entity childEntity = (Entity)this.Children[0]; childEntity.DropWithChildren(); } this.Drop(); }
private void CheckCloneWithChildren(int parentId) { if (this.Id == parentId) { throw new Exception("Нельзя копировать объект в самого себя или в объекты нижнего уровня"); } EntityChildrenCollection children = this.Children; for (int i = 0; i < children.Count; i++) { Entity childEntity = (Entity)children[i]; childEntity.CheckCloneWithChildren(parentId); } }
public IEntity CloneWithChildren(int parentId) { CheckCloneWithChildren(parentId); Entity entity = (Entity)this.Clone(); entity.ParentId = parentId; entity.Post(); EntityChildrenCollection children = this.Children; for (int i = 0; i < children.Count; i++) { IEntity childEntity = children[i]; childEntity.CloneWithChildren(entity.Id); } return(entity); }