protected void EhTableParentChanged(object sender, Main.ParentChangedEventArgs pce) { if (object.ReferenceEquals(this, pce.OldParent) && this.ContainsTable((DataTable)sender)) { this.Remove((DataTable)sender); } else if (!this.ContainsTable((DataTable)sender)) { throw new ApplicationException("Not allowed to set child's parent to this collection before adding it to the collection"); } }
/// <summary> /// EventHandler used to catch unauthorized parent changes in child objects. /// </summary> /// <param name="sender">The child object which signal a parent change.</param> /// <param name="e">The parent change details.</param> protected void EhChildParentChanged(object sender, Main.ParentChangedEventArgs e) { // this event should not happen, or someone try to // change the parents of my collection throw new ApplicationException("Unexpected change of DataColumnsCollection's parent belonging to table " + this.Name); }