/// <summary> /// Removes a tree node from the network topology and disposes it. /// </summary> /// <param name="node">The node to remove and delete.</param> public void RemoveNode(ITreeNode node) { if (node == null) { throw new ArgumentNullException(@"node"); } if (!this.Contains(node)) { var message = string.Format(CultureInfo.CurrentUICulture, Resources.Node_IsNotPartOfTheTopology, node.Name); throw new BaseException(message); } if (node.HasChildren) { foreach (var childNode in node.Children) { this.RemoveNode(childNode); } } lock (this.nodes) { try { if (this.nodes.Contains(node)) { this.nodes.Remove(node); DisconnectNodeFromTopology(node); this.OnNodeRemoved(node); } } finally { node.Dispose(); } } }