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 for predefined nodes.
if (PredefinedNodes != null)
{
NodeState node = null;
if (PredefinedNodes.TryGetValue(nodeId, out node))
{
return handle = new NodeHandle(nodeId, node);
}
}
// parse the identifier.
HdaParsedNodeId parsedNodeId = HdaParsedNodeId.Parse(nodeId);
if (parsedNodeId != 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;
}
}