Skip to content

Commit b80344c

Browse files
committed
Fixed duplicated instance issue #11
1 parent b4e95e3 commit b80344c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

NodeSetToAML.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,9 +1284,16 @@ InternalElementType RecursiveAddModifyInstance<T>(ref T parent, UANode toAdd) wh
12841284
}
12851285
Debug.Assert(suc != null);
12861286

1287+
// check if instance already exists before adding a new one #11
1288+
string id = AmlIDFromNodeId(toAdd.DecodedNodeId);
1289+
ie = (InternalElementType)m_cAEXDocument.FindByID(id);
1290+
if (ie != null)
1291+
return ie;
1292+
1293+
12871294
ie = suc.CreateClassInstance(); // this crates GUID IDs for all the sub-elements
12881295
ie.Name = toAdd.DecodedBrowseName.Name;
1289-
ie.ID = AmlIDFromNodeId(toAdd.DecodedNodeId); // decided not to replace the GUID IDs in the top level instances
1296+
ie.ID = id; // decided not to replace the GUID IDs in the top level instances
12901297
SetBrowseNameUri(ie.Attribute, toAdd);
12911298

12921299

0 commit comments

Comments
 (0)