예제 #1
0
        private void ImportNodeset2Xml(IDictionary <NodeId, IList <IReference> > externalReferences, string resourcepath, int pass)
        {
            // workaround for bug https://github.com/dotnet/runtime/issues/67622
            File.WriteAllText(resourcepath, File.ReadAllText(resourcepath).Replace("<Value/>", "<Value xsi:nil='true' />"));

            using (Stream stream = new FileStream(resourcepath, FileMode.Open))
            {
                UANodeSet nodeSet = UANodeSet.Read(stream);

                NodeStateCollection predefinedNodes = new NodeStateCollection();
                nodeSet.Import(SystemContext, predefinedNodes);
# if DEBUG
                DebugOutput(nodeSet, predefinedNodes);
#endif
                for (int i = 0; i < predefinedNodes.Count; i++)
                {
                    try
                    {
                        AddPredefinedNode(SystemContext, predefinedNodes[i]);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Pass " + pass.ToString() + ": Importing node ns=" + predefinedNodes[i].NodeId.NamespaceIndex + ";i=" + predefinedNodes[i].NodeId.Identifier + " (" + predefinedNodes[i].DisplayName + ") failed with error: " + ex.Message);
                    }
                }
            }
예제 #2
0
        public virtual void Initialise(CustomNodeManager2 nodeManager)
        {
            ApplicationNodeManager = nodeManager;
            if (string.IsNullOrEmpty(ResourcePath))
            {
                return;
            }
            NamespaceUris = new List <string>();
            NodeStateCollection predefinedNodeStateCollection = new NodeStateCollection();
            Stream    stream    = new FileStream(ResourcePath, FileMode.Open);
            UANodeSet uaNodeSet = UANodeSet.Read(stream);

            NamespaceUris.AddRange(ApplicationNodeManager.NamespaceUris);
            // Update namespace table
            if (uaNodeSet.NamespaceUris != null)
            {
                foreach (string namespaceUri in uaNodeSet.NamespaceUris)
                {
                    NamespaceUris.Add(namespaceUri);
                    ApplicationNodeManager.SystemContext.NamespaceUris.GetIndexOrAppend(namespaceUri);
                }
            }
            // Update server table
            if (uaNodeSet.ServerUris != null)
            {
                foreach (string serverUri in uaNodeSet.ServerUris)
                {
                    ServerUris.Add(serverUri);
                    ApplicationNodeManager.SystemContext.ServerUris.GetIndexOrAppend(serverUri);
                }
            }
            uaNodeSet.Import(ApplicationNodeManager.SystemContext, predefinedNodeStateCollection);
            NodeStateCollection = predefinedNodeStateCollection;
        }
예제 #3
0
        private void ImportNodeset2Xml(IDictionary <NodeId, IList <IReference> > externalReferences, string resourcepath)
        {
            using (Stream stream = new FileStream(resourcepath, FileMode.Open))
            {
                UANodeSet nodeSet = UANodeSet.Read(stream);

                NodeStateCollection predefinedNodes = new NodeStateCollection();
                nodeSet.Import(SystemContext, predefinedNodes);

                for (int i = 0; i < predefinedNodes.Count; i++)
                {
                    AddPredefinedNode(SystemContext, predefinedNodes[i]);
                }
            }
        }