public void Unregister(ICFU cfu) { var toRemove = ChildCollection.Where(x => x.Value.Equals(cfu)).Select(x => x.Key).ToList(); //ToList required, as we remove from the source foreach (var key in toRemove) { ChildCollection.Remove(key); } machine.UnregisterAsAChildOf(this, cfu); }
/// <summary> /// Release the child form index when it is unloaded /// </summary> /// <param name="e">OnClosed event args</param> protected override void OnClosed(EventArgs e) { base.OnClosed(e); // Remove from the collection only if the calling form is a MDI child form if (this.IsMdiContainer == false && this.MdiParent != null) { ChildCollection.Remove(this.Name.ToString()); childNames.Remove(this.CurrentFormName); this.IntimateParent(false); } }
public virtual void Unregister(T peripheral) { var toRemove = ChildCollection.Where(x => x.Value.Equals(peripheral)).Select(x => x.Key).ToList(); if (toRemove.Count == 0) { throw new RegistrationException("The specified peripheral was never registered."); } foreach (var key in toRemove) { ChildCollection.Remove(key); } }