Opc.Ua.Server.CustomNodeManager2.CreateNode C# (CSharp) 메소드

CreateNode() 공개 메소드

Creates a new instance and assigns unique identifiers to all children.
public CreateNode ( ServerSystemContext context, Opc.Ua.NodeId parentId, Opc.Ua.NodeId referenceTypeId, Opc.Ua.QualifiedName browseName, BaseInstanceState instance ) : Opc.Ua.NodeId
context ServerSystemContext The operation context.
parentId Opc.Ua.NodeId An optional parent identifier.
referenceTypeId Opc.Ua.NodeId The reference type from the parent.
browseName Opc.Ua.QualifiedName The browse name.
instance Opc.Ua.BaseInstanceState The instance to create.
리턴 Opc.Ua.NodeId
        public NodeId CreateNode(
            ServerSystemContext context,
            NodeId parentId,
            NodeId referenceTypeId,
            QualifiedName browseName,
            BaseInstanceState instance)
        {
            ServerSystemContext contextToUse = (ServerSystemContext)m_systemContext.Copy(context);

            lock (Lock)
            {
                if (m_predefinedNodes == null)
                {
                    m_predefinedNodes = new NodeIdDictionary<NodeState>();
                }

                instance.ReferenceTypeId = referenceTypeId;

                NodeState parent = null;

                if (parentId != null)
                {
                    if (!m_predefinedNodes.TryGetValue(parentId, out parent))
                    {
                        throw ServiceResultException.Create(
                            StatusCodes.BadNodeIdUnknown,
                            "Cannot find parent with id: {0}",
                            parentId);
                    }

                    parent.AddChild(instance);
                }

                instance.Create(contextToUse, null, browseName, null, true);
                AddPredefinedNode(contextToUse, instance);

                return instance.NodeId;
            }
        }
CustomNodeManager2