protected virtual void AddPredefinedNode(ISystemContext context, NodeState node)
{
if (m_predefinedNodes == null)
{
m_predefinedNodes = new NodeIdDictionary<NodeState>();
}
NodeState activeNode = AddBehaviourToPredefinedNode(context, node);
m_predefinedNodes[activeNode.NodeId] = activeNode;
BaseTypeState type = activeNode as BaseTypeState;
if (type != null)
{
AddTypesToTypeTree(type);
}
// update the root notifiers.
if (m_rootNotifiers != null)
{
for (int ii = 0; ii < m_rootNotifiers.Count; ii++)
{
if (m_rootNotifiers[ii].NodeId == activeNode.NodeId)
{
m_rootNotifiers[ii] = activeNode;
// need to prevent recursion with the server object.
if (activeNode.NodeId != ObjectIds.Server)
{
activeNode.OnReportEvent = OnReportEvent;
if (!activeNode.ReferenceExists(ReferenceTypeIds.HasNotifier, true, ObjectIds.Server))
{
activeNode.AddReference(ReferenceTypeIds.HasNotifier, true, ObjectIds.Server);
}
}
break;
}
}
}
List<BaseInstanceState> children = new List<BaseInstanceState>();
activeNode.GetChildren(context, children);
for (int ii = 0; ii < children.Count; ii++)
{
AddPredefinedNode(context, children[ii]);
}
}