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);
}
}
}
}
}