Opc.Ua.Com.Server.ComDaBrowseCache.FindChild C# (CSharp) Method

FindChild() public method

Finds the child with the specified name.
public FindChild ( Session session, string itemId, string childName ) : ComDaBrowseElement
session Opc.Ua.Client.Session The session.
itemId string The item id.
childName string Name of the child.
return ComDaBrowseElement
        public ComDaBrowseElement FindChild(Session session, string itemId, string childName)
        {
            TraceState("FindChild", itemId, childName);

            // find the element in the cache.
            BrowseElement parent = null;

            lock (m_lock)
            {
                if (itemId == null)
                {
                    itemId = String.Empty;
                }

                if (!m_cache.TryGetValue(itemId, out parent))
                {
                    parent = null;
                }
            }

            // fetch the element from the server.
            if (parent == null)
            {
                NodeId nodeId = m_mapper.GetRemoteNodeId(itemId);
                parent = CreateBrowseElement(session, nodeId);

                if (parent == null)
                {
                    return null;
                }
            }

            // name make actually be an item id.
            string childId = childName;

            // look up the child reference.
            ReferenceDescription reference = null;

            if (parent.ReferencesByName.TryGetValue(childName, out reference))
            {
                childId = m_mapper.GetLocalItemId((NodeId)reference.NodeId);
            }

            // look up target of reference in the cache.
            BrowseElement child = null;

            lock (m_lock)
            {
                if (m_cache.TryGetValue(childId, out child))
                {
                    return child;
                }
            }

            // return the child.
            return Lookup(session, childId);
        }