From 125ed2bb954e999b4d82e9096c5bd8ed3cab93bd Mon Sep 17 00:00:00 2001 From: c0c0bird Date: Mon, 15 Jan 2024 18:51:25 +0100 Subject: [PATCH] Convert RootId to NodeId explicitly with namespace (#583) Co-authored-by: Corinna John --- Workshop/Common/NodeHandle.cs | 18 ++++++++++++++++++ Workshop/Common/QuickstartNodeManager.cs | 8 ++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Workshop/Common/NodeHandle.cs b/Workshop/Common/NodeHandle.cs index 8b7a2dc51..254b8c578 100644 --- a/Workshop/Common/NodeHandle.cs +++ b/Workshop/Common/NodeHandle.cs @@ -87,6 +87,24 @@ public string RootId } } + /// + /// A unique identifier for the root of a complex object tree. + /// Like , but combined with the namespace. + /// + public NodeId RootNodeId + { + get + { + if (ParsedNodeId != null) + { + // the RootId does not contain a namespace, so it has to be re-constructed to be used as a NodeId + return new NodeId(ParsedNodeId.RootId, ParsedNodeId.NamespaceIndex); + } + + return null; + } + } + /// /// A path to a component within the tree identified by the root id. /// diff --git a/Workshop/Common/QuickstartNodeManager.cs b/Workshop/Common/QuickstartNodeManager.cs index 9fd5df720..a9aff530f 100644 --- a/Workshop/Common/QuickstartNodeManager.cs +++ b/Workshop/Common/QuickstartNodeManager.cs @@ -4060,7 +4060,7 @@ protected NodeState LookupNodeInComponentCache(ISystemContext context, NodeHandl if (!String.IsNullOrEmpty(handle.ComponentPath)) { - if (m_componentCache.TryGetValue(handle.RootId, out entry)) + if (m_componentCache.TryGetValue(handle.RootNodeId, out entry)) { return entry.Entry.FindChildBySymbolicName(context, handle.ComponentPath); } @@ -4095,7 +4095,7 @@ protected void RemoveNodeFromComponentCache(ISystemContext context, NodeHandle h if (!String.IsNullOrEmpty(handle.ComponentPath)) { - nodeId = handle.RootId; + nodeId = handle.RootNodeId; } CacheEntry entry = null; @@ -4135,7 +4135,7 @@ protected NodeState AddNodeToComponentCache(ISystemContext context, NodeHandle h { CacheEntry entry = null; - if (m_componentCache.TryGetValue(handle.RootId, out entry)) + if (m_componentCache.TryGetValue(handle.RootNodeId, out entry)) { entry.RefCount++; @@ -4154,7 +4154,7 @@ protected NodeState AddNodeToComponentCache(ISystemContext context, NodeHandle h entry = new CacheEntry(); entry.RefCount = 1; entry.Entry = root; - m_componentCache.Add(handle.RootId, entry); + m_componentCache.Add(handle.RootNodeId, entry); } }