From 6c02c356b949d969cff3360ea65c9cda1e7ee45c Mon Sep 17 00:00:00 2001 From: Randy Armstrong Date: Wed, 17 Jan 2024 19:11:55 -0800 Subject: [PATCH] Updates for REST prototype. --- .../Opc.Ua.Core/Stack/Client/UserIdentity.cs | 2 +- .../Stack/State/NodeStateCollection.cs | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Stack/Opc.Ua.Core/Stack/Client/UserIdentity.cs b/Stack/Opc.Ua.Core/Stack/Client/UserIdentity.cs index 6f21c5181..9a39f0c78 100644 --- a/Stack/Opc.Ua.Core/Stack/Client/UserIdentity.cs +++ b/Stack/Opc.Ua.Core/Stack/Client/UserIdentity.cs @@ -121,7 +121,7 @@ public string PolicyId /// public string DisplayName { - get { return m_displayName; } + get { return m_displayName; } set { m_displayName = value; } } /// diff --git a/Stack/Opc.Ua.Core/Stack/State/NodeStateCollection.cs b/Stack/Opc.Ua.Core/Stack/State/NodeStateCollection.cs index 8c913c4a3..24ffb73a5 100644 --- a/Stack/Opc.Ua.Core/Stack/State/NodeStateCollection.cs +++ b/Stack/Opc.Ua.Core/Stack/State/NodeStateCollection.cs @@ -16,6 +16,7 @@ using System.Reflection; using System.Runtime.Serialization; using System.Xml; +using System.Xml.Serialization; namespace Opc.Ua { @@ -181,6 +182,33 @@ public void SaveAsNodeSet2(ISystemContext context, Stream ostrm, string version) nodeSet.Write(ostrm); } + private static T Load(Stream istrm) + { + var settings = new XmlReaderSettings() { + DtdProcessing = DtdProcessing.Prohibit + }; + + XmlSerializer serializer = new XmlSerializer(typeof(T)); + + using (var reader = XmlReader.Create(istrm, settings)) + { + return (T)serializer.Deserialize(reader); + } + } + + /// + /// Loads a NodeSet2 into a NodeStateCollection. + /// + public static NodeStateCollection LoadAsNodeSet2(ISystemContext context, Stream istrm) + { + Opc.Ua.Export.UANodeSet nodeSet = Load(istrm); + + NodeStateCollection nodes = new NodeStateCollection(); + nodeSet.Import(context, nodes); + + return nodes; + } + /// /// Writes the schema information to a static XML export file. ///