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

AddReferenceToLocalNode() private method

Ensures any changes to built-in nodes are reflected in the diagnostics node manager.
private AddReferenceToLocalNode ( ILocalNode source, NodeId referenceTypeId, bool isInverse, ExpandedNodeId targetId, bool isInternal ) : void
source ILocalNode
referenceTypeId NodeId
isInverse bool
targetId ExpandedNodeId
isInternal bool
return void
        private void AddReferenceToLocalNode(
            ILocalNode     source,
            NodeId         referenceTypeId,
            bool           isInverse,
            ExpandedNodeId targetId,
            bool isInternal)
        {
            source.References.Add(referenceTypeId, isInverse, targetId);

            if (!isInternal && source.NodeId.NamespaceIndex == 0)
            {
                lock (Server.DiagnosticsNodeManager.Lock)
                {
                    NodeState state = Server.DiagnosticsNodeManager.FindPredefinedNode(source.NodeId, null);

                    if (state != null)
                    {
                        INodeBrowser browser = state.CreateBrowser(
                            m_server.DefaultSystemContext,
                            null,
                            referenceTypeId,
                            true,
                            (isInverse) ? BrowseDirection.Inverse : BrowseDirection.Forward,
                            null,
                            null,
                            true);

                        bool found = false;

                        for (IReference reference = browser.Next(); reference != null; reference = browser.Next())
                        {
                            if (reference.TargetId == targetId)
                            {
                                found = true;
                                break;
                            }
                        }

                        if (!found)
                        {
                            state.AddReference(referenceTypeId, isInverse, targetId);
                        }
                    }
                }
            }
        }