public virtual void SetParent(IHaveHeirarchy value) { if (value != _Parent) { _Parent = value; if (!IsLoadingDto) { MarkThisDirty(); } } }
/// <summary> /// Use this when adding children to make sure meta state is properly maintained. /// Adds child to Children, marks this as dirty, sets child.parent to this /// (child can only have one parent). Override this to update appropriate Id lists /// in descending objects. /// </summary> /// <param name="child">child to add to this object.</param> /// <exception cref="ArgumentException">child.Parent must be null</exception> public virtual void AddChild(IHaveHeirarchy child) { if (child.Parent != null && child.Parent != this) { throw new ArgumentException(); } Children.Add(child); if (!IsLoadingDto) { MarkThisDirty(); } child.SetParent(this); }