protected override NodeHandle GetManagerHandle(ServerSystemContext context, NodeId nodeId, IDictionary<NodeId, NodeState> cache)
{
lock (Lock)
{
// quickly exclude nodes that are not in the namespace.
if (!IsNodeIdInNamespace(nodeId))
{
return null;
}
// check cache.
if (cache != null)
{
NodeState node = null;
if (cache.TryGetValue(nodeId, out node))
{
return new NodeHandle(nodeId, node);
}
}
NodeHandle handle = null;
try
{
// check if node already being monitored.
if (MonitoredNodes != null)
{
MonitoredNode2 monitoredNode2 = null;
if (MonitoredNodes.TryGetValue(nodeId, out monitoredNode2))
{
handle = new NodeHandle(nodeId, monitoredNode2.Node);
handle.MonitoredNode = monitoredNode2;
return handle;
}
}
// check for predefined nodes.
if (PredefinedNodes != null)
{
NodeState node = null;
if (PredefinedNodes.TryGetValue(nodeId, out node))
{
return handle = new NodeHandle(nodeId, node);
}
}
// parse the identifier.
AeParsedNodeId parsedNodeId = AeParsedNodeId.Parse(nodeId);
if (parsedNodeId != null)
{
if (parsedNodeId.RootType == AeModelUtils.AeEventTypeMapping && m_typeCache != null)
{
AeEventTypeMappingState mappingNode = m_typeCache.GetMappingNode(SystemContext, nodeId);
if (mappingNode != null)
{
return handle = new NodeHandle(nodeId, mappingNode);
}
return null;
}
handle = new NodeHandle();
handle.NodeId = nodeId;
handle.Validated = false;
handle.Node = null;
handle.ParsedNodeId = parsedNodeId;
return handle;
}
}
finally
{
if (handle != null && handle.Node != null && cache != null)
{
cache.Add(nodeId, handle.Node);
}
}
return null;
}
}