当前位置: 首页>>代码示例>>C#>>正文


C# NamespaceTable.GetString方法代码示例

本文整理汇总了C#中Opc.Ua.NamespaceTable.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# NamespaceTable.GetString方法的具体用法?C# NamespaceTable.GetString怎么用?C# NamespaceTable.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Opc.Ua.NamespaceTable的用法示例。


在下文中一共展示了NamespaceTable.GetString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TranslateNamespaceIndexes

        /// <summary>
        /// Updates the path to use the indexes from the target table.
        /// </summary>
        /// <param name="currentTable">The NamespaceTable which the RelativePathString currently references</param>
        /// <param name="targetTable">The NamespaceTable which the RelativePathString should reference</param>
        public void TranslateNamespaceIndexes(NamespaceTable currentTable, NamespaceTable targetTable)
        {
            // build mapping table.
            int[] mappings = new int[currentTable.Count];
            mappings[0] = 0;

            // copy mappings.
            string[] uris = new string[mappings.Length];

            for (int ii = 1; ii < mappings.Length; ii++)
            {
                uris[ii] = currentTable.GetString((uint)ii);

                if (uris[ii] != null)
                {
                    mappings[ii] = targetTable.GetIndex(uris[ii]);
                }
            }

            // update each element.
            foreach (Element element in m_elements)
            {
                QualifiedName qname = element.ReferenceTypeName;

                if (qname != null && qname.NamespaceIndex > 0)
                {
                    if (qname.NamespaceIndex < mappings.Length && mappings[qname.NamespaceIndex] > 0)
                    {
                        element.ReferenceTypeName = new QualifiedName(qname.Name, (ushort)mappings[qname.NamespaceIndex]);
                    }
                }

                qname = element.TargetName;

                if (qname != null && qname.NamespaceIndex > 0)
                {
                    if (qname.NamespaceIndex < mappings.Length && mappings[qname.NamespaceIndex] > 0)
                    {
                        element.TargetName = new QualifiedName(qname.Name, (ushort)mappings[qname.NamespaceIndex]);
                    }
                }
            }
        }
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:48,代码来源:RelativePath.cs

示例2: ImportExpandedNodeId

        /// <summary>
        /// Imports a ExpandedNodeId
        /// </summary>
        private Opc.Ua.ExpandedNodeId ImportExpandedNodeId(string source, NamespaceTable namespaceUris, StringTable serverUris)
        {
            if (String.IsNullOrEmpty(source))
            {
                return Opc.Ua.ExpandedNodeId.Null;
            }

            // parse the node.
            Opc.Ua.ExpandedNodeId nodeId = Opc.Ua.ExpandedNodeId.Parse(source);

            if (nodeId.ServerIndex <= 0 && nodeId.NamespaceIndex <= 0 && String.IsNullOrEmpty(nodeId.NamespaceUri))
            {
                return nodeId;
            }

            uint serverIndex = ImportServerIndex(nodeId.ServerIndex, serverUris);
            ushort namespaceIndex = ImportNamespaceIndex(nodeId.NamespaceIndex, namespaceUris);

            if (serverIndex > 0)
            {
                string namespaceUri = nodeId.NamespaceUri;

                if (String.IsNullOrEmpty(nodeId.NamespaceUri))
                {
                    namespaceUri = namespaceUris.GetString(namespaceIndex);
                }

                nodeId = new Opc.Ua.ExpandedNodeId(nodeId.Identifier, 0, namespaceUri, serverIndex);
                return nodeId;
            }


            nodeId = new Opc.Ua.ExpandedNodeId(nodeId.Identifier, namespaceIndex, null, 0);
            return nodeId;
        }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:38,代码来源:DataSource.cs

示例3: UpdateNamespaceTable

        /// <summary>
        /// Updates the namespace table with URI used in the relative path.
        /// </summary>
        /// <param name="currentTable">The current table.</param>
        /// <param name="targetTable">The target table.</param>
        public void UpdateNamespaceTable(NamespaceTable currentTable, NamespaceTable targetTable)
        {
            // build mapping table.
            int[] mappings = new int[currentTable.Count];
            mappings[0] = 0;

            if (mappings.Length > 0)
            {
                mappings[1] = 1;
            }

            // ensure a placeholder for the local namespace.
            if (targetTable.Count <= 1)
            {
                targetTable.Append("---");
            }

            string[] uris = new string[mappings.Length];

            for (int ii = 2; ii < mappings.Length; ii++)
            {
                uris[ii] = currentTable.GetString((uint)ii);

                if (uris[ii] != null)
                {
                    mappings[ii] = targetTable.GetIndex(uris[ii]);
                }
            }

            // update each element.
            foreach (Element element in m_elements)
            {
                // check reference type name.
                QualifiedName qname = element.ReferenceTypeName;

                if (qname != null && qname.NamespaceIndex > 1)
                {
                    if (qname.NamespaceIndex < mappings.Length)
                    {
                        if (mappings[qname.NamespaceIndex] == -1)
                        {
                            mappings[qname.NamespaceIndex] = targetTable.GetIndexOrAppend(uris[qname.NamespaceIndex]);
                        }
                    }
                }

                // check target name.
                qname = element.TargetName;

                if (qname != null && qname.NamespaceIndex > 1)
                {
                    if (qname.NamespaceIndex < mappings.Length)
                    {
                        if (mappings[qname.NamespaceIndex] == -1)
                        {
                            mappings[qname.NamespaceIndex] = targetTable.GetIndexOrAppend(uris[qname.NamespaceIndex]);
                        }
                    }
                }
            }
        }
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:66,代码来源:RelativePath.cs

示例4: IsValid

        /// <summary>
        /// Returns true if the QualifiedName is valid.
        /// </summary>
        public static bool IsValid(QualifiedName value, NamespaceTable namespaceUris)
        {
            if (value == null || String.IsNullOrEmpty(value.Name))
            {
                return false;
            }

            if (namespaceUris != null)
            {
                if (namespaceUris.GetString((ushort)value.NamespaceIndex) == null)
                {
                    return false;
                }
            }
                
            return true;
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:20,代码来源:QualifiedName.cs


注:本文中的Opc.Ua.NamespaceTable.GetString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。