Opc.Ua.Server.CoreNodeManager.FindTargetId C# (CSharp) Method

FindTargetId() public method

Returns the id the first node with the specified browse name if it exists. null otherwise
public FindTargetId ( NodeId sourceId, NodeId referenceTypeId, bool isInverse, QualifiedName browseName ) : NodeId
sourceId NodeId
referenceTypeId NodeId
isInverse bool
browseName QualifiedName
return NodeId
        public NodeId FindTargetId(NodeId sourceId, NodeId referenceTypeId, bool isInverse, QualifiedName browseName)
        {
            if (sourceId == null)        throw new ArgumentNullException("sourceId");
            if (referenceTypeId == null) throw new ArgumentNullException("referenceTypeId");

            try
            {
                m_lock.Enter();

                ILocalNode source = GetManagerHandle(sourceId) as ILocalNode;

                if (source == null)
                {
                    return null;
                }
                
                foreach (ReferenceNode reference in source.References)
                {
                    if (reference.IsInverse != isInverse || !m_server.TypeTree.IsTypeOf(reference.ReferenceTypeId, referenceTypeId))
                    {
                        continue;
                    }

                    ExpandedNodeId targetId = reference.TargetId;

                    if (targetId.IsAbsolute)
                    {
                        continue;
                    }

                    ILocalNode target = GetManagerHandle((NodeId)targetId) as ILocalNode;

                    if (target == null)
                    {
                        continue;
                    }
                    
                    if (QualifiedName.IsNull(browseName) || target.BrowseName == browseName)
                    {
                        return (NodeId)targetId;
                    }
                }
                    
                return null;
            }
            finally
            {
                m_lock.Exit();
            } 
        }