Opc.Ua.Com.Client.ParsedNodeId.ConstructIdForComponent C# (CSharp) Method

ConstructIdForComponent() public static method

Constructs the node identifier for a component.
public static ConstructIdForComponent ( NodeState component, ushort namespaceIndex ) : Opc.Ua.NodeId
component NodeState The component.
namespaceIndex ushort Index of the namespace.
return Opc.Ua.NodeId
        public static NodeId ConstructIdForComponent(NodeState component, ushort namespaceIndex)
        {
            if (component == null)
            {
                return null;
            }

            // components must be instances with a parent.
            BaseInstanceState instance = component as BaseInstanceState;

            if (instance == null || instance.Parent == null)
            {
                return component.NodeId;
            }

            // parent must have a string identifier.
            string parentId = instance.Parent.NodeId.Identifier as string;

            if (parentId == null)
            {
                return null;
            }

            StringBuilder buffer = new StringBuilder();
            buffer.Append(parentId);

            // check if the parent is another component.
            int index = parentId.IndexOf('?');

            if (index < 0)
            {
                buffer.Append('?');
            }
            else
            {
                buffer.Append('/');
            }

            buffer.Append(component.SymbolicName);

            // return the node identifier.
            return new NodeId(buffer.ToString(), namespaceIndex);
        }

Usage Example

        /// <summary>
        /// Creates the NodeId for the specified node.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="node">The node.</param>
        /// <returns>The new NodeId.</returns>
        /// <remarks>
        /// This method is called by the NodeState.Create() method which initializes a Node from
        /// the type model. During initialization a number of child nodes are created and need to
        /// have NodeIds assigned to them. This implementation constructs NodeIds by constructing
        /// strings. Other implementations could assign unique integers or Guids and save the new
        /// Node in a dictionary for later lookup.
        /// </remarks>
        public override NodeId New(ISystemContext context, NodeState node)
        {
            if (node is ServerStatusState)
            {
                return(node.NodeId);
            }

            return(ParsedNodeId.ConstructIdForComponent(node, NamespaceIndex));
        }
All Usage Examples Of Opc.Ua.Com.Client.ParsedNodeId::ConstructIdForComponent