/// <summary> /// Recursively indexes the node and its children. /// </summary> protected virtual void RemovePredefinedNode( ISystemContext context, NodeState node, List<LocalReference> referencesToRemove) { m_predefinedNodes.Remove(node.NodeId); node.UpdateChangeMasks(NodeStateChangeMasks.Deleted); node.ClearChangeMasks(context, false); OnNodeRemoved(node); // remove from the parent. BaseInstanceState instance = node as BaseInstanceState; if (instance != null && instance.Parent != null) { instance.Parent.RemoveChild(instance); } // remove children. List<BaseInstanceState> children = new List<BaseInstanceState>(); node.GetChildren(context, children); for (int ii = 0; ii < children.Count; ii++) { node.RemoveChild(children[ii]); } for (int ii = 0; ii < children.Count; ii++) { RemovePredefinedNode(context, children[ii], referencesToRemove); } // remove from type table. BaseTypeState type = node as BaseTypeState; if (type != null) { m_server.TypeTree.Remove(type.NodeId); } // remove inverse references. List<IReference> references = new List<IReference>(); node.GetReferences(context, references); for (int ii = 0; ii < references.Count; ii++) { IReference reference = references[ii]; if (reference.TargetId.IsAbsolute) { continue; } LocalReference referenceToRemove = new LocalReference( (NodeId)reference.TargetId, reference.ReferenceTypeId, reference.IsInverse, node.NodeId); referencesToRemove.Add(referenceToRemove); } }