Skip to content

Commit 5fb1ad5

Browse files
committed
处理空节点的问题。 🔪
1 parent 87648ec commit 5fb1ad5

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

externals/opc/samples/client/BrowseCommand.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ private static CommandOutletContent Dump(OpcNode node)
7474
if(!string.IsNullOrEmpty(node.Label))
7575
content.Last.Append(CommandOutletColor.DarkGray, $" {node.Label}");
7676

77-
content.Last
78-
.Append(CommandOutletColor.DarkCyan, '(')
79-
.Append(CommandOutletColor.DarkYellow, node.Type)
80-
.Append(CommandOutletColor.DarkCyan, ')');
77+
if(node.Type != null)
78+
content.Last
79+
.Append(CommandOutletColor.DarkCyan, '(')
80+
.Append(CommandOutletColor.DarkYellow, node.Type)
81+
.Append(CommandOutletColor.DarkCyan, ')');
8182

8283
if(!string.IsNullOrEmpty(node.Description) && !string.Equals(node.Label, node.Description))
8384
content.Last.Append(CommandOutletColor.DarkGray, $" {node.Description}");

externals/opc/src/OpcNodeType.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ partial class OpcNodeType
102102
internal static OpcNodeType Get(ExpandedNodeId id) => Get((NodeId)id);
103103
internal static OpcNodeType Get(NodeId id)
104104
{
105+
if(id == null || id.IsNullNodeId)
106+
return null;
107+
105108
if(_types.TryGetValue(id, out var type))
106109
return type;
107110

0 commit comments

Comments
 (0)